1 #ifndef ABLATELIBRARY_TWOPHASEEULERADVECTION_HPP
2 #define ABLATELIBRARY_TWOPHASEEULERADVECTION_HPP
5 #include "eos/perfectGas.hpp"
6 #include "eos/stiffenedGas.hpp"
7 #include "eos/twoPhase.hpp"
8 #include "finiteVolume/compressibleFlowFields.hpp"
9 #include "finiteVolume/fluxCalculator/fluxCalculator.hpp"
10 #include "process.hpp"
12 namespace ablate::finiteVolume::processes {
16 inline const static std::string VOLUME_FRACTION_FIELD = eos::TwoPhase::VF;
26 struct DecodeDataStructGas {
37 struct DecodeDataStructStiff {
49 static PetscErrorCode FormFunctionGas(SNES snes, Vec x, Vec F,
void *ctx);
50 static PetscErrorCode FormJacobianGas(SNES snes, Vec x, Mat J, Mat P,
void *ctx);
51 static PetscErrorCode FormFunctionStiff(SNES snes, Vec x, Vec F,
void *ctx);
52 static PetscErrorCode FormJacobianStiff(SNES snes, Vec x, Mat J, Mat P,
void *ctx);
58 class TwoPhaseDecoder {
60 virtual void DecodeTwoPhaseEulerState(PetscInt dim,
const PetscInt *uOff,
const PetscReal *conservedValues,
const PetscReal *normal, PetscReal *density, PetscReal *densityG,
61 PetscReal *densityL, PetscReal *normalVelocity, PetscReal *velocity, PetscReal *internalEnergy, PetscReal *internalEnergyG, PetscReal *internalEnergyL,
62 PetscReal *aG, PetscReal *aL, PetscReal *MG, PetscReal *ML, PetscReal *p, PetscReal *T, PetscReal *alpha) = 0;
63 virtual ~TwoPhaseDecoder() =
default;
69 class PerfectGasPerfectGasDecoder :
public TwoPhaseDecoder {
70 const std::shared_ptr<eos::PerfectGas> eosGas;
71 const std::shared_ptr<eos::PerfectGas> eosLiquid;
76 std::vector<PetscReal> gasEulerFieldScratch;
77 std::vector<PetscReal> liquidEulerFieldScratch;
93 PerfectGasPerfectGasDecoder(PetscInt dim,
const std::shared_ptr<eos::PerfectGas> &perfectGasEos1,
const std::shared_ptr<eos::PerfectGas> &perfectGasEos2);
94 void DecodeTwoPhaseEulerState(PetscInt dim,
const PetscInt *uOff,
const PetscReal *conservedValues,
const PetscReal *normal, PetscReal *density, PetscReal *densityG, PetscReal *densityL,
95 PetscReal *normalVelocity, PetscReal *velocity, PetscReal *internalEnergy, PetscReal *internalEnergyG, PetscReal *internalEnergyL, PetscReal *aG, PetscReal *aL,
96 PetscReal *MG, PetscReal *ML, PetscReal *p, PetscReal *T, PetscReal *alpha)
override;
102 class PerfectGasStiffenedGasDecoder :
public TwoPhaseDecoder {
103 const std::shared_ptr<eos::PerfectGas> eosGas;
104 const std::shared_ptr<eos::StiffenedGas> eosLiquid;
109 std::vector<PetscReal> gasEulerFieldScratch;
110 std::vector<PetscReal> liquidEulerFieldScratch;
115 eos::ThermodynamicFunction gasComputeTemperature;
116 eos::ThermodynamicTemperatureFunction gasComputeInternalEnergy;
117 eos::ThermodynamicTemperatureFunction gasComputeSpeedOfSound;
118 eos::ThermodynamicTemperatureFunction gasComputePressure;
120 eos::ThermodynamicFunction liquidComputeTemperature;
121 eos::ThermodynamicTemperatureFunction liquidComputeInternalEnergy;
122 eos::ThermodynamicTemperatureFunction liquidComputeSpeedOfSound;
123 eos::ThermodynamicTemperatureFunction liquidComputePressure;
126 PerfectGasStiffenedGasDecoder(PetscInt dim,
const std::shared_ptr<eos::PerfectGas> &perfectGasEos1,
const std::shared_ptr<eos::StiffenedGas> &perfectGasEos2);
128 void DecodeTwoPhaseEulerState(PetscInt dim,
const PetscInt *uOff,
const PetscReal *conservedValues,
const PetscReal *normal, PetscReal *density, PetscReal *densityG, PetscReal *densityL,
129 PetscReal *normalVelocity, PetscReal *velocity, PetscReal *internalEnergy, PetscReal *internalEnergyG, PetscReal *internalEnergyL, PetscReal *aG, PetscReal *aL,
130 PetscReal *MG, PetscReal *ML, PetscReal *p, PetscReal *T, PetscReal *alpha)
override;
136 class StiffenedGasStiffenedGasDecoder :
public TwoPhaseDecoder {
137 const std::shared_ptr<eos::StiffenedGas> eosGas;
138 const std::shared_ptr<eos::StiffenedGas> eosLiquid;
143 std::vector<PetscReal> gasEulerFieldScratch;
144 std::vector<PetscReal> liquidEulerFieldScratch;
149 eos::ThermodynamicFunction gasComputeTemperature;
150 eos::ThermodynamicTemperatureFunction gasComputeInternalEnergy;
151 eos::ThermodynamicTemperatureFunction gasComputeSpeedOfSound;
152 eos::ThermodynamicTemperatureFunction gasComputePressure;
154 eos::ThermodynamicFunction liquidComputeTemperature;
155 eos::ThermodynamicTemperatureFunction liquidComputeInternalEnergy;
156 eos::ThermodynamicTemperatureFunction liquidComputeSpeedOfSound;
157 eos::ThermodynamicTemperatureFunction liquidComputePressure;
160 StiffenedGasStiffenedGasDecoder(PetscInt dim,
const std::shared_ptr<eos::StiffenedGas> &perfectGasEos1,
const std::shared_ptr<eos::StiffenedGas> &perfectGasEos2);
162 void DecodeTwoPhaseEulerState(PetscInt dim,
const PetscInt *uOff,
const PetscReal *conservedValues,
const PetscReal *normal, PetscReal *density, PetscReal *densityG, PetscReal *densityL,
163 PetscReal *normalVelocity, PetscReal *velocity, PetscReal *internalEnergy, PetscReal *internalEnergyG, PetscReal *internalEnergyL, PetscReal *aG, PetscReal *aL,
164 PetscReal *MG, PetscReal *ML, PetscReal *p, PetscReal *T, PetscReal *alpha)
override;
167 const std::shared_ptr<eos::EOS> eosTwoPhase;
168 std::shared_ptr<eos::EOS> eosGas;
169 std::shared_ptr<eos::EOS> eosLiquid;
170 const std::shared_ptr<fluxCalculator::FluxCalculator> fluxCalculatorGasGas;
171 const std::shared_ptr<fluxCalculator::FluxCalculator> fluxCalculatorGasLiquid;
172 const std::shared_ptr<fluxCalculator::FluxCalculator> fluxCalculatorLiquidGas;
173 const std::shared_ptr<fluxCalculator::FluxCalculator> fluxCalculatorLiquidLiquid;
178 std::shared_ptr<TwoPhaseDecoder> decoder;
181 static PetscErrorCode UpdateAuxTemperatureField2Gas(PetscReal time, PetscInt dim,
const PetscFVCellGeom *cellGeom,
const PetscInt uOff[],
const PetscScalar *conservedValues,
const PetscInt aOff[],
182 PetscScalar *auxField,
void *ctx);
184 static PetscErrorCode UpdateAuxPressureField2Gas(PetscReal time, PetscInt dim,
const PetscFVCellGeom *cellGeom,
const PetscInt uOff[],
const PetscScalar *conservedValues,
const PetscInt aOff[],
185 PetscScalar *auxField,
void *ctx);
187 static PetscErrorCode UpdateAuxVelocityField2Gas(PetscReal time, PetscInt dim,
const PetscFVCellGeom *cellGeom,
const PetscInt uOff[],
const PetscScalar *conservedValues,
const PetscInt aOff[],
188 PetscScalar *auxField,
void *ctx);
190 TwoPhaseEulerAdvection(std::shared_ptr<eos::EOS> eosTwoPhase,
const std::shared_ptr<parameters::Parameters> ¶meters, std::shared_ptr<fluxCalculator::FluxCalculator> fluxCalculatorGasGas,
191 std::shared_ptr<fluxCalculator::FluxCalculator> fluxCalculatorGasLiquid, std::shared_ptr<fluxCalculator::FluxCalculator> fluxCalculatorLiquidGas,
192 std::shared_ptr<fluxCalculator::FluxCalculator> fluxCalculatorLiquidLiquid);
199 static PetscErrorCode CompressibleFlowComputeEulerFlux(PetscInt dim,
const PetscFVFaceGeom *fg,
const PetscInt uOff[],
const PetscScalar fieldL[],
const PetscScalar fieldR[],
200 const PetscInt aOff[],
const PetscScalar auxL[],
const PetscScalar auxR[], PetscScalar *flux,
void *ctx);
201 static PetscErrorCode CompressibleFlowComputeVFFlux(PetscInt dim,
const PetscFVFaceGeom *fg,
const PetscInt uOff[],
const PetscScalar fieldL[],
const PetscScalar fieldR[],
const PetscInt aOff[],
202 const PetscScalar auxL[],
const PetscScalar auxR[], PetscScalar *flux,
void *ctx);
212 static std::shared_ptr<TwoPhaseDecoder>
CreateTwoPhaseDecoder(PetscInt dim,
const std::shared_ptr<eos::EOS> &eosGas,
const std::shared_ptr<eos::EOS> &eosLiquid);
static const std::string CONSERVED
The conserved prefix used for fields that have a conserved and non conserved form.
Definition: compressibleFlowFields.hpp:22
Definition: finiteVolumeSolver.hpp:28
Definition: process.hpp:7
Definition: twoPhaseEulerAdvection.hpp:14
void Setup(ablate::finiteVolume::FiniteVolumeSolver &flow) override
Definition: twoPhaseEulerAdvection.cpp:226
static std::shared_ptr< TwoPhaseDecoder > CreateTwoPhaseDecoder(PetscInt dim, const std::shared_ptr< eos::EOS > &eosGas, const std::shared_ptr< eos::EOS > &eosLiquid)
Definition: twoPhaseEulerAdvection.cpp:800
Definition: solver.hpp:17
Definition: twoPhaseEulerAdvection.hpp:19