21 #ifndef FUB_EQUATIONS_EULER_EQUATION_HPP 
   22 #define FUB_EQUATIONS_EULER_EQUATION_HPP 
   29                      const Eigen::Array<double, Dim, 1>& momentum) noexcept {
 
   30   return 0.5 * momentum.matrix().squaredNorm() / density;
 
   33 template <
int Dim, 
int N, 
int O, 
int MR, 
int MC>
 
   36     const Eigen::Array<double, Dim, N, O, MR, MC>& momentum) noexcept {
 
   37   Array1d squaredMomentum = momentum.matrix().colwise().squaredNorm();
 
   38   return 0.5 * squaredMomentum / density;
 
   41 template <
int Dim, 
int N, 
int O, 
int MR, 
int MC>
 
   43                       const Eigen::Array<double, Dim, N, O, MR, MC>& momentum,
 
   45   mask = mask && (density > 0.0);
 
   46   Array1d squaredMomentum = momentum.matrix().colwise().squaredNorm();
 
   48   safe_density = mask.select(density, 1.0);
 
   50   return 0.5 * squaredMomentum / safe_density;
 
   54   template <
typename Equation, 
typename State,
 
   55             typename = std::enable_if_t<
 
   61                            std::forward<State>(state));
 
   66   template <
typename Equation, 
typename State,
 
   67             typename = std::enable_if_t<
 
   73                            std::forward<State>(state));
 
   78   template <
typename Equation, 
typename State, 
typename... Indices,
 
   86                            std::forward<State>(state), d...);
 
   91   template <
typename Equation, 
typename State, 
typename... Indices,
 
   99                            std::forward<State>(state), d...);
 
  104   template <
typename Equation, 
typename State, 
typename... Indices,
 
  112                            std::forward<State>(state), d...);
 
  117   template <
typename Equation, 
typename State,
 
  118             typename = std::enable_if_t<
 
  124                            std::forward<State>(state));
 
  129   template <
typename Equation, 
typename State,
 
  130             typename = std::enable_if_t<
 
  136                            std::forward<State>(state));
 
  141   template <
typename Equation, 
typename State,
 
  142             typename = std::enable_if_t<
 
  148                            std::forward<State>(state));
 
  153   template <
typename Equation, 
typename State,
 
  154             typename = std::enable_if_t<
 
  160                            std::forward<State>(state));
 
  165   template <
typename Equation, 
typename State,
 
  166             typename = std::enable_if_t<
 
  172                            std::forward<State>(state));
 
  177   template <
typename Equation, 
typename State,
 
  178             typename = std::enable_if_t<
 
  184                            std::forward<State>(state));
 
  189   template <
typename Equation, 
typename State,
 
  190             typename = std::enable_if_t<
 
  196                            std::forward<State>(state));
 
  201   template <
typename Equation, 
typename Dest, 
typename State,
 
  209                            std::forward<Dest>(dest),
 
  210                            std::forward<State>(state));
 
  215   template <
typename Equation, 
typename Dest, 
typename State,
 
  224                            std::forward<Dest>(dest),
 
  225                            std::forward<State>(state));
 
  241                            std::forward<Dest>(dest), std::forward<State>(state),
 
  242                            std::forward<Velocity>(velocity));
 
  246       typename Equation, 
typename Dest, 
typename State,
 
  255                            std::forward<Dest>(dest), std::forward<State>(state));
 
  271             typename = std::enable_if_t<
 
  275                                  double, 
double>::value ||
 
  281                             Complete<std::decay_t<Equation>>& dest,
 
  282                             const Complete<std::decay_t<Equation>>& src,
 
  283                             double pressure_dest, 
double efficiency) 
const 
  287                                    const Complete<std::decay_t<Equation>>&,
 
  288                                    double, 
double>::value) {
 
  291                                    const Complete<std::decay_t<Equation>>&,
 
  292                                    double, 
double>::value) {
 
  294                       pressure_dest, efficiency);
 
  296       const auto old_velocity = 
Velocity(eq, src);
 
  297       const double rhoE_kin = 
KineticEnergy(src.density, src.momentum);
 
  298       constexpr 
int N = std::decay_t<Equation>::Rank();
 
  301       dest.energy = src.energy - rhoE_kin;
 
  302       const double h_before = (dest.energy + dest.pressure) / dest.density;
 
  304       const double h_after = (dest.energy + dest.pressure) / dest.density;
 
  305       const double h_diff = h_before - h_after;
 
  306       const double e_kin_new =
 
  307           2.0 * efficiency * std::abs(h_diff) + old_velocity.matrix().squaredNorm();
 
  309       const int sign = (h_diff >= 0) - (h_diff < 0);
 
  310       dest.momentum[0] = dest.density * (sign * std::sqrt(e_kin_new));
 
  311       dest.energy = dest.energy + 
KineticEnergy(dest.density, dest.momentum);
 
  317   template <
typename Equation, 
typename State,
 
  324                            std::forward<State>(state));
 
  329   template <
