ryujin 2.1.1 revision 7ab52d499a3934b3ba6afcabe5103994024860b0
limiter.h
Go to the documentation of this file.
1//
2// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
3// Copyright (C) 2023 - 2024 by the ryujin authors
4//
5
6#pragma once
7
8#include "hyperbolic_system.h"
9
10#include <compile_time_options.h>
12#include <newton.h>
13#include <simd.h>
14
15namespace ryujin
16{
17 namespace Skeleton
18 {
19 template <typename ScalarNumber = double>
20 class LimiterParameters : public dealii::ParameterAcceptor
21 {
22 public:
23 LimiterParameters(const std::string &subsection = "/Limiter")
24 : ParameterAcceptor(subsection)
25 {
26 iterations_ = 2;
27 add_parameter(
28 "iterations", iterations_, "Number of limiter iterations");
29 }
30
31 ACCESSOR_READ_ONLY(iterations);
32
33 private:
34 unsigned int iterations_;
35 };
36
37
43 template <int dim, typename Number = double>
44 class Limiter
45 {
46 public:
51
53
55
56 using state_type = typename View::state_type;
57
59
61
63
65
83
87 static constexpr unsigned int n_bounds = 0;
88
92 using Bounds = std::array<Number, n_bounds>;
93
97 Limiter(const HyperbolicSystem &hyperbolic_system,
98 const Parameters &parameters,
99 const PrecomputedVector &precomputed_values)
100 : hyperbolic_system(hyperbolic_system)
101 , parameters(parameters)
102 , precomputed_values(precomputed_values)
103 {
104 }
105
109 void reset(const unsigned int /*i*/,
110 const state_type & /*new_U_i*/,
111 const flux_contribution_type & /*new_flux_i*/)
112 {
113 // empty
114 }
115
120 void accumulate(const unsigned int * /*js*/,
121 const state_type & /*U_j*/,
122 const flux_contribution_type & /*flux_j*/,
123 const dealii::Tensor<1, dim, Number> & /*scaled_c_ij*/,
124 const state_type & /*affine_shift*/)
125 {
126 // empty
127 }
128
132 Bounds bounds(const Number /*hd_i*/) const
133 {
134 auto relaxed_bounds = bounds_;
135
136 return relaxed_bounds;
137 }
138
144 static Bounds combine_bounds(const Bounds & /*bounds_left*/,
145 const Bounds & /*bounds_right*/)
146 {
147 return Bounds{};
148 }
149
150 //*}
153
160 std::tuple<Number, bool> limit(const Bounds & /*bounds*/,
161 const state_type & /*U*/,
162 const state_type & /*P*/,
163 const Number /*t_min*/ = Number(0.),
164 const Number t_max = Number(1.))
165 {
166 return {t_max, true};
167 }
168
169 //*}
174
181 static bool
182 is_in_invariant_domain(const HyperbolicSystem & /*hyperbolic_system*/,
183 const Bounds & /*bounds*/,
184 const state_type & /*U*/)
185 {
186 return true;
187 }
188
189 private:
191
193
194 const HyperbolicSystem &hyperbolic_system;
195 const Parameters &parameters;
196 const PrecomputedVector &precomputed_values;
197
198 Bounds bounds_;
200 };
201 } // namespace Skeleton
202} // namespace ryujin
dealii::Tensor< 1, problem_dimension, Number > state_type
typename get_value_type< Number >::type ScalarNumber
Vectors::MultiComponentVector< ScalarNumber, n_precomputed_values > PrecomputedVector
LimiterParameters(const std::string &subsection="/Limiter")
Definition: limiter.h:23
typename View::ScalarNumber ScalarNumber
Definition: limiter.h:54
static Bounds combine_bounds(const Bounds &, const Bounds &)
Definition: limiter.h:144
void accumulate(const unsigned int *, const state_type &, const flux_contribution_type &, const dealii::Tensor< 1, dim, Number > &, const state_type &)
Definition: limiter.h:120
typename View::state_type state_type
Definition: limiter.h:56
static constexpr unsigned int n_bounds
Definition: limiter.h:87
typename View::flux_contribution_type flux_contribution_type
Definition: limiter.h:58
void reset(const unsigned int, const state_type &, const flux_contribution_type &)
Definition: limiter.h:109
std::tuple< Number, bool > limit(const Bounds &, const state_type &, const state_type &, const Number=Number(0.), const Number t_max=Number(1.))
Definition: limiter.h:160
std::array< Number, n_bounds > Bounds
Definition: limiter.h:92
Bounds bounds(const Number) const
Definition: limiter.h:132
Limiter(const HyperbolicSystem &hyperbolic_system, const Parameters &parameters, const PrecomputedVector &precomputed_values)
Definition: limiter.h:97
LimiterParameters< ScalarNumber > Parameters
Definition: limiter.h:62
typename View::PrecomputedVector PrecomputedVector
Definition: limiter.h:60
static bool is_in_invariant_domain(const HyperbolicSystem &, const Bounds &, const state_type &)
Definition: limiter.h:182