8#include <compile_time_options.h>
17 namespace ScalarConservation
19 template <
typename ScalarNumber =
double>
24 : ParameterAcceptor(subsection)
28 "iterations", iterations_,
"Number of limiter iterations");
30 relaxation_factor_ = ScalarNumber(1.);
31 add_parameter(
"relaxation factor",
33 "Factor for scaling the relaxation window with r_i = "
34 "factor * (m_i/|Omega|)^(1.5/d).");
41 unsigned int iterations_;
42 ScalarNumber relaxation_factor_;
51 template <
int dim,
typename Number =
double>
91 using Bounds = std::array<Number, n_bounds>;
99 : hyperbolic_system(hyperbolic_system)
100 , parameters(parameters)
101 , precomputed_values(precomputed_values)
118 const Bounds &bounds_right)
const;
161 const dealii::Tensor<1, dim, Number> &scaled_c_ij,
182 const Number t_min = Number(0.),
183 const Number t_max = Number(1.))
const;
199 Number u_relaxation_numerator;
200 Number u_relaxation_denominator;
212 template <
int dim,
typename Number>
213 DEAL_II_ALWAYS_INLINE
inline auto
217 const auto view = hyperbolic_system.view<dim, Number>();
218 const auto u_i = view.state(U_i);
223 template <
int dim,
typename Number>
227 const auto &[u_min_l, u_max_l] = bounds_left;
228 const auto &[u_min_r, u_max_r] = bounds_right;
230 return {std::min(u_min_l, u_min_r), std::max(u_max_l, u_max_r)};
234 template <
int dim,
typename Number>
235 DEAL_II_ALWAYS_INLINE
inline auto
237 const Number &hd)
const ->
Bounds
239 auto relaxed_bounds = bounds;
240 auto &[u_min, u_max] = relaxed_bounds;
244 Number r = std::sqrt(hd);
245 if constexpr (dim == 2)
246 r = dealii::Utilities::fixed_power<3>(std::sqrt(r));
247 else if constexpr (dim == 1)
248 r = dealii::Utilities::fixed_power<3>(r);
249 r *= parameters.relaxation_factor();
251 u_min = std::min((Number(1.) - r) * u_min, (Number(1.) + r) * u_min);
252 u_max = std::max((Number(1.) + r) * u_max, (Number(1.) - r) * u_max);
254 return relaxed_bounds;
258 template <
int dim,
typename Number>
259 DEAL_II_ALWAYS_INLINE
inline void
269 auto &[u_min, u_max] = bounds_;
271 u_min = Number(std::numeric_limits<ScalarNumber>::max());
272 u_max = Number(std::numeric_limits<ScalarNumber>::lowest());
276 u_relaxation_numerator = Number(0.);
277 u_relaxation_denominator = Number(0.);
281 template <
int dim,
typename Number>
283 const unsigned int * ,
286 const dealii::Tensor<1, dim, Number> &scaled_c_ij,
289 const auto view = hyperbolic_system.view<dim, Number>();
292 auto &[u_min, u_max] = bounds_;
294 const auto u_i = view.state(U_i);
295 const auto u_j = view.state(U_j);
297 const auto U_ij_bar =
302 const auto u_ij_bar = view.state(U_ij_bar);
306 u_min = std::min(u_min, u_ij_bar);
307 u_max = std::max(u_max, u_ij_bar);
312 const auto beta_ij = Number(1.);
313 u_relaxation_numerator += beta_ij * (u_i + u_j);
314 u_relaxation_denominator += std::abs(beta_ij);
318 template <
int dim,
typename Number>
319 DEAL_II_ALWAYS_INLINE
inline auto
322 const auto &[u_min, u_max] = bounds_;
324 auto relaxed_bounds = fully_relax_bounds(bounds_, hd_i);
325 auto &[u_min_relaxed, u_max_relaxed] = relaxed_bounds;
329 constexpr ScalarNumber eps = std::numeric_limits<ScalarNumber>::epsilon();
331 const Number u_relaxation =
333 std::abs(u_relaxation_numerator) /
334 (std::abs(u_relaxation_denominator) + Number(eps));
336 u_min_relaxed = std::max(u_min_relaxed, u_min - u_relaxation);
337 u_max_relaxed = std::min(u_max_relaxed, u_max + u_relaxation);
339 return relaxed_bounds;
static constexpr unsigned int problem_dimension
std::array< Number, n_precomputed_values > precomputed_type
Vectors::MultiComponentVector< ScalarNumber, n_precomputed_values > PrecomputedVector
typename get_value_type< Number >::type ScalarNumber
dealii::Tensor< 1, problem_dimension, Number > state_type
flux_type flux_contribution_type
ACCESSOR_READ_ONLY(iterations)
LimiterParameters(const std::string &subsection="/Limiter")
ACCESSOR_READ_ONLY(relaxation_factor)
std::array< Number, n_bounds > Bounds
Limiter(const HyperbolicSystem &hyperbolic_system, const Parameters ¶meters, const PrecomputedVector &precomputed_values)
typename View::PrecomputedVector PrecomputedVector
Bounds fully_relax_bounds(const Bounds &bounds, const Number &hd) const
typename View::state_type state_type
Bounds combine_bounds(const Bounds &bounds_left, const Bounds &bounds_right) const
Bounds projection_bounds_from_state(const unsigned int i, const state_type &U_i) const
void reset(const unsigned int i, const state_type &U_i, const flux_contribution_type &flux_i)
std::tuple< Number, bool > limit(const Bounds &bounds, const state_type &U, const state_type &P, const Number t_min=Number(0.), const Number t_max=Number(1.)) const
static constexpr unsigned int n_bounds
typename View::ScalarNumber ScalarNumber
static constexpr auto problem_dimension
Bounds bounds(const Number hd_i) const
typename View::flux_contribution_type flux_contribution_type
void accumulate(const unsigned int *js, const state_type &U_j, const flux_contribution_type &flux_j, const dealii::Tensor< 1, dim, Number > &scaled_c_ij, const state_type &affine_shift)
typename View::precomputed_type precomputed_type
DEAL_II_ALWAYS_INLINE FT add(const FT &flux_left_ij, const FT &flux_right_ij)
DEAL_II_ALWAYS_INLINE dealii::Tensor< 1, problem_dim, T > contract(const FT &flux_ij, const TT &c_ij)