ryujin 2.1.1 revision 0348cbb53a3e4b1da2a4c037e81f88f2d21ce219
parabolic_solver.h
Go to the documentation of this file.
1//
2// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
3// Copyright (C) 2023 - 2024 by the ryujin authors
4//
5
6#pragma once
7
8#include "hyperbolic_module.h"
9
10#include <compile_time_options.h>
11
12#include <convenience_macros.h>
13#include <initial_values.h>
14#include <mpi_ensemble.h>
15#include <offline_data.h>
16#include <simd.h>
17#include <sparse_matrix_simd.h>
18
20
21#include <deal.II/base/mg_level_object.h>
22#include <deal.II/base/parameter_acceptor.h>
23#include <deal.II/base/smartpointer.h>
24#include <deal.II/base/timer.h>
25#include <deal.II/lac/la_parallel_block_vector.h>
26#include <deal.II/lac/precondition.h>
27#include <deal.II/lac/sparse_matrix.templates.h>
28#include <deal.II/lac/vector.h>
29#include <deal.II/matrix_free/matrix_free.h>
30#include <deal.II/multigrid/mg_base.h>
31#include <deal.II/multigrid/mg_smoother.h>
32#include <deal.II/multigrid/mg_transfer_matrix_free.h>
33
34namespace ryujin
35{
36 namespace NavierStokes
37 {
38 template <int, typename>
39 class DiagonalMatrix;
40
113 template <typename Description, int dim, typename Number = double>
114 class ParabolicSolver final : public dealii::ParameterAcceptor
115 {
116 public:
121
123
124 using View =
125 typename Description::template HyperbolicSystemView<dim, Number>;
126
128
129 using ScalarNumber = typename View::ScalarNumber;
130
131 static constexpr auto problem_dimension = View::problem_dimension;
132
133 using state_type = typename View::state_type;
134
136
138
140
142
146
151 const MPIEnsemble &mpi_ensemble,
152 std::map<std::string, dealii::Timer> &computing_timer,
153 const HyperbolicSystem &hyperbolic_system,
154 const ParabolicSystem &parabolic_system,
155 const OfflineData<dim, Number> &offline_data,
156 const InitialValues<Description, dim, Number> &initial_values,
157 const std::string &subsection = "ParabolicSolver");
158
164 void prepare();
165
167
171
177 void backward_euler_step(const StateVector &old_state_vector,
178 const Number old_t,
179 StateVector &new_state_vector,
180 Number tau,
181 const IDViolationStrategy id_violation_strategy,
182 const bool reinitialize_gmg) const;
183
189 void print_solver_statistics(std::ostream &output) const;
190
192
196
197 ACCESSOR_READ_ONLY(n_restarts)
198 ACCESSOR_READ_ONLY(n_warnings)
199
200 //@}
201
202 private:
207
208 bool use_gmg_velocity_;
209 ACCESSOR_READ_ONLY(use_gmg_velocity)
210
211 bool use_gmg_internal_energy_;
212 ACCESSOR_READ_ONLY(use_gmg_internal_energy)
213
214 Number tolerance_;
215 bool tolerance_linfty_norm_;
216
217 unsigned int gmg_max_iter_vel_;
218 unsigned int gmg_max_iter_en_;
219 double gmg_smoother_range_vel_;
220 double gmg_smoother_range_en_;
221 double gmg_smoother_max_eig_vel_;
222 double gmg_smoother_max_eig_en_;
223 unsigned int gmg_smoother_degree_;
224 unsigned int gmg_smoother_n_cg_iter_;
225 unsigned int gmg_min_level_;
226
228
232
233 // FIXME: refactor
234 static constexpr unsigned int order_fe = 1;
235 static constexpr unsigned int order_quad = 2;
236
237 const MPIEnsemble &mpi_ensemble_;
238 std::map<std::string, dealii::Timer> &computing_timer_;
239
240 dealii::SmartPointer<const HyperbolicSystem> hyperbolic_system_;
241 dealii::SmartPointer<const ParabolicSystem> parabolic_system_;
242 dealii::SmartPointer<const ryujin::OfflineData<dim, Number>>
243 offline_data_;
244 dealii::SmartPointer<
246 initial_values_;
247
248 mutable unsigned int n_restarts_;
249 mutable unsigned int n_warnings_;
250 mutable double n_iterations_velocity_;
251 mutable double n_iterations_internal_energy_;
252
253 mutable dealii::MatrixFree<dim, Number> matrix_free_;
254
255 mutable BlockVector velocity_;
256 mutable BlockVector velocity_rhs_;
257 mutable ScalarVector internal_energy_;
258 mutable ScalarVector internal_energy_rhs_;
259 mutable ScalarVector density_;
260
261 mutable dealii::MGLevelObject<dealii::MatrixFree<dim, float>>
262 level_matrix_free_;
263 mutable dealii::MGConstrainedDoFs mg_constrained_dofs_;
264 mutable dealii::MGLevelObject<
265 dealii::LinearAlgebra::distributed::Vector<float>>
266 level_density_;
267 mutable MGTransferVelocity<dim, float> mg_transfer_velocity_;
268 mutable dealii::MGLevelObject<VelocityMatrix<dim, float, Number>>
269 level_velocity_matrices_;
270 mutable MGTransferEnergy<dim, float> mg_transfer_energy_;
271 mutable dealii::MGLevelObject<EnergyMatrix<dim, float, Number>>
272 level_energy_matrices_;
273
274 mutable dealii::mg::SmootherRelaxation<
275 dealii::PreconditionChebyshev<
277 dealii::LinearAlgebra::distributed::BlockVector<float>,
279 dealii::LinearAlgebra::distributed::BlockVector<float>>
280 mg_smoother_velocity_;
281
282 mutable dealii::mg::SmootherRelaxation<
283 dealii::PreconditionChebyshev<
285 dealii::LinearAlgebra::distributed::Vector<float>>,
286 dealii::LinearAlgebra::distributed::Vector<float>>
287 mg_smoother_energy_;
288
290 };
291
292 } // namespace NavierStokes
293} /* namespace ryujin */
void backward_euler_step(const StateVector &old_state_vector, const Number old_t, StateVector &new_state_vector, Number tau, const IDViolationStrategy id_violation_strategy, const bool reinitialize_gmg) const
typename Description::ParabolicSystem ParabolicSystem
typename View::ScalarNumber ScalarNumber
typename View::StateVector StateVector
typename Description::template HyperbolicSystemView< dim, Number > View
void print_solver_statistics(std::ostream &output) const
typename Description::HyperbolicSystem HyperbolicSystem
Vectors::ScalarVector< Number > ScalarVector
Vectors::BlockVector< Number > BlockVector
ParabolicSolver(const MPIEnsemble &mpi_ensemble, std::map< std::string, dealii::Timer > &computing_timer, const HyperbolicSystem &hyperbolic_system, const ParabolicSystem &parabolic_system, const OfflineData< dim, Number > &offline_data, const InitialValues< Description, dim, Number > &initial_values, const std::string &subsection="ParabolicSolver")
typename View::state_type state_type
#define ACCESSOR_READ_ONLY(member)
dealii::LinearAlgebra::distributed::Vector< Number > ScalarVector
Definition: state_vector.h:31
dealii::LinearAlgebra::distributed::BlockVector< Number > BlockVector
Definition: state_vector.h:37
std::tuple< MultiComponentVector< Number, problem_dim >, MultiComponentVector< Number, prec_dim >, BlockVector< Number > > StateVector
Definition: state_vector.h:51
Euler::HyperbolicSystem HyperbolicSystem
Definition: description.h:31
NavierStokes::ParabolicSystem ParabolicSystem
Definition: description.h:36