ExaDG
Loading...
Searching...
No Matches
mean_velocity_calculator.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_INCOMPRESSIBLE_NAVIER_STOKES_POSTPROCESSOR_MEAN_VELOCITY_CALCULATOR_H_
23#define INCLUDE_EXADG_INCOMPRESSIBLE_NAVIER_STOKES_POSTPROCESSOR_MEAN_VELOCITY_CALCULATOR_H_
24
25#include <exadg/matrix_free/integrators.h>
26#include <exadg/utilities/print_functions.h>
27
28namespace ExaDG
29{
30namespace IncNS
31{
32template<int dim>
34{
36 : calculate(false),
37 write_to_file(false),
38 direction(dealii::Tensor<1, dim, double>()),
39 directory("output/"),
40 filename("mean_velocity")
41 {
42 }
43
44 void
45 print(dealii::ConditionalOStream & pcout)
46 {
47 if(calculate == true)
48 {
49 pcout << " Mean velocity/flow rate calculator:" << std::endl;
50
51 print_parameter(pcout, "Calculate mean velocity/flow rate", calculate);
52 print_parameter(pcout, "Write results to file", write_to_file);
53 if(write_to_file == true)
54 {
55 print_parameter(pcout, "Directory", directory);
56 print_parameter(pcout, "Filename", filename);
57 }
58 }
59 }
60
61 // calculate mean velocity?
62 bool calculate;
63
64 // Set containing boundary ID's of the surface area
65 // for which we want to calculate the mean velocity.
66 // This parameter is only relevant for area-based computation.
67 std::set<dealii::types::boundary_id> boundary_IDs;
68
69 // write results to file?
70 bool write_to_file;
71
72 // Direction in which we want to compute the flow rate
73 // This parameter is only relevant for volume-based computation.
74 dealii::Tensor<1, dim, double> direction;
75
76 // directory and filename
77 std::string directory;
78 std::string filename;
79};
80
81template<int dim, typename Number>
83{
84public:
85 typedef dealii::LinearAlgebra::distributed::Vector<Number> VectorType;
86
87 typedef CellIntegrator<dim, dim, Number> CellIntegratorU;
88 typedef FaceIntegrator<dim, dim, Number> FaceIntegratorU;
89
91
92 typedef dealii::VectorizedArray<Number> scalar;
93
94 MeanVelocityCalculator(dealii::MatrixFree<dim, Number> const & matrix_free_in,
95 unsigned int const dof_index_in,
96 unsigned int const quad_index_in,
97 MeanVelocityCalculatorData<dim> const & data_in,
98 MPI_Comm const & comm_in);
99
100 /*
101 * Calculates the mean velocity through a given cross section of the domain by dividing
102 * the flow rate through the cross section area. This function is more general than
103 * calculate_mean_velocity_volume() and can be used for domains with varying cross-section
104 * area in streamwise direction.
105 */
106 Number
107 calculate_mean_velocity_area(VectorType const & velocity, double const & time);
108
109 /*
110 * Calculate mean velocity (only makes sense if the domain has a constant cross-section area in
111 * streamwise direction.
112 */
113 Number
114 calculate_mean_velocity_volume(VectorType const & velocity, double const & time);
115
116 /*
117 * Calculate flow rate in m^3/s, for example for problems with non-constant cross-section area. To
118 * obtain the flow rate, the length of the domain in streamwise direction has to be specified.
119 */
120 Number
121 calculate_flow_rate_volume(VectorType const & velocity,
122 double const & time,
123 double const & length) const;
124
125 /*
126 * Calculates the flow rate through a given cross section of the domain.
127 */
128 Number
129 calculate_flow_rate_area(VectorType const & velocity, double const & time) const;
130
131
132private:
133 void
134 write_output(Number const & value, double const & time, std::string const & name) const;
135
136 Number
137 calculate_area() const;
138
139 Number
140 calculate_volume() const;
141
142 void
143 local_calculate_volume(dealii::MatrixFree<dim, Number> const & data,
144 std::vector<Number> & dst,
145 VectorType const &,
146 std::pair<unsigned int, unsigned int> const & cell_range) const;
147
148 Number
149 do_calculate_flow_rate_area(VectorType const & velocity) const;
150
151 Number
152 do_calculate_mean_velocity_volume(VectorType const & velocity) const;
153
154 Number
155 do_calculate_flow_rate_volume(VectorType const & velocity) const;
156
157 void
158 local_calculate_flow_rate_volume(dealii::MatrixFree<dim, Number> const & data,
159 std::vector<Number> & dst,
160 VectorType const & src,
161 std::pair<unsigned int, unsigned int> const & cell_range) const;
162
164 dealii::MatrixFree<dim, Number> const & matrix_free;
165 unsigned int dof_index, quad_index;
166 bool area_has_been_initialized, volume_has_been_initialized;
167 double area, volume;
168 mutable bool clear_files;
169
170 MPI_Comm const mpi_comm;
171};
172
173} // namespace IncNS
174} // namespace ExaDG
175
176#endif /* INCLUDE_EXADG_INCOMPRESSIBLE_NAVIER_STOKES_POSTPROCESSOR_MEAN_VELOCITY_CALCULATOR_H_ */
Definition mean_velocity_calculator.h:83
Definition driver.cpp:33
Definition mean_velocity_calculator.h:34