ExaDG
Loading...
Searching...
No Matches
kinetic_energy_calculation.h
1/* ______________________________________________________________________
2 *
3 * ExaDG - High-Order Discontinuous Galerkin for the Exa-Scale
4 *
5 * Copyright (C) 2021 by the ExaDG authors
6 *
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <https://www.gnu.org/licenses/>.
19 * ______________________________________________________________________
20 */
21
22#ifndef INCLUDE_EXADG_POSTPROCESSOR_KINETIC_ENERGY_CALCULATION_H_
23#define INCLUDE_EXADG_POSTPROCESSOR_KINETIC_ENERGY_CALCULATION_H_
24
25// deal.II
26#include <deal.II/matrix_free/matrix_free.h>
27
28// ExaDG
29#include <exadg/incompressible_navier_stokes/spatial_discretization/curl_compute.h>
30#include <exadg/matrix_free/integrators.h>
31#include <exadg/postprocessor/time_control.h>
32#include <exadg/utilities/print_functions.h>
33
34namespace ExaDG
35{
37{
39 : evaluate_individual_terms(false),
40 viscosity(1.0),
41 directory("output/"),
42 filename("kinetic_energy"),
43 clear_file(true)
44 {
45 }
46
47 void
48 print(dealii::ConditionalOStream & pcout)
49 {
50 if(time_control_data.is_active)
51 {
52 pcout << std::endl << " Calculate kinetic energy:" << std::endl;
53
54 // only implemented for unsteady problem
55 time_control_data.print(pcout, true /*unsteady*/);
56
57 print_parameter(pcout, "Evaluate individual terms", evaluate_individual_terms);
58 print_parameter(pcout, "Directory of output files", directory);
59 print_parameter(pcout, "Filename", filename);
60 print_parameter(pcout, "Clear file", clear_file);
61 }
62 }
63
64 TimeControlData time_control_data;
65
66 // perform detailed analysis and evaluate contribution of individual terms (e.g., convective term,
67 // viscous term) to overall kinetic energy dissipation?
68 bool evaluate_individual_terms;
69
70 // kinematic viscosity
71 double viscosity;
72
73 // directory and filename
74 std::string directory;
75 std::string filename;
76 bool clear_file;
77};
78
79template<int dim, typename Number>
81{
82public:
83 static unsigned int const number_vorticity_components = (dim == 2) ? 1 : dim;
84
85 typedef dealii::LinearAlgebra::distributed::Vector<Number> VectorType;
86
87 typedef dealii::VectorizedArray<Number> scalar;
88 typedef dealii::Tensor<1, dim, dealii::VectorizedArray<Number>> vector;
89 typedef dealii::Tensor<2, dim, dealii::VectorizedArray<Number>> tensor;
90
91 KineticEnergyCalculator(MPI_Comm const & comm);
92
93 void
94 setup(dealii::MatrixFree<dim, Number> const & matrix_free_in,
95 unsigned int const dof_index_in,
96 unsigned int const quad_index_in,
97 KineticEnergyData const & kinetic_energy_data_in);
98
99 void
100 evaluate(VectorType const & velocity, double const time, bool const unsteady);
101
102 TimeControl time_control;
103
104protected:
105 void
106 calculate_basic(VectorType const & velocity, double const time);
107
108 /*
109 * This function calculates the kinetic energy
110 *
111 * Kinetic energy: E_k = 1/V * 1/2 * (1,u*u)_Omega, V=(1,1)_Omega is the volume
112 *
113 * Enstrophy: 1/V * 0.5 (1,rot(u)*rot(u))_Omega, V=(1,1)_Omega is the volume
114 *
115 * Dissipation rate: epsilon = nu/V * (1, grad(u):grad(u))_Omega, V=(1,1)_Omega is the volume
116 *
117 * Note that
118 *
119 * epsilon = 2 * nu * Enstrophy
120 *
121 * for incompressible flows (div(u)=0) and periodic boundary conditions.
122 */
123 Number
124 integrate(dealii::MatrixFree<dim, Number> const & matrix_free_data,
125 VectorType const & velocity,
126 Number & energy,
127 Number & enstrophy,
128 Number & dissipation,
129 Number & max_vorticity);
130
131 void
132 cell_loop(dealii::MatrixFree<dim, Number> const & data,
133 std::vector<Number> & dst,
134 VectorType const & src,
135 std::pair<unsigned int, unsigned int> const & cell_range);
136
137 MPI_Comm const mpi_comm;
138
139 bool clear_files;
140
141 dealii::MatrixFree<dim, Number> const * matrix_free;
142 unsigned int dof_index, quad_index;
144};
145
146} // namespace ExaDG
147
148#endif /* INCLUDE_EXADG_POSTPROCESSOR_KINETIC_ENERGY_CALCULATION_H_ */
Definition kinetic_energy_calculation.h:81
Definition time_control.h:64
Definition driver.cpp:33
Definition kinetic_energy_calculation.h:37
Definition time_control.h:40