ryujin 2.1.1 revision 71cdc42292164f8095c0bd62c4ea75ebcfac58fa
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 dealii::LinearAlgebra::distributed::BlockVector<Number>;
134
136
138
139 using state_type = typename View::state_type;
140
142
146
151 const MPIEnsemble &mpi_ensemble,
152 const OfflineData<dim, Number> &offline_data,
153 const HyperbolicSystem &hyperbolic_system,
154 const ParabolicSystem &parabolic_system,
155 const InitialValues<Description, dim, Number> &initial_values,
156 const std::string &subsection = "ParabolicModule");
157
163 void prepare();
164
166
170
178 void reinit_state_vector(StateVector & /*state_vector*/) const
179 {
180 // do nothing
181 }
182
187 void prepare_state_vector(StateVector &state_vector, Number t) const;
188
198 template <int stages>
199 void
200 backward_euler_step(const StateVector &old_state_vector,
201 const Number old_t,
202 std::array<std::reference_wrapper<const StateVector>,
203 stages> stage_state_vectors,
204 const std::array<Number, stages> stage_weights,
205 StateVector &new_state_vector,
206 Number tau) const;
207
213 void crank_nicolson_step(const StateVector &old_state_vector,
214 const Number old_t,
215 StateVector &new_state_vector,
216 Number tau) const;
217
222 {
223 id_violation_strategy_ = strategy;
224 }
225
227
231
237 void print_solver_statistics(std::ostream &output) const;
238
242 ACCESSOR_READ_ONLY(n_restarts)
243
244
249 ACCESSOR_READ_ONLY(n_corrections)
250
251
255 ACCESSOR_READ_ONLY(n_warnings)
256
257 private:
259
263
264 bool use_gmg_velocity_;
265 bool use_gmg_internal_energy_;
266
267 Number tolerance_;
268 bool tolerance_linfty_norm_;
269
270 unsigned int gmg_max_iter_vel_;
271 unsigned int gmg_max_iter_en_;
272 double gmg_smoother_range_vel_;
273 double gmg_smoother_range_en_;
274 double gmg_smoother_max_eig_vel_;
275 double gmg_smoother_max_eig_en_;
276 unsigned int gmg_smoother_degree_;
277 unsigned int gmg_smoother_n_cg_iter_;
278 unsigned int gmg_min_level_;
279
281
285
286 // FIXME: refactor
287 static constexpr unsigned int order_fe = 1;
288 static constexpr unsigned int order_quad = 2;
289
290 const MPIEnsemble &mpi_ensemble_;
291
292 dealii::ObserverPointer<const HyperbolicSystem> hyperbolic_system_;
293 dealii::ObserverPointer<const ParabolicSystem> parabolic_system_;
294 dealii::ObserverPointer<const ryujin::OfflineData<dim, Number>>
295 offline_data_;
296 dealii::ObserverPointer<
298 initial_values_;
299
300 mutable IDViolationStrategy id_violation_strategy_;
301
302 mutable unsigned int cycle_;
303
304 mutable unsigned int n_restarts_;
305 mutable unsigned int n_corrections_;
306 mutable unsigned int n_warnings_;
307 mutable double n_iterations_velocity_;
308 mutable double n_iterations_internal_energy_;
309
310 mutable dealii::MatrixFree<dim, Number> matrix_free_;
311
312 mutable BlockHostVector velocity_;
313 mutable BlockHostVector velocity_rhs_;
314 mutable ScalarHostVector internal_energy_;
315 mutable ScalarHostVector internal_energy_rhs_;
316 mutable ScalarHostVector density_;
317
318 mutable dealii::MGLevelObject<dealii::MatrixFree<dim, float>>
319 level_matrix_free_;
320 mutable dealii::MGConstrainedDoFs mg_constrained_dofs_;
321 mutable dealii::MGLevelObject<
322 dealii::LinearAlgebra::distributed::Vector<float>>
323 level_density_;
324 mutable MGTransferVelocity<dim, float> mg_transfer_velocity_;
325 mutable dealii::MGLevelObject<VelocityMatrix<dim, float, Number>>
326 level_velocity_matrices_;
327 mutable MGTransferEnergy<dim, float> mg_transfer_energy_;
328 mutable dealii::MGLevelObject<EnergyMatrix<dim, float, Number>>
329 level_energy_matrices_;
330
331 mutable dealii::mg::SmootherRelaxation<
332 dealii::PreconditionChebyshev<
334 dealii::LinearAlgebra::distributed::BlockVector<float>,
336 dealii::LinearAlgebra::distributed::BlockVector<float>>
337 mg_smoother_velocity_;
338
339 mutable dealii::mg::SmootherRelaxation<
340 dealii::PreconditionChebyshev<
342 dealii::LinearAlgebra::distributed::Vector<float>>,
343 dealii::LinearAlgebra::distributed::Vector<float>>
344 mg_smoother_energy_;
345
347
351
361 void step(const StateVector &old_state_vector,
362 const Number old_t,
363 StateVector &new_state_vector,
364 Number tau,
365 const bool crank_nicolson_extrapolation) const;
366
368 };
369
370 } // namespace NavierStokes
371} /* 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
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
dealii::LinearAlgebra::distributed::BlockVector< Number > BlockHostVector
typename View::StateVector StateVector
typename View::ScalarNumber ScalarNumber
#define ACCESSOR_READ_ONLY(member)
dealii::LinearAlgebra::distributed::Vector< Number > ScalarHostVector
Euler::Description Description