41 typename T::Tcons cons,
42 typename T::Tprim prim,
44 typename T::Tscal vn) {
49 { self.cons_to_prim(cons) } -> std::convertible_to<typename T::Tprim>;
50 { self.prim_to_cons(prim) } -> std::convertible_to<typename T::Tcons>;
51 { self.sound_speed(prim) } -> std::convertible_to<typename T::Tscal>;
52 { self.vn(prim, n) } -> std::convertible_to<typename T::Tscal>;
53 { self.flux(prim, n) } -> std::convertible_to<typename T::Tcons>;
54 { self.flux(prim, n, vn) } -> std::convertible_to<typename T::Tcons>;
66 typename T::Tcons cons,
67 typename T::Tprim prim,
69 typename T::Tscal vn) {
74 { self.cons_to_prim(cons) } -> std::convertible_to<typename T::Tprim>;
75 { self.prim_to_cons(prim) } -> std::convertible_to<typename T::Tcons>;
76 { self.vn(prim, n) } -> std::convertible_to<typename T::Tscal>;
77 { self.flux(prim, n) } -> std::convertible_to<typename T::Tcons>;
78 { self.flux(prim, n, vn) } -> std::convertible_to<typename T::Tcons>;
85 { self.gamma() } -> std::convertible_to<typename T::Tscal>;
91 { self.gamma(prim) } -> std::convertible_to<typename T::Tscal>;
113 template<Flu
idStateAdiabaticSpec FSpec>
116 const typename FSpec::Tprim &prim_l,
117 const typename FSpec::Tprim &prim_r) {
119 const typename FSpec::Tscal gamma = fspec.gamma();
120 return {gamma, gamma};
122 return {fspec.gamma(prim_l), fspec.gamma(prim_r)};
126 template<
class VecType>
128 using Tvec = VecType;
129 using Tscal = shambase::VecComponent<Tvec>;
136 const ConsState &operator*=(
const Tscal);
139 template<
class VecType>
141 using Tvec = VecType;
142 using Tscal = shambase::VecComponent<Tvec>;
144 Tscal rho{}, press{};
152 rhovel += cst.rhovel;
157 const ConsState<Tvec> operator+(
const ConsState<Tvec> &lhs,
const ConsState<Tvec> &rhs) {
158 return ConsState<Tvec>(lhs) += rhs;
165 rhovel -= cst.rhovel;
176 const typename ConsState<Tvec>::Tscal factor) {
185 const typename ConsState<Tvec>::Tscal factor,
const ConsState<Tvec> &rhs) {
191 const ConsState<Tvec> &lhs,
const typename ConsState<Tvec>::Tscal factor) {
195 template<
class VecType>
197 using Tvec = VecType;
198 using Tscal = shambase::VecComponent<Tvec>;
200 std::array<ConsState<Tvec>, 3> f;
204 inline constexpr shambase::VecComponent<Tvec> rhoekin(
205 shambase::VecComponent<Tvec> rho, Tvec v) {
206 using Tscal = shambase::VecComponent<Tvec>;
207 const Tscal v2 = v[0] * v[0] + v[1] * v[1] + v[2] * v[2];
208 return 0.5 * rho * v2;
212 inline constexpr ConsState<Tvec> prim_to_cons(
213 const PrimState<Tvec> prim,
typename PrimState<Tvec>::Tscal gamma) {
214 ConsState<Tvec> cons;
218 const auto rhoeint = prim.press / (gamma - 1.0);
219 cons.rhoe = rhoeint + rhoekin(prim.rho, prim.vel);
221 cons.rhovel[0] = prim.rho * prim.vel[0];
222 cons.rhovel[1] = prim.rho * prim.vel[1];
223 cons.rhovel[2] = prim.rho * prim.vel[2];
235 prim.vel[0] = cons.rhovel[0] / cons.rho;
236 prim.vel[1] = cons.rhovel[1] / cons.rho;
237 prim.vel[2] = cons.rhovel[2] / cons.rho;
239 const auto rhoeint = cons.rhoe - rhoekin(prim.rho, prim.vel);
240 prim.press = (gamma - 1.0) * rhoeint;
255 typename PrimState<Tvec>::Tscal vn,
256 typename PrimState<Tvec>::Tscal gamma) {
259 const auto rhoeint = prim.press / (gamma - 1.0);
260 const auto rhoe = rhoeint + rhoekin(prim.rho, prim.vel);
262 flux.rho = prim.rho * vn;
264 flux.rhoe = (rhoe + prim.press) * vn;
266 flux.rhovel[0] = prim.rho * vn * prim.vel[0] + prim.press * n[0];
267 flux.rhovel[1] = prim.rho * vn * prim.vel[1] + prim.press * n[1];
268 flux.rhovel[2] = prim.rho * vn * prim.vel[2] + prim.press * n[2];
280 const PrimState<Tvec> prim, Tvec n,
typename PrimState<Tvec>::Tscal gamma) {
281 const auto vn = n[0] * prim.vel[0] + n[1] * prim.vel[1] + n[2] * prim.vel[2];
286 inline constexpr shambase::VecComponent<Tvec> sound_speed(
287 PrimState<Tvec> prim, shambase::VecComponent<Tvec> gamma) {
288 return sycl::sqrt(gamma * prim.press / prim.rho);
291 template<
class Tcons>
292 inline constexpr Tcons y_to_x(
const Tcons c) {
295 cprime.rhoe = c.rhoe;
296 cprime.rhovel[0] = c.rhovel[1];
297 cprime.rhovel[1] = -c.rhovel[0];
298 cprime.rhovel[2] = c.rhovel[2];
302 template<
class Tcons>
303 inline constexpr Tcons x_to_y(
const Tcons c) {
306 cprime.rhoe = c.rhoe;
307 cprime.rhovel[0] = -c.rhovel[1];
308 cprime.rhovel[1] = c.rhovel[0];
309 cprime.rhovel[2] = c.rhovel[2];
313 template<
class Tcons>
314 inline constexpr Tcons z_to_x(
const Tcons c) {
317 cprime.rhoe = c.rhoe;
318 cprime.rhovel[0] = c.rhovel[2];
319 cprime.rhovel[1] = c.rhovel[1];
320 cprime.rhovel[2] = -c.rhovel[0];
324 template<
class Tcons>
325 inline constexpr Tcons x_to_z(
const Tcons c) {
328 cprime.rhoe = c.rhoe;
329 cprime.rhovel[0] = -c.rhovel[2];
330 cprime.rhovel[1] = c.rhovel[1];
331 cprime.rhovel[2] = c.rhovel[0];
335 template<
class Tcons>
336 inline constexpr Tcons invert_axis(
const Tcons c) {
339 cprime.rhoe = c.rhoe;
340 cprime.rhovel[0] = -c.rhovel[0];
341 cprime.rhovel[1] = -c.rhovel[1];
342 cprime.rhovel[2] = -c.rhovel[2];
350 template<
class Tprim>
351 inline constexpr Tprim prim_y_to_x(
const Tprim p) {
354 pprime.press = p.press;
355 pprime.vel[0] = p.vel[1];
356 pprime.vel[1] = -p.vel[0];
357 pprime.vel[2] = p.vel[2];
361 template<
class Tprim>
362 inline constexpr Tprim prim_z_to_x(
const Tprim p) {
365 pprime.press = p.press;
366 pprime.vel[0] = p.vel[2];
367 pprime.vel[1] = p.vel[1];
368 pprime.vel[2] = -p.vel[0];
372 template<
class Tprim>
373 inline constexpr Tprim prim_invert_axis(
const Tprim p) {
376 pprime.press = p.press;
377 pprime.vel[0] = -p.vel[0];
378 pprime.vel[1] = -p.vel[1];
379 pprime.vel[2] = -p.vel[2];
383 template<
class VecType>
385 using Tvec = VecType;
386 using Tscal = shambase::VecComponent<Tvec>;
396 template<
class VecType>
398 using Tvec = VecType;
399 using Tscal = shambase::VecComponent<Tvec>;
407 rhovel += d_cst.rhovel;
412 const DustConsState<Tvec> operator+(
413 const DustConsState<Tvec> &lhs,
const DustConsState<Tvec> &rhs) {
414 return DustConsState<Tvec>(lhs) += rhs;
420 rhovel -= d_cst.rhovel;
432 const typename DustConsState<Tvec>::Tscal factor) {
450 template<
class VecType>
452 using Tvec = VecType;
453 using Tscal = shambase::VecComponent<Tvec>;
454 std::array<DustConsState<Tvec>, 3> f;
460 d_cons.rho = d_prim.rho;
461 d_cons.rhovel = (d_prim.vel * d_prim.rho);
466 inline constexpr DustPrimState<Tvec> d_cons_to_prim(
const DustConsState<Tvec> d_cons) {
467 DustPrimState<Tvec> d_prim;
468 d_prim.rho = d_cons.rho;
469 d_prim.vel = (d_cons.rhovel * (1 / d_cons.rho));
483 d_flux.rho = d_prim.rho * vn;
484 d_flux.rhovel = d_prim.vel * (d_prim.rho * vn);
495 const auto vn = n[0] * d_prim.vel[0] + n[1] * d_prim.vel[1] + n[2] * d_prim.vel[2];
499 template<
class Tcons>
500 inline constexpr Tcons d_x_to_y(
const Tcons c) {
503 d_cst.rhovel[0] = -c.rhovel[1];
504 d_cst.rhovel[1] = c.rhovel[0];
505 d_cst.rhovel[2] = c.rhovel[2];
510 template<
class Tcons>
511 inline constexpr Tcons d_y_to_x(
const Tcons c) {
514 d_cst.rhovel[0] = c.rhovel[1];
515 d_cst.rhovel[1] = -c.rhovel[0];
516 d_cst.rhovel[2] = c.rhovel[2];
520 template<
class Tcons>
521 inline constexpr Tcons d_x_to_z(
const Tcons c) {
524 d_cst.rhovel[0] = -c.rhovel[2];
525 d_cst.rhovel[1] = c.rhovel[1];
526 d_cst.rhovel[2] = c.rhovel[0];
530 template<
class Tcons>
531 inline constexpr Tcons d_z_to_x(
const Tcons c) {
534 d_cst.rhovel[0] = c.rhovel[2];
535 d_cst.rhovel[1] = c.rhovel[1];
536 d_cst.rhovel[2] = -c.rhovel[0];
540 template<
class Tcons>
541 inline constexpr Tcons d_invert_axis(
const Tcons c) {
544 d_cst.rhovel = -(c.rhovel);
552 template<
class Tprim>
553 inline constexpr Tprim d_prim_y_to_x(
const Tprim p) {
556 pprime.vel[0] = p.vel[1];
557 pprime.vel[1] = -p.vel[0];
558 pprime.vel[2] = p.vel[2];
562 template<
class Tprim>
563 inline constexpr Tprim d_prim_z_to_x(
const Tprim p) {
566 pprime.vel[0] = p.vel[2];
567 pprime.vel[1] = p.vel[1];
568 pprime.vel[2] = -p.vel[0];
572 template<
class Tprim>
573 inline constexpr Tprim d_prim_invert_axis(
const Tprim p) {
576 pprime.vel = -(p.vel);
583 template<
class VecType>
585 using Tvec = VecType;
586 using Tscal = shambase::VecComponent<Tvec>;
592 Tprim cons_to_prim(Tcons c)
const {
return shammath::cons_to_prim(c, m_gamma); }
593 Tcons prim_to_cons(Tprim p)
const {
return shammath::prim_to_cons(p, m_gamma); }
594 Tscal sound_speed(Tprim p)
const {
return shammath::sound_speed(p, m_gamma); }
595 Tscal vn(Tprim p, Tvec n)
const {
return sham::dot(p.vel, n); }
596 Tcons flux(Tprim p, Tvec n, Tscal vn)
const {
600 Tscal gamma()
const {
return m_gamma; }
612 template<
class VecType>
614 using Tvec = VecType;
615 using Tscal = shambase::VecComponent<Tvec>;
619 Tprim cons_to_prim(Tcons c)
const {
return shammath::d_cons_to_prim(c); }
620 Tcons prim_to_cons(Tprim p)
const {
return shammath::d_prim_to_cons(p); }
621 Tscal vn(Tprim p, Tvec n)
const {
return sham::dot(p.vel, n); }
The flux operations a dust (pressureless) Riemann solver needs, so that solvers (see riemann_dust_hll...
A FluidStateSpec that also exposes the adiabatic index, for solvers (e.g. HLLC) that need gamma direc...
An equation of state paired with the flux/wave-speed operations a Riemann solver needs,...
True if T exposes a single, state-independent adiabatic index via gamma().
True if T exposes a per-primitive-state adiabatic index via gamma(prim).
Namespace for internal details of the logs module.
namespace for math utility
constexpr DustConsState< Tvec > d_hydro_flux_n(const DustPrimState< Tvec > d_prim, Tvec n, typename DustPrimState< Tvec >::Tscal vn)
Pressureless (dust) flux across a face of normal n, given a precomputed normal velocity vn = dot(d_pr...
constexpr std::pair< typename FSpec::Tscal, typename FSpec::Tscal > get_adiabatic_index_lr(const FSpec &fspec, const typename FSpec::Tprim &prim_l, const typename FSpec::Tprim &prim_r)
Read the left/right adiabatic indices a HLLC-style solver should use for a given L/R pair.
constexpr ConsState< Tvec > hydro_flux_n(const PrimState< Tvec > prim, Tvec n, typename PrimState< Tvec >::Tscal vn, typename PrimState< Tvec >::Tscal gamma)
Euler flux across a face of normal n, given a precomputed normal velocity vn = dot(prim....
FluidStateSpec implementation for an ideal (adiabatic) gas equation of state.
cons_to_prim/prim_to_cons/vn/flux wrapper for a pressureless (dust) fluid. Unlike FluidStateAdiabatic...