ExaDG
Loading...
Searching...
No Matches
operator_pressure_correction.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_SPATIAL_DISCRETIZATION_OPERATOR_PRESSURE_CORRECTION_H_
23#define INCLUDE_EXADG_INCOMPRESSIBLE_NAVIER_STOKES_SPATIAL_DISCRETIZATION_OPERATOR_PRESSURE_CORRECTION_H_
24
25#include <exadg/incompressible_navier_stokes/spatial_discretization/operator_projection_methods.h>
26#include <exadg/solvers_and_preconditioners/newton/newton_solver.h>
27
28namespace ExaDG
29{
30namespace IncNS
31{
32// forward declaration
33template<int dim, typename Number>
34class OperatorPressureCorrection;
35
36template<int dim, typename Number>
38{
39private:
40 typedef dealii::LinearAlgebra::distributed::Vector<Number> VectorType;
41
43
44public:
46 : pde_operator(nullptr), rhs_vector(nullptr), time(0.0), scaling_factor_mass(1.0)
47 {
48 }
49
50 void
51 initialize(PDEOperator const & pde_operator)
52 {
53 this->pde_operator = &pde_operator;
54 }
55
56 void
57 update(VectorType const & rhs_vector, double const & time, double const & scaling_factor)
58 {
59 this->rhs_vector = &rhs_vector;
60 this->time = time;
61 this->scaling_factor_mass = scaling_factor;
62 }
63
64 /*
65 * The implementation of the Newton solver requires a function called
66 * 'evaluate_residual'.
67 */
68 void
69 evaluate_residual(VectorType & dst, VectorType const & src)
70 {
71 pde_operator->evaluate_nonlinear_residual(dst, src, rhs_vector, time, scaling_factor_mass);
72 }
73
74private:
75 PDEOperator const * pde_operator;
76
77 VectorType const * rhs_vector;
78 double time;
79 double scaling_factor_mass;
80};
81
82template<int dim, typename Number = double>
84{
85private:
89
90 typedef typename Base::VectorType VectorType;
91
92 typedef typename Base::scalar scalar;
93 typedef typename Base::vector vector;
94 typedef typename Base::tensor tensor;
95
96 typedef typename Base::Range Range;
97
98 typedef typename Base::FaceIntegratorU FaceIntegratorU;
99 typedef typename Base::FaceIntegratorP FaceIntegratorP;
100
101public:
102 /*
103 * Constructor.
104 */
106 std::shared_ptr<Grid<dim> const> grid,
107 std::shared_ptr<dealii::Mapping<dim> const> mapping,
108 std::shared_ptr<MultigridMappings<dim, Number>> const multigrid_mappings,
109 std::shared_ptr<BoundaryDescriptor<dim> const> boundary_descriptor,
110 std::shared_ptr<FieldFunctions<dim> const> field_functions,
111 Parameters const & parameters,
112 std::string const & field,
113 MPI_Comm const & mpi_comm);
114
115 /*
116 * Destructor.
117 */
119
120 /*
121 * Initializes the inverse pressure mass matrix operator needed for the pressure correction
122 * scheme, as well as the pressure mass operator needed in the ALE case only (where the mass
123 * operator may be evaluated at different times depending on the specific ALE formulation chosen).
124 */
125 void
126 setup_derived() final;
127
128 void
129 update_after_grid_motion(bool const update_matrix_free) final;
130
131 /*
132 * Momentum step:
133 */
134
135 /*
136 * Stokes equations or convective term treated explicitly: solve linear system of equations
137 */
138 unsigned int
139 solve_linear_momentum_equation(VectorType & solution,
140 VectorType const & rhs,
141 bool const & update_preconditioner,
142 double const & scaling_factor_mass);
143
144 /*
145 * Calculation of right-hand side vector:
146 */
147
148 // viscous term
149 void
150 rhs_add_viscous_term(VectorType & dst, double const time) const;
151
152 /*
153 * Convective term treated implicitly: solve non-linear system of equations
154 */
155 std::tuple<unsigned int, unsigned int>
156 solve_nonlinear_momentum_equation(VectorType & dst,
157 VectorType const & rhs_vector,
158 double const & time,
159 bool const & update_preconditioner,
160 double const & scaling_factor_mass);
161
162 /*
163 * This function evaluates the nonlinear residual.
164 */
165 void
166 evaluate_nonlinear_residual(VectorType & dst,
167 VectorType const & src,
168 VectorType const * rhs_vector,
169 double const & time,
170 double const & scaling_factor_mass) const;
171
172 /*
173 * This function evaluates the nonlinear residual of the steady Navier-Stokes equations (momentum
174 * equation and continuity equation).
175 */
176 void
177 evaluate_nonlinear_residual_steady(VectorType & dst_u,
178 VectorType & dst_p,
179 VectorType const & src_u,
180 VectorType const & src_p,
181 double const & time) const;
182
183 /*
184 * This function applies the linearized momentum operator and is used for throughput measurements.
185 */
186 void
187 apply_momentum_operator(VectorType & dst, VectorType const & src);
188
189 /*
190 * Projection step.
191 */
192
193 // rhs pressure gradient
194 void
195 rhs_pressure_gradient_term_dirichlet_bc_from_dof_vector(VectorType & dst,
196 VectorType const & pressure) const;
197
198 void
199 evaluate_pressure_gradient_term_dirichlet_bc_from_dof_vector(VectorType & dst,
200 VectorType const & src,
201 VectorType const & pressure) const;
202
203 /*
204 * Pressure update step.
205 */
206
207 // apply inverse pressure mass operator
208 void
209 apply_inverse_pressure_mass_operator(VectorType & dst, VectorType const & src) const;
210
211 /*
212 * pressure Poisson equation.
213 */
214 unsigned int
215 solve_pressure(VectorType & dst, VectorType const & src, bool const update_preconditioner) const;
216
217 void
218 rhs_ppe_laplace_add(VectorType & dst, double const & time) const;
219
220 void
221 rhs_ppe_laplace_add_dirichlet_bc_from_dof_vector(VectorType & dst, VectorType const & src) const;
222
223 void
224 interpolate_pressure_dirichlet_bc(VectorType & dst, double const & time) const;
225
226private:
227 void
228 setup_preconditioners_and_solvers() final;
229
230 /*
231 * Setup of momentum solver (operator, preconditioner, solver).
232 */
233 void
234 setup_momentum_preconditioner();
235
236 void
237 setup_momentum_solver();
238
239 /*
240 * Setup of inverse mass operator for pressure.
241 */
242 void
243 setup_inverse_mass_operator_pressure();
244
245 void
246 cell_loop_empty(dealii::MatrixFree<dim, Number> const &,
247 VectorType &,
248 VectorType const &,
249 Range const &) const
250 {
251 }
252
253 void
254 face_loop_empty(dealii::MatrixFree<dim, Number> const &,
255 VectorType &,
256 VectorType const &,
257 Range const &) const
258 {
259 }
260
261 void
262 local_interpolate_pressure_dirichlet_bc_boundary_face(
263 dealii::MatrixFree<dim, Number> const & matrix_free,
264 VectorType & dst,
265 VectorType const & src,
266 Range const & face_range) const;
267
268 InverseMassOperator<dim, 1, Number> inverse_mass_pressure;
269
270 /*
271 * Momentum equation.
272 */
273
274 // Nonlinear operator and solver
276
277 std::shared_ptr<Newton::Solver<VectorType,
281 momentum_newton_solver;
282
283 // linear solver (momentum_operator serves as linear operator)
284 std::shared_ptr<PreconditionerBase<Number>> momentum_preconditioner;
285 std::shared_ptr<Krylov::SolverBase<VectorType>> momentum_linear_solver;
286};
287
288} // namespace IncNS
289} // namespace ExaDG
290
291#endif /* INCLUDE_EXADG_INCOMPRESSIBLE_NAVIER_STOKES_SPATIAL_DISCRETIZATION_OPERATOR_PRESSURE_CORRECTION_H_ \
292 */
Definition grid.h:40
Definition momentum_operator.h:40
Definition operator_pressure_correction.h:38
Definition operator_pressure_correction.h:84
void setup_derived() final
Definition operator_pressure_correction.cpp:60
Definition operator_projection_methods.h:37
Definition parameters.h:46
Definition spatial_operator_base.h:68
Definition inverse_mass_operator.h:53
Definition iterative_solvers_dealii_wrapper.h:40
Definition grid.h:84
Definition newton_solver.h:40
Definition driver.cpp:33
Definition boundary_descriptor.h:240
Definition field_functions.h:31