7#include <deal.II/base/point.h>
8#include <deal.II/base/tensor.h>
9#include <deal.II/lac/vector.h>
18 using namespace dealii;
22 Model &
asImp() {
return static_cast<Model &
>(*this); }
23 const Model &
asImp()
const {
return static_cast<const Model &
>(*this); }
26 template <
int dim,
typename NumberType,
typename Solutions_s,
typename Solutions_n,
typename M = Model>
27 void numflux(std::array<Tensor<1, dim, NumberType>, M::Components::count_fe_functions(0)> &NF,
28 const Tensor<1, dim> &normal,
const Point<dim> &p,
const Solutions_s &sol_s,
29 const Solutions_n &sol_n)
const
31 using std::max, std::abs;
33 static_assert(std::is_same<M, Model>::value,
"The call of this method should not have touched M.");
34 using Components =
typename M::Components;
36 std::array<Tensor<1, dim, NumberType>, Components::count_fe_functions(0)> F_s{};
37 std::array<Tensor<1, dim, NumberType>, Components::count_fe_functions(0)> F_n{};
38 asImp().flux(F_s, p, sol_s);
39 asImp().flux(F_n, p, sol_n);
48 std::array<Tensor<1, dim, NumberType>, Components::count_fe_functions(0)> dflux_s{};
49 std::array<Tensor<1, dim, NumberType>, Components::count_fe_functions(0)> dflux_n{};
50 for (
uint i = 0; i < Model::Components::count_fe_functions(0); ++i) {
51 auto du = 1e-5 * (0.5 * (abs(u_s[i]) + abs(u_n[i])) + 1e-9);
54 asImp().flux(dflux_s, p, Solutions_s::as(std::tuple_cat(std::tie(du_s),
tuple_tail(sol_s))));
55 asImp().flux(dflux_n, p, Solutions_n::as(std::tuple_cat(std::tie(du_n),
tuple_tail(sol_n))));
63 for (
uint d = 0; d < dim; ++d)
64 NF[i][d] = 0.5 * (F_s[i][d] + F_n[i][d]) - 0.5 * alpha * (u_n[i] - u_s[i]);
73 template <u
int i>
using value =
typename std::tuple_element<i, std::tuple<T...>>::type;
76 static constexpr std::array<int,
sizeof...(n)>
value{{n...}};
77 static constexpr int size =
sizeof...(n);
80 static constexpr std::array<int,
sizeof...(n)>
value{{n...}};
81 static constexpr int size =
sizeof...(n);
85 Model &
asImp() {
return static_cast<Model &
>(*this); }
86 const Model &
asImp()
const {
return static_cast<const Model &
>(*this); }
87 template <
int i>
using C =
typename std::tuple_element<i, std::tuple<Collections...>>::type;
90 template <
uint dependent,
int dim,
typename NumberType,
typename Solutions_s,
typename Solutions_n,
92 void ldg_numflux(std::array<Tensor<1, dim, NumberType>, M::Components::count_fe_functions(dependent)> &NF,
93 const Tensor<1, dim> &normal,
const Point<dim> &p,
const Solutions_s &u_s,
94 const Solutions_n &u_n)
const
96 static_assert(std::is_same<M, Model>::value,
"The call of this method should not have touched M.");
97 static_assert(dependent >= 1,
"This is LDG, not DG.");
99 using Dirs =
typename C<dependent - 1>::template value<0>;
100 using UD =
typename C<dependent - 1>::template value<1>;
101 static_assert(Dirs::size == UD::size && UD::size >= M::Components::count_fe_functions(dependent),
102 "Mismatch in array sizes.");
103 using Components =
typename M::Components;
106 for (
uint i = 0; i < dim; ++i)
109 std::array<std::array<Tensor<1, dim, NumberType>, Components::count_fe_functions(dependent)>, 2> F;
113 if (scalar_product(t, normal) >= 0) {
115 asImp().template ldg_flux<dependent>(F[0], p, u_s);
116 asImp().template ldg_flux<dependent>(F[1], p, u_n);
119 asImp().template ldg_flux<dependent>(F[0], p, u_n);
120 asImp().template ldg_flux<dependent>(F[1], p, u_s);
123 for (
uint i = 0; i < Components::count_fe_functions(dependent); ++i)
124 NF[i][Dirs::value[i]] = F[UD::value[i]][i][Dirs::value[i]];
131 template <
int dim,
typename NumberType,
typename Solutions_s,
typename Solutions_n,
typename M = Model>
132 void numflux(std::array<Tensor<1, dim, NumberType>, M::Components::count_fe_functions(0)> &,
133 const Tensor<1, dim> &,
const Point<dim> &,
const Solutions_s &,
const Solutions_n &)
const
135 static_assert(std::is_same<M, Model>::value,
"The call of this method should not have touched M.");
141 Model &
asImp() {
return static_cast<Model &
>(*this); }
142 const Model &
asImp()
const {
return static_cast<const Model &
>(*this); }
145 template <
int dim,
typename NumberType,
typename Solutions,
typename M = Model>
146 void boundary_numflux(std::array<Tensor<1, dim, NumberType>, M::Components::count_fe_functions(0)> &F,
147 const Tensor<1, dim> & ,
const Point<dim> &p,
const Solutions &sol)
const
149 static_assert(std::is_same<M, Model>::value,
"The call of this method should not have touched M.");
150 asImp().flux(F, p, sol);
153 template <u
int dependent,
int dim,
typename NumberType,
typename Solutions,
typename M = Model>
155 ldg_boundary_numflux(std::array<Tensor<1, dim, NumberType>, M::Components::count_fe_functions(dependent)> &BNF,
156 const Tensor<1, dim> & ,
const Point<dim> &p,
const Solutions &u)
const
158 static_assert(std::is_same<M, Model>::value,
"The call of this method should not have touched M.");
159 asImp().template ldg_flux<dependent>(BNF, p, u);
Definition numflux.hh:140
const Model & asImp() const
Definition numflux.hh:142
Model & asImp()
Definition numflux.hh:141
void ldg_boundary_numflux(std::array< Tensor< 1, dim, NumberType >, M::Components::count_fe_functions(dependent)> &BNF, const Tensor< 1, dim > &, const Point< dim > &p, const Solutions &u) const
Definition numflux.hh:155
void boundary_numflux(std::array< Tensor< 1, dim, NumberType >, M::Components::count_fe_functions(0)> &F, const Tensor< 1, dim > &, const Point< dim > &p, const Solutions &sol) const
Definition numflux.hh:146
typename std::tuple_element< i, std::tuple< Collections... > >::type C
Definition numflux.hh:87
const Model & asImp() const
Definition numflux.hh:86
Model & asImp()
Definition numflux.hh:85
void ldg_numflux(std::array< Tensor< 1, dim, NumberType >, M::Components::count_fe_functions(dependent)> &NF, const Tensor< 1, dim > &normal, const Point< dim > &p, const Solutions_s &u_s, const Solutions_n &u_n) const
Definition numflux.hh:92
const Model & asImp() const
Definition numflux.hh:23
void numflux(std::array< Tensor< 1, dim, NumberType >, M::Components::count_fe_functions(0)> &NF, const Tensor< 1, dim > &normal, const Point< dim > &p, const Solutions_s &sol_s, const Solutions_n &sol_n) const
Definition numflux.hh:27
Model & asImp()
Definition numflux.hh:22
Definition numflux.hh:129
void numflux(std::array< Tensor< 1, dim, NumberType >, M::Components::count_fe_functions(0)> &, const Tensor< 1, dim > &, const Point< dim > &, const Solutions_s &, const Solutions_n &) const
Definition numflux.hh:132
constexpr uint from_right
Definition numflux.hh:69
constexpr uint from_left
Definition numflux.hh:70
Definition complex_math.hh:14
constexpr auto tuple_tail(const std::tuple< Head, Tail... > &t)
Definition tuples.hh:222
NT dot(const A1 &a1, const A2 &a2)
A dot product which takes the dot product between a1 and a2, assuming each has n entries which can be...
Definition math.hh:203
std::array< NT, n > vector_to_array(const Vector &v)
Definition tuples.hh:203
unsigned int uint
Definition utils.hh:22
Definition complex_math.hh:59
constexpr auto & get(DiFfRG::named_tuple< tuple_type, strs... > &ob)
Definition tuples.hh:119
static constexpr int size
Definition numflux.hh:77
static constexpr std::array< int, sizeof...(n)> value
Definition numflux.hh:76
typename std::tuple_element< i, std::tuple< T... > >::type value
Definition numflux.hh:73
static constexpr int size
Definition numflux.hh:81
static constexpr std::array< int, sizeof...(n)> value
Definition numflux.hh:80