ExaDG
Loading...
Searching...
No Matches
flow_rate_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_FLOW_RATE_CALCULATOR_H_
23#define INCLUDE_EXADG_INCOMPRESSIBLE_NAVIER_STOKES_POSTPROCESSOR_FLOW_RATE_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{
35 FlowRateCalculatorData() : calculate(false), write_to_file(false), filename("flow_rate")
36 {
37 }
38
39 void
40 print(dealii::ConditionalOStream & pcout)
41 {
42 if(calculate == true)
43 {
44 pcout << " Flow rate calculator:" << std::endl;
45
46 print_parameter(pcout, "Calculate flow rate", calculate);
47 print_parameter(pcout, "Write results to file", write_to_file);
48 if(write_to_file == true)
49 {
50 print_parameter(pcout, "Directory", directory);
51 print_parameter(pcout, "Filename", filename);
52 }
53 }
54 }
55
56 // calculate?
57 bool calculate;
58
59 // write results to file?
60 bool write_to_file;
61
62 // directory and filename
63 std::string directory;
64 std::string filename;
65};
66
67
68/*
69 * This class calculates a vector of flow rates where the different entries of the vector correspond
70 * to different boundary IDs, i.e., one outflow boundary may only consist of faces with the same
71 * boundary ID. This class is intended to be used in cases where the number of outflow boundaries is
72 * very large with a typical use case being the human lung (where the number of outflow boundaries
73 * is 2^{N-1} with N being the number of airway generations). The reason behind is that calculating
74 * the flow rate requires global communication since different processors may share the same outflow
75 * boundary and the implementation in this class only requires one communication for all outflow
76 * boundaries.
77 *
78 * Note: For a small number of outflow boundaries (for example 1-10), the more modular class
79 * MeanVelocityCalculator should be used rather than this specialized implementation.
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
90 typedef dealii::VectorizedArray<Number> scalar;
91
92 FlowRateCalculator(dealii::MatrixFree<dim, Number> const & matrix_free_in,
93 unsigned int const dof_index_in,
94 unsigned int const quad_index_in,
95 FlowRateCalculatorData<dim> const & data_in,
96 MPI_Comm const & mpi_comm_in);
97
98 Number
99 calculate_flow_rates(VectorType const & velocity,
100 double const & time,
101 std::map<dealii::types::boundary_id, Number> & flow_rates);
102
103
104private:
105 void
106 write_output(Number const & value, double const & time, std::string const & name);
107
108 void
109 do_calculate_flow_rates(VectorType const & velocity,
110 std::map<dealii::types::boundary_id, Number> & flow_rates);
111
112 FlowRateCalculatorData<dim> const & data;
113 dealii::MatrixFree<dim, Number> const & matrix_free;
114 unsigned int dof_index, quad_index;
115 bool clear_files;
116
117 MPI_Comm const mpi_comm;
118};
119
120} // namespace IncNS
121} // namespace ExaDG
122
123
124#endif /* INCLUDE_EXADG_INCOMPRESSIBLE_NAVIER_STOKES_POSTPROCESSOR_FLOW_RATE_CALCULATOR_H_ */
Definition flow_rate_calculator.h:83
Definition driver.cpp:33
Definition flow_rate_calculator.h:34