typename Equation, 
typename State, 
typename... Indices,
 
  337                            std::forward<State>(state), d...);
 
  341 template <
typename Equation, 
typename State>
 
#define FUB_ASSERT(x)
Definition: assert.hpp:39
 
Definition: EulerEquation.hpp:26
 
constexpr struct fub::euler::InternalEnergyFn InternalEnergy
 
constexpr struct fub::euler::KineticStateFromCompleteFn KineticStateFromComplete
 
constexpr struct fub::euler::SpeedOfSoundFn SpeedOfSound
 
constexpr struct fub::euler::EnergyFn Energy
 
double KineticEnergy(double density, const Eigen::Array< double, Dim, 1 > &momentum) noexcept
Definition: EulerEquation.hpp:28
 
constexpr struct fub::euler::GammaFn Gamma
 
constexpr struct fub::euler::SpeciesFn Species
 
constexpr struct fub::euler::SpecificGasConstantFn SpecificGasConstant
 
constexpr struct fub::euler::TotalEnthalpyFn TotalEnthalpy
 
constexpr struct fub::euler::SetIsentropicPressureFn SetIsentropicPressure
 
constexpr struct fub::euler::PressureFn Pressure
 
constexpr struct fub::euler::MoleFractionsFn MoleFractions
 
constexpr struct fub::euler::MomentumFn Momentum
 
constexpr struct fub::euler::CompleteFromKineticStateFn CompleteFromKineticState
 
constexpr struct fub::euler::DensityFn Density
 
constexpr struct fub::euler::IsentropicExpansionWithoutDissipationFn IsentropicExpansionWithoutDissipation
 
constexpr struct fub::euler::VelocityFn Velocity
 
constexpr struct fub::euler::MachnumberFn Machnumber
 
constexpr struct fub::euler::TemperatureFn Temperature
 
constexpr struct fub::euler::SetVelocityFn SetVelocity
 
std::conditional_t< N==1||M==1, Eigen::Array< T, N, M >, Eigen::Array< T, N, M, Eigen::RowMajor > > Array
Definition: Eigen.hpp:50
 
Array< double, 1 > Array1d
Definition: Eigen.hpp:53
 
invoke_result_t< decltype(fub::meta::tag_invoke), _Tag, _Args... > tag_invoke_result_t
Definition: type_traits.hpp:347
 
Array< bool, 1 > MaskArray
Definition: Eigen.hpp:59
 
static constexpr all_type all
Definition: mdspan.hpp:741
 
This type has a constructor which takes an equation and might allocate any dynamically sized member v...
Definition: State.hpp:335
 
Definition: EulerEquation.hpp:229
 
constexpr auto operator()(Equation &&eq, Dest &&dest, State &&state, Velocity &&velocity) const noexcept(is_nothrow_tag_invocable< CompleteFromKineticStateFn, Equation, Dest, State, Velocity >::value) -> tag_invoke_result_t< CompleteFromKineticStateFn, Equation, Dest, State, Velocity >
Definition: EulerEquation.hpp:234
 
constexpr auto operator()(Equation &&eq, Dest &&dest, State &&state) const noexcept(is_nothrow_tag_invocable< CompleteFromKineticStateFn, Equation, Dest, State >::value) -> tag_invoke_result_t< CompleteFromKineticStateFn, Equation, Dest, State >
Definition: EulerEquation.hpp:249
 
Definition: EulerEquation.hpp:65
 
constexpr auto operator()(Equation &&eq, State &&state) const noexcept(is_nothrow_tag_invocable< DensityFn, Equation, State >::value) -> tag_invoke_result_t< DensityFn, Equation, State >
Definition: EulerEquation.hpp:69
 
Definition: EulerEquation.hpp:128
 
constexpr auto operator()(Equation &&eq, State &&state) const noexcept(is_nothrow_tag_invocable< EnergyFn, Equation, State >::value) -> tag_invoke_result_t< EnergyFn, Equation, State >
Definition: EulerEquation.hpp:132
 
Definition: EulerEquation.hpp:53
 
constexpr auto operator()(Equation &&eq, State &&state) const noexcept(is_nothrow_tag_invocable< GammaFn, Equation, State >::value) -> tag_invoke_result_t< GammaFn, Equation, State >
Definition: EulerEquation.hpp:57
 
Definition: EulerEquation.hpp:176
 
constexpr auto operator()(Equation &&eq, State &&state) const noexcept(is_nothrow_tag_invocable< InternalEnergyFn, Equation, State >::value) -> tag_invoke_result_t< InternalEnergyFn, Equation, State >
Definition: EulerEquation.hpp:180
 
Definition: EulerEquation.hpp:269
 
constexpr void operator()(Equation &&eq, Complete< std::decay_t< Equation >> &dest, const Complete< std::decay_t< Equation >> &src, double pressure_dest, double efficiency) const noexcept(is_nothrow_tag_invocable< IsentropicExpansionWithoutDissipationFn, Equation, Complete< std::decay_t< Equation >> &, const Complete< std::decay_t< Equation >> &, double, double >::value)
Definition: EulerEquation.hpp:280
 
