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 EXADG_POSTPROCESSOR_KINETIC_ENERGY_CALCULATION_H_
23#define 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{
36struct KineticEnergyData
37{
38 KineticEnergyData()
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>
80class KineticEnergyCalculator
81{
82public:
83 typedef dealii::LinearAlgebra::distributed::Vector<Number> VectorType;
84
85 typedef dealii::VectorizedArray<Number> scalar;
86 typedef dealii::Tensor<1, dim, dealii::VectorizedArray<Number>> vector;
87 typedef dealii::Tensor<2, dim, dealii::VectorizedArray<Number>> tensor;
88
89 KineticEnergyCalculator(MPI_Comm const & comm);
90
91 void
92 setup(dealii::MatrixFree<dim, Number> const & matrix_free_in,
93 unsigned int const dof_index_in,
94 unsigned int const quad_index_in,
95 KineticEnergyData const & kinetic_energy_data_in);
96
97 void
98 evaluate(VectorType const & velocity, double const time, bool const unsteady);
99
100 TimeControl time_control;
101
102protected:
103 void
104 calculate_basic(VectorType const & velocity, double const time);
105
106 /*
107 * This function calculates the kinetic energy
108 *
109 * Kinetic energy: E_k = 1/V * 1/2 * (1,u*u)_Omega, V=(1,1)_Omega is the volume
110 *
111 * Enstrophy: 1/V * 0.5 (1,rot(u)*rot(u))_Omega, V=(1,1)_Omega is the volume
112 *
113 * Dissipation rate: epsilon = nu/V * (1, grad(u):grad(u))_Omega, V=(1,1)_Omega is the volume
114 *
115 * Note that
116 *
117 * epsilon = 2 * nu * Enstrophy
118 *
119 * for incompressible flows (div(u)=0) and periodic boundary conditions.
120 */
121 Number
122 integrate(dealii::MatrixFree<dim, Number> const & matrix_free_data,
123 VectorType const & velocity,
124 Number & energy,
125 Number & enstrophy,
126 Number & dissipation,
127 Number & max_vorticity);
128
129 void
130 cell_loop(dealii::MatrixFree<dim, Number> const & data,
131 std::vector<Number> & dst,
132 VectorType const & src,
133 std::pair<unsigned int, unsigned int> const & cell_range);
134
135 MPI_Comm const mpi_comm;
136
137 bool clear_files;
138
139 dealii::MatrixFree<dim, Number> const * matrix_free;
140 unsigned int dof_index, quad_index;
142};
143
144} // namespace ExaDG
145
146#endif /* EXADG_POSTPROCESSOR_KINETIC_ENERGY_CALCULATION_H_ */
Definition time_control.h:64
Definition driver.cpp:33
Definition kinetic_energy_calculation.h:37
Definition time_control.h:40