Lethe Open-Source Library version 1.2.0
Developer Guide
Loading...
Searching...
No Matches
postprocessing_cfd.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (c) 2020-2026 The Lethe Authors
2// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception OR LGPL-2.1-or-later
3
4#ifndef lethe_postprocessing_cfd_h
5#define lethe_postprocessing_cfd_h
6
8
10
11#include <deal.II/base/quadrature_lib.h>
12
13#include <deal.II/dofs/dof_handler.h>
14
15/**
16 * @brief Calculate the pressure drop and total pressure drop between two boundaries.
17 * The pressure drop thus calculated has units of Length^2/Time^2.
18 *
19 * @return Pressure drop of the flow between two boundaries of the domain
20 *
21 * @param dof_handler The dof_handler used for the calculation
22 *
23 * @param evaluation_point The solution for which the pressure drop is calculated. The velocity field is assumed to be the "dim" field
24 *
25 * @param cell_quadrature_formula The cell quadrature formula for the calculation
26 *
27 * @param face_quadrature_formula The face quadrature formula for the calculation
28 *
29 * @param mapping The mapping of the simulation
30 *
31 * @param inlet_boundary_id The id of the inlet boundary
32 *
33 * @param outlet_boundary_id The id of the outlet boundary
34 */
35template <int dim, typename VectorType>
36std::pair<double, double>
37calculate_pressure_drop(const DoFHandler<dim> &dof_handler,
38 const Mapping<dim> &mapping,
39 const VectorType &evaluation_point,
40 const Quadrature<dim> &cell_quadrature_formula,
41 const Quadrature<dim - 1> &face_quadrature_formula,
42 const unsigned int inlet_boundary_id,
43 const unsigned int outlet_boundary_id);
44
45/**
46 * @brief Calculate the CFL condition on the simulation domain
47 * @return CFL maximal value in the domain
48 * Post-processing function
49 * This function calculates the maximal CFL value in the domain
50 *
51 * @param dof_handler The dof_handler used for the calculation
52 *
53 * @param evaluation_point The solution for which the CFL is calculated. The velocity field is assumed to be the first field.
54 *
55 * @param quadrature_formula The quadrature formula for the calculation
56 *
57 * @param mapping The mapping of the simulation
58 */
59template <int dim, typename VectorType>
60double
61calculate_CFL(const DoFHandler<dim> &dof_handler,
62 const VectorType &evaluation_point,
63 const double time_step,
64 const Quadrature<dim> &quadrature_formula,
65 const Mapping<dim> &mapping);
66
67/**
68 * @brief Calculate the average enstrophy in the simulation domain
69 * @return average kinetic energy in the domain
70 * Post-processing function
71 * This function calculates the average enstrophy in the simulation domain
72 *
73 * @param dof_handler The dof_handler used for the calculation
74 *
75 * @param evaluation_point The solution at which the force is calculated
76 *
77 * @param quadrature_formula The quadrature formula for the calculation
78 *
79 * @param mapping The mapping of the simulation
80 */
81template <int dim, typename VectorType>
82double
83calculate_enstrophy(const DoFHandler<dim> &dof_handler,
84 const VectorType &evaluation_point,
85 const Quadrature<dim> &quadrature_formula,
86 const Mapping<dim> &mapping);
87
88/**
89 * @brief Calculate the average kinetic energy in the simulation domain
90 * @return average kinetic energy in the domain
91 * Post-processing function
92 * This function calculates the average kinetic energy in the simulation domain
93 *
94 * @param[in] dof_handler The dof_handler used for the calculation
95 *
96 * @param[in] evaluation_point The solution for the calculation
97 *
98 * @param[in] quadrature_formula The quadrature formula for the calculation
99 *
100 * @param[in] mapping The mapping of the simulation
101 */
102template <int dim, typename VectorType>
103double
104calculate_kinetic_energy(const DoFHandler<dim> &dof_handler,
105 const VectorType &evaluation_point,
106 const Quadrature<dim> &quadrature_formula,
107 const Mapping<dim> &mapping);
108
109/**
110 * @brief Calculate the average power done by pressure in the simulation
111 * domain. The average power is defined as ∫u.∇pdΩ/∫1dΩ
112 * @return Average power done by pressure in the simulation domain
113 * Post-processing function
114 *
115 * @param[in] dof_handler The dof_handler used for the calculation
116 *
117 * @param[in] evaluation_point The solution for the calculation
118 *
119 * @param[in] quadrature_formula The quadrature formula for the calculation
120 *
121 * @param[in] mapping The mapping of the simulation
122 */
123template <int dim, typename VectorType>
124double
125calculate_pressure_power(const DoFHandler<dim> &dof_handler,
126 const VectorType &evaluation_point,
127 const Quadrature<dim> &quadrature_formula,
128 const Mapping<dim> &mapping);
129
130/**
131 * @brief Calculate the viscous dissipation of kinetic energy which is defined as
132 * ∫∇u.τdΩ/∫1dΩ
133 * @return Viscous dissipation of kinetic energy
134 * Post-processing function
135 *
136 * @param[in] dof_handler The dof_handler used for the calculation
137 *
138 * @param[in] evaluation_point The solution for the calculation
139 *
140 * @param[in] quadrature_formula The quadrature formula for the calculation
141 *
142 * @param[in] mapping The mapping of the simulation
143 *
144 * @param[in] properties_manager Manager for the physical properties used to
145 * calculate the kinematic viscosity
146 */
147template <int dim, typename VectorType>
148double
150 const DoFHandler<dim> &dof_handler,
151 const VectorType &evaluation_point,
152 const Quadrature<dim> &quadrature_formula,
153 const Mapping<dim> &mapping,
154 const PhysicalPropertiesManager &properties_manager);
155
156/**
157 * @brief Calculates the apparent viscosity of the fluid for non Newtonian flows.
158 * @return the apparent viscosity
159 * Post-processing function
160 *
161 * @param dof_handler The dof_handler used for the calculation
162 *
163 * @param evaluation_point The solution at which the force is calculated
164 *
165 * @param quadrature_formula The quadrature formula for the calculation
166 *
167 * @param mapping The mapping of the simulation
168 *
169 * @param physical_properties The parameters containing the required physical properties
170 */
171template <int dim, typename VectorType>
172double
174 const DoFHandler<dim> &dof_handler,
175 const VectorType &evaluation_point,
176 const Quadrature<dim> &quadrature_formula,
177 const Mapping<dim> &mapping,
178 const PhysicalPropertiesManager &properties_manager);
179
180/**
181 * @brief Calculates the force due to the fluid motion on every boundary conditions
182 * @return std::vector of forces on each boundary condition
183 * Post-processing function
184 * This function calculates the force acting on each of the boundary conditions
185 * within the domain. It generates a vector which size is the number of boundary
186 * conditions
187 *
188 * @param dof_handler The dof_handler used for the calculation
189 *
190 * @param evaluation_point The solution at which the force is calculated
191 *
192 * @param physical_properties The parameters containing the required physical properties
193 *
194 * @param boundary_conditions The boundary conditions object
195 *
196 * @param face_quadrature_formula The face quadrature formula for the calculation
197 *
198 * @param mapping The mapping of the simulation
199 */
200template <int dim, typename VectorType>
201std::vector<std::map<types::boundary_id, Tensor<1, dim>>>
202calculate_forces(const DoFHandler<dim> &dof_handler,
203 const VectorType &evaluation_point,
204 const PhysicalPropertiesManager &properties_manager,
206 &boundary_conditions,
207 const Quadrature<dim - 1> &face_quadrature_formula,
208 const Mapping<dim> &mapping);
209
210
211/**
212 * @brief Calculates the torques due to the fluid motion on every boundary conditions
213 * @return std::vector of torques on each boundary condition
214 * Post-processing function
215 * This function calculates the torqueacting on each of the boundary conditions
216 * within the domain. It generates a vector which size is the number of boundary
217 * conditions.
218 *
219 * @param dof_handler The dof_handler used for the calculation.
220 *
221 * @param evaluation_point The solution at which the torque is calculated.
222 *
223 * @param physical_properties The parameters containing the required physical properties.
224 *
225 * @param boundary_conditions The boundary conditions object.
226 *
227 * @param face_quadrature_formula The face quadrature formula for the calculation.
228 *
229 * @param mapping The mapping of the simulation.
230 */
231template <int dim, typename VectorType>
232std::map<types::boundary_id, Tensor<1, 3>>
233calculate_torques(const DoFHandler<dim> &dof_handler,
234 const VectorType &evaluation_point,
235 const PhysicalPropertiesManager &properties_manager,
237 &boundary_conditions,
238 const Quadrature<dim - 1> &face_quadrature_formula,
239 const Mapping<dim> &mapping);
240
241
242/**
243 * @brief Calculates the L2 norm of the error on velocity and pressure
244 * @return std::pair<double,double> containing the L2 norm of the error for velocity and pressure
245 * Post-processing function
246 * This function calculates the L2 norm of the error on the velocity and
247 * pressure. Since the pressure in GLS is defined up to a given constant, the
248 * mean solution of the pressure is removed from both the analytical and the
249 * numerical solution to ensure that the convergence can be monitored correctly.
250 *
251 * @param dof_handler The dof_handler used for the calculation.
252 *
253 * @param evaluation_point The solution at which the torque is calculated.
254 *
255 * @param exact_solution The exact solution, a function of dim+1 component for velocity + pressure
256 *
257 * @param quadrature_formula The quadrature formula for the calculation.
258 *
259 * @param mapping The mapping of the simulation.
260 */
261template <int dim, typename VectorType>
262std::pair<double, double>
263calculate_L2_error(const DoFHandler<dim> &dof_handler,
264 const VectorType &evaluation_point,
265 const Function<dim> *exact_solution,
266 const Quadrature<dim> &quadrature_formula,
267 const Mapping<dim> &mapping);
268
269/**
270 * @brief calculate_flow_rate. This function calculates the volumetric flow
271 * rate at the selected boundary. It actually calculates the flow rate through
272 * the summation of the value at each cell surface with the normal vector,
273 * the velocity value and the area.
274 *
275 * @param dof_handler. The argument used to get finite elements
276 *
277 * @param present_solution. The vector which contains all the values to
278 * calculate the flow rate
279 *
280 * @param boundary_id. The inlet boundary
281 *
282 * @param face_quadrature_formula The face quadrature formula for the calculation
283 *
284 * @param mapping The mapping of the simulation
285 */
286template <int dim, typename VectorType>
287std::pair<double, double>
288calculate_flow_rate(const DoFHandler<dim> &dof_handler,
289 const VectorType &present_solution,
290 const unsigned int &boundary_id,
291 const Quadrature<dim - 1> &face_quadrature_formula,
292 const Mapping<dim> &mapping);
293
294/**
295 * @brief calculate_average_velocity. This function calculates average velocity
296 * from the volumetric flow rate at the selected boundary.
297 *
298 * @param dof_handler. The argument used to get finite elements
299 *
300 * @param present_solution. The vector which contains all the values to
301 * calculate the flow rate
302 *
303 * @param boundary_id. The inlet boundary
304 *
305 * @param face_quadrature_formula The face quadrature formula for the calculation
306 *
307 * @param mapping The mapping of the simulation
308 */
309template <int dim, typename VectorType>
310double
311calculate_average_velocity(const DoFHandler<dim> &dof_handler,
312 const VectorType &present_solution,
313 const unsigned int &boundary_id,
314 const Quadrature<dim - 1> &face_quadrature_formula,
315 const Mapping<dim> &mapping);
316
317/**
318 * @brief calculate_average_velocity. This function calculates the average velocity of
319 * the domain for the solver GLS VANS.
320 *
321 * Ū = ∫ε(v⋅γ)dΩ/∫εdΩ
322 * Where Ū is the average velocity, ε is the void fraction, v is the velocity
323 * of the cell, γ is the vector of the cell (flow direction) and dΩ is the
324 * volume of the cell.
325 *
326 * @param dof_handler. The argument used to get velocity at quadrature points
327 *
328 * @param void_fraction_dof_handler. The argument used to get void fraction at quadrature points
329 *
330 * @param present_solution. The vector which contains the velocity values
331 *
332 * @param present_void_fraction_solution. The vector which contains the void fraction values
333 *
334 * @param flow_direction. The flow direction
335 *
336 * @param quadrature_formula The quadrature formula for the calculation
337 *
338 * @param mapping The mapping of the simulation
339 */
340template <int dim, typename VectorType>
341double
342calculate_average_velocity(const DoFHandler<dim> &dof_handler,
343 const DoFHandler<dim> &void_fraction_dof_handler,
344 const VectorType &present_solution,
345 const VectorType &present_void_fraction_solution,
346 const unsigned int &flow_direction,
347 const Quadrature<dim> &quadrature_formula,
348 const Mapping<dim> &mapping);
349
350
351
352#define lethe_postprocessing_cfd_h
353
354#endif
This class manages the boundary conditions forhe fluid dynamics solver It introduces the boundary fun...
Class that manages the physical properties model which are required to calculate the various physical...
double calculate_pressure_power(const DoFHandler< dim > &dof_handler, const VectorType &evaluation_point, const Quadrature< dim > &quadrature_formula, const Mapping< dim > &mapping)
Calculate the average power done by pressure in the simulation domain. The average power is defined a...
std::pair< double, double > calculate_pressure_drop(const DoFHandler< dim > &dof_handler, const Mapping< dim > &mapping, const VectorType &evaluation_point, const Quadrature< dim > &cell_quadrature_formula, const Quadrature< dim - 1 > &face_quadrature_formula, const unsigned int inlet_boundary_id, const unsigned int outlet_boundary_id)
Calculate the pressure drop and total pressure drop between two boundaries. The pressure drop thus ca...
double calculate_apparent_viscosity(const DoFHandler< dim > &dof_handler, const VectorType &evaluation_point, const Quadrature< dim > &quadrature_formula, const Mapping< dim > &mapping, const PhysicalPropertiesManager &properties_manager)
Calculates the apparent viscosity of the fluid for non Newtonian flows.
std::map< types::boundary_id, Tensor< 1, 3 > > calculate_torques(const DoFHandler< dim > &dof_handler, const VectorType &evaluation_point, const PhysicalPropertiesManager &properties_manager, const BoundaryConditions::FluidDynamicsBoundaryConditions< dim > &boundary_conditions, const Quadrature< dim - 1 > &face_quadrature_formula, const Mapping< dim > &mapping)
Calculates the torques due to the fluid motion on every boundary conditions.
std::pair< double, double > calculate_flow_rate(const DoFHandler< dim > &dof_handler, const VectorType &present_solution, const unsigned int &boundary_id, const Quadrature< dim - 1 > &face_quadrature_formula, const Mapping< dim > &mapping)
calculate_flow_rate. This function calculates the volumetric flow rate at the selected boundary....
double calculate_kinetic_energy(const DoFHandler< dim > &dof_handler, const VectorType &evaluation_point, const Quadrature< dim > &quadrature_formula, const Mapping< dim > &mapping)
Calculate the average kinetic energy in the simulation domain.
double calculate_CFL(const DoFHandler< dim > &dof_handler, const VectorType &evaluation_point, const double time_step, const Quadrature< dim > &quadrature_formula, const Mapping< dim > &mapping)
Calculate the CFL condition on the simulation domain.
double calculate_average_velocity(const DoFHandler< dim > &dof_handler, const VectorType &present_solution, const unsigned int &boundary_id, const Quadrature< dim - 1 > &face_quadrature_formula, const Mapping< dim > &mapping)
calculate_average_velocity. This function calculates average velocity from the volumetric flow rate a...
std::pair< double, double > calculate_L2_error(const DoFHandler< dim > &dof_handler, const VectorType &evaluation_point, const Function< dim > *exact_solution, const Quadrature< dim > &quadrature_formula, const Mapping< dim > &mapping)
Calculates the L2 norm of the error on velocity and pressure.
std::vector< std::map< types::boundary_id, Tensor< 1, dim > > > calculate_forces(const DoFHandler< dim > &dof_handler, const VectorType &evaluation_point, const PhysicalPropertiesManager &properties_manager, const BoundaryConditions::FluidDynamicsBoundaryConditions< dim > &boundary_conditions, const Quadrature< dim - 1 > &face_quadrature_formula, const Mapping< dim > &mapping)
Calculates the force due to the fluid motion on every boundary conditions.
double calculate_enstrophy(const DoFHandler< dim > &dof_handler, const VectorType &evaluation_point, const Quadrature< dim > &quadrature_formula, const Mapping< dim > &mapping)
Calculate the average enstrophy in the simulation domain.
double calculate_viscous_dissipation(const DoFHandler< dim > &dof_handler, const VectorType &evaluation_point, const Quadrature< dim > &quadrature_formula, const Mapping< dim > &mapping, const PhysicalPropertiesManager &properties_manager)
Calculate the viscous dissipation of kinetic energy which is defined as ∫∇u.τdΩ/∫1dΩ
GlobalVectorType VectorType