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