ExaDG
Loading...
Searching...
No Matches
operator_projection_methods.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_SPATIAL_DISCRETIZATION_OPERATOR_PROJECTION_METHODS_H_
23#define EXADG_INCOMPRESSIBLE_NAVIER_STOKES_SPATIAL_DISCRETIZATION_OPERATOR_PROJECTION_METHODS_H_
24
25// ExaDG
26#include <exadg/incompressible_navier_stokes/preconditioners/multigrid_preconditioner_momentum.h>
27#include <exadg/incompressible_navier_stokes/spatial_discretization/spatial_operator_base.h>
28#include <exadg/solvers_and_preconditioners/newton/newton_solver.h>
29#include <exadg/solvers_and_preconditioners/preconditioners/block_jacobi_preconditioner.h>
30#include <exadg/solvers_and_preconditioners/preconditioners/inverse_mass_preconditioner.h>
31#include <exadg/solvers_and_preconditioners/preconditioners/jacobi_preconditioner.h>
32
33namespace ExaDG
34{
35namespace IncNS
36{
37// forward declaration
38template<int dim, typename Number>
40
41template<int dim, typename Number>
42class NonlinearMomentumOperator
43{
44private:
45 typedef dealii::LinearAlgebra::distributed::Vector<Number> VectorType;
46
48
49public:
50 NonlinearMomentumOperator()
51 : pde_operator(nullptr), rhs_vector(nullptr), time(0.0), scaling_factor_mass(1.0)
52 {
53 }
54
55 void
56 initialize(PDEOperator const & pde_operator)
57 {
58 this->pde_operator = &pde_operator;
59 }
60
61 void
62 update(VectorType const & rhs_vector, double const & time, double const & scaling_factor)
63 {
64 this->rhs_vector = &rhs_vector;
65 this->time = time;
66 this->scaling_factor_mass = scaling_factor;
67 }
68
69 /*
70 * The implementation of the Newton solver requires a function called
71 * 'evaluate_residual'.
72 */
73 void
74 evaluate_residual(VectorType & dst, VectorType const & src)
75 {
76 pde_operator->evaluate_nonlinear_residual(dst, src, rhs_vector, time, scaling_factor_mass);
77 }
78
79private:
80 PDEOperator const * pde_operator;
81
82 VectorType const * rhs_vector;
83 double time;
84 double scaling_factor_mass;
85};
86
87/*
88 * Base class for projection-type incompressible Navier-Stokes solvers such as the high-order dual
89 * splitting (velocity-correction) scheme or pressure correction schemes.
90 */
91template<int dim, typename Number>
92class OperatorProjectionMethods : public SpatialOperatorBase<dim, Number>
93{
94protected:
95 typedef SpatialOperatorBase<dim, Number> Base;
96
97 typedef typename Base::VectorType VectorType;
98 typedef typename Base::MultigridPoisson MultigridPoisson;
99
100public:
101 /*
102 * Constructor.
103 */
104 OperatorProjectionMethods(
105 std::shared_ptr<Grid<dim> const> grid,
106 std::shared_ptr<dealii::Mapping<dim> const> mapping,
107 std::shared_ptr<MultigridMappings<dim, Number>> const multigrid_mappings,
108 std::shared_ptr<BoundaryDescriptor<dim> const> boundary_descriptor,
109 std::shared_ptr<FieldFunctions<dim> const> field_functions,
110 Parameters const & parameters,
111 std::string const & field,
112 MPI_Comm const & mpi_comm);
113
114 /*
115 * Destructor.
116 */
117 virtual ~OperatorProjectionMethods();
118
119protected:
120 /*
121 * Calls setup() function of base class and additionally initializes the pressure Poisson operator
122 * needed for projection-type methods.
123 */
124 void
125 setup_derived() override;
126
127 void
128 setup_preconditioners_and_solvers() override;
129
130public:
131 void
132 update_after_grid_motion(bool const update_matrix_free) override;
133
134 /*
135 * Pressure Poisson equation: This function evaluates the inhomogeneous parts of boundary face
136 * integrals of the negative Laplace operator and adds the result to the dst-vector.
137 */
138 void
139 do_rhs_ppe_laplace_add(VectorType & dst, double const & time) const;
140
141 /*
142 * This function solves the pressure Poisson equation and returns the number of iterations.
143 */
144 unsigned int
145 do_solve_pressure(VectorType & dst,
146 VectorType const & src,
147 bool const update_preconditioner) const;
148
149 /*
150 * This function applies the projection operator (used for throughput measurements).
151 */
152 void
153 apply_projection_operator(VectorType & dst, VectorType const & src) const;
154
155 /*
156 * This function applies the Laplace operator (used for throughput measurements).
157 */
158 void
159 apply_laplace_operator(VectorType & dst, VectorType const & src) const;
160
161 /*
162 * Momentum step:
163 */
164
165 /*
166 * Momentum step is a linear system of equations
167 */
168 unsigned int
169 solve_linear_momentum_equation(VectorType & solution,
170 VectorType const & rhs,
171 VectorType const & transport_velocity,
172 bool const & update_preconditioner,
173 double const & scaling_factor_mass);
174
175 /*
176 * This function evaluates the rhs-contribution of the viscous term and adds the result to the
177 * dst-vector.
178 */
179 void
180 rhs_add_viscous_term(VectorType & dst, double const time) const;
181
182 /*
183 * This function evaluates the rhs-contribution of the convective term and adds the result to the
184 * dst-vector. This functions is only used for a "linearly implicit formulation" of the convective
185 * term.
186 */
187 void
188 rhs_add_convective_term(VectorType & dst,
189 VectorType const & transport_velocity,
190 double const time) const;
191
192 /*
193 * Momentum step is a non-linear system of equations
194 */
195 std::tuple<unsigned int, unsigned int>
196 solve_nonlinear_momentum_equation(VectorType & dst,
197 VectorType const & rhs_vector,
198 double const & time,
199 bool const & update_preconditioner,
200 double const & scaling_factor_mass);
201
202 /*
203 * This function evaluates the nonlinear residual.
204 */
205 void
206 evaluate_nonlinear_residual(VectorType & dst,
207 VectorType const & src,
208 VectorType const * rhs_vector,
209 double const & time,
210 double const & scaling_factor_mass) const;
211
212protected:
213 // Pressure Poisson equation (operator, preconditioner, solver).
215
216 std::shared_ptr<PreconditionerBase<Number>> preconditioner_pressure_poisson;
217
218 std::shared_ptr<Krylov::SolverBase<VectorType>> pressure_poisson_solver;
219
220 /*
221 * Momentum equation.
222 */
223
224 // Nonlinear operator and solver
226
227 std::shared_ptr<Newton::Solver<VectorType,
231 momentum_newton_solver;
232
233 // linear solver (momentum_operator serves as linear operator)
234 std::shared_ptr<PreconditionerBase<Number>> momentum_preconditioner;
235 std::shared_ptr<Krylov::SolverBase<VectorType>> momentum_linear_solver;
236
237 void
238 setup_momentum_preconditioner();
239
240 void
241 setup_momentum_solver();
242
243private:
244 void
245 initialize_laplace_operator();
246
247 /*
248 * Setup functions called during setup of pressure Poisson solver.
249 */
250 void
251 setup_preconditioner_pressure_poisson();
252
253 void
254 setup_solver_pressure_poisson();
255};
256
257} // namespace IncNS
258} // namespace ExaDG
259
260#endif /* EXADG_INCOMPRESSIBLE_NAVIER_STOKES_SPATIAL_DISCRETIZATION_OPERATOR_PROJECTION_METHODS_H_ \
261 */
Definition grid.h:40
Definition momentum_operator.h:61
Definition operator_projection_methods.h:43
Definition operator_projection_methods.h:93
void setup_derived() override
Definition operator_projection_methods.cpp:59
Definition parameters.h:46
Definition iterative_solvers_dealii_wrapper.h:40
Definition grid.h:84
Definition newton_solver.h:40
Definition laplace_operator.h:230
Definition driver.cpp:33
Definition boundary_descriptor.h:240
Definition field_functions.h:31