ryujin 2.1.1 revision 0eab90fbc6e1ac9f2e0a2e6d16f9f023c13a02f7
parabolic_module.template.h
Go to the documentation of this file.
1//
2// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
3// Copyright (C) 2023 by the ryujin authors
4//
5
6#pragma once
7
8#include "parabolic_module.h"
9
10namespace ryujin
11{
12 using namespace dealii;
13
14 template <typename Description, int dim, typename Number>
16 const MPIEnsemble &mpi_ensemble,
17 std::map<std::string, dealii::Timer> &computing_timer,
18 const OfflineData<dim, Number> &offline_data,
19 const HyperbolicSystem &hyperbolic_system,
20 const ParabolicSystem &parabolic_system,
21 const InitialValues<Description, dim, Number> &initial_values,
22 const std::string &subsection /*= "ParabolicModule"*/)
23 : ParameterAcceptor(subsection)
24 , id_violation_strategy_(IDViolationStrategy::warn)
25 , parabolic_solver_(mpi_ensemble,
26 computing_timer,
27 hyperbolic_system,
28 parabolic_system,
29 offline_data,
30 initial_values,
31 subsection)
32 , n_restarts_(0)
33 , n_corrections_(0)
34 , n_warnings_(0)
35 {
36 }
37
38
39 template <typename Description, int dim, typename Number>
41 {
42#ifdef DEBUG_OUTPUT
43 std::cout << "ParabolicModule<Description, dim, Number>::prepare()"
44 << std::endl;
45#endif
46 if constexpr (!ParabolicSystem::is_identity)
47 parabolic_solver_.prepare();
48
49 cycle_ = 0;
50 }
51
52
53 template <typename Description, int dim, typename Number>
55 StateVector &state_vector, Number t) const
56 {
57#ifdef DEBUG_OUTPUT
58 std::cout << "ParabolicModule<Description, dim, "
59 "Number>::prepare_state_vector()"
60 << std::endl;
61#endif
63 if constexpr (ParabolicSystem::is_identity) {
64 AssertThrow(
65 false,
66 dealii::ExcMessage("The parabolic system is the identity. This "
67 "function should have never been called."));
68 __builtin_trap();
69
70 } else {
71 parabolic_solver_.prepare_state_vector(state_vector, t);
72 }
73 }
74
75
76 template <typename Description, int dim, typename Number>
77 template <int stages>
79 const StateVector &old_state_vector,
80 const Number old_t,
81 std::array<std::reference_wrapper<const StateVector>,
82 stages> /*stage_state_vectors*/,
83 const std::array<Number, stages> /*stage_weights*/,
84 StateVector &new_state_vector,
85 Number tau) const
86 {
87 if constexpr (ParabolicSystem::is_identity) {
88 AssertThrow(
89 false,
90 dealii::ExcMessage("The parabolic system is the identity. This "
91 "function should have never been called."));
92 __builtin_trap();
93
94 } else {
95
96 AssertThrow(stages == 0,
97 dealii::ExcMessage("Although IMEX schemes are implemented, "
98 "the high order fluxes are not. "));
99
100 const bool reinit_gmg = cycle_++ % 4 == 0;
101 parabolic_solver_.backward_euler_step(old_state_vector,
102 old_t,
103 new_state_vector,
104 tau,
105 id_violation_strategy_,
106 reinit_gmg);
107
108 /* Update statistics: */
109 n_restarts_ = parabolic_solver_.n_restarts();
110 n_corrections_ = parabolic_solver_.n_corrections();
111 n_warnings_ = parabolic_solver_.n_warnings();
112 }
113 }
114
115
116 template <typename Description, int dim, typename Number>
118 const StateVector &old_state_vector,
119 const Number old_t,
120 StateVector &new_state_vector,
121 Number tau) const
122 {
123 if constexpr (ParabolicSystem::is_identity) {
124 AssertThrow(
125 false,
126 dealii::ExcMessage("The parabolic system is the identity. This "
127 "function should have never been called."));
128 __builtin_trap();
129
130 } else {
131
132 const bool reinit_gmg = cycle_++ % 4 == 0;
133 parabolic_solver_.crank_nicolson_step(old_state_vector,
134 old_t,
135 new_state_vector,
136 tau,
137 id_violation_strategy_,
138 reinit_gmg);
139
140 /* Update statistics: */
141 n_restarts_ = parabolic_solver_.n_restarts();
142 n_corrections_ = parabolic_solver_.n_corrections();
143 n_warnings_ = parabolic_solver_.n_warnings();
144 }
145 }
146
147
148 template <typename Description, int dim, typename Number>
150 std::ostream &output) const
151 {
152 if constexpr (!ParabolicSystem::is_identity) {
153 parabolic_solver_.print_solver_statistics(output);
154 }
155 }
156
157} /* namespace ryujin */
void prepare_state_vector(StateVector &state_vector, Number t) const
typename View::StateVector StateVector
void crank_nicolson_step(const StateVector &old_state_vector, const Number old_t, StateVector &new_state_vector, Number tau) const
typename Description::ParabolicSystem ParabolicSystem
ParabolicModule(const MPIEnsemble &mpi_ensemble, std::map< std::string, dealii::Timer > &computing_timer, const OfflineData< dim, Number > &offline_data, const HyperbolicSystem &hyperbolic_system, const ParabolicSystem &parabolic_system, const InitialValues< Description, dim, Number > &initial_values, const std::string &subsection="/ParabolicModule")
typename Description::HyperbolicSystem HyperbolicSystem
void print_solver_statistics(std::ostream &output) 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