ABLATE Source Documentation  0.12.34
stiffenedGas.hpp
1 #ifndef ABLATELIBRARY_STIFFENEDGAS_HPP
2 #define ABLATELIBRARY_STIFFENEDGAS_HPP
3 
4 #include <memory>
5 #include "eos.hpp"
6 #include "parameters/parameters.hpp"
7 #include "utilities/vectorUtilities.hpp"
8 
9 namespace ablate::eos {
10 
11 class StiffenedGas : public EOS {
12  private:
13  // constant to be replaced with the number of species for thermodynamic properties
14  constexpr static inline int SPECIES_SIZE = -1;
15 
16  // the stiffened gas does not allow species
17  const std::vector<std::string> species;
18  struct Parameters {
19  PetscReal gamma;
20  PetscReal Cp;
21  PetscReal p0;
22  PetscInt numberSpecies;
23  };
24  Parameters parameters;
25 
26  struct FunctionContext {
27  PetscInt dim;
28  PetscInt eulerOffset;
29  Parameters parameters;
30  };
31 
40  static PetscErrorCode DensityFunction(const PetscReal conserved[], PetscReal* property, void* ctx);
41  static PetscErrorCode PressureFunction(const PetscReal conserved[], PetscReal* property, void* ctx);
42  static PetscErrorCode TemperatureFunction(const PetscReal conserved[], PetscReal* property, void* ctx);
43  static PetscErrorCode InternalSensibleEnergyFunction(const PetscReal conserved[], PetscReal* property, void* ctx);
44  static PetscErrorCode SensibleEnthalpyFunction(const PetscReal conserved[], PetscReal* property, void* ctx);
45  static PetscErrorCode SpecificHeatConstantVolumeFunction(const PetscReal conserved[], PetscReal* property, void* ctx);
46  static PetscErrorCode SpecificHeatConstantPressureFunction(const PetscReal conserved[], PetscReal* property, void* ctx);
47  static PetscErrorCode SpeedOfSoundFunction(const PetscReal conserved[], PetscReal* property, void* ctx);
48  static PetscErrorCode SpeciesSensibleEnthalpyFunction(const PetscReal conserved[], PetscReal* property, void* ctx);
60  static PetscErrorCode DensityTemperatureFunction(const PetscReal conserved[], PetscReal T, PetscReal* property, void* ctx);
61  static PetscErrorCode PressureTemperatureFunction(const PetscReal conserved[], PetscReal T, PetscReal* property, void* ctx);
62  static PetscErrorCode TemperatureTemperatureFunction(const PetscReal conserved[], PetscReal T, PetscReal* property, void* ctx);
63  static PetscErrorCode InternalSensibleEnergyTemperatureFunction(const PetscReal conserved[], PetscReal T, PetscReal* property, void* ctx);
64  static PetscErrorCode SensibleEnthalpyTemperatureFunction(const PetscReal conserved[], PetscReal T, PetscReal* property, void* ctx);
65  static PetscErrorCode SpecificHeatConstantVolumeTemperatureFunction(const PetscReal conserved[], PetscReal T, PetscReal* property, void* ctx);
66  static PetscErrorCode SpecificHeatConstantPressureTemperatureFunction(const PetscReal conserved[], PetscReal T, PetscReal* property, void* ctx);
67  static PetscErrorCode SpeedOfSoundTemperatureFunction(const PetscReal conserved[], PetscReal T, PetscReal* property, void* ctx);
68  static PetscErrorCode SpeciesSensibleEnthalpyTemperatureFunction(const PetscReal conserved[], PetscReal T, PetscReal* property, void* ctx);
74  using ThermodynamicStaticFunction = PetscErrorCode (*)(const PetscReal conserved[], PetscReal* property, void* ctx);
75  using ThermodynamicTemperatureStaticFunction = PetscErrorCode (*)(const PetscReal conserved[], PetscReal temperature, PetscReal* property, void* ctx);
76  std::map<ThermodynamicProperty, std::tuple<ThermodynamicStaticFunction, ThermodynamicTemperatureStaticFunction, int>> thermodynamicFunctions = {
77  {ThermodynamicProperty::Density, {DensityFunction, DensityTemperatureFunction, 1}},
78  {ThermodynamicProperty::Pressure, {PressureFunction, PressureTemperatureFunction, 1}},
79  {ThermodynamicProperty::Temperature, {TemperatureFunction, TemperatureTemperatureFunction, 1}},
80  {ThermodynamicProperty::InternalSensibleEnergy, {InternalSensibleEnergyFunction, InternalSensibleEnergyTemperatureFunction, 1}},
81  {ThermodynamicProperty::SensibleEnthalpy, {SensibleEnthalpyFunction, SensibleEnthalpyTemperatureFunction, 1}},
82  {ThermodynamicProperty::SpecificHeatConstantVolume, {SpecificHeatConstantVolumeFunction, SpecificHeatConstantVolumeTemperatureFunction, 1}},
83  {ThermodynamicProperty::SpecificHeatConstantPressure, {SpecificHeatConstantPressureFunction, SpecificHeatConstantPressureTemperatureFunction, 1}},
84  {ThermodynamicProperty::SpeedOfSound, {SpeedOfSoundFunction, SpeedOfSoundTemperatureFunction, 1}},
85  {ThermodynamicProperty::SpeciesSensibleEnthalpy, {SpeciesSensibleEnthalpyFunction, SpeciesSensibleEnthalpyTemperatureFunction, SPECIES_SIZE}}};
86 
87  public:
88  explicit StiffenedGas(std::shared_ptr<ablate::parameters::Parameters>, std::vector<std::string> species = {});
89  void View(std::ostream& stream) const override;
90 
95  PetscReal GetSpecificHeatRatio() const { return parameters.gamma; }
96 
101  PetscReal GetSpecificHeatCp() const { return parameters.Cp; }
102 
107  PetscReal GetReferencePressure() const { return parameters.p0; }
108 
115  ThermodynamicFunction GetThermodynamicFunction(ThermodynamicProperty property, const std::vector<domain::Field>& fields) const override;
116 
123  ThermodynamicTemperatureFunction GetThermodynamicTemperatureFunction(ThermodynamicProperty property, const std::vector<domain::Field>& fields) const override;
124 
131  EOSFunction GetFieldFunctionFunction(const std::string& field, ThermodynamicProperty property1, ThermodynamicProperty property2, std::vector<std::string> otherProperties) const override;
132 
137  const std::vector<std::string>& GetSpeciesVariables() const override { return species; }
138 
143  [[nodiscard]] virtual const std::vector<std::string>& GetProgressVariables() const override { return ablate::utilities::VectorUtilities::Empty<std::string>; }
144 };
145 
146 } // namespace ablate::eos
147 
148 #endif // ABLATELIBRARY_STIFFENEDGAS_HPP
Definition: eos.hpp:60
Definition: stiffenedGas.hpp:11
PetscReal GetSpecificHeatRatio() const
Definition: stiffenedGas.hpp:95
EOSFunction GetFieldFunctionFunction(const std::string &field, ThermodynamicProperty property1, ThermodynamicProperty property2, std::vector< std::string > otherProperties) const override
Definition: stiffenedGas.cpp:51
const std::vector< std::string > & GetSpeciesVariables() const override
Definition: stiffenedGas.hpp:137
ThermodynamicTemperatureFunction GetThermodynamicTemperatureFunction(ThermodynamicProperty property, const std::vector< domain::Field > &fields) const override
Definition: stiffenedGas.cpp:37
PetscReal GetSpecificHeatCp() const
Definition: stiffenedGas.hpp:101
PetscReal GetReferencePressure() const
Definition: stiffenedGas.hpp:107
ThermodynamicFunction GetThermodynamicFunction(ThermodynamicProperty property, const std::vector< domain::Field > &fields) const override
Definition: stiffenedGas.cpp:25
void View(std::ostream &stream) const override
Definition: stiffenedGas.cpp:12
virtual const std::vector< std::string > & GetProgressVariables() const override
Definition: stiffenedGas.hpp:143