Finite Volume Solver  prototype
A framework to build finite volume solvers for the AG Klein at the Freie Universität Berlin.
PerfectGasMix.hpp
Go to the documentation of this file.
1 // Copyright (c) 2019 Maikel Nadolski
2 //
3 // Permission is hereby granted, free of charge, to any person obtaining a copy
4 // of this software and associated documentation files (the "Software"), to deal
5 // in the Software without restriction, including without limitation the rights
6 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 // copies of the Software, and to permit persons to whom the Software is
8 // furnished to do so, subject to the following conditions:
9 //
10 // The above copyright notice and this permission notice shall be included in
11 // all copies or substantial portions of the Software.
12 //
13 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19 // SOFTWARE.
20 
21 #ifndef FUB_EQUATIONS_PERFECT_GAS_MIX_HPP
22 #define FUB_EQUATIONS_PERFECT_GAS_MIX_HPP
23 
24 #include "fub/State.hpp"
25 #include "fub/StateArray.hpp"
26 
27 #include "fub/CompleteFromCons.hpp"
28 #include "fub/Equation.hpp"
29 #include "fub/ext/Eigen.hpp"
30 
32 
33 #include <array>
34 
35 namespace fub {
36 
37 template <int Rank> struct PerfectGasMix;
38 
39 /// This is a template class for constructing conservative states for the
40 /// perfect gas equations.
41 template <typename Density, typename Momentum, typename Energy,
42  typename Species>
48 };
49 
50 template <int Rank>
53  VectorDepth<-1>>;
54 
55 namespace meta {
56 template <int R> struct Rank<PerfectGasMixConsShape<R>> : int_constant<R> {};
57 } // namespace meta
58 
59 // We "register" the conservative state with our framework.
60 // This enables us to name and iterate over all member variables in a given
61 // conservative state.
62 template <typename... Xs> struct StateTraits<PerfectGasMixConservative<Xs...>> {
63  static constexpr auto names =
64  std::make_tuple("Density", "Momentum", "Energy", "Species");
65 
66  static constexpr auto pointers_to_member =
71 
72  template <int Rank> using Depths = PerfectGasMixConsShape<Rank>;
73 
74  template <int Rank> using Equation = PerfectGasMix<Rank>;
75 };
76 
77 template <typename Density, typename Velocity, typename Pressure,
78  typename Species>
84 };
85 
86 template <int Rank>
89  VectorDepth<-1>>;
90 
91 namespace meta {
92 template <int R> struct Rank<PerfectGasMixPrimShape<R>> : int_constant<R> {};
93 } // namespace meta
94 
95 template <typename... Xs> struct StateTraits<PerfectGasMixPrimitive<Xs...>> {
96  static constexpr auto names =
97  std::make_tuple("Density", "Velocity", "Pressure", "Species");
98 
99  static constexpr auto pointers_to_member =
104 
105  template <int Rank> using Depths = PerfectGasMixPrimShape<Rank>;
106 
107  template <int Rank> using Equation = PerfectGasMix<Rank>;
108 };
109 
110 template <typename Density, typename Temperature, typename MoleFractions>
115 };
116 
119 
120 namespace meta {
122 } // namespace meta
123 
124 template <typename... Xs> struct StateTraits<PerfectGasMixKineticState<Xs...>> {
125  static constexpr auto names =
126  std::make_tuple("Density", "Temperature", "MoleFractions");
127 
128  static constexpr auto pointers_to_member =
132 
133  template <int Rank> using Depths = PerfectGasMixKineticStateShape;
134 
135  template <int Rank> using Equation = PerfectGasMix<Rank>;
136 };
137 
138 template <typename Minus, typename Zero, typename Plus, typename Species>
140  Minus minus;
141  Zero zero;
142  Plus plus;
144 };
145 
146 template <int Rank>
149  VectorDepth<-1>>;
150 
151 namespace meta {
152 template <int R> struct Rank<PerfectGasMixCharShape<R>> : int_constant<R> {};
153 } // namespace meta
154 
155 template <typename... Xs>
157  static constexpr auto names =
158  std::make_tuple("Minus", "Zero", "Plus", "Species");
159 
160  static constexpr auto pointers_to_member =
165 
166  template <int Rank> using Depths = PerfectGasMixCharShape<Rank>;
167 
168  template <int Rank> using Equation = PerfectGasMix<Rank>;
169 };
170 
171 template <typename Density, typename Momentum, typename Energy,
172  typename Species, typename Pressure, typename SpeedOfSound>
174  : PerfectGasMixConservative<Density, Momentum, Energy, Species> {
177 };
178 
179 template <int Rank>
183 
184 namespace meta {
185 template <int R>
187 } // namespace meta
188 
189 // We "register" the complete state with our framework.
190 // This enables us to name and iterate over all member variables in a given
191 // compete state.
192 template <typename... Xs> struct StateTraits<PerfectGasMixComplete<Xs...>> {
193  static constexpr auto names = std::make_tuple(
194  "Density", "Momentum", "Energy", "Species", "Pressure", "SpeedOfSound");
195  static constexpr auto pointers_to_member =
196  std::make_tuple(&PerfectGasMixComplete<Xs...>::density,
202 
203  template <int Rank> using Depths = PerfectGasMixCompleteShape<Rank>;
204 
205  template <int Rank> using Equation = PerfectGasMix<Rank>;
206 };
207 
208 template <int N> struct PerfectGasMix {
214 
220 
221  static constexpr int Rank() noexcept { return N; }
222 
223  void Flux(Conservative& flux, const Complete& state,
224  [[maybe_unused]] Direction dir = Direction::X) const noexcept;
225 
226  void Flux(ConservativeArray& flux, const CompleteArray& state,
227  [[maybe_unused]] Direction dir) const noexcept;
228 
229  void Flux(ConservativeArray& flux, const CompleteArray& state, MaskArray mask,
230  [[maybe_unused]] Direction dir) const noexcept;
231 
232  void CompleteFromCons(Complete& complete,
233  const ConservativeBase<PerfectGasMix>& cons) const
234  noexcept;
235 
237  const ConservativeArrayBase<PerfectGasMix>& cons) const
238  noexcept;
239 
242  MaskArray mask) const noexcept;
243 
245  double pressure,
246  const Array<double, -1, 1>& species) const noexcept;
247 
248  // CompleteArray CompleteFromPrim(Array1d density, const Array<double, N>& u,
249  // Array1d pressure,
250  // const MaskArray& mask) const noexcept;
251 
252  Array<double, N, 1> Velocity(const Complete& q) const noexcept;
253  Array<double, N> Velocity(const CompleteArray& q) const noexcept;
254 
255  double Machnumber(const Complete& q) const noexcept;
256 
257  double Temperature(const Complete& q) const noexcept;
258  Array1d Temperature(const CompleteArray& q) const noexcept;
259 
260  int n_species{0};
261 
262  // Rspec = cp - cv
263  // gamma = cp / cv
264  // cp = cv gamma
265  // Rspec = gamma cv - cv
266  // Rspec = (gamma - 1) cv
267  // Rpsec /(gamma - 1) = cv
268  double Rspec{1.};
269  double gamma{1.28};
270  double gamma_minus_1_inv{1.0 / (gamma - 1.0)};
271 
272  Array1d gamma_array_{Array1d::Constant(gamma)};
274 
275 private:
276  template <typename State>
277  friend constexpr auto tag_invoke(tag_t<Depths>, const PerfectGasMix& eq,
278  Type<State>) noexcept {
279  using Depths = typename State::Traits::template Depths<N>;
280  ToConcreteDepths<Depths> depths{};
281  if constexpr (std::is_same_v<Depths, PerfectGasMixKineticStateShape>) {
282  depths.mole_fractions = eq.n_species + 1;
283  } else {
284  depths.species = eq.n_species;
285  }
286  return depths;
287  }
288 
289  template <typename Density, typename Momentum, typename Energy,
290  typename Species>
291  friend auto
294  Species>&) noexcept {
295  if constexpr (std::is_same_v<double, Density>) {
296  return eq.gamma;
297  } else {
298  return Array1d::Constant(eq.gamma);
299  }
300  }
301 
302  template <typename Density, typename Momentum, typename Energy,
303  typename Species>
304  friend const Density&
307  Species>& q) noexcept {
308  return q.density;
309  }
310 
311  template <typename Density, typename Momentum, typename Energy,
312  typename Species>
313  friend auto
316  Species>& q) noexcept {
317  return (q.energy - euler::KineticEnergy(q.density, q.momentum)) / q.density;
318  }
319 
320  template <typename Density, typename Temperature, typename MoleFractions>
321  friend auto
324  MoleFractions>& q) noexcept {
325  // Rspec = cp - cv
326  // gamma = cp / cv
327  // cp = cv gamma
328  // Rspec = gamma cv - cv
329  // Rspec = (gamma - 1) cv
330  // Rpsec /(gamma - 1) = cv
331  const double cv = eq.Rspec * eq.gamma_minus_1_inv;
332  return cv * q.temperature;
333  }
334 
336  const PerfectGasMix& eq, Complete& q,
337  const KineticState& kin,
338  const Array<double, N, 1>& u) noexcept {
339  q.density = kin.density;
340  q.momentum = q.density * u;
341  const double e = euler::InternalEnergy(eq, kin);
342  q.energy = q.density * (e + 0.5 * u.matrix().squaredNorm());
343  const double RT = eq.Rspec * kin.temperature;
344  q.pressure = RT * q.density;
345  q.speed_of_sound = std::sqrt(eq.gamma * RT);
346  const double sum = kin.mole_fractions.sum();
347  for (int i = 0; i < eq.n_species; i++) {
348  q.species[i] = q.density * kin.mole_fractions[i] / sum;
349  }
350  }
351 
353  const PerfectGasMix& eq, KineticState& kin,
354  const Complete& q) noexcept {
355  kin.density = q.density;
356  kin.temperature = euler::Temperature(eq, q);
357  double sum = 0.0;
358  for (int i = 0; i < eq.n_species; ++i) {
359  kin.mole_fractions[i] = q.species[i] / q.density;
360  sum += kin.mole_fractions[i];
361  }
362  kin.mole_fractions[eq.n_species] = std::max(0.0, 1.0 - sum);
363  }
364 
365  template <typename Density, typename Momentum, typename Energy,
366  typename Species>
367  friend const Momentum&
370  Species>& q) noexcept {
371  return q.momentum;
372  }
373 
374  template <typename Density, typename Momentum, typename Energy,
375  typename Species>
376  friend decltype(auto) tag_invoke(
377  tag_t<euler::Momentum>, const PerfectGasMix&,
379  int d) noexcept {
380  if constexpr (std::is_same_v<double, Density>) {
381  return q.momentum[d];
382  } else {
383  return q.row(d);
384  }
385  }
386 
387  template <typename Density, typename Momentum, typename Energy,
388  typename Species>
389  friend Momentum
392  Species>& q) noexcept {
393  if constexpr (std::is_same_v<double, Density>) {
394  return q.momentum / q.density;
395  } else {
397  for (int i = 0; i < N; ++i) {
398  v.row(i) = q.momentum.row(i) / q.density;
399  }
400  return v;
401  }
402  }
403 
404  template <typename Density, typename Momentum, typename Energy,
405  typename Species>
406  friend void
409  nodeduce_t<const Momentum&> v) noexcept {
410  if constexpr (std::is_same_v<double, Density>) {
411  const double rhoE_kin_old = euler::KineticEnergy(q.density, q.momentum);
412  q.momentum = q.density * v;
413  const double rhoE_kin_new = euler::KineticEnergy(q.density, q.momentum);
414  q.energy += rhoE_kin_new - rhoE_kin_old;
415  }
416  }
417 
418  template <typename Density, typename Momentum, typename Energy,
419  typename Species>
420  friend auto tag_invoke(
423  int d) noexcept {
424  if constexpr (std::is_same_v<double, Density>) {
425  return q.momentum[d] / q.density;
426  } else {
427  return q.row(d) / q.density;
428  }
429  }
430 
431  template <typename Density, typename Momentum, typename Energy,
432  typename Species>
433  friend const Energy&
436  Species>& q) noexcept {
437  return q.energy;
438  }
439 
440  template <typename Density, typename Momentum, typename Energy,
441  typename Species>
442  friend const Species&
445  Species>& q) noexcept {
446  return q.species;
447  }
448 
449  template <typename Density, typename Velocity, typename Pressure,
450  typename Species>
451  friend const Species&
454  q) noexcept {
455  return q.species;
456  }
457 
458  template <typename Density, typename Momentum, typename Energy,
459  typename Species>
460  friend decltype(auto) tag_invoke(
461  tag_t<euler::Species>, const PerfectGasMix&,
463  int d) noexcept {
464  if constexpr (std::is_same_v<double, Density>) {
465  return q.species[d];
466  } else {
467  return q.species.row(d);
468  }
469  }
470 
471  template <typename Density, typename Momentum, typename Energy,
472  typename Species, typename Pressure, typename SpeedOfSound>
473  friend Density
476  Pressure, SpeedOfSound>& q) noexcept {
477  return (q.energy + q.pressure) / q.density;
478  }
479 
480  template <typename Density, typename Momentum, typename Energy,
481  typename Species, typename Pressure, typename SpeedOfSound>
482  friend const Pressure&
485  Pressure, SpeedOfSound>& q) noexcept {
486  return q.pressure;
487  }
488 
490  const KineticState& q) noexcept {
491  return eq.Rspec * q.temperature * q.density;
492  }
493 
494  template <typename Density, typename Momentum, typename Energy,
495  typename Species, typename Pressure, typename SpeedOfSound>
496  friend const SpeedOfSound&
499  Pressure, SpeedOfSound>& q) noexcept {
500  return q.speed_of_sound;
501  }
502 
504  const PerfectGasMix& eq, Complete& q,
505  const Complete& q0, double p_new) noexcept {
506  const double rho_old = euler::Density(eq, q0);
507  const double p_old = euler::Pressure(eq, q0);
508  const double T_old = euler::Temperature(eq, q0);
509  const Array<double, N, 1> u_old = euler::Velocity(eq, q0);
510  const double c = euler::SpeedOfSound(eq, q0);
511  const double c2 = c*c;
512  const double Ma2 = u_old.matrix().squaredNorm() / c2;
513 
514  const double alpha = 1.0 + 0.5 * Ma2 / eq.gamma_minus_1_inv;
515  const double rho_0 = rho_old * std::pow(alpha, eq.gamma_minus_1_inv);
516  const double p_0 = p_old * std::pow(alpha, eq.gamma * eq.gamma_minus_1_inv);
517  const double T_0 = T_old * alpha;
518 
519  const double rho_new = rho_0 * std::pow(p_new / p_0, 1 / eq.gamma);
520  const double T_new = p_new / rho_new / eq.Rspec;
521 
522  // a = (gamma - 1) / 2
523  // T0 = T_new (1 + a Ma2_n)
524  // (gamma R) (T_0 - T_new) / a = (gamma R) (T_new (1 + a Ma2_n) - T_new) / a = (gamma R) T_new Ma2_n = c2_n Ma2_n = u2_n
525  const double u2_new = 2.0 * eq.gamma_minus_1_inv * eq.gamma * eq.Rspec * (T_0 - T_new);
526  // const Array<double, N, 1> u0 = euler::Velocity(eq, q0);
528  u_new[0] = ((u2_new > 0.0) - (u2_new < 0.0)) * std::sqrt(std::abs(u2_new));
529 
530  // Array<double, N, 1> u_new = u_old;
531  // u_new[0] =
532  // u_old[0] +
533  // 2.0 * std::sqrt(eq.gamma * q0.pressure / q0.density) *
534  // eq.gamma_minus_1_inv -
535  // 2.0 * std::sqrt(eq.gamma * p_new / rho_new) * eq.gamma_minus_1_inv;
536  // const double rho_new =
537  // std::pow(p_new / q0.pressure, 1 / eq.gamma) * q0.density;
538  const Array<double, N, 1> rhou_new = rho_new * u_new;
539  const double rhoE_new =
540  p_new * eq.gamma_minus_1_inv + euler::KineticEnergy(rho_new, rhou_new);
541 
542  q.density = rho_new;
543  q.momentum = rhou_new;
544  q.energy = rhoE_new;
545  q.species = q0.species;
546  q.pressure = p_new;
547  q.speed_of_sound = std::sqrt(eq.gamma * p_new / rho_new);
548  }
549 };
550 
551 // We define this class only for dimensions 1 to 3.
552 // The definitions will be found in its source file PerfectGasMix.cpp
553 extern template struct PerfectGasMix<1>;
554 extern template struct PerfectGasMix<2>;
555 extern template struct PerfectGasMix<3>;
556 
557 template <int Rank>
559  Complete<PerfectGasMix<Rank>>& complete,
560  const Primitive<PerfectGasMix<Rank>>& prim) {
561  complete = equation.CompleteFromPrim(prim.density, prim.velocity,
562  prim.pressure, prim.species);
563 }
564 
565 template <int Rank>
568  const PrimitiveArray<PerfectGasMix<Rank>>& prim) {
569  complete.density = prim.density;
570  for (int i = 0; i < Rank; ++i) {
571  complete.momentum.row(i) = complete.density * prim.velocity.row(i);
572  }
573  complete.pressure = prim.pressure;
574  for (int s = 0; s < equation.n_species; ++s) {
575  complete.species.row(s) = prim.density * prim.species.row(s);
576  }
577  const Array1d e_kin =
578  euler::KineticEnergy(complete.density, complete.momentum);
579  complete.energy = e_kin + complete.pressure * equation.gamma_minus_1_inv;
580  complete.speed_of_sound =
581  (equation.gamma * complete.pressure / complete.density).sqrt();
582 }
583 
584 template <int Rank>
587  const Complete<PerfectGasMix<Rank>>& complete) {
588  prim.density = complete.density;
589  prim.pressure = complete.pressure;
590  prim.velocity = complete.momentum / complete.density;
591  for (int i = 0; i < equation.n_species; ++i) {
592  prim.species[i] = complete.species[i] / complete.density;
593  }
594 }
595 
596 template <int Rank>
599  const CompleteArray<PerfectGasMix<Rank>>& complete) {
600  prim.density = complete.density;
601  prim.pressure = complete.pressure;
602  for (int i = 0; i < Rank; ++i) {
603  prim.velocity.row(i) = complete.momentum.row(i) / complete.density;
604  }
605  for (int i = 0; i < equation.n_species; ++i) {
606  prim.species.row(i) = complete.species.row(i) / complete.density;
607  }
608 }
609 
610 template <int Rank>
612  const PerfectGasMix<Rank>& eq,
615  const Array<double, Rank>& u) noexcept {
616  q.density = kin.density;
617  for (int i = 0; i < Rank; ++i) {
618  q.momentum.row(i) = q.density * u.row(i);
619  }
620  const Array1d e = euler::InternalEnergy(eq, kin);
621  const Array1d rhoE_kin = euler::KineticEnergy(q.density, q.momentum);
622  q.energy = q.density * e + rhoE_kin;
623  const Array1d RT = eq.Rspec * kin.temperature;
624  q.pressure = RT * q.density;
625  q.speed_of_sound = Eigen::sqrt(eq.gamma * RT);
626  const Array1d sum = kin.mole_fractions.colwise().sum();
627  for (int i = 0; i < eq.n_species; i++) {
628  q.species.row(i) = q.density * kin.mole_fractions.row(i) / sum;
629  }
630 }
631 
632 template <int Rank>
635  const KineticState<PerfectGasMix<Rank>>& kin) noexcept {
637  euler::CompleteFromKineticState(eq, q, kin, u);
638 }
639 
640 template <int Rank>
642  const PerfectGasMix<Rank>& eq,
644  const CompleteArray<PerfectGasMix<Rank>>& q) noexcept {
645  kin.density = q.density;
646  kin.temperature = euler::Temperature(eq, q);
647  kin.mole_fractions.setZero();
648  for (int i = 0; i < eq.n_species; ++i) {
649  kin.mole_fractions.row(i) = (q.species.row(i) / q.density).max(0.0);
650  }
651  Array1d sum = kin.mole_fractions.colwise().sum();
652  kin.mole_fractions.row(eq.n_species) = (1.0 - sum).max(0.0);
653  sum = kin.mole_fractions.colwise().sum();
654  for (int i = 0; i < eq.n_species + 1; ++i) {
655  kin.mole_fractions.row(i) /= sum;
656  }
657  FUB_ASSERT(kin.mole_fractions.colwise().sum().isApproxToConstant(1.0));
658 }
659 
660 template <int Rank>
662  const Complete<PerfectGasMix<Rank>>& q) noexcept {
663  return eq.Temperature(q);
664 }
665 
666 template <int Rank>
668  const CompleteArray<PerfectGasMix<Rank>>& q) noexcept {
669  return eq.Temperature(q);
670 }
671 
672 /// @{
673 /// \brief Defines how to rotate a given state of the euler equations.
674 ///
675 /// This function is needed when computing the reference state in the boundary
676 /// flux of the cut-cell stabilizations.
678  const Conservative<PerfectGasMix<2>>& state,
679  const Eigen::Matrix<double, 2, 2>& rotation,
680  const PerfectGasMix<2>&);
681 
683  const Complete<PerfectGasMix<2>>& state,
684  const Eigen::Matrix<double, 2, 2>& rotation,
685  const PerfectGasMix<2>&);
686 
688  const Conservative<PerfectGasMix<3>>& state,
689  const Eigen::Matrix<double, 3, 3>& rotation,
690  const PerfectGasMix<3>&);
691 
693  const Complete<PerfectGasMix<3>>& state,
694  const Eigen::Matrix<double, 3, 3>& rotation,
695  const PerfectGasMix<3>&);
696 /// @}
697 
699  const Conservative<PerfectGasMix<1>>& state,
700  const Eigen::Matrix<double, 1, 1>& normal,
701  const PerfectGasMix<1>& gas);
702 
704  const Conservative<PerfectGasMix<2>>& state,
705  const Eigen::Vector2d& normal, const PerfectGasMix<2>& gas);
706 
708  const Conservative<PerfectGasMix<3>>& state,
709  const Eigen::Vector3d& normal, const PerfectGasMix<3>& gas);
710 
712  const Complete<PerfectGasMix<1>>& state,
713  const Eigen::Matrix<double, 1, 1>& normal,
714  const PerfectGasMix<1>& gas);
715 
717  const Complete<PerfectGasMix<2>>& state,
718  const Eigen::Vector2d& normal, const PerfectGasMix<2>& gas);
719 
721  const Complete<PerfectGasMix<3>>& state,
722  const Eigen::Vector3d& normal, const PerfectGasMix<3>& gas);
723 
724 } // namespace fub
725 
726 #endif
#define FUB_ASSERT(x)
Definition: assert.hpp:39
constexpr struct fub::euler::InternalEnergyFn InternalEnergy
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::SpeciesFn Species
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::VelocityFn Velocity
constexpr struct fub::euler::TemperatureFn Temperature
The fub namespace.
Definition: AnyBoundaryCondition.hpp:31
std::conditional_t< N==1||M==1, Eigen::Array< T, N, M >, Eigen::Array< T, N, M, Eigen::RowMajor > > Array
Definition: Eigen.hpp:50
PerfectGasMixKineticState< ScalarDepth, ScalarDepth, VectorDepth<-1 > > PerfectGasMixKineticStateShape
Definition: PerfectGasMix.hpp:118
Array< double, 1 > Array1d
Definition: Eigen.hpp:53
typename nodeduce< T >::type nodeduce_t
Definition: type_traits.hpp:47
constexpr struct fub::DepthsFn Depths
std::decay_t< decltype(T)> tag_t
Definition: type_traits.hpp:350
void Rotate(Conservative< IdealGasMix< 2 >> &rotated, const Conservative< IdealGasMix< 2 >> &state, const Eigen::Matrix< double, 2, 2 > &rotation, const IdealGasMix< 2 > &)
Defines how to rotate a given state of the euler equations.
void PrimFromComplete(const PerfectGas< Rank > &, Primitive< PerfectGas< Rank >> &prim, const Complete< PerfectGas< Rank >> &complete)
Definition: PerfectGas.hpp:322
void CompleteFromPrim(const PerfectGas< Rank > &equation, Complete< PerfectGas< Rank >> &complete, const Primitive< PerfectGas< Rank >> &prim)
Definition: PerfectGas.hpp:314
void tag_invoke(tag_t< euler::CompleteFromKineticState >, const PerfectGasMix< Rank > &eq, CompleteArray< PerfectGasMix< Rank >> &q, const KineticStateArray< PerfectGasMix< Rank >> &kin, const Array< double, Rank > &u) noexcept
Definition: PerfectGasMix.hpp:611
Direction
This is a type safe type to denote a dimensional split direction.
Definition: Direction.hpp:30
boost::mp11::mp_transform< ToConcreteDepth, Depths > ToConcreteDepths
Definition: State.hpp:122
void Reflect(Complete< IdealGasMix< 1 >> &reflected, const Complete< IdealGasMix< 1 >> &state, const Eigen::Matrix< double, 1, 1 > &normal, const IdealGasMix< 1 > &gas)
Array< bool, 1 > MaskArray
Definition: Eigen.hpp:59
std::integral_constant< int, I > int_constant
Definition: type_traits.hpp:183
typename detail::ConservativeArrayBaseImpl< Eq, Width >::type ConservativeArrayBase
Definition: StateArray.hpp:132
boost::mp11::mp_transform< detail::DepthToStateValueType, typename Equation::ConservativeDepths > ConservativeBase
This type alias transforms state depths into a conservative state associated with a specified equatio...
Definition: State.hpp:247
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: StateArray.hpp:108
Definition: State.hpp:301
Definition: PerfectGasMix.hpp:139
Zero zero
Definition: PerfectGasMix.hpp:141
Species species
Definition: PerfectGasMix.hpp:143
Minus minus
Definition: PerfectGasMix.hpp:140
Plus plus
Definition: PerfectGasMix.hpp:142
Definition: PerfectGasMix.hpp:174
SpeedOfSound speed_of_sound
Definition: PerfectGasMix.hpp:176
Pressure pressure
Definition: PerfectGasMix.hpp:175
This is a template class for constructing conservative states for the perfect gas equations.
Definition: PerfectGasMix.hpp:43
Momentum momentum
Definition: PerfectGasMix.hpp:45
Density density
Definition: PerfectGasMix.hpp:44
Species species
Definition: PerfectGasMix.hpp:47
Energy energy
Definition: PerfectGasMix.hpp:46
Definition: PerfectGasMix.hpp:111
MoleFractions mole_fractions
Definition: PerfectGasMix.hpp:114
Temperature temperature
Definition: PerfectGasMix.hpp:113
Density density
Definition: PerfectGasMix.hpp:112
Definition: PerfectGasMix.hpp:79
Pressure pressure
Definition: PerfectGasMix.hpp:82
Velocity velocity
Definition: PerfectGasMix.hpp:81
Species species
Definition: PerfectGasMix.hpp:83
Density density
Definition: PerfectGasMix.hpp:80
Definition: PerfectGasMix.hpp:208
Array< double, N, 1 > Velocity(const Complete &q) const noexcept
Array1d gamma_minus_1_inv_array_
Definition: PerfectGasMix.hpp:273
friend auto tag_invoke(tag_t< euler::InternalEnergy >, const PerfectGasMix &eq, const PerfectGasMixKineticState< Density, Temperature, MoleFractions > &q) noexcept
Definition: PerfectGasMix.hpp:322
double Rspec
Definition: PerfectGasMix.hpp:268
static constexpr int Rank() noexcept
Definition: PerfectGasMix.hpp:221
Array1d gamma_array_
Definition: PerfectGasMix.hpp:272
friend const Species & tag_invoke(tag_t< euler::Species >, const PerfectGasMix &, const PerfectGasMixPrimitive< Density, Velocity, Pressure, Species > &q) noexcept
Definition: PerfectGasMix.hpp:452
friend const Energy & tag_invoke(tag_t< euler::Energy >, const PerfectGasMix &, const PerfectGasMixConservative< Density, Momentum, Energy, Species > &q) noexcept
Definition: PerfectGasMix.hpp:434
void Flux(Conservative &flux, const Complete &state, [[maybe_unused]] Direction dir=Direction::X) const noexcept
friend const Momentum & tag_invoke(tag_t< euler::Momentum >, const PerfectGasMix &, const PerfectGasMixConservative< Density, Momentum, Energy, Species > &q) noexcept
Definition: PerfectGasMix.hpp:368
void CompleteFromCons(CompleteArray &complete, const ConservativeArrayBase< PerfectGasMix > &cons) const noexcept
Complete CompleteFromPrim(double density, const Array< double, N, 1 > &u, double pressure, const Array< double, -1, 1 > &species) const noexcept
friend Density tag_invoke(tag_t< euler::TotalEnthalpy >, const PerfectGasMix &, const PerfectGasMixComplete< Density, Momentum, Energy, Species, Pressure, SpeedOfSound > &q) noexcept
Definition: PerfectGasMix.hpp:474
friend const SpeedOfSound & tag_invoke(tag_t< euler::SpeedOfSound >, const PerfectGasMix &, const PerfectGasMixComplete< Density, Momentum, Energy, Species, Pressure, SpeedOfSound > &q) noexcept
Definition: PerfectGasMix.hpp:497
void CompleteFromCons(Complete &complete, const ConservativeBase< PerfectGasMix > &cons) const noexcept
double Temperature(const Complete &q) const noexcept
void Flux(ConservativeArray &flux, const CompleteArray &state, MaskArray mask, [[maybe_unused]] Direction dir) const noexcept
int n_species
Definition: PerfectGasMix.hpp:260
Array1d Temperature(const CompleteArray &q) const noexcept
friend auto tag_invoke(tag_t< euler::Gamma >, const PerfectGasMix &eq, const PerfectGasMixConservative< Density, Momentum, Energy, Species > &) noexcept
Definition: PerfectGasMix.hpp:292
void Flux(ConservativeArray &flux, const CompleteArray &state, [[maybe_unused]] Direction dir) const noexcept
friend void tag_invoke(tag_t< euler::CompleteFromKineticState >, const PerfectGasMix &eq, Complete &q, const KineticState &kin, const Array< double, N, 1 > &u) noexcept
Definition: PerfectGasMix.hpp:335
friend const Species & tag_invoke(tag_t< euler::Species >, const PerfectGasMix &, const PerfectGasMixConservative< Density, Momentum, Energy, Species > &q) noexcept
Definition: PerfectGasMix.hpp:443
constexpr friend auto tag_invoke(tag_t< Depths >, const PerfectGasMix &eq, Type< State >) noexcept
Definition: PerfectGasMix.hpp:277
void CompleteFromCons(CompleteArray &complete, const ConservativeArrayBase< PerfectGasMix > &cons, MaskArray mask) const noexcept
friend auto tag_invoke(tag_t< euler::InternalEnergy >, const PerfectGasMix &eq, const PerfectGasMixConservative< Density, Momentum, Energy, Species > &q) noexcept
Definition: PerfectGasMix.hpp:314
double gamma
Definition: PerfectGasMix.hpp:269
friend void tag_invoke(tag_t< euler::SetVelocity >, const PerfectGasMix &, PerfectGasMixConservative< Density, Momentum, Energy, Species > &q, nodeduce_t< const Momentum & > v) noexcept
Definition: PerfectGasMix.hpp:407
friend void tag_invoke(tag_t< euler::KineticStateFromComplete >, const PerfectGasMix &eq, KineticState &kin, const Complete &q) noexcept
Definition: PerfectGasMix.hpp:352
friend auto tag_invoke(tag_t< euler::SetIsentropicPressure >, const PerfectGasMix &eq, Complete &q, const Complete &q0, double p_new) noexcept
Definition: PerfectGasMix.hpp:503
friend auto tag_invoke(tag_t< euler::Velocity >, const PerfectGasMix &, const PerfectGasMixConservative< Density, Momentum, Energy, Species > &q, int d) noexcept
Definition: PerfectGasMix.hpp:420
double gamma_minus_1_inv
Definition: PerfectGasMix.hpp:270
double Machnumber(const Complete &q) const noexcept
friend const Pressure & tag_invoke(tag_t< euler::Pressure >, const PerfectGasMix &, const PerfectGasMixComplete< Density, Momentum, Energy, Species, Pressure, SpeedOfSound > &q) noexcept
Definition: PerfectGasMix.hpp:483
friend Momentum tag_invoke(tag_t< euler::Velocity >, const PerfectGasMix &, const PerfectGasMixConservative< Density, Momentum, Energy, Species > &q) noexcept
Definition: PerfectGasMix.hpp:390
friend const Density & tag_invoke(tag_t< euler::Density >, const PerfectGasMix &, const PerfectGasMixConservative< Density, Momentum, Energy, Species > &q) noexcept
Definition: PerfectGasMix.hpp:305
Array< double, N > Velocity(const CompleteArray &q) const noexcept
friend double tag_invoke(tag_t< euler::Pressure >, const PerfectGasMix &eq, const KineticState &q) noexcept
Definition: PerfectGasMix.hpp:489
Definition: StateArray.hpp:89
Definition: State.hpp:290
This type is used to tag scalar quantities.
Definition: State.hpp:109
Definition: State.hpp:35
Definition: State.hpp:162
This type is used to tag quantities with a depth known at compile time.
Definition: State.hpp:112
Definition: State.hpp:39