ExaDG
Loading...
Searching...
No Matches
operator.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_COMPRESSIBLE_NAVIER_STOKES_SPATIAL_DISCRETIZATION_OPERATOR_H_
23#define EXADG_COMPRESSIBLE_NAVIER_STOKES_SPATIAL_DISCRETIZATION_OPERATOR_H_
24
25// deal.II
26#include <deal.II/fe/fe_dgq.h>
27#include <deal.II/fe/fe_system.h>
28#include <deal.II/lac/la_parallel_vector.h>
29
30// ExaDG
31#include <exadg/compressible_navier_stokes/spatial_discretization/calculators.h>
32#include <exadg/compressible_navier_stokes/spatial_discretization/interface.h>
33#include <exadg/compressible_navier_stokes/spatial_discretization/kernels_and_operators.h>
34#include <exadg/compressible_navier_stokes/user_interface/boundary_descriptor.h>
35#include <exadg/compressible_navier_stokes/user_interface/field_functions.h>
36#include <exadg/compressible_navier_stokes/user_interface/parameters.h>
37#include <exadg/grid/grid.h>
38#include <exadg/matrix_free/matrix_free_data.h>
39#include <exadg/operators/inverse_mass_operator.h>
40#include <exadg/operators/navier_stokes_calculators.h>
41
42namespace ExaDG
43{
44namespace CompNS
45{
46template<int dim, typename Number>
47class Operator : public dealii::EnableObserverPointer, public Interface::Operator<Number>
48{
49private:
50 typedef dealii::LinearAlgebra::distributed::Vector<Number> VectorType;
51
52public:
53 Operator(std::shared_ptr<Grid<dim> const> grid,
54 std::shared_ptr<dealii::Mapping<dim> const> mapping,
55 std::shared_ptr<BoundaryDescriptor<dim> const> boundary_descriptor,
56 std::shared_ptr<FieldFunctions<dim> const> field_functions,
57 Parameters const & param,
58 std::string const & field,
59 MPI_Comm const & mpi_comm);
60
61 void
62 fill_matrix_free_data(MatrixFreeData<dim, Number> & matrix_free_data) const;
63
67 void
68 setup();
69
75 void
76 setup(std::shared_ptr<dealii::MatrixFree<dim, Number> const> matrix_free,
77 std::shared_ptr<MatrixFreeData<dim, Number> const> matrix_free_data);
78
79 dealii::types::global_dof_index
80 get_number_of_dofs() const;
81
82 // initialization of DoF vectors
83 void
84 initialize_dof_vector(VectorType & src) const final;
85
86 void
87 initialize_dof_vector_scalar(VectorType & src) const;
88
89 void
90 initialize_dof_vector_dim_components(VectorType & src) const;
91
92 // required for restart functionality
93 void
94 serialize_vectors(std::vector<VectorType const *> const & vectors) const final;
95
96 void
97 deserialize_vectors(std::vector<VectorType *> const & vectors) final;
98
99 // set initial conditions
100 void
101 prescribe_initial_conditions(VectorType & src, double const time) const final;
102
103 /*
104 * This function is used in case of explicit time integration:
105 * This function evaluates the right-hand side operator, the
106 * convective and viscous terms (subsequently multiplied by -1.0 in order
107 * to shift these terms to the right-hand side of the equations)
108 * and finally applies the inverse mass operator.
109 */
110 void
111 evaluate(VectorType & dst, VectorType const & src, Number const time) const final;
112
113 void
114 evaluate_convective(VectorType & dst, VectorType const & src, Number const time) const;
115
116 void
117 evaluate_viscous(VectorType & dst, VectorType const & src, Number const time) const;
118
119 void
120 evaluate_convective_and_viscous(VectorType & dst,
121 VectorType const & src,
122 Number const time) const;
123
124 void
125 apply_inverse_mass(VectorType & dst, VectorType const & src) const;
126
127 // getters
128 dealii::MatrixFree<dim, Number> const &
129 get_matrix_free() const;
130
131 dealii::Mapping<dim> const &
132 get_mapping() const;
133
134 dealii::FiniteElement<dim> const &
135 get_fe() const;
136
137 dealii::DoFHandler<dim> const &
138 get_dof_handler() const;
139
140 dealii::DoFHandler<dim> const &
141 get_dof_handler_scalar() const;
142
143 dealii::DoFHandler<dim> const &
144 get_dof_handler_vector() const;
145
146 unsigned int
147 get_dof_index_vector() const;
148
149 unsigned int
150 get_dof_index_scalar() const;
151
152 unsigned int
153 get_quad_index_standard() const;
154
155 // pressure
156 void
157 compute_pressure(VectorType & dst, VectorType const & src) const;
158
159 // velocity
160 void
161 compute_velocity(VectorType & dst, VectorType const & src) const;
162
163 // temperature
164 void
165 compute_temperature(VectorType & dst, VectorType const & src) const;
166
167 // vorticity
168 void
169 compute_vorticity(VectorType & dst, VectorType const & src) const;
170
171 // divergence
172 void
173 compute_divergence(VectorType & dst, VectorType const & src) const;
174
175 // shear rate
176 void
177 compute_shear_rate(VectorType & dst, VectorType const & src) const;
178
179 double
180 get_wall_time_operator_evaluation() const final;
181
182 // global CFL criterion: calculates the time step size for a given global maximum velocity
183 double
184 calculate_time_step_cfl_global() const final;
185
186 // Calculate time step size according to diffusion term
187 double
188 calculate_time_step_diffusion() const final;
189
190private:
191 void
192 initialize_dof_handler_and_constraints();
193
194 void
195 setup_operators();
196
197 unsigned int
198 get_dof_index_all() const;
199
200 unsigned int
201 get_quad_index_overintegration_conv() const;
202
203 unsigned int
204 get_quad_index_overintegration_vis() const;
205
206 unsigned int
207 get_quad_index_l2_projections() const;
208
209 /*
210 * Grid
211 */
212 std::shared_ptr<Grid<dim> const> grid;
213
214 /*
215 * Mapping
216 */
217 std::shared_ptr<dealii::Mapping<dim> const> mapping;
218
219 /*
220 * User interface: Boundary conditions and field functions.
221 */
222 std::shared_ptr<BoundaryDescriptor<dim> const> boundary_descriptor;
223 std::shared_ptr<FieldFunctions<dim> const> field_functions;
224
225 /*
226 * List of parameters.
227 */
228 Parameters const & param;
229
230 std::string const field;
231
232 /*
233 * Basic finite element ingredients.
234 */
235
236 std::shared_ptr<dealii::FiniteElement<dim>> fe; // all (dim+2) components: (rho, rho u, rho E)
237 std::shared_ptr<dealii::FiniteElement<dim>> fe_vector; // e.g. velocity
238 std::shared_ptr<dealii::FiniteElement<dim>> fe_scalar; // scalar quantity, e.g, pressure
239
240 // dealii::DoFHandler
241 dealii::DoFHandler<dim> dof_handler; // all (dim+2) components: (rho, rho u, rho E)
242 dealii::DoFHandler<dim> dof_handler_vector; // e.g. velocity
243 dealii::DoFHandler<dim> dof_handler_scalar; // scalar quantity, e.g, pressure
244
245 std::string const dof_index_all = "all_fields";
246 std::string const dof_index_vector = "vector";
247 std::string const dof_index_scalar = "scalar";
248
249 std::string const quad_index_standard = "standard";
250 std::string const quad_index_overintegration_conv = "overintegration_conv";
251 std::string const quad_index_overintegration_vis = "overintegration_vis";
252
253 // required for de-/serialization
254 std::shared_ptr<dealii::FiniteElement<dim>> fe_mapping;
255 std::shared_ptr<dealii::DoFHandler<dim>> dof_handler_mapping;
256
257 std::string const quad_index_l2_projections = quad_index_standard;
258 // alternative: use more accurate over-integration strategy
259 // std::string const quad_index_l2_projections = quad_index_overintegration_conv;
260
261 /*
262 * Constraints.
263 */
264 dealii::AffineConstraints<Number> constraint;
265
266 /*
267 * Matrix-free operator evaluation.
268 */
269 std::shared_ptr<MatrixFreeData<dim, Number> const> matrix_free_data;
270 std::shared_ptr<dealii::MatrixFree<dim, Number> const> matrix_free;
271
272 /*
273 * Basic operators.
274 */
275 MassOperator<dim, Number> mass_operator;
276 BodyForceOperator<dim, Number> body_force_operator;
277 ConvectiveOperator<dim, Number> convective_operator;
278 ViscousOperator<dim, Number> viscous_operator;
279
280 /*
281 * Merged operators.
282 */
283 CombinedOperator<dim, Number> combined_operator;
284
285 InverseMassOperator<dim, dim + 2, Number> inverse_mass_all;
286 InverseMassOperator<dim, dim, Number> inverse_mass_vector;
287 InverseMassOperator<dim, 1, Number> inverse_mass_scalar;
288
289 // L2 projections to calculate derived quantities
290 p_u_T_Calculator<dim, Number> p_u_T_calculator;
291 VorticityCalculator<dim, Number> vorticity_calculator;
292 DivergenceCalculator<dim, Number> divergence_calculator;
293 ShearRateCalculator<dim, Number> shear_rate_calculator;
294
295 /*
296 * MPI
297 */
298 MPI_Comm const mpi_comm;
299
300 /*
301 * Output to screen.
302 */
303 dealii::ConditionalOStream pcout;
304
305 // wall time for operator evaluation
306 mutable double wall_time_operator_evaluation;
307};
308
309} // namespace CompNS
310} // namespace ExaDG
311
312#endif /* EXADG_COMPRESSIBLE_NAVIER_STOKES_SPATIAL_DISCRETIZATION_OPERATOR_H_ */
Definition kernels_and_operators.h:301
Definition kernels_and_operators.h:1689
Definition kernels_and_operators.h:510
Definition interface.h:36
Definition kernels_and_operators.h:417
void setup()
Definition operator.cpp:268
Definition parameters.h:38
Definition kernels_and_operators.h:949
Definition calculators.h:43
Definition navier_stokes_calculators.h:36
Definition grid.h:40
Definition navier_stokes_calculators.h:73
Definition navier_stokes_calculators.h:115
Definition driver.cpp:33
Definition boundary_descriptor.h:107
Definition field_functions.h:31
Definition matrix_free_data.h:40