ExaDG
Loading...
Searching...
No Matches
spatial_operator.h
1/* ______________________________________________________________________
2 *
3 * ExaDG - High-Order Discontinuous Galerkin for the Exa-Scale
4 *
5 * Copyright (C) 2023 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_ACOUSTIC_CONSERVATION_EQUATIONS_SPATIAL_DISCRETIZATION_SPATIAL_OPERATOR_BASE_H_
23#define EXADG_ACOUSTIC_CONSERVATION_EQUATIONS_SPATIAL_DISCRETIZATION_SPATIAL_OPERATOR_BASE_H_
24
25// deal.II
26#include <deal.II/fe/fe_dgq.h>
27#include <deal.II/fe/fe_simplex_p.h>
28#include <deal.II/fe/fe_system.h>
29
30// ExaDG
31#include <exadg/acoustic_conservation_equations/spatial_discretization/interface.h>
32#include <exadg/acoustic_conservation_equations/spatial_discretization/operators/operator.h>
33#include <exadg/acoustic_conservation_equations/user_interface/boundary_descriptor.h>
34#include <exadg/acoustic_conservation_equations/user_interface/field_functions.h>
35#include <exadg/acoustic_conservation_equations/user_interface/parameters.h>
36#include <exadg/grid/grid.h>
37#include <exadg/matrix_free/matrix_free_data.h>
38#include <exadg/operators/inverse_mass_operator.h>
39#include <exadg/operators/rhs_operator.h>
40#include <exadg/utilities/lazy_ptr.h>
41
42namespace ExaDG
43{
44namespace Acoustics
45{
55template<int dim, typename Number>
57{
58 using BlockVectorType = typename Interface::SpatialOperator<Number>::BlockVectorType;
59 using VectorType = dealii::LinearAlgebra::distributed::Vector<Number>;
60
61public:
62 static unsigned int const block_index_pressure = 0;
63 static unsigned int const block_index_velocity = 1;
64
65 /*
66 * Constructor.
67 */
68 SpatialOperator(std::shared_ptr<Grid<dim> const> grid,
69 std::shared_ptr<dealii::Mapping<dim> const> mapping,
70 std::shared_ptr<BoundaryDescriptor<dim> const> boundary_descriptor,
71 std::shared_ptr<FieldFunctions<dim> const> field_functions,
72 Parameters const & parameters,
73 std::string const & field,
74 MPI_Comm const & mpi_comm);
75
76 void
77 fill_matrix_free_data(MatrixFreeData<dim, Number> & matrix_free_data) const;
78
82 void
83 setup();
84
91 void
92 setup(std::shared_ptr<dealii::MatrixFree<dim, Number> const> matrix_free_in,
93 std::shared_ptr<MatrixFreeData<dim, Number> const> matrix_free_data_in);
94
95 /*
96 * Getters and setters.
97 */
98 dealii::MatrixFree<dim, Number> const &
99 get_matrix_free() const;
100
101 std::string
102 get_dof_name_pressure() const;
103
104 unsigned int
105 get_dof_index_pressure() const;
106
107 std::string
108 get_dof_name_velocity() const;
109
110 unsigned int
111 get_dof_index_velocity() const;
112
113 unsigned int
114 get_quad_index_pressure() const;
115
116 unsigned int
117 get_quad_index_velocity() const;
118
119 unsigned int
120 get_quad_index_pressure_velocity() const;
121
122 std::shared_ptr<dealii::Mapping<dim> const>
123 get_mapping() const;
124
125 dealii::FiniteElement<dim> const &
126 get_fe_p() const;
127
128 dealii::FiniteElement<dim> const &
129 get_fe_u() const;
130
131 dealii::DoFHandler<dim> const &
132 get_dof_handler_p() const;
133
134 dealii::DoFHandler<dim> const &
135 get_dof_handler_u() const;
136
137 dealii::AffineConstraints<Number> const &
138 get_constraint_p() const;
139
140 dealii::AffineConstraints<Number> const &
141 get_constraint_u() const;
142
143 dealii::types::global_dof_index
144 get_number_of_dofs() const;
145
146 /*
147 * Initialization of vectors.
148 */
149 void
150 initialize_dof_vector(BlockVectorType & dst) const final;
151
152 void
153 initialize_dof_vector_pressure(VectorType & dst) const;
154
155 /*
156 * Prescribe initial conditions using a specified analytical/initial solution function.
157 */
158 void
159 prescribe_initial_conditions(BlockVectorType & dst, double const time) const final;
160
161 /*
162 * Set aero-acoustic source term.
163 */
164 void
165 set_aero_acoustic_source_term(VectorType const & aero_acoustic_source_term_in);
166
167 /*
168 * This function is used in case of explicit time integration:
169 * This function evaluates the right-hand side operator, the
170 * convective and viscous terms (subsequently multiplied by -1.0 in order
171 * to shift these terms to the right-hand side of the equations)
172 * and finally applies the inverse mass operator.
173 */
174 void
175 evaluate(BlockVectorType & dst, BlockVectorType const & src, double const time) const final;
176
177 /*
178 * Operators.
179 */
180
181 // acoustic operator
182 void
183 evaluate_acoustic_operator(BlockVectorType & dst,
184 BlockVectorType const & src,
185 double const time) const;
186
194 void
195 apply_scaled_inverse_mass_operator(BlockVectorType & dst, BlockVectorType const & src) const;
196
197 // Calculate time step size according to local CFL criterion
198 double
199 calculate_time_step_cfl() const final;
200
201private:
202 void
203 initialize_dof_handler_and_constraints();
204
205 void
206 initialize_operators();
207
208 /*
209 * Grid
210 */
211 std::shared_ptr<Grid<dim> const> grid;
212
213 /*
214 * dealii::Mapping (In case of moving meshes (ALE), this is the dynamic mapping describing the
215 * deformed configuration.)
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 /*
231 * A name describing the field being solved.
232 */
233 std::string const field;
234
235 /*
236 * Basic finite element ingredients.
237 */
238 std::shared_ptr<dealii::FiniteElement<dim>> fe_p;
239 std::shared_ptr<dealii::FiniteElement<dim>> fe_u;
240
241 dealii::DoFHandler<dim> dof_handler_p;
242 dealii::DoFHandler<dim> dof_handler_u;
243
244 dealii::AffineConstraints<Number> constraint_p, constraint_u;
245
246 std::string const dof_index_p = "pressure";
247 std::string const dof_index_u = "velocity";
248
249 std::string const quad_index_p = "pressure";
250 std::string const quad_index_u = "velocity";
251
252 // Quadrature that works for both, pressure and velocity, i.e. n_q=(max(k_p,k_u)+1)^dim.
253 // This quadrature is needed for the acoustic operator which iterates over pressure and
254 // velocity quadrature points in the same loop (for performance reasons).
255 std::string const quad_index_p_u = "pressure_velocity";
256
257 std::shared_ptr<MatrixFreeData<dim, Number> const> matrix_free_data;
258 std::shared_ptr<dealii::MatrixFree<dim, Number> const> matrix_free;
259
260 /*
261 * Basic operators.
262 */
263 Operator<dim, Number> acoustic_operator;
264
265 /*
266 * Inverse mass operator
267 */
268 InverseMassOperator<dim, 1, Number> inverse_mass_pressure;
269 InverseMassOperator<dim, dim, Number> inverse_mass_velocity;
270
271 /*
272 * RHS operator that acts on the pressure DoFs
273 */
274 RHSOperator<dim, Number, 1> rhs_operator;
275
276 // The aero-acoustic source term has been computed externally.
277 VectorType const * aero_acoustic_source_term;
278
279 MPI_Comm const mpi_comm;
280
281 dealii::ConditionalOStream pcout;
282};
283
284} // namespace Acoustics
285} // namespace ExaDG
286
287#endif /* EXADG_ACOUSTIC_CONSERVATION_EQUATIONS_SPATIAL_DISCRETIZATION_SPATIAL_OPERATOR_BASE_H_ */
Definition operator.h:175
Definition parameters.h:41
Definition spatial_operator.h:57
void apply_scaled_inverse_mass_operator(BlockVectorType &dst, BlockVectorType const &src) const
Definition spatial_operator.cpp:361
void setup()
Definition spatial_operator.cpp:114
Definition grid.h:40
Definition inverse_mass_operator.h:53
Definition rhs_operator.h:107
Definition driver.cpp:33
Definition boundary_descriptor.h:64
Definition field_functions.h:31
Definition matrix_free_data.h:40