ryujin 2.1.1 revision b04fb4aba7bd97ddfa5994a6b4b6e8586eb15db2
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 Euler
35 {
37 }
38
39 namespace NavierStokes
40 {
41 template <int, typename>
42 class DiagonalMatrix;
43
116 template <int dim, typename Number = double>
117 class ParabolicModule final : public dealii::ParameterAcceptor
118 {
119 public:
124
126
128
130
132
134 dealii::LinearAlgebra::distributed::BlockVector<Number>;
135
137
139
140 using state_type = typename View::state_type;
141
143
147
151 ParabolicModule(const MPIEnsemble &mpi_ensemble,
152 const OfflineData<dim, Number> &offline_data,
153 const HyperbolicSystem &hyperbolic_system,
154 const ParabolicSystem &parabolic_system,
156 &initial_values,
157 const std::string &subsection = "ParabolicModule");
158
164 void prepare();
165
167
171
179 void reinit_state_vector(StateVector<Number> & /*state_vector*/) const
180 {
181 // do nothing
182 }
183
188 void prepare_state_vector(StateVector<Number> &state_vector,
189 Number t) const;
190
200 template <int stages>
202 const StateVector<Number> &old_state_vector,
203 const Number old_t,
204 std::array<std::reference_wrapper<const StateVector<Number>>, stages>
205 stage_state_vectors,
206 const std::array<Number, stages> stage_weights,
207 StateVector<Number> &new_state_vector,
208 Number tau) const;
209
215 void crank_nicolson_step(const StateVector<Number> &old_state_vector,
216 const Number old_t,
217 StateVector<Number> &new_state_vector,
218 Number tau) const;
219
224 {
225 id_violation_strategy_ = strategy;
226 }
227
229
233
239 void print_solver_statistics(std::ostream &output) const;
240
244 ACCESSOR_READ_ONLY(n_restarts)
245
246
251 ACCESSOR_READ_ONLY(n_corrections)
252
253
257 ACCESSOR_READ_ONLY(n_warnings)
258
259 private:
261
265
266 bool use_gmg_velocity_;
267 bool use_gmg_internal_energy_;
268
269 Number tolerance_;
270 bool tolerance_linfty_norm_;
271
272 unsigned int gmg_max_iter_vel_;
273 unsigned int gmg_max_iter_en_;
274 double gmg_smoother_range_vel_;
275 double gmg_smoother_range_en_;
276 double gmg_smoother_max_eig_vel_;
277 double gmg_smoother_max_eig_en_;
278 unsigned int gmg_smoother_degree_;
279 unsigned int gmg_smoother_n_cg_iter_;
280 unsigned int gmg_min_level_;
281
283
287
288 // FIXME: refactor
289 static constexpr unsigned int order_fe = 1;
290 static constexpr unsigned int order_quad = 2;
291
292 const MPIEnsemble &mpi_ensemble_;
293
294 dealii::ObserverPointer<const HyperbolicSystem> hyperbolic_system_;
295 dealii::ObserverPointer<const ParabolicSystem> parabolic_system_;
296 dealii::ObserverPointer<const ryujin::OfflineData<dim, Number>>
297 offline_data_;
298 dealii::ObserverPointer<
300 initial_values_;
301
302 mutable IDViolationStrategy id_violation_strategy_;
303
304 mutable unsigned int cycle_;
305
306 mutable unsigned int n_restarts_;
307 mutable unsigned int n_corrections_;
308 mutable unsigned int n_warnings_;
309 mutable double n_iterations_velocity_;
310 mutable double n_iterations_internal_energy_;
311
312 mutable dealii::MatrixFree<dim, Number> matrix_free_;
313
314 mutable BlockHostVector velocity_;
315 mutable BlockHostVector velocity_rhs_;
316 mutable ScalarHostVector<Number> internal_energy_;
317 mutable ScalarHostVector<Number> internal_energy_rhs_;
318 mutable ScalarHostVector<Number> density_;
319
320 mutable dealii::MGLevelObject<dealii::MatrixFree<dim, float>>
321 level_matrix_free_;
322 mutable dealii::MGConstrainedDoFs mg_constrained_dofs_;
323 mutable dealii::MGLevelObject<
324 dealii::LinearAlgebra::distributed::Vector<float>>
325 level_density_;
326 mutable MGTransferVelocity<dim, float> mg_transfer_velocity_;
327 mutable dealii::MGLevelObject<VelocityMatrix<dim, float, Number>>
328 level_velocity_matrices_;
329 mutable MGTransferEnergy<dim, float> mg_transfer_energy_;
330 mutable dealii::MGLevelObject<EnergyMatrix<dim, float, Number>>
331 level_energy_matrices_;
332
333 mutable dealii::mg::SmootherRelaxation<
334 dealii::PreconditionChebyshev<
336 dealii::LinearAlgebra::distributed::BlockVector<float>,
338 dealii::LinearAlgebra::distributed::BlockVector<float>>
339 mg_smoother_velocity_;
340
341 mutable dealii::mg::SmootherRelaxation<
342 dealii::PreconditionChebyshev<
344 dealii::LinearAlgebra::distributed::Vector<float>>,
345 dealii::LinearAlgebra::distributed::Vector<float>>
346 mg_smoother_energy_;
347
349
353
363 void step(const StateVector<Number> &old_state_vector,
364 const Number old_t,
365 StateVector<Number> &new_state_vector,
366 Number tau,
367 const bool crank_nicolson_extrapolation) const;
368
370 };
371
372 } // namespace NavierStokes
373} /* namespace ryujin */
dealii::Tensor< 1, problem_dimension, Number > state_type
static constexpr unsigned int problem_dimension
typename get_value_type< Number >::type ScalarNumber
void backward_euler_step(const StateVector< Number > &old_state_vector, const Number old_t, std::array< std::reference_wrapper< const StateVector< Number > >, stages > stage_state_vectors, const std::array< Number, stages > stage_weights, StateVector< Number > &new_state_vector, Number tau) const
void set_id_violation_strategy(const IDViolationStrategy &strategy) const
void reinit_state_vector(StateVector< Number > &) const
void print_solver_statistics(std::ostream &output) const
void crank_nicolson_step(const StateVector< Number > &old_state_vector, const Number old_t, StateVector< Number > &new_state_vector, Number tau) const
void prepare_state_vector(StateVector< Number > &state_vector, Number t) const
dealii::LinearAlgebra::distributed::BlockVector< Number > BlockHostVector
typename View::ScalarNumber ScalarNumber
#define ACCESSOR_READ_ONLY(member)
dealii::LinearAlgebra::distributed::Vector< Number > ScalarHostVector
Euler::HyperbolicDescription HyperbolicDescription