3#include <deal.II/base/config.h>
5#include <deal.II/base/exceptions.h>
6#include <deal.II/base/tensor.h>
7#include <deal.II/base/vectorization.h>
60 v.density() = v.density()
63 v.momentum(0) = v.momentum(0)
66 v.total_energy() = v.total_energy()
77 v.pressure() = v.pressure()
80 v.velocity(0) = v.velocity(0)
83 v.temperature() = v.temperature()
100 g.grad_total_energy()
108 template <
typename T>
111 m.heat_capacity_ratio()
114 m.specific_gas_constant()
122 template <
typename T>
125 m.heat_capacity_ratio()
128 m.specific_isobaric_heat()
131 m.stiffening_pressure()
139 template <
typename T>
142 m.heat_capacity_ratio()
145 m.specific_isobaric_heat()
148 m.stiffening_pressure()
162 template <
typename T>
165 m.specific_isochoric_heat()
168 m.reference_state_sound_speed()
171 m.reference_state_density()
174 m.reference_state_pressure()
188 template <EOSIsConservativeValueView ValueView, IdealGasIsMaterialView MaterialView>
189 static inline DEAL_II_ALWAYS_INLINE
193 return (material_view.heat_capacity_ratio() - 1.) *
194 (value_view.total_energy() -
195 value_view.density() * 0.5 *
212 static inline DEAL_II_ALWAYS_INLINE
215 const GradientView &gradient_view,
216 const MaterialView &material_view)
219 1. / value_view.density() *
220 (gradient_view.grad_total_energy() -
221 1. / value_view.density() * value_view.total_energy() * gradient_view.grad_density());
223 return (material_view.heat_capacity_ratio() - 1.0) / material_view.specific_gas_constant() *
236 template <EOSIsConservativeValueView ValueView, IdealGasIsMaterialView MaterialView>
237 static inline DEAL_II_ALWAYS_INLINE
241 return std::sqrt(material_view.heat_capacity_ratio() *
253 template <EOSIsConservativeValueView ValueView, IdealGasIsMaterialView MaterialView>
254 static inline DEAL_II_ALWAYS_INLINE
256 temperature(
const ValueView &value_view,
const MaterialView &material_view)
259 (material_view.specific_gas_constant() * value_view.density());
271 template <
typename ValueType,
274 static inline DEAL_II_ALWAYS_INLINE
278 const MaterialView &material_view)
280 return pressure / (material_view.heat_capacity_ratio() - 1.);
290 template <
typename ValueView, IdealGasIsMaterialView MaterialView>
291 static inline DEAL_II_ALWAYS_INLINE
296 (value_view.density() * (material_view.heat_capacity_ratio() - 1.));
313 static inline DEAL_II_ALWAYS_INLINE
316 const PrimitiveValueView &primitive_value_view,
317 const MaterialView &material_view)
319 const auto pressure = primitive_value_view.pressure();
320 const auto temperature = primitive_value_view.temperature();
321 const auto velocity = primitive_value_view.velocity();
323 const auto density = pressure / (material_view.specific_gas_constant() *
temperature);
326 conservative_value_view.density() = density;
329 for (
unsigned int d = 0; d < dim; ++d)
330 conservative_value_view.momentum(d) = density * velocity[d];
333 conservative_value_view.total_energy() =
334 density * (material_view.specific_gas_constant() /
335 (material_view.heat_capacity_ratio() - 1.) *
temperature +
350 template <EOSIsConservativeValueView ValueView, StiffenedGasIsMaterialView MaterialView>
351 static inline DEAL_II_ALWAYS_INLINE
355 return (material_view.heat_capacity_ratio() - 1.) *
356 (value_view.total_energy() -
357 value_view.density() * 0.5 *
359 material_view.heat_capacity_ratio() * material_view.stiffening_pressure();
375 static inline DEAL_II_ALWAYS_INLINE
378 const GradientView &gradient_view,
379 const MaterialView &material_view)
381 const auto inv_rho = 1. / value_view.density();
384 inv_rho * (gradient_view.grad_total_energy() -
385 inv_rho * value_view.total_energy() * gradient_view.grad_density());
387 return material_view.heat_capacity_ratio() / material_view.specific_isobaric_heat() *
389 material_view.stiffening_pressure() * inv_rho * inv_rho *
390 gradient_view.grad_density());
402 template <EOSIsConservativeValueView ValueView, StiffenedGasIsMaterialView MaterialView>
403 static inline DEAL_II_ALWAYS_INLINE
408 material_view.heat_capacity_ratio() *
410 value_view.density());
422 template <EOSIsConservativeValueView ValueView, StiffenedGasIsMaterialView MaterialView>
423 static inline DEAL_II_ALWAYS_INLINE
425 temperature(
const ValueView &value_view,
const MaterialView &material_view)
428 material_view.stiffening_pressure()) *
429 material_view.heat_capacity_ratio() /
430 (material_view.specific_isobaric_heat() * value_view.density() *
431 (material_view.heat_capacity_ratio() - 1.));
443 template <
typename ValueType,
446 static inline DEAL_II_ALWAYS_INLINE
450 const MaterialView &material_view)
453 material_view.heat_capacity_ratio() * material_view.stiffening_pressure()) /
454 (material_view.heat_capacity_ratio() - 1.);
464 template <
typename ValueView, StiffenedGasIsMaterialView MaterialView>
465 static inline DEAL_II_ALWAYS_INLINE
470 material_view.heat_capacity_ratio() * material_view.stiffening_pressure()) /
471 (value_view.density() * (material_view.heat_capacity_ratio() - 1.));
486 static inline DEAL_II_ALWAYS_INLINE
489 const PrimitiveValueView &primitive_value_view,
490 const MaterialView &material_view)
493 (primitive_value_view.pressure() + material_view.stiffening_pressure()) *
494 material_view.heat_capacity_ratio() /
495 (material_view.specific_isobaric_heat() * primitive_value_view.temperature() *
496 (material_view.heat_capacity_ratio() - 1.));
499 conservative_value_view.density() = density;
502 for (
unsigned int d = 0; d < dim; ++d)
503 conservative_value_view.momentum(d) = density * primitive_value_view.velocity(d);
506 conservative_value_view.total_energy() =
508 (material_view.specific_isobaric_heat() / material_view.heat_capacity_ratio() *
509 primitive_value_view.temperature() +
510 material_view.stiffening_pressure() / density +
511 0.5 *
scalar_product(primitive_value_view.velocity(), primitive_value_view.velocity()));
527 static inline DEAL_II_ALWAYS_INLINE
531 return ((material_view.heat_capacity_ratio() - 1.) *
532 (value_view.total_energy() -
533 0.5 * value_view.density() *
535 value_view.density() * material_view.heat_bound()) -
536 material_view.heat_capacity_ratio() * material_view.stiffening_pressure() *
537 (1. - value_view.density() * material_view.covolume())) /
538 (1. - value_view.density() * material_view.covolume());
554 static inline DEAL_II_ALWAYS_INLINE
557 const GradientView &gradient_view,
558 const MaterialView &material_view)
560 const auto inv_rho = 1. / value_view.density();
563 inv_rho * (gradient_view.grad_total_energy() -
564 inv_rho * value_view.total_energy() * gradient_view.grad_density());
566 return material_view.heat_capacity_ratio() / material_view.specific_isobaric_heat() *
568 material_view.stiffening_pressure() * inv_rho * inv_rho *
569 gradient_view.grad_density());
583 static inline DEAL_II_ALWAYS_INLINE
588 material_view.heat_capacity_ratio() *
590 (value_view.density() * (1. - value_view.density() * material_view.covolume())));
604 static inline DEAL_II_ALWAYS_INLINE
606 temperature(
const ValueView &value_view,
const MaterialView &material_view)
609 material_view.stiffening_pressure()) *
610 (1. / value_view.density() - material_view.covolume()) *
611 material_view.heat_capacity_ratio() /
612 ((material_view.heat_capacity_ratio() - 1.) * material_view.specific_isobaric_heat());
625 template <
typename ValueType,
628 static inline DEAL_II_ALWAYS_INLINE
631 const ValueView &value_view,
632 const MaterialView &material_view)
635 material_view.heat_capacity_ratio() * material_view.stiffening_pressure()) /
636 (material_view.heat_capacity_ratio() - 1.) *
637 (1. - value_view.density() * material_view.covolume()) +
638 value_view.density() * material_view.heat_bound();
648 template <
typename ValueView, NobleAbelStiffenedGasIsMaterialView MaterialView>
649 static inline DEAL_II_ALWAYS_INLINE
654 material_view.heat_capacity_ratio() * material_view.stiffening_pressure()) /
655 (material_view.heat_capacity_ratio() - 1.) *
656 (1. / value_view.density() - material_view.covolume()) +
657 material_view.heat_bound();
672 static inline DEAL_II_ALWAYS_INLINE
675 const PrimitiveValueView &primitive_value_view,
676 const MaterialView &material_view)
678 const auto pressure = primitive_value_view.pressure();
679 const auto temperature = primitive_value_view.temperature();
682 (pressure + material_view.stiffening_pressure()) /
683 (material_view.specific_isobaric_heat() *
temperature *
684 (material_view.heat_capacity_ratio() - 1.) / material_view.heat_capacity_ratio() +
685 material_view.covolume() * (pressure + material_view.stiffening_pressure()));
688 conservative_value_view.density() = density;
691 for (
unsigned int d = 0; d < dim; ++d)
692 conservative_value_view.momentum(d) = density * primitive_value_view.velocity(d);
695 conservative_value_view.total_energy() =
697 (material_view.specific_isobaric_heat() / material_view.heat_capacity_ratio() *
699 material_view.stiffening_pressure() * (1. / density - material_view.covolume()) +
700 material_view.heat_bound() +
701 0.5 *
scalar_product(primitive_value_view.velocity(), primitive_value_view.velocity()));
716 template <EOSIsConservativeValueView ValueView, WeaklyCompressibleIsMaterialView MaterialView>
717 static inline DEAL_II_ALWAYS_INLINE
721 return material_view.reference_state_sound_speed() *
722 material_view.reference_state_sound_speed() *
723 (value_view.density() - material_view.reference_state_density()) +
724 material_view.reference_state_pressure();
740 static inline DEAL_II_ALWAYS_INLINE
743 const GradientView &gradient_view,
744 const MaterialView &material_view)
747 1. / value_view.density() *
748 (gradient_view.grad_total_energy() -
749 value_view.total_energy() / value_view.density() * gradient_view.grad_density());
751 return 1. / material_view.specific_isochoric_heat() *
764 template <EOSIsConservativeValueView ValueView, WeaklyCompressibleIsMaterialView MaterialView>
765 static inline DEAL_II_ALWAYS_INLINE
770 using ReturnType =
decltype(value_view.density());
772 return ReturnType(material_view.reference_state_sound_speed());
784 template <EOSIsConservativeValueView ValueView, WeaklyCompressibleIsMaterialView MaterialView>
785 static inline DEAL_II_ALWAYS_INLINE
787 temperature(
const ValueView &value_view,
const MaterialView &material_view)
789 return (value_view.total_energy() / value_view.density() -
790 0.5 *
scalar_product(value_view.velocity(), value_view.velocity())) /
791 material_view.specific_isochoric_heat();
803 template <
typename ValueType,
806 static inline DEAL_II_ALWAYS_INLINE
813 "inner_energy_from_pressure() is not defined for the weakly compressible EOS."));
824 template <
typename ValueView, WeaklyCompressibleIsMaterialView MaterialView>
825 static inline DEAL_II_ALWAYS_INLINE
829 return value_view.total_energy() / value_view.density() -
830 0.5 *
scalar_product(value_view.velocity(), value_view.velocity());
845 static inline DEAL_II_ALWAYS_INLINE
848 const PrimitiveValueView &primitive_value_view,
849 const MaterialView &material_view)
851 const auto pressure = primitive_value_view.pressure();
852 const auto temperature = primitive_value_view.temperature();
853 const auto velocity = primitive_value_view.velocity();
855 const auto density = (pressure - material_view.reference_state_pressure()) /
856 (material_view.reference_state_sound_speed() *
857 material_view.reference_state_sound_speed()) +
858 material_view.reference_state_density();
861 conservative_value_view.density() = density;
864 for (
unsigned int d = 0; d < dim; ++d)
865 conservative_value_view.momentum(d) = density * velocity[d];
868 conservative_value_view.total_energy() =
869 density * (material_view.specific_isochoric_heat() *
temperature +
877 template <
typename T>
881 } -> std::convertible_to<
const std::array<CompressibleFlow::EquationOfState,
882 std::tuple_size_v<
decltype(T::supported_eos)>> &>;
893 template <
typename Derived, CompressibleFlow::EquationOfState EOS>
897 return std::ranges::find(Derived::supported_eos, EOS) != Derived::supported_eos.end();
917 template <
typename Derived,
typename F>
918 inline DEAL_II_ALWAYS_INLINE
decltype(
auto)
921 auto check_support = [](CompressibleFlow::EquationOfState type) {
924 if (type == CompressibleFlow::EquationOfState::ideal_gas)
925 return supports_eos<Derived, CompressibleFlow::EquationOfState::ideal_gas>();
926 if (type == CompressibleFlow::EquationOfState::stiffened_gas)
927 return supports_eos<Derived, CompressibleFlow::EquationOfState::stiffened_gas>();
928 if (type == CompressibleFlow::EquationOfState::noble_abel_stiffened_gas)
930 CompressibleFlow::EquationOfState::noble_abel_stiffened_gas>();
931 if (type == CompressibleFlow::EquationOfState::weakly_compressible)
932 return supports_eos<Derived, CompressibleFlow::EquationOfState::weakly_compressible>();
940 case CompressibleFlow::EquationOfState::ideal_gas:
941 if constexpr (check_support(CompressibleFlow::EquationOfState::ideal_gas))
945 case CompressibleFlow::EquationOfState::stiffened_gas:
946 if constexpr (check_support(CompressibleFlow::EquationOfState::stiffened_gas))
950 case CompressibleFlow::EquationOfState::noble_abel_stiffened_gas:
951 if constexpr (check_support(CompressibleFlow::EquationOfState::noble_abel_stiffened_gas))
955 case CompressibleFlow::EquationOfState::weakly_compressible:
956 if constexpr (check_support(CompressibleFlow::EquationOfState::weakly_compressible))
964 AssertThrow(
false, dealii::ExcMessage(
"The provided EOS is not supported by this View."));
977 template <
int dim, ArithmeticType ValueType,
typename Derived>
983 return dispatch_eos<Derived>(
eos_type(), [&](
auto eos) ->
decltype(
auto) {
991 return dispatch_eos<Derived>(
eos_type(), [&](
auto eos) ->
decltype(
auto) {
999 return dispatch_eos<Derived>(
eos_type(), [&](
auto eos) ->
decltype(
auto) {
1007 return dispatch_eos<Derived>(
eos_type(), [&](
auto eos) ->
decltype(
auto) {
1015 return dispatch_eos<Derived>(
eos_type(), [&](
auto eos) ->
decltype(
auto) {
1024 return static_cast<const Derived &
>(*this).eos_type();
1030 return static_cast<const Derived &
>(*this);
1042 template <
int dim,
typename Derived>
1048 return dispatch_eos<Derived>(
eos_type(), [&](
auto eos) ->
decltype(
auto) {
1057 return static_cast<const Derived &
>(*this);
1063 return static_cast<const Derived &
>(*this).eos_type();
Definition equation_of_state.hpp:24
Definition equation_of_state.hpp:92
Definition equation_of_state.hpp:41
Definition equation_of_state.hpp:58
Definition equation_of_state.hpp:75
Concept ensuring a type defines a specific, compatible supported_eos array.
Definition equation_of_state.hpp:878
Definition equation_of_state.hpp:109
Definition equation_of_state.hpp:140
Definition equation_of_state.hpp:123
Definition equation_of_state.hpp:163
Definition equation_of_state.hpp:18
DEAL_II_ALWAYS_INLINE decltype(auto) dispatch_eos(CompressibleFlow::EquationOfState eos_type, F &&f)
Definition equation_of_state.hpp:919
constexpr bool supports_eos()
Dispatch helper function that checks at compile-time whether an equation of state is supported.
Definition equation_of_state.hpp:895
dealii::VectorizedArray< number, N > scalar_product(const dealii::VectorizedArray< number, N > &scalar, const dealii::Tensor< 1, 1, dealii::VectorizedArray< number, N > > &vec)
Definition dealii_tensor.hpp:60
dealii::Tensor< 1, n_rows, number > matrix_vector_product(const dealii::Tensor< 1, n_rows, dealii::Tensor< 1, n_columns, number > > &matrix, const dealii::Tensor< 1, n_columns, number > &vector)
Definition dealii_tensor.hpp:80
Definition equation_of_state.hpp:1044
const Derived & derived() const
Definition equation_of_state.hpp:1055
decltype(auto) grad_temperature() const
Definition equation_of_state.hpp:1046
decltype(auto) eos_type() const
Definition equation_of_state.hpp:1061
Definition equation_of_state.hpp:979
const Derived & derived() const
Definition equation_of_state.hpp:1028
decltype(auto) speed_of_sound() const
Definition equation_of_state.hpp:997
decltype(auto) specific_internal_energy() const
Definition equation_of_state.hpp:1013
decltype(auto) eos_type() const
Definition equation_of_state.hpp:1022
decltype(auto) temperature() const
Definition equation_of_state.hpp:989
decltype(auto) pressure() const
Definition equation_of_state.hpp:981
decltype(auto) inner_energy_from_pressure(const ValueType &pressure) const
Definition equation_of_state.hpp:1005
Definition equation_of_state.hpp:179
static DEAL_II_ALWAYS_INLINE void conservative_from_primitive(WritableConservativeValueView &conservative_value_view, const PrimitiveValueView &primitive_value_view, const MaterialView &material_view)
Definition equation_of_state.hpp:315
static DEAL_II_ALWAYS_INLINE auto inner_energy_from_pressure(const ValueType &pressure, const ValueView &, const MaterialView &material_view)
Definition equation_of_state.hpp:276
static DEAL_II_ALWAYS_INLINE auto grad_temperature(const ValueView &value_view, const GradientView &gradient_view, const MaterialView &material_view)
Definition equation_of_state.hpp:214
static DEAL_II_ALWAYS_INLINE auto temperature(const ValueView &value_view, const MaterialView &material_view)
Definition equation_of_state.hpp:256
static DEAL_II_ALWAYS_INLINE auto speed_of_sound(const ValueView &value_view, const MaterialView &material_view)
Definition equation_of_state.hpp:239
static DEAL_II_ALWAYS_INLINE auto thermodynamic_pressure(const ValueView &value_view, const MaterialView &material_view)
Definition equation_of_state.hpp:191
static DEAL_II_ALWAYS_INLINE auto specific_internal_energy(const ValueView &value_view, const MaterialView &material_view)
Definition equation_of_state.hpp:293
Definition equation_of_state.hpp:516
static DEAL_II_ALWAYS_INLINE auto temperature(const ValueView &value_view, const MaterialView &material_view)
Definition equation_of_state.hpp:606
static DEAL_II_ALWAYS_INLINE void conservative_from_primitive(WritableConservativeValueView &conservative_value_view, const PrimitiveValueView &primitive_value_view, const MaterialView &material_view)
Definition equation_of_state.hpp:674
static DEAL_II_ALWAYS_INLINE auto thermodynamic_pressure(const ValueView &value_view, const MaterialView &material_view)
Definition equation_of_state.hpp:529
static DEAL_II_ALWAYS_INLINE auto speed_of_sound(const ValueView &value_view, const MaterialView &material_view)
Definition equation_of_state.hpp:585
static DEAL_II_ALWAYS_INLINE auto specific_internal_energy(const ValueView &value_view, const MaterialView &material_view)
Definition equation_of_state.hpp:651
static DEAL_II_ALWAYS_INLINE auto grad_temperature(const ValueView &value_view, const GradientView &gradient_view, const MaterialView &material_view)
Definition equation_of_state.hpp:556
static DEAL_II_ALWAYS_INLINE auto inner_energy_from_pressure(const ValueType &pressure, const ValueView &value_view, const MaterialView &material_view)
Definition equation_of_state.hpp:630
Definition equation_of_state.hpp:341
static DEAL_II_ALWAYS_INLINE auto specific_internal_energy(const ValueView &value_view, const MaterialView &material_view)
Definition equation_of_state.hpp:467
static DEAL_II_ALWAYS_INLINE auto inner_energy_from_pressure(const ValueType &pressure, const ValueView &, const MaterialView &material_view)
Definition equation_of_state.hpp:448
static DEAL_II_ALWAYS_INLINE auto temperature(const ValueView &value_view, const MaterialView &material_view)
Definition equation_of_state.hpp:425
static DEAL_II_ALWAYS_INLINE auto thermodynamic_pressure(const ValueView &value_view, const MaterialView &material_view)
Definition equation_of_state.hpp:353
static DEAL_II_ALWAYS_INLINE auto speed_of_sound(const ValueView &value_view, const MaterialView &material_view)
Definition equation_of_state.hpp:405
static DEAL_II_ALWAYS_INLINE void conservative_from_primitive(WritableConservativeValueView &conservative_value_view, const PrimitiveValueView &primitive_value_view, const MaterialView &material_view)
Definition equation_of_state.hpp:488
static DEAL_II_ALWAYS_INLINE auto grad_temperature(const ValueView &value_view, const GradientView &gradient_view, const MaterialView &material_view)
Definition equation_of_state.hpp:377
Definition equation_of_state.hpp:706
static DEAL_II_ALWAYS_INLINE auto thermodynamic_pressure(const ValueView &value_view, const MaterialView &material_view)
Definition equation_of_state.hpp:719
static DEAL_II_ALWAYS_INLINE auto speed_of_sound(const ValueView &value_view, const MaterialView &material_view)
Definition equation_of_state.hpp:767
static DEAL_II_ALWAYS_INLINE auto grad_temperature(const ValueView &value_view, const GradientView &gradient_view, const MaterialView &material_view)
Definition equation_of_state.hpp:742
static DEAL_II_ALWAYS_INLINE auto specific_internal_energy(const ValueView &value_view, const MaterialView &)
Definition equation_of_state.hpp:827
static DEAL_II_ALWAYS_INLINE void conservative_from_primitive(WritableConservativeValueView &conservative_value_view, const PrimitiveValueView &primitive_value_view, const MaterialView &material_view)
Definition equation_of_state.hpp:847
static DEAL_II_ALWAYS_INLINE auto inner_energy_from_pressure(const ValueType &, const ValueView &, const MaterialView &)
Definition equation_of_state.hpp:808
static DEAL_II_ALWAYS_INLINE auto temperature(const ValueView &value_view, const MaterialView &material_view)
Definition equation_of_state.hpp:787