ryujin 2.1.1 revision b04fb4aba7bd97ddfa5994a6b4b6e8586eb15db2
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#include <utility>
24
25namespace ryujin
26{
47 enum class IDViolationStrategy : std::uint8_t {
52 warn,
53
60 };
61
62
79 class Restart final
80 {
81 public:
83 };
84
85
99 class Correction final
100 {
101 };
102
103
112 template <typename HyperbolicDescription, int dim, typename Number = double>
113 class HyperbolicModule final : public dealii::ParameterAcceptor
114 {
115 public:
120
122
123 using View = typename HyperbolicSystem::template View<dim, Number>;
124
125 using Indicator =
126 typename HyperbolicDescription::template Indicator<Number>;
127
128 using Limiter = typename HyperbolicDescription::template Limiter<Number>;
129
131 typename HyperbolicDescription::template WaveSpeedEstimator<Number>;
132
133 static constexpr auto problem_dimension = View::problem_dimension;
134
135 using state_type = typename View::state_type;
136
137 static constexpr auto n_precomputed_values = View::n_precomputed_values;
138
139 using precomputed_type = typename View::precomputed_type;
140
141 static constexpr auto n_initial_precomputed_values =
142 View::n_initial_precomputed_values;
143
144 using initial_precomputed_type = typename View::initial_precomputed_type;
145
147
151
156 const MPIEnsemble &mpi_ensemble,
160 const std::string &subsection = "/HyperbolicModule");
161
167 void prepare();
168
170
174
181 void reinit_state_vector(StateVector<Number> &state_vector) const;
182
198 void prepare_state_vector(StateVector<Number> &state_vector,
199 Number t) const;
200
263 template <int stages>
264 Number step(const StateVector<Number> &old_state_vector,
265 std::array<std::reference_wrapper<const StateVector<Number>>,
266 stages> stage_state_vectors,
267 const std::array<Number, stages> stage_weights,
268 StateVector<Number> &new_state_vector,
269 Number tau = Number(0.),
270 Number tau_max = std::numeric_limits<Number>::max()) const;
271
279 void set_cfl(Number new_cfl) const
280 {
281 Assert(cfl_ > Number(0.), dealii::ExcInternalError());
282 cfl_ = new_cfl;
283 }
284
291 void set_acceptable_tau_max_ratio(Number new_acceptable_tau_max_ratio) const
292 {
293 Assert(new_acceptable_tau_max_ratio >= Number(1.),
294 dealii::ExcInternalError());
295 acceptable_tau_max_ratio_ = new_acceptable_tau_max_ratio;
296 }
297
302 {
303 id_violation_strategy_ = strategy;
304 }
305
307
311
317
318
325
330
335
340
347
354
361
368
369 private:
371
375
389 template <typename MemorySpace>
390 void apply_boundary_conditions(MultiComponentVector<Number> &U,
391 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<
415 const InitialValues<HyperbolicDescription, dim, Number>>
416 initial_values_;
417
418 mutable Number cfl_;
419 mutable Number acceptable_tau_max_ratio_;
420
421 mutable IDViolationStrategy id_violation_strategy_;
422
423 mutable unsigned int n_restarts_;
424 mutable unsigned int n_corrections_;
425 mutable unsigned int n_warnings_;
426
427 MultiComponentVector<Number> initial_precomputed_;
428
429 mutable ScalarVector<Number> alpha_;
430
431 static constexpr auto n_bounds =
432 decltype(std::declval<const Limiter &>()
433 .template view<dim, Number>())::n_bounds;
434 mutable MultiComponentVector<Number> bounds_;
435
436 mutable MultiComponentVector<Number> r_;
437
438 /*
439 * A compact buffer holding all boundary states of the hyperbolic state
440 * vector, see apply_boundary_conditions().
441 */
442 mutable Mirrored<Number *> boundary_states_{
443 "hyperbolic_module_boundary_states"};
444
445 mutable SparseMatrix<Number> dij_matrix_;
446 mutable SparseMatrix<Number> lij_matrix_;
447 mutable SparseMatrix<Number> lij_matrix_next_;
448 mutable SparseMatrix<Number, problem_dimension> pij_matrix_;
449
451 };
452
453} /* namespace ryujin */
void reinit_state_vector(StateVector< Number > &state_vector) const
const auto & n_restarts() const
typename HyperbolicSystem::template View< dim, Number > View
const auto & n_corrections() const
typename HyperbolicDescription::HyperbolicSystem HyperbolicSystem
const auto & initial_precomputed() const
const auto & acceptable_tau_max_ratio() const
static constexpr auto problem_dimension
static constexpr auto n_precomputed_values
const auto & n_warnings() const
void set_id_violation_strategy(const IDViolationStrategy &strategy) const
typename View::precomputed_type precomputed_type
typename View::state_type state_type
void set_acceptable_tau_max_ratio(Number new_acceptable_tau_max_ratio) const
const auto & alpha() const
void prepare_state_vector(StateVector< Number > &state_vector, Number t) const
Number step(const StateVector< Number > &old_state_vector, 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=Number(0.), Number tau_max=std::numeric_limits< Number >::max()) const
const auto & hyperbolic_system() const
const auto & offline_data() const
static constexpr auto n_initial_precomputed_values
typename HyperbolicDescription::template Indicator< Number > Indicator
typename HyperbolicDescription::template WaveSpeedEstimator< Number > WaveSpeedEstimator
void set_cfl(Number new_cfl) const
typename HyperbolicDescription::template Limiter< Number > Limiter
const auto & cfl() const
typename View::initial_precomputed_type initial_precomputed_type
#define ACCESSOR_READ_ONLY(member)
SmartPointer< T, P > ObserverPointer