ryujin 2.1.1 revision ee5cbcbf2346c1299c942d0e1f13b46449973c18
Loading...
Searching...
No Matches
limiter.h
Go to the documentation of this file.
1//
2// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
3// Copyright (C) 2023 - 2025 by the ryujin authors
4//
5
6#pragma once
7
8#include <compile_time_options.h>
9
10#include "hyperbolic_system.h"
11
12#include <compile_time_options.h>
14#include <newton.h>
15#include <observer_pointer.h>
16#include <simd.h>
17
18namespace ryujin
19{
20 namespace Skeleton
21 {
22 template <int dim, typename Number = double>
23 class LimiterView;
24
30 template <typename ScalarNumber = double>
31 class Limiter : public dealii::ParameterAcceptor
32 {
33 public:
38
43 template <int dim, typename Number = double>
45
47
51
55 Limiter(const HyperbolicSystem &hyperbolic_system,
56 const std::string &subsection = "/Limiter")
57 : ParameterAcceptor(subsection)
58 , hyperbolic_system_(&hyperbolic_system)
59 {
60 iterations_ = 2;
61 add_parameter(
62 "iterations", iterations_, "Number of limiter iterations");
63 }
64
70 template <int dim, typename Number>
71 auto view() const
72 {
73 return View<dim, Number>{
74 hyperbolic_system_->template view<dim, Number>(), *this};
75 }
76
77 private:
79
83
84 unsigned int iterations_;
85
87
91
92 dealii::ObserverPointer<const HyperbolicSystem> hyperbolic_system_;
93
95
96 template <int, typename>
97 friend class LimiterView;
98 };
99
100
109 template <int dim, typename Number>
111 {
112 public:
117
119
121
122 using state_type = typename View::state_type;
123
125
127
129
136 static constexpr unsigned int n_bounds = 0;
137
141 using Bounds = std::array<Number, n_bounds>;
142
147 LimiterView(const View &view, const Limiter<ScalarNumber> &limiter)
148 : view_(view)
149 , limiter_(limiter)
150 {
151 }
152
156 unsigned int iterations() const
157 {
158 return limiter_.iterations_;
159 }
160
166 const unsigned int /*i*/,
167 const state_type & /*U_i*/) const
168 {
169 return Bounds{};
170 }
171
177 Bounds combine_bounds(const Bounds & /*bounds_left*/,
178 const Bounds & /*bounds_right*/) const
179 {
180 return Bounds{};
181 }
182
188 Bounds fully_relax_bounds(const Bounds & /*bounds*/,
189 const Number & /*hd*/) const
190 {
191 return Bounds{};
192 }
193
195
214
218 void reset(const PrecomputedVectorView & /*pv*/,
219 const unsigned int /*i*/,
220 const state_type & /*U_i*/,
221 const flux_contribution_type & /*flux_i*/)
222 {
223 // empty
224 }
225
231 const unsigned int * /*js*/,
232 const state_type & /*U_j*/,
233 const flux_contribution_type & /*flux_j*/,
234 const dealii::Tensor<1, dim, Number> & /*scaled_c_ij*/,
235 const state_type & /*affine_shift*/)
236 {
237 // empty
238 }
239
243 Bounds bounds(const Number hd_i) const
244 {
245 auto relaxed_bounds = fully_relax_bounds(bounds_, hd_i);
246
247 return relaxed_bounds;
248 }
249
251
255
262 std::tuple<Number, bool> limit(const Bounds & /*bounds*/,
263 const state_type & /*U*/,
264 const state_type & /*P*/,
265 const Number /*t_min*/ = Number(0.),
266 const Number t_max = Number(1.)) const
267 {
268 return {t_max, true};
269 }
270
271 private:
273
277
278 const View view_;
279 const Limiter<ScalarNumber> &limiter_;
280
281 Bounds bounds_;
283 };
284 } // namespace Skeleton
285} // namespace ryujin
Vectors::MultiComponentVectorView< ScalarNumber, n_precomputed_values, dealii::VectorizedArray< ScalarNumber >::size(), dealii::MemorySpace::Host, false > PrecomputedVectorView
dealii::Tensor< 1, problem_dimension, Number > state_type
typename get_value_type< Number >::type ScalarNumber
Bounds bounds(const Number hd_i) const
Definition limiter.h:243
LimiterView(const View &view, const Limiter< ScalarNumber > &limiter)
Definition limiter.h:147
typename View::flux_contribution_type flux_contribution_type
Definition limiter.h:124
HyperbolicSystemView< dim, Number > View
Definition limiter.h:118
unsigned int iterations() const
Definition limiter.h:156
Bounds projection_bounds_from_state(const PrecomputedVectorView &, const unsigned int, const state_type &) const
Definition limiter.h:165
void reset(const PrecomputedVectorView &, const unsigned int, const state_type &, const flux_contribution_type &)
Definition limiter.h:218
typename View::ScalarNumber ScalarNumber
Definition limiter.h:120
std::array< Number, n_bounds > Bounds
Definition limiter.h:141
Bounds combine_bounds(const Bounds &, const Bounds &) const
Definition limiter.h:177
typename View::PrecomputedVectorView PrecomputedVectorView
Definition limiter.h:126
static constexpr unsigned int n_bounds
Definition limiter.h:136
Bounds fully_relax_bounds(const Bounds &, const Number &) const
Definition limiter.h:188
void accumulate(const PrecomputedVectorView &, const unsigned int *, const state_type &, const flux_contribution_type &, const dealii::Tensor< 1, dim, Number > &, const state_type &)
Definition limiter.h:230
std::tuple< Number, bool > limit(const Bounds &, const state_type &, const state_type &, const Number=Number(0.), const Number t_max=Number(1.)) const
Definition limiter.h:262
typename View::state_type state_type
Definition limiter.h:122
Limiter(const HyperbolicSystem &hyperbolic_system, const std::string &subsection="/Limiter")
Definition limiter.h:55