Definition: EulerEquation.hpp:214
 
constexpr auto operator()(Equation &&eq, Dest &&dest, State &&state) const noexcept(is_nothrow_tag_invocable< KineticStateFromCompleteFn, Equation, Dest, State >::value) -> tag_invoke_result_t< KineticStateFromCompleteFn, Equation, Dest, State >
Definition: EulerEquation.hpp:218
 
Definition: EulerEquation.hpp:152
 
constexpr auto operator()(Equation &&eq, State &&state) const noexcept(is_nothrow_tag_invocable< MachnumberFn, Equation, State >::value) -> tag_invoke_result_t< MachnumberFn, Equation, State >
Definition: EulerEquation.hpp:156
 
Definition: EulerEquation.hpp:200
 
constexpr auto operator()(Equation &&eq, Dest &&dest, State &&state) const noexcept(is_nothrow_tag_invocable< MoleFractionsFn, Equation, State >::value) -> tag_invoke_result_t< MoleFractionsFn, Equation, State >
Definition: EulerEquation.hpp:204
 
Definition: EulerEquation.hpp:77
 
constexpr auto operator()(Equation &&eq, State &&state, Indices... d) const noexcept(is_nothrow_tag_invocable< MomentumFn, Equation, State, Indices... >::value) -> tag_invoke_result_t< MomentumFn, Equation, State, Indices... >
Definition: EulerEquation.hpp:82
 
Definition: EulerEquation.hpp:140
 
constexpr auto operator()(Equation &&eq, State &&state) const noexcept(is_nothrow_tag_invocable< PressureFn, Equation, State >::value) -> tag_invoke_result_t< PressureFn, Equation, State >
Definition: EulerEquation.hpp:144
 
Definition: EulerEquation.hpp:259
 
constexpr auto operator()(Args &&... args) const noexcept(is_nothrow_tag_invocable< SetIsentropicPressureFn, Args... >::value) -> tag_invoke_result_t< SetIsentropicPressureFn, Args... >
Definition: EulerEquation.hpp:262
 
Definition: EulerEquation.hpp:103
 
constexpr auto operator()(Equation &&eq, State &&state, Indices... d) const noexcept(is_nothrow_tag_invocable< SetVelocityFn, Equation, State, Indices... >::value) -> tag_invoke_result_t< SetVelocityFn, Equation, State, Indices... >
Definition: EulerEquation.hpp:108
 
Definition: EulerEquation.hpp:328
 
constexpr auto operator()(Equation &&eq, State &&state, Indices... d) const noexcept(is_nothrow_tag_invocable< SpeciesFn, Equation, State, Indices... >::value) -> tag_invoke_result_t< SpeciesFn, Equation, State, Indices... >
Definition: EulerEquation.hpp:333
 
Definition: EulerEquation.hpp:316
 
constexpr auto operator()(Equation &&eq, State &&state) const noexcept(is_nothrow_tag_invocable< SpecificGasConstantFn, Equation, State >::value) -> tag_invoke_result_t< SpecificGasConstantFn, Equation, State >
Definition: EulerEquation.hpp:320
 
Definition: EulerEquation.hpp:116
 
constexpr auto operator()(Equation &&eq, State &&state) const noexcept(is_nothrow_tag_invocable< SpeedOfSoundFn, Equation, State >::value) -> tag_invoke_result_t< SpeedOfSoundFn, Equation, State >
Definition: EulerEquation.hpp:120
 
Definition: EulerEquation.hpp:164
 
constexpr auto operator()(Equation &&eq, State &&state) const noexcept(is_nothrow_tag_invocable< TemperatureFn, Equation, State >::value) -> tag_invoke_result_t< TemperatureFn, Equation, State >
Definition: EulerEquation.hpp:168
 
Definition: EulerEquation.hpp:188
 
constexpr auto operator()(Equation &&eq, State &&state) const noexcept(is_nothrow_tag_invocable< TotalEnthalpyFn, Equation, State >::value) -> tag_invoke_result_t< TotalEnthalpyFn, Equation, State >
Definition: EulerEquation.hpp:192
 
Definition: EulerEquation.hpp:90
 
constexpr auto operator()(Equation &&eq, State &&state, Indices... d) const noexcept(is_nothrow_tag_invocable< VelocityFn, Equation, State, Indices... >::value) -> tag_invoke_result_t< VelocityFn, Equation, State, Indices... >
Definition: EulerEquation.hpp:95
 
Definition: EulerEquation.hpp:343
 
This is std::true_type if a given object f of type T is callable by fub::invoke(f,...
Definition: type_traits.hpp:215
 
Definition: type_traits.hpp:339
 
Definition: type_traits.hpp:323
 
This file adds basic type traits utilities which are not yet implemented in all standard libraries.