mirror of
https://github.com/OpenFOAM/OpenFOAM-6.git
synced 2025-12-08 06:57:46 +00:00
reactingEulerFoam/phaseSystem: Create an ordered container for phaseModels
The previous method using a HashTable required a separate ordered list of names which is hard to work with and maintain.
This commit is contained in:
@ -254,14 +254,14 @@ public:
|
||||
virtual volScalarField& he()
|
||||
{
|
||||
notImplemented("multiphaseMixtureThermo::he()");
|
||||
return phases_[0]->thermo().he();
|
||||
return phases_[0].thermo().he();
|
||||
}
|
||||
|
||||
//- Enthalpy/Internal energy [J/kg]
|
||||
virtual const volScalarField& he() const
|
||||
{
|
||||
notImplemented("multiphaseMixtureThermo::he() const");
|
||||
return phases_[0]->thermo().he();
|
||||
return phases_[0].thermo().he();
|
||||
}
|
||||
|
||||
//- Enthalpy/Internal energy
|
||||
|
||||
@ -50,7 +50,7 @@ Foam::ThermoPhaseModel<BasePhaseModel, ThermoType>::ThermoPhaseModel
|
||||
{
|
||||
thermoPtr_.set
|
||||
(
|
||||
ThermoType::New(fluid.mesh(), phaseName).ptr()
|
||||
ThermoType::New(fluid.mesh(), this->name()).ptr()
|
||||
);
|
||||
|
||||
thermo_ = thermoPtr_.ptr();
|
||||
|
||||
@ -72,6 +72,13 @@ Foam::phaseModel::phaseModel
|
||||
}
|
||||
|
||||
|
||||
Foam::autoPtr<Foam::phaseModel> Foam::phaseModel::clone() const
|
||||
{
|
||||
notImplemented("phaseModel::clone() const");
|
||||
return autoPtr<phaseModel>(NULL);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::phaseModel::~phaseModel()
|
||||
@ -86,6 +93,12 @@ const Foam::word& Foam::phaseModel::name() const
|
||||
}
|
||||
|
||||
|
||||
const Foam::word& Foam::phaseModel::keyword() const
|
||||
{
|
||||
return name_;
|
||||
}
|
||||
|
||||
|
||||
const Foam::phaseSystem& Foam::phaseModel::fluid() const
|
||||
{
|
||||
return fluid_;
|
||||
|
||||
@ -107,9 +107,8 @@ public:
|
||||
const word& phaseName
|
||||
);
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~phaseModel();
|
||||
//- Return clone
|
||||
autoPtr<phaseModel> clone() const;
|
||||
|
||||
|
||||
// Selectors
|
||||
@ -120,12 +119,43 @@ public:
|
||||
const word& phaseName
|
||||
);
|
||||
|
||||
//- Return a pointer to a new phase created on freestore
|
||||
// from Istream
|
||||
class iNew
|
||||
{
|
||||
const phaseSystem& fluid_;
|
||||
|
||||
public:
|
||||
|
||||
iNew
|
||||
(
|
||||
const phaseSystem& fluid
|
||||
)
|
||||
:
|
||||
fluid_(fluid)
|
||||
{}
|
||||
|
||||
autoPtr<phaseModel> operator()(Istream& is) const
|
||||
{
|
||||
return autoPtr<phaseModel>
|
||||
(
|
||||
phaseModel::New(fluid_, word(is))
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~phaseModel();
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Return the name of this phase
|
||||
const word& name() const;
|
||||
|
||||
const word& keyword() const;
|
||||
|
||||
//- Return the system to which this phase belongs
|
||||
const phaseSystem& fluid() const;
|
||||
|
||||
|
||||
@ -41,31 +41,7 @@ const Foam::word Foam::phaseSystem::propertiesName("phaseProperties");
|
||||
|
||||
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
|
||||
|
||||
Foam::phaseSystem::phaseModelTable
|
||||
Foam::phaseSystem::generatePhaseModels(const wordList& phaseNames) const
|
||||
{
|
||||
phaseModelTable phaseModels;
|
||||
|
||||
forAllConstIter(wordList, phaseNames, phaseNameIter)
|
||||
{
|
||||
phaseModels.insert
|
||||
(
|
||||
*phaseNameIter,
|
||||
phaseModel::New
|
||||
(
|
||||
*this,
|
||||
*phaseNameIter
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
// normalise ?
|
||||
|
||||
return phaseModels;
|
||||
}
|
||||
|
||||
|
||||
Foam::tmp<Foam::surfaceScalarField> Foam::phaseSystem::generatePhi
|
||||
Foam::tmp<Foam::surfaceScalarField> Foam::phaseSystem::calcPhi
|
||||
(
|
||||
const phaseModelTable& phaseModels
|
||||
) const
|
||||
@ -77,7 +53,7 @@ Foam::tmp<Foam::surfaceScalarField> Foam::phaseSystem::generatePhi
|
||||
new surfaceScalarField
|
||||
(
|
||||
"phi",
|
||||
fvc::interpolate(phaseModelIter()())*phaseModelIter()->phi()
|
||||
fvc::interpolate(phaseModelIter())*phaseModelIter().phi()
|
||||
)
|
||||
);
|
||||
|
||||
@ -86,8 +62,8 @@ Foam::tmp<Foam::surfaceScalarField> Foam::phaseSystem::generatePhi
|
||||
for (; phaseModelIter != phaseModels.end(); ++ phaseModelIter)
|
||||
{
|
||||
tmpPhi() +=
|
||||
fvc::interpolate(phaseModelIter()())
|
||||
*phaseModelIter()->phi();
|
||||
fvc::interpolate(phaseModelIter())
|
||||
*phaseModelIter().phi();
|
||||
}
|
||||
|
||||
return tmpPhi;
|
||||
@ -167,11 +143,9 @@ Foam::phaseSystem::phaseSystem
|
||||
|
||||
mesh_(mesh),
|
||||
|
||||
phaseNames_(lookup("phases")),
|
||||
phaseModels_(lookup("phases"), phaseModel::iNew(*this)),
|
||||
|
||||
phaseModels_(generatePhaseModels(phaseNames_)),
|
||||
|
||||
phi_(generatePhi(phaseModels_)),
|
||||
phi_(calcPhi(phaseModels_)),
|
||||
|
||||
dpdt_
|
||||
(
|
||||
@ -197,7 +171,7 @@ Foam::phaseSystem::phaseSystem
|
||||
blendingMethod::New
|
||||
(
|
||||
iter().dict(),
|
||||
wordList(lookup("phases"))
|
||||
phaseModels_.toc()
|
||||
)
|
||||
);
|
||||
}
|
||||
@ -224,12 +198,12 @@ Foam::tmp<Foam::volScalarField> Foam::phaseSystem::rho() const
|
||||
|
||||
tmp<volScalarField> tmpRho
|
||||
(
|
||||
phaseModelIter()()*phaseModelIter()->rho()
|
||||
phaseModelIter()*phaseModelIter().rho()
|
||||
);
|
||||
|
||||
for (; phaseModelIter != phaseModels_.end(); ++ phaseModelIter)
|
||||
{
|
||||
tmpRho() += phaseModelIter()()*phaseModelIter()->rho();
|
||||
tmpRho() += phaseModelIter()*phaseModelIter().rho();
|
||||
}
|
||||
|
||||
return tmpRho;
|
||||
@ -242,12 +216,12 @@ Foam::tmp<Foam::volVectorField> Foam::phaseSystem::U() const
|
||||
|
||||
tmp<volVectorField> tmpU
|
||||
(
|
||||
phaseModelIter()()*phaseModelIter()->U()
|
||||
phaseModelIter()*phaseModelIter().U()
|
||||
);
|
||||
|
||||
for (; phaseModelIter != phaseModels_.end(); ++ phaseModelIter)
|
||||
{
|
||||
tmpU() += phaseModelIter()()*phaseModelIter()->U();
|
||||
tmpU() += phaseModelIter()*phaseModelIter().U();
|
||||
}
|
||||
|
||||
return tmpU;
|
||||
@ -292,7 +266,7 @@ void Foam::phaseSystem::correct()
|
||||
{
|
||||
forAllIter(phaseModelTable, phaseModels_, phaseModelIter)
|
||||
{
|
||||
phaseModelIter()->correct();
|
||||
phaseModelIter().correct();
|
||||
}
|
||||
}
|
||||
|
||||
@ -303,15 +277,17 @@ void Foam::phaseSystem::correctKinematics()
|
||||
|
||||
forAllIter(phaseModelTable, phaseModels_, phaseModelIter)
|
||||
{
|
||||
phaseModelIter()->correctKinematics();
|
||||
phaseModelIter().correctKinematics();
|
||||
|
||||
updateDpdt = updateDpdt || phaseModelIter()->thermo().dpdt();
|
||||
updateDpdt = updateDpdt || phaseModelIter().thermo().dpdt();
|
||||
}
|
||||
|
||||
//phaseModelTable::iterator iter = phaseModels_.begin();
|
||||
|
||||
// Update the pressure time-derivative if required
|
||||
if (updateDpdt)
|
||||
{
|
||||
dpdt_ = fvc::ddt(phaseModels_.begin()()().thermo().p());
|
||||
dpdt_ = fvc::ddt(phaseModels_.begin()()->thermo().p());
|
||||
}
|
||||
}
|
||||
|
||||
@ -320,7 +296,7 @@ void Foam::phaseSystem::correctThermo()
|
||||
{
|
||||
forAllIter(phaseModelTable, phaseModels_, phaseModelIter)
|
||||
{
|
||||
phaseModelIter()->correctThermo();
|
||||
phaseModelIter().correctThermo();
|
||||
}
|
||||
}
|
||||
|
||||
@ -329,7 +305,7 @@ void Foam::phaseSystem::correctTurbulence()
|
||||
{
|
||||
forAllIter(phaseModelTable, phaseModels_, phaseModelIter)
|
||||
{
|
||||
phaseModelIter()->correctTurbulence();
|
||||
phaseModelIter().correctTurbulence();
|
||||
}
|
||||
}
|
||||
|
||||
@ -338,7 +314,7 @@ void Foam::phaseSystem::correctEnergyTransport()
|
||||
{
|
||||
forAllIter(phaseModelTable, phaseModels_, phaseModelIter)
|
||||
{
|
||||
phaseModelIter()->correctEnergyTransport();
|
||||
phaseModelIter().correctEnergyTransport();
|
||||
}
|
||||
}
|
||||
|
||||
@ -351,7 +327,7 @@ bool Foam::phaseSystem::read()
|
||||
|
||||
forAllIter(phaseModelTable, phaseModels_, phaseModelIter)
|
||||
{
|
||||
readOK &= phaseModelIter()->read();
|
||||
readOK &= phaseModelIter().read();
|
||||
}
|
||||
|
||||
// models ...
|
||||
|
||||
@ -42,6 +42,7 @@ SourceFiles
|
||||
#include "phasePair.H"
|
||||
#include "orderedPhasePair.H"
|
||||
#include "HashPtrTable.H"
|
||||
#include "PtrDictionary.H"
|
||||
|
||||
#include "IOMRFZoneList.H"
|
||||
#include "fvIOoptionList.H"
|
||||
@ -117,15 +118,17 @@ public:
|
||||
>
|
||||
massTransferTable;
|
||||
|
||||
// typedef
|
||||
// HashTable<autoPtr<phaseModel>, word, word::hash>
|
||||
// phaseModelTable;
|
||||
|
||||
typedef PtrDictionary<phaseModel> phaseModelTable;
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
// Protected typedefs
|
||||
|
||||
typedef
|
||||
HashTable<autoPtr<phaseModel>, word, word::hash>
|
||||
phaseModelTable;
|
||||
|
||||
typedef
|
||||
HashTable<dictionary, phasePairKey, phasePairKey::hash>
|
||||
dictTable;
|
||||
@ -162,9 +165,6 @@ protected:
|
||||
//- Reference to the mesh
|
||||
const fvMesh& mesh_;
|
||||
|
||||
//- Phase names
|
||||
wordList phaseNames_;
|
||||
|
||||
//- Phase models
|
||||
phaseModelTable phaseModels_;
|
||||
|
||||
@ -198,16 +198,10 @@ protected:
|
||||
|
||||
// Protected member functions
|
||||
|
||||
//- Generate the phases
|
||||
HashTable<autoPtr<phaseModel> > generatePhaseModels
|
||||
//- Calculate and return the mixture flux
|
||||
tmp<surfaceScalarField> calcPhi
|
||||
(
|
||||
const wordList& names
|
||||
) const;
|
||||
|
||||
//- Generate the mixture flux
|
||||
tmp<surfaceScalarField> generatePhi
|
||||
(
|
||||
const HashTable<autoPtr<phaseModel> >& phaseModels
|
||||
const phaseModelTable& phaseModels
|
||||
) const;
|
||||
|
||||
//- Generate pairs
|
||||
@ -360,6 +354,12 @@ public:
|
||||
//- Constant access the mesh
|
||||
inline const fvMesh& mesh() const;
|
||||
|
||||
//- Constant access the phase models
|
||||
inline const phaseModelTable& phases() const;
|
||||
|
||||
//- Access the phase models
|
||||
inline phaseModelTable& phases();
|
||||
|
||||
//- Constant access the mixture flux
|
||||
inline const surfaceScalarField& phi() const;
|
||||
|
||||
|
||||
@ -31,6 +31,20 @@ inline const Foam::fvMesh& Foam::phaseSystem::mesh() const
|
||||
}
|
||||
|
||||
|
||||
inline const Foam::phaseSystem::phaseModelTable&
|
||||
Foam::phaseSystem::phases() const
|
||||
{
|
||||
return phaseModels_;
|
||||
}
|
||||
|
||||
|
||||
inline Foam::phaseSystem::phaseModelTable&
|
||||
Foam::phaseSystem::phases()
|
||||
{
|
||||
return phaseModels_;
|
||||
}
|
||||
|
||||
|
||||
inline const Foam::surfaceScalarField& Foam::phaseSystem::phi() const
|
||||
{
|
||||
return phi_;
|
||||
|
||||
@ -151,12 +151,12 @@ void Foam::phaseSystem::generatePairsAndSubModels
|
||||
HashTable<autoPtr<modelType>, phasePairKey, phasePairKey::hash>
|
||||
modelTypeTable;
|
||||
|
||||
forAllConstIter(wordList, phaseNames_, phaseNameIter)
|
||||
forAllConstIter(phaseModelTable, phaseModels_, phaseModelIter)
|
||||
{
|
||||
modelTypeTable tempModels;
|
||||
generatePairsAndSubModels
|
||||
(
|
||||
IOobject::groupName(modelName, *phaseNameIter),
|
||||
IOobject::groupName(modelName, phaseModelIter().name()),
|
||||
tempModels
|
||||
);
|
||||
|
||||
@ -175,7 +175,7 @@ void Foam::phaseSystem::generatePairsAndSubModels
|
||||
|
||||
models[tempModelIter.key()].insert
|
||||
(
|
||||
*phaseNameIter,
|
||||
phaseModelIter().name(),
|
||||
*tempModelIter
|
||||
);
|
||||
}
|
||||
|
||||
@ -72,7 +72,6 @@ setRefCell
|
||||
pRefValue
|
||||
);
|
||||
mesh.setFluxRequired(p_rgh.name());
|
||||
mesh.setFluxRequired(alpha1.name());
|
||||
|
||||
const IOMRFZoneList& MRF = fluid.MRF();
|
||||
fv::IOoptionList& fvOptions = fluid.fvOptions();
|
||||
|
||||
@ -57,10 +57,13 @@ Foam::twoPhaseSystem::twoPhaseSystem
|
||||
)
|
||||
:
|
||||
phaseSystem(mesh),
|
||||
phase1_(phaseModels_[phaseNames_[0]]()),
|
||||
phase2_(phaseModels_[phaseNames_[1]]())
|
||||
phase1_(phaseModels_.first()),
|
||||
phase2_(phaseModels_.last())
|
||||
{
|
||||
phase2_.volScalarField::operator=(scalar(1) - phase1_);
|
||||
|
||||
volScalarField& alpha1 = phase1_;
|
||||
mesh.setFluxRequired(alpha1.name());
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user