1 #ifndef ABLATELIBRARY_TWOPHASE_HPP
2 #define ABLATELIBRARY_TWOPHASE_HPP
6 #include "eos/perfectGas.hpp"
7 #include "eos/stiffenedGas.hpp"
8 #include "parameters/parameters.hpp"
9 namespace ablate::eos {
12 inline const static std::string VF =
"volumeFraction";
15 const std::shared_ptr<eos::EOS> eos1;
16 const std::shared_ptr<eos::EOS> eos2;
18 std::vector<std::string> species;
19 std::vector<std::string> otherPropertiesList = {
"VF"};
29 PetscInt numberSpecies1;
30 std::vector<std::string> species1;
31 PetscInt numberSpecies2;
32 std::vector<std::string> species2;
34 Parameters parameters;
35 struct FunctionContext {
38 PetscInt densityVFOffset;
39 PetscInt volumeFractionOffset;
40 Parameters parameters;
49 Parameters parameters;
62 static PetscErrorCode DensityFunction(
const PetscReal conserved[], PetscReal* property,
void* ctx);
63 static PetscErrorCode InternalSensibleEnergyFunction(
const PetscReal conserved[], PetscReal* property,
void* ctx);
64 static PetscErrorCode SpeciesSensibleEnthalpyFunction(
const PetscReal conserved[], PetscReal* property,
void* ctx);
66 static PetscErrorCode DensityTemperatureFunction(
const PetscReal conserved[], PetscReal T, PetscReal* property,
void* ctx);
67 static PetscErrorCode InternalSensibleEnergyTemperatureFunction(
const PetscReal conserved[], PetscReal T, PetscReal* property,
void* ctx);
68 static PetscErrorCode SpeciesSensibleEnthalpyTemperatureFunction(
const PetscReal conserved[], PetscReal T, PetscReal* property,
void* ctx);
71 static PetscErrorCode PressureFunctionGasGas(
const PetscReal conserved[], PetscReal* property,
void* ctx);
72 static PetscErrorCode TemperatureFunctionGasGas(
const PetscReal conserved[], PetscReal* property,
void* ctx);
73 static PetscErrorCode SensibleEnthalpyFunctionGasGas(
const PetscReal conserved[], PetscReal* property,
void* ctx);
74 static PetscErrorCode SpecificHeatConstantVolumeFunctionGasGas(
const PetscReal conserved[], PetscReal* property,
void* ctx);
75 static PetscErrorCode SpecificHeatConstantPressureFunctionGasGas(
const PetscReal conserved[], PetscReal* property,
void* ctx);
76 static PetscErrorCode SpeedOfSoundFunctionGasGas(
const PetscReal conserved[], PetscReal* property,
void* ctx);
78 static PetscErrorCode PressureTemperatureFunctionGasGas(
const PetscReal conserved[], PetscReal T, PetscReal* property,
void* ctx);
79 static PetscErrorCode TemperatureTemperatureFunctionGasGas(
const PetscReal conserved[], PetscReal T, PetscReal* property,
void* ctx);
80 static PetscErrorCode SensibleEnthalpyTemperatureFunctionGasGas(
const PetscReal conserved[], PetscReal T, PetscReal* property,
void* ctx);
81 static PetscErrorCode SpecificHeatConstantVolumeTemperatureFunctionGasGas(
const PetscReal conserved[], PetscReal T, PetscReal* property,
void* ctx);
82 static PetscErrorCode SpecificHeatConstantPressureTemperatureFunctionGasGas(
const PetscReal conserved[], PetscReal T, PetscReal* property,
void* ctx);
83 static PetscErrorCode SpeedOfSoundTemperatureFunctionGasGas(
const PetscReal conserved[], PetscReal T, PetscReal* property,
void* ctx);
86 static PetscErrorCode PressureFunctionGasLiquid(
const PetscReal conserved[], PetscReal* property,
void* ctx);
87 static PetscErrorCode TemperatureFunctionGasLiquid(
const PetscReal conserved[], PetscReal* property,
void* ctx);
88 static PetscErrorCode SensibleEnthalpyFunctionGasLiquid(
const PetscReal conserved[], PetscReal* property,
void* ctx);
89 static PetscErrorCode SpecificHeatConstantVolumeFunctionGasLiquid(
const PetscReal conserved[], PetscReal* property,
void* ctx);
90 static PetscErrorCode SpecificHeatConstantPressureFunctionGasLiquid(
const PetscReal conserved[], PetscReal* property,
void* ctx);
91 static PetscErrorCode SpeedOfSoundFunctionGasLiquid(
const PetscReal conserved[], PetscReal* property,
void* ctx);
93 static PetscErrorCode PressureTemperatureFunctionGasLiquid(
const PetscReal conserved[], PetscReal T, PetscReal* property,
void* ctx);
94 static PetscErrorCode TemperatureTemperatureFunctionGasLiquid(
const PetscReal conserved[], PetscReal T, PetscReal* property,
void* ctx);
95 static PetscErrorCode SensibleEnthalpyTemperatureFunctionGasLiquid(
const PetscReal conserved[], PetscReal T, PetscReal* property,
void* ctx);
96 static PetscErrorCode SpecificHeatConstantVolumeTemperatureFunctionGasLiquid(
const PetscReal conserved[], PetscReal T, PetscReal* property,
void* ctx);
97 static PetscErrorCode SpecificHeatConstantPressureTemperatureFunctionGasLiquid(
const PetscReal conserved[], PetscReal T, PetscReal* property,
void* ctx);
98 static PetscErrorCode SpeedOfSoundTemperatureFunctionGasLiquid(
const PetscReal conserved[], PetscReal T, PetscReal* property,
void* ctx);
101 static PetscErrorCode PressureFunctionLiquidLiquid(
const PetscReal conserved[], PetscReal* property,
void* ctx);
102 static PetscErrorCode TemperatureFunctionLiquidLiquid(
const PetscReal conserved[], PetscReal* property,
void* ctx);
103 static PetscErrorCode SensibleEnthalpyFunctionLiquidLiquid(
const PetscReal conserved[], PetscReal* property,
void* ctx);
104 static PetscErrorCode SpecificHeatConstantVolumeFunctionLiquidLiquid(
const PetscReal conserved[], PetscReal* property,
void* ctx);
105 static PetscErrorCode SpecificHeatConstantPressureFunctionLiquidLiquid(
const PetscReal conserved[], PetscReal* property,
void* ctx);
106 static PetscErrorCode SpeedOfSoundFunctionLiquidLiquid(
const PetscReal conserved[], PetscReal* property,
void* ctx);
108 static PetscErrorCode PressureTemperatureFunctionLiquidLiquid(
const PetscReal conserved[], PetscReal T, PetscReal* property,
void* ctx);
109 static PetscErrorCode TemperatureTemperatureFunctionLiquidLiquid(
const PetscReal conserved[], PetscReal T, PetscReal* property,
void* ctx);
110 static PetscErrorCode SensibleEnthalpyTemperatureFunctionLiquidLiquid(
const PetscReal conserved[], PetscReal T, PetscReal* property,
void* ctx);
111 static PetscErrorCode SpecificHeatConstantVolumeTemperatureFunctionLiquidLiquid(
const PetscReal conserved[], PetscReal T, PetscReal* property,
void* ctx);
112 static PetscErrorCode SpecificHeatConstantPressureTemperatureFunctionLiquidLiquid(
const PetscReal conserved[], PetscReal T, PetscReal* property,
void* ctx);
113 static PetscErrorCode SpeedOfSoundTemperatureFunctionLiquidLiquid(
const PetscReal conserved[], PetscReal T, PetscReal* property,
void* ctx);
115 using ThermodynamicStaticFunction = PetscErrorCode (*)(
const PetscReal conserved[], PetscReal* property,
void* ctx);
116 using ThermodynamicTemperatureStaticFunction = PetscErrorCode (*)(
const PetscReal conserved[], PetscReal temperature, PetscReal* property,
void* ctx);
118 std::map<ThermodynamicProperty, std::pair<ThermodynamicStaticFunction, ThermodynamicTemperatureStaticFunction>> thermodynamicFunctionsGasGas = {
119 {ThermodynamicProperty::Density, {DensityFunction, DensityTemperatureFunction}},
120 {ThermodynamicProperty::Pressure, {PressureFunctionGasGas, PressureTemperatureFunctionGasGas}},
121 {ThermodynamicProperty::Temperature, {TemperatureFunctionGasGas, TemperatureTemperatureFunctionGasGas}},
122 {ThermodynamicProperty::InternalSensibleEnergy, {InternalSensibleEnergyFunction, InternalSensibleEnergyTemperatureFunction}},
123 {ThermodynamicProperty::SensibleEnthalpy, {SensibleEnthalpyFunctionGasGas, SensibleEnthalpyTemperatureFunctionGasGas}},
124 {ThermodynamicProperty::SpecificHeatConstantVolume, {SpecificHeatConstantVolumeFunctionGasGas, SpecificHeatConstantVolumeTemperatureFunctionGasGas}},
125 {ThermodynamicProperty::SpecificHeatConstantPressure, {SpecificHeatConstantPressureFunctionGasGas, SpecificHeatConstantPressureTemperatureFunctionGasGas}},
126 {ThermodynamicProperty::SpeedOfSound, {SpeedOfSoundFunctionGasGas, SpeedOfSoundTemperatureFunctionGasGas}},
127 {ThermodynamicProperty::SpeciesSensibleEnthalpy, {SpeciesSensibleEnthalpyFunction, SpeciesSensibleEnthalpyTemperatureFunction}}};
129 std::map<ThermodynamicProperty, std::pair<ThermodynamicStaticFunction, ThermodynamicTemperatureStaticFunction>> thermodynamicFunctionsGasLiquid = {
130 {ThermodynamicProperty::Density, {DensityFunction, DensityTemperatureFunction}},
131 {ThermodynamicProperty::Pressure, {PressureFunctionGasLiquid, PressureTemperatureFunctionGasLiquid}},
132 {ThermodynamicProperty::Temperature, {TemperatureFunctionGasLiquid, TemperatureTemperatureFunctionGasLiquid}},
133 {ThermodynamicProperty::InternalSensibleEnergy, {InternalSensibleEnergyFunction, InternalSensibleEnergyTemperatureFunction}},
134 {ThermodynamicProperty::SensibleEnthalpy, {SensibleEnthalpyFunctionGasLiquid, SensibleEnthalpyTemperatureFunctionGasLiquid}},
135 {ThermodynamicProperty::SpecificHeatConstantVolume, {SpecificHeatConstantVolumeFunctionGasLiquid, SpecificHeatConstantVolumeTemperatureFunctionGasLiquid}},
136 {ThermodynamicProperty::SpecificHeatConstantPressure, {SpecificHeatConstantPressureFunctionGasLiquid, SpecificHeatConstantPressureTemperatureFunctionGasLiquid}},
137 {ThermodynamicProperty::SpeedOfSound, {SpeedOfSoundFunctionGasLiquid, SpeedOfSoundTemperatureFunctionGasLiquid}},
138 {ThermodynamicProperty::SpeciesSensibleEnthalpy, {SpeciesSensibleEnthalpyFunction, SpeciesSensibleEnthalpyTemperatureFunction}}};
140 std::map<ThermodynamicProperty, std::pair<ThermodynamicStaticFunction, ThermodynamicTemperatureStaticFunction>> thermodynamicFunctionsLiquidLiquid = {
141 {ThermodynamicProperty::Density, {DensityFunction, DensityTemperatureFunction}},
142 {ThermodynamicProperty::Pressure, {PressureFunctionLiquidLiquid, PressureTemperatureFunctionLiquidLiquid}},
143 {ThermodynamicProperty::Temperature, {TemperatureFunctionLiquidLiquid, TemperatureTemperatureFunctionLiquidLiquid}},
144 {ThermodynamicProperty::InternalSensibleEnergy, {InternalSensibleEnergyFunction, InternalSensibleEnergyTemperatureFunction}},
145 {ThermodynamicProperty::SensibleEnthalpy, {SensibleEnthalpyFunctionLiquidLiquid, SensibleEnthalpyTemperatureFunctionLiquidLiquid}},
146 {ThermodynamicProperty::SpecificHeatConstantVolume, {SpecificHeatConstantVolumeFunctionLiquidLiquid, SpecificHeatConstantVolumeTemperatureFunctionLiquidLiquid}},
147 {ThermodynamicProperty::SpecificHeatConstantPressure, {SpecificHeatConstantPressureFunctionLiquidLiquid, SpecificHeatConstantPressureTemperatureFunctionLiquidLiquid}},
148 {ThermodynamicProperty::SpeedOfSound, {SpeedOfSoundFunctionLiquidLiquid, SpeedOfSoundTemperatureFunctionLiquidLiquid}},
149 {ThermodynamicProperty::SpeciesSensibleEnthalpy, {SpeciesSensibleEnthalpyFunction, SpeciesSensibleEnthalpyTemperatureFunction}}};
154 const std::set<ThermodynamicProperty> speciesSizedProperties = {ThermodynamicProperty::SpeciesSensibleEnthalpy};
157 explicit TwoPhase(std::shared_ptr<eos::EOS> eos1, std::shared_ptr<eos::EOS> eos2);
158 void View(std::ostream& stream)
const override;
160 const std::shared_ptr<ablate::eos::EOS> GetEOSGas()
const {
return eos1; }
161 const std::shared_ptr<ablate::eos::EOS> GetEOSLiquid()
const {
return eos2; }
163 ThermodynamicFunction
GetThermodynamicFunction(ThermodynamicProperty property,
const std::vector<domain::Field>& fields)
const override;
167 EOSFunction
GetFieldFunctionFunction(
const std::string& field, ThermodynamicProperty property1, ThermodynamicProperty property2, std::vector<std::string> otherProperties)
const override;
171 [[nodiscard]]
virtual const std::vector<std::string>&
GetProgressVariables()
const override {
return ablate::utilities::VectorUtilities::Empty<std::string>; }
Definition: twoPhase.hpp:10
const std::vector< std::string > & GetFieldFunctionProperties() const override
Definition: twoPhase.hpp:168
void View(std::ostream &stream) const override
Definition: twoPhase.cpp:212
ThermodynamicFunction GetThermodynamicFunction(ThermodynamicProperty property, const std::vector< domain::Field > &fields) const override
Definition: twoPhase.cpp:220
const std::vector< std::string > & GetSpeciesVariables() const override
Definition: twoPhase.hpp:170
ThermodynamicTemperatureFunction GetThermodynamicTemperatureFunction(ThermodynamicProperty property, const std::vector< domain::Field > &fields) const override
Definition: twoPhase.cpp:268
EOSFunction GetFieldFunctionFunction(const std::string &field, ThermodynamicProperty property1, ThermodynamicProperty property2, std::vector< std::string > otherProperties) const override
Definition: twoPhase.cpp:308
virtual const std::vector< std::string > & GetProgressVariables() const override
Definition: twoPhase.hpp:171
Definition: twoPhase.hpp:44
Definition: twoPhase.hpp:51