21 #ifndef FUB_EQUATION_HPP
22 #define FUB_EQUATION_HPP
31 #include <fmt/format.h>
35 template <
typename Eq,
typename... Args>
36 using FluxT = decltype(std::declval<Eq>().
Flux(std::declval<Args>()...));
38 template <
typename Eq>
44 template <
typename Eq,
typename N =
int_constant<kDefaultChunkSize>>
49 template <
typename Eq>
53 template <
typename Eq,
typename N =
int_constant<kDefaultChunkSize>>
58 template <
typename Equation>
61 template <
typename Equation,
int N = kDefaultChunkSize>
63 :
is_detected<VectorizedFluxT, Equation, int_constant<N>> {};
65 template <
typename Equation>
68 template <
typename Equation,
int N = kDefaultChunkSize>
70 :
is_detected<VectorizedReconstructT, Equation, int_constant<N>> {};
72 template <
typename Equation>
74 HasVectorizedReconstruction<Equation>> {
77 template <
typename Extent>
79 std::ptrdiff_t n = 1) {
80 const std::array<std::ptrdiff_t, Extent::rank()>
extents =
85 template <
typename State,
typename Layout,
int Rank>
93 const std::ptrdiff_t lower = pdv.Box().lower[Rank];
94 const std::ptrdiff_t upper = pdv.Box().upper[Rank];
96 Embed<Rank + 1>(box, {lower, upper});
97 return pdv.Subview(embedded_box);
102 [&](
auto& dest,
const auto& src) { dest = subview(src, box); }, strided,
107 template <
typename Eq,
typename Equation = std::decay_t<Eq>>
110 [[maybe_unused]]
double x = 0.0) {
114 equation.Flux(flux, state, dir, x);
118 flux = equation.Flux(state, dir, x);
122 flux = equation.Flux(state, dir);
126 equation.Flux(flux, state, dir);
130 template <
typename Eq,
typename Equation = std::decay_t<Eq>>
133 [[maybe_unused]]
double x = 0.0) {
137 equation.Flux(flux, state, dir, x);
141 flux = equation.Flux(state, dir, x);
145 flux = equation.Flux(state, dir);
149 equation.Flux(flux, state, dir);
153 template <
typename Eq,
typename Equation = std::decay_t<Eq>>
156 [[maybe_unused]]
double x = 0.0) {
160 equation.Flux(flux, state, mask, dir, x);
164 flux = equation.Flux(state, mask, dir, x);
168 flux = equation.Flux(state, mask, dir);
172 equation.Flux(flux, state, mask, dir);
174 Flux(equation, flux, state, dir, x);
178 template <
typename State,
typename ReturnType,
typename Equation>
181 constexpr
auto names = Traits::names;
183 const std::size_t n_names =
186 varnames.reserve(n_names);
187 boost::mp11::tuple_for_each(
Zip(names,
StateToTuple(depths)), [&](
auto xs) {
188 const int ncomp = std::get<1>(xs);
190 varnames.push_back(std::get<0>(xs));
192 for (
int i = 0; i < ncomp; ++i) {
193 varnames.push_back(fmt::format(
"{}_{}", std::get<0>(xs), i));
An extents object defines a multidimensional index space which is the Cartesian product of integers e...
Definition: mdspan.hpp:208
This mapping does row first indexing (as in Fortran).
Definition: mdspan.hpp:302
constexpr const Extents & extents() const noexcept
Definition: mdspan.hpp:325
The fub namespace.
Definition: AnyBoundaryCondition.hpp:31
auto Shrink(const layout_left::mapping< Extent > &layout, Direction dir, std::ptrdiff_t n=1)
Definition: Equation.hpp:78
void Flux(Eq &&equation, Conservative< Equation > &flux, const Complete< Equation > &state, Direction dir, [[maybe_unused]] double x=0.0)
Definition: Equation.hpp:108
typename remove_cvref< T >::type remove_cvref_t
Definition: type_traits.hpp:226
ReturnType VarNames(const Equation &equation)
Definition: Equation.hpp:179
View< State > Subview(const BasicView< State, Layout, Rank > &state, const IndexBox< Rank > &box)
Definition: Equation.hpp:86
void ForEachVariable(F function, Ts &&... states)
Definition: State.hpp:89
decltype(std::declval< Eq >().Flux(std::declval< Args >()...)) FluxT
Definition: Equation.hpp:36
constexpr std::array< std::ptrdiff_t, Extents::rank()> AsArray(Extents e) noexcept
Definition: PatchDataView.hpp:154
constexpr struct fub::DepthsFn Depths
decltype(std::declval< const Eq & >().Reconstruct(std::declval< Complete< Eq > & >(), std::declval< const Conservative< Eq > & >())) ScalarReconstructT
Definition: Equation.hpp:51
decltype(std::declval< const Eq & >().Reconstruct(std::declval< CompleteArray< Eq, N::value > & >(), std::declval< const ConservativeArray< Eq, N::value > & >())) VectorizedReconstructT
Definition: Equation.hpp:56
decltype(std::declval< const Eq & >().Flux(std::declval< Conservative< Eq > & >(), std::declval< const Complete< Eq > & >(), Direction::X)) ScalarFluxT
Definition: Equation.hpp:42
decltype(std::declval< const Eq & >().Flux(std::declval< ConservativeArray< Eq, N::value > & >(), std::declval< const CompleteArray< Eq, N::value > & >(), Direction::X)) VectorizedFluxT
Definition: Equation.hpp:47
std::ptrdiff_t Extent(const PatchDataView< T, R, L > &pdv)
Definition: StateRow.hpp:127
Direction
This is a type safe type to denote a dimensional split direction.
Definition: Direction.hpp:30
constexpr auto Zip(Ts &&... ts)
Definition: State.hpp:65
std::array< std::ptrdiff_t, N > Shift(const std::array< std::ptrdiff_t, N > &idx, Direction dir, std::ptrdiff_t shift)
Definition: PatchDataView.hpp:37
Array< bool, 1 > MaskArray
Definition: Eigen.hpp:59
auto StateToTuple(const State &x)
Definition: State.hpp:322
Definition: State.hpp:403
Definition: StateArray.hpp:178
This type has a constructor which takes an equation and might allocate any dynamically sized member v...
Definition: State.hpp:335
Definition: StateArray.hpp:135
This type has a constructor which takes an equation and might allocate any dynamically sized member v...
Definition: State.hpp:251
Definition: Equation.hpp:74
Definition: Equation.hpp:59
Definition: Equation.hpp:66
Definition: Equation.hpp:63
Definition: Equation.hpp:70
Definition: PatchDataView.hpp:56
Definition: PatchDataView.hpp:201
static constexpr int Rank() noexcept
Definition: PatchDataView.hpp:223
PatchDataView< T, R, layout_stride > Subview(const IndexBox< R > &box) const
Definition: PatchDataView.hpp:245
Definition: State.hpp:162
Definition: type_traits.hpp:129
This is std::true_type if Op<Args...> is a valid SFINAE expression and the return type is exactly Exp...
Definition: type_traits.hpp:108
This is std::true_type if Op<Args...> is a valid SFINAE expression.
Definition: type_traits.hpp:92
This file adds basic type traits utilities which are not yet implemented in all standard libraries.