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