ryujin 2.1.1 revision ee5cbcbf2346c1299c942d0e1f13b46449973c18
Loading...
Searching...
No Matches
hyperbolic_module.h
Go to the documentation of this file.
1//
2// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
3// Copyright (C) 2020 - 2026 by the ryujin authors
4//
5
6#pragma once
7
8#include <compile_time_options.h>
9
10#include "convenience_macros.h"
11#include "initial_values.h"
12#include "mpi_ensemble.h"
13#include "observer_pointer.h"
14#include "offline_data.h"
15#include "sparse_matrix.h"
16#include "state_vector.h"
17
18#include <deal.II/base/parameter_acceptor.h>
19#include <deal.II/lac/sparse_matrix.templates.h>
20#include <deal.II/lac/vector.h>
21
22#include <functional>
23
24namespace ryujin
25{
46 enum class IDViolationStrategy : std::uint8_t {
51 warn,
52
59 };
60
61
78 class Restart final
79 {
80 public:
82 };
83
84
98 class Correction final
99 {
100 };
101
102
111 template <typename Description, int dim, typename Number = double>
112 class HyperbolicModule final : public dealii::ParameterAcceptor
113 {
114 public:
119
121
122 using View = typename HyperbolicSystem::template View<dim, Number>;
123
124 using Indicator = typename Description::template Indicator<Number>;
125
126 using Limiter = typename Description::template Limiter<Number>;
127
129 typename Description::template WaveSpeedEstimator<Number>;
130
131 static constexpr auto problem_dimension = View::problem_dimension;
132
133 using state_type = typename View::state_type;
134
135 static constexpr auto n_precomputed_values = View::n_precomputed_values;
136
137 using precomputed_type = typename View::precomputed_type;
138
139 using initial_precomputed_type = typename View::initial_precomputed_type;
140
141 using StateVector = typename View::StateVector;
142
143 using InitialPrecomputedVector = typename View::InitialPrecomputedVector;
144
146
150
155 const MPIEnsemble &mpi_ensemble,
158 const InitialValues<Description, dim, Number> &initial_values,
159 const std::string &subsection = "/HyperbolicModule");
160
166 void prepare();
167
169
173
180 void reinit_state_vector(StateVector &state_vector) const;
181
197 void prepare_state_vector(StateVector &state_vector, Number t) const;
198
261 template <int stages>
262 Number step(const StateVector &old_state_vector,
263 std::array<std::reference_wrapper<const StateVector>, stages>
264 stage_state_vectors,
265 const std::array<Number, stages> stage_weights,
266 StateVector &new_state_vector,
267 Number tau = Number(0.),
268 Number tau_max = std::numeric_limits<Number>::max()) const;
269
277 void set_cfl(Number new_cfl) const
278 {
279 Assert(cfl_ > Number(0.), dealii::ExcInternalError());
280 cfl_ = new_cfl;
281 }
282
289 void set_acceptable_tau_max_ratio(Number new_acceptable_tau_max_ratio) const
290 {
291 Assert(new_acceptable_tau_max_ratio >= Number(1.),
292 dealii::ExcInternalError());
293 acceptable_tau_max_ratio_ = new_acceptable_tau_max_ratio;
294 }
295
300 {
301 id_violation_strategy_ = strategy;
302 }
303
305
309
315
316
323
328
333
338
345
352
359
366
367 private:
369
373
374 using HyperbolicVector =
375 Vectors::MultiComponentVector<Number, problem_dimension>;
376
390 template <typename MemorySpace>
391 void apply_boundary_conditions(HyperbolicVector &U, const Number t) const;
392
394
398 Indicator indicator_;
399
400 Limiter limiter_;
401
402 WaveSpeedEstimator wave_speed_estimator_;
403
405
409
410 const MPIEnsemble &mpi_ensemble_;
411
412 dealii::ObserverPointer<const OfflineData<dim, Number>> offline_data_;
413 dealii::ObserverPointer<const HyperbolicSystem> hyperbolic_system_;
414 dealii::ObserverPointer<const InitialValues<Description, dim, Number>>
415 initial_values_;
416
417 mutable Number cfl_;
418 mutable Number acceptable_tau_max_ratio_;
419
420 mutable IDViolationStrategy id_violation_strategy_;
421
422 mutable unsigned int n_restarts_;
423 mutable unsigned int n_corrections_;
424 mutable unsigned int n_warnings_;
425
426 InitialPrecomputedVector initial_precomputed_;
427
428 using ScalarVector = typename Vectors::ScalarVector<Number>;
429 mutable ScalarVector alpha_;
430
431 static constexpr auto n_bounds =
432 Limiter::template View<dim, Number>::n_bounds;
433 mutable Vectors::MultiComponentVector<Number, n_bounds> bounds_;
434
435 mutable HyperbolicVector r_;
436
437 /*
438 * A compact buffer holding all boundary states of the hyperbolic state
439 * vector, see apply_boundary_conditions().
440 */
441 mutable Mirrored<Number *> boundary_states_{
442 "hyperbolic_module_boundary_states"};
443
444 mutable SparseMatrix<Number> dij_matrix_;
445 mutable SparseMatrix<Number> lij_matrix_;
446 mutable SparseMatrix<Number> lij_matrix_next_;
447 mutable SparseMatrix<Number, problem_dimension> pij_matrix_;
448
450 };
451
452} /* namespace ryujin */
const auto & n_warnings() const
typename HyperbolicSystem::template View< dim, Number > View
static constexpr auto problem_dimension
void reinit_state_vector(StateVector &state_vector) const
const auto & acceptable_tau_max_ratio() const
typename Description::template WaveSpeedEstimator< Number > WaveSpeedEstimator
typename View::initial_precomputed_type initial_precomputed_type
static constexpr auto n_precomputed_values
typename Description::HyperbolicSystem HyperbolicSystem
void set_id_violation_strategy(const IDViolationStrategy &strategy) const
void set_acceptable_tau_max_ratio(Number new_acceptable_tau_max_ratio) const
typename View::StateVector StateVector
typename View::precomputed_type precomputed_type
typename View::state_type state_type
const auto & cfl() const
const auto & alpha() const
Number step(const StateVector &old_state_vector, std::array< std::reference_wrapper< const StateVector >, stages > stage_state_vectors, const std::array< Number, stages > stage_weights, StateVector &new_state_vector, Number tau=Number(0.), Number tau_max=std::numeric_limits< Number >::max()) const
void set_cfl(Number new_cfl) const
typename Description::template Indicator< Number > Indicator
typename Description::template Limiter< Number > Limiter
const auto & n_corrections() const
typename View::InitialPrecomputedVector InitialPrecomputedVector
const auto & hyperbolic_system() const
const auto & offline_data() const
void prepare_state_vector(StateVector &state_vector, Number t) const
const auto & n_restarts() const
const auto & initial_precomputed() const
#define ACCESSOR_READ_ONLY(member)
SmartPointer< T, P > ObserverPointer
Euler::HyperbolicSystem HyperbolicSystem
Definition description.h:34