14#include <deal.II/base/parameter_acceptor.h>
15#include <deal.II/base/vectorization.h>
20 namespace ShallowWater
22 template <
typename ScalarNumber =
double>
27 : ParameterAcceptor(subsection)
29 evc_factor_ = ScalarNumber(1.);
30 add_parameter(
"evc factor",
32 "Factor for scaling the entropy viscocity commuator");
38 ScalarNumber evc_factor_;
48 template <
int dim,
typename Number =
double>
99 : hyperbolic_system(hyperbolic_system)
100 , parameters(parameters)
101 , precomputed_values(precomputed_values)
117 const dealii::Tensor<1, dim, Number> &c_ij);
122 Number
alpha(
const Number h_i);
140 Number pressure_i = 0.;
155 template <
int dim,
typename Number>
156 DEAL_II_ALWAYS_INLINE
inline void
161 const auto view = hyperbolic_system.view<dim, Number>();
163 const auto &[eta_m, h_star] =
164 precomputed_values.template get_tensor<Number, precomputed_type>(i);
166 h_i = view.water_depth(U_i);
168 d_eta_i = view.mathematical_entropy_derivative(U_i);
170 pressure_i = view.pressure(U_i);
177 template <
int dim,
typename Number>
179 const unsigned int *js,
181 const dealii::Tensor<1, dim, Number> &c_ij)
185 const auto view = hyperbolic_system.view<dim, Number>();
187 const auto &[eta_j, h_star_j] =
188 precomputed_values.template get_tensor<Number, precomputed_type>(js);
190 const auto velocity_j =
191 view.momentum(U_j) * view.inverse_water_depth_sharp(U_j);
192 const auto f_j = view.f(U_j);
193 const auto pressure_j = view.pressure(U_j);
195 left += (eta_j + pressure_j) * (velocity_j * c_ij);
197 for (
unsigned int k = 0; k < problem_dimension; ++k)
198 right[k] += (f_j[k] - f_i[k]) * c_ij;
202 template <
int dim,
typename Number>
203 DEAL_II_ALWAYS_INLINE
inline Number
207 for (
unsigned int k = 0; k < problem_dimension; ++k) {
208 my_sum += d_eta_i[k] * right[k];
211 Number numerator = std::abs(left - my_sum);
212 Number denominator = std::abs(left) + std::abs(my_sum);
214 const auto regularization =
215 Number(100. * std::numeric_limits<ScalarNumber>::min());
217 const auto quotient =
218 std::abs(numerator) /
219 (denominator + std::max(hd_i * std::abs(eta_i), regularization));
221 return std::min(Number(1.), parameters.evc_factor() * quotient);
dealii::Tensor< 1, problem_dimension, dealii::Tensor< 1, dim, Number > > flux_type
typename get_value_type< Number >::type ScalarNumber
Vectors::MultiComponentVector< ScalarNumber, n_precomputed_values > PrecomputedVector
dealii::Tensor< 1, problem_dimension, Number > state_type
std::array< Number, n_precomputed_values > precomputed_type
static constexpr unsigned int problem_dimension
IndicatorParameters(const std::string &subsection="/Indicator")
ACCESSOR_READ_ONLY(evc_factor)
typename View::PrecomputedVector PrecomputedVector
typename View::state_type state_type
typename View::flux_type flux_type
typename View::precomputed_type precomputed_type
void reset(const unsigned int, const state_type &U_i)
void accumulate(const unsigned int *js, const state_type &U_j, const dealii::Tensor< 1, dim, Number > &c_ij)
static constexpr auto problem_dimension
typename View::ScalarNumber ScalarNumber
Indicator(const HyperbolicSystem &hyperbolic_system, const Parameters ¶meters, const PrecomputedVector &precomputed_values)
Number alpha(const Number h_i)
IndicatorParameters< ScalarNumber > Parameters