ryujin 2.1.1 revision ee5cbcbf2346c1299c942d0e1f13b46449973c18
Loading...
Searching...
No Matches
parabolic_module.h
Go to the documentation of this file.
1//
2// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
3// Copyright (C) 2023 - 2026 by the ryujin authors
4//
5
6#pragma once
7
8#include <compile_time_options.h>
9
10#include "hyperbolic_module.h"
11
12#include "observer_pointer.h"
13#include <convenience_macros.h>
14#include <initial_values.h>
15#include <mpi_ensemble.h>
16#include <offline_data.h>
17#include <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/lac/la_parallel_block_vector.h>
24#include <deal.II/lac/precondition.h>
25#include <deal.II/lac/sparse_matrix.templates.h>
26#include <deal.II/lac/vector.h>
27#include <deal.II/matrix_free/matrix_free.h>
28#include <deal.II/multigrid/mg_base.h>
29#include <deal.II/multigrid/mg_smoother.h>
30#include <deal.II/multigrid/mg_transfer_matrix_free.h>
31
32namespace ryujin
33{
34 namespace NavierStokes
35 {
36 template <int, typename>
37 class DiagonalMatrix;
38
39 struct Description;
40
113 template <int dim, typename Number = double>
114 class ParabolicModule final : public dealii::ParameterAcceptor
115 {
116 public:
121
123
125
127
129
131
133
135
137
138 using state_type = typename View::state_type;
139
141
145
150 const MPIEnsemble &mpi_ensemble,
151 const OfflineData<dim, Number> &offline_data,
152 const HyperbolicSystem &hyperbolic_system,
153 const ParabolicSystem &parabolic_system,
154 const InitialValues<Description, dim, Number> &initial_values,
155 const std::string &subsection = "ParabolicModule");
156
162 void prepare();
163
165
169
177 void reinit_state_vector(StateVector & /*state_vector*/) const
178 {
179 // do nothing
180 }
181
186 void prepare_state_vector(StateVector &state_vector, Number t) const;
187
197 template <int stages>
198 void
199 backward_euler_step(const StateVector &old_state_vector,
200 const Number old_t,
201 std::array<std::reference_wrapper<const StateVector>,
202 stages> stage_state_vectors,
203 const std::array<Number, stages> stage_weights,
204 StateVector &new_state_vector,
205 Number tau) const;
206
212 void crank_nicolson_step(const StateVector &old_state_vector,
213 const Number old_t,
214 StateVector &new_state_vector,
215 Number tau) const;
216
221 {
222 id_violation_strategy_ = strategy;
223 }
224
226
230
236 void print_solver_statistics(std::ostream &output) const;
237
241 ACCESSOR_READ_ONLY(n_restarts)
242
243
248 ACCESSOR_READ_ONLY(n_corrections)
249
250
254 ACCESSOR_READ_ONLY(n_warnings)
255
256 private:
258
262
263 bool use_gmg_velocity_;
264 bool use_gmg_internal_energy_;
265
266 Number tolerance_;
267 bool tolerance_linfty_norm_;
268
269 unsigned int gmg_max_iter_vel_;
270 unsigned int gmg_max_iter_en_;
271 double gmg_smoother_range_vel_;
272 double gmg_smoother_range_en_;
273 double gmg_smoother_max_eig_vel_;
274 double gmg_smoother_max_eig_en_;
275 unsigned int gmg_smoother_degree_;
276 unsigned int gmg_smoother_n_cg_iter_;
277 unsigned int gmg_min_level_;
278
280
284
285 // FIXME: refactor
286 static constexpr unsigned int order_fe = 1;
287 static constexpr unsigned int order_quad = 2;
288
289 const MPIEnsemble &mpi_ensemble_;
290
291 dealii::ObserverPointer<const HyperbolicSystem> hyperbolic_system_;
292 dealii::ObserverPointer<const ParabolicSystem> parabolic_system_;
293 dealii::ObserverPointer<const ryujin::OfflineData<dim, Number>>
294 offline_data_;
295 dealii::ObserverPointer<
297 initial_values_;
298
299 mutable IDViolationStrategy id_violation_strategy_;
300
301 mutable unsigned int cycle_;
302
303 mutable unsigned int n_restarts_;
304 mutable unsigned int n_corrections_;
305 mutable unsigned int n_warnings_;
306 mutable double n_iterations_velocity_;
307 mutable double n_iterations_internal_energy_;
308
309 mutable dealii::MatrixFree<dim, Number> matrix_free_;
310
311 mutable BlockHostVector velocity_;
312 mutable BlockHostVector velocity_rhs_;
313 mutable ScalarHostVector internal_energy_;
314 mutable ScalarHostVector internal_energy_rhs_;
315 mutable ScalarHostVector density_;
316
317 mutable dealii::MGLevelObject<dealii::MatrixFree<dim, float>>
318 level_matrix_free_;
319 mutable dealii::MGConstrainedDoFs mg_constrained_dofs_;
320 mutable dealii::MGLevelObject<
321 dealii::LinearAlgebra::distributed::Vector<float>>
322 level_density_;
323 mutable MGTransferVelocity<dim, float> mg_transfer_velocity_;
324 mutable dealii::MGLevelObject<VelocityMatrix<dim, float, Number>>
325 level_velocity_matrices_;
326 mutable MGTransferEnergy<dim, float> mg_transfer_energy_;
327 mutable dealii::MGLevelObject<EnergyMatrix<dim, float, Number>>
328 level_energy_matrices_;
329
330 mutable dealii::mg::SmootherRelaxation<
331 dealii::PreconditionChebyshev<
333 dealii::LinearAlgebra::distributed::BlockVector<float>,
335 dealii::LinearAlgebra::distributed::BlockVector<float>>
336 mg_smoother_velocity_;
337
338 mutable dealii::mg::SmootherRelaxation<
339 dealii::PreconditionChebyshev<
341 dealii::LinearAlgebra::distributed::Vector<float>>,
342 dealii::LinearAlgebra::distributed::Vector<float>>
343 mg_smoother_energy_;
344
346
350
360 void step(const StateVector &old_state_vector,
361 const Number old_t,
362 StateVector &new_state_vector,
363 Number tau,
364 const bool crank_nicolson_extrapolation) const;
365
367 };
368
369 } // namespace NavierStokes
370} /* namespace ryujin */
dealii::Tensor< 1, problem_dimension, Number > state_type
static constexpr unsigned int problem_dimension
Vectors::StateVector< ScalarNumber, problem_dimension, n_precomputed_values > StateVector
typename get_value_type< Number >::type ScalarNumber
void reinit_state_vector(StateVector &) const
void crank_nicolson_step(const StateVector &old_state_vector, const Number old_t, StateVector &new_state_vector, Number tau) const
Vectors::BlockHostVector< Number > BlockHostVector
void prepare_state_vector(StateVector &state_vector, Number t) const
void backward_euler_step(const StateVector &old_state_vector, const Number old_t, std::array< std::reference_wrapper< const StateVector >, stages > stage_state_vectors, const std::array< Number, stages > stage_weights, StateVector &new_state_vector, Number tau) const
void set_id_violation_strategy(const IDViolationStrategy &strategy) const
void print_solver_statistics(std::ostream &output) const
Vectors::ScalarHostVector< Number > ScalarHostVector
typename View::StateVector StateVector
typename View::ScalarNumber ScalarNumber
#define ACCESSOR_READ_ONLY(member)
dealii::LinearAlgebra::distributed::BlockVector< Number > BlockHostVector
dealii::LinearAlgebra::distributed::Vector< Number > ScalarHostVector
Euler::Description Description