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());
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -146,6 +146,7 @@ public:
|
||||
// and annul the argument.
|
||||
void transfer(DictionaryBase<IDLListType, T>&);
|
||||
|
||||
|
||||
// Member operators
|
||||
|
||||
void operator=(const DictionaryBase&);
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -73,6 +73,21 @@ public:
|
||||
|
||||
//- Construct from Istream
|
||||
PtrDictionary(Istream&);
|
||||
|
||||
|
||||
// Member operators
|
||||
|
||||
//- Find and return entry
|
||||
const T& operator[](const word& key) const
|
||||
{
|
||||
return *DictionaryBase<DLPtrList<T>, T>::operator[](key);
|
||||
}
|
||||
|
||||
//- Find and return entry
|
||||
T& operator[](const word& key)
|
||||
{
|
||||
return *DictionaryBase<DLPtrList<T>, T>::operator[](key);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -203,6 +203,7 @@ public:
|
||||
// and annul the argument list.
|
||||
void transfer(LList<LListBase, T>&);
|
||||
|
||||
|
||||
// Member operators
|
||||
|
||||
void operator=(const LList<LListBase, T>&);
|
||||
@ -265,6 +266,16 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
inline iterator begin()
|
||||
{
|
||||
return LListBase::begin();
|
||||
}
|
||||
|
||||
inline const iterator& end()
|
||||
{
|
||||
return static_cast<const iterator&>(LListBase::end());
|
||||
}
|
||||
|
||||
|
||||
// STL const_iterator
|
||||
|
||||
@ -313,6 +324,26 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
inline const_iterator cbegin() const
|
||||
{
|
||||
return LListBase::cbegin();
|
||||
}
|
||||
|
||||
inline const const_iterator& cend() const
|
||||
{
|
||||
return static_cast<const const_iterator&>(LListBase::cend());
|
||||
}
|
||||
|
||||
inline const_iterator begin() const
|
||||
{
|
||||
return LListBase::begin();
|
||||
}
|
||||
|
||||
inline const const_iterator& end() const
|
||||
{
|
||||
return static_cast<const const_iterator&>(LListBase::end());
|
||||
}
|
||||
|
||||
|
||||
// IOstream operators
|
||||
|
||||
|
||||
@ -209,6 +209,16 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
inline iterator begin()
|
||||
{
|
||||
return LListBase::begin();
|
||||
}
|
||||
|
||||
inline const iterator& end()
|
||||
{
|
||||
return static_cast<const iterator&>(LListBase::end());
|
||||
}
|
||||
|
||||
|
||||
// STL const_iterator
|
||||
|
||||
@ -256,6 +266,26 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
inline const_iterator cbegin() const
|
||||
{
|
||||
return LListBase::cbegin();
|
||||
}
|
||||
|
||||
inline const const_iterator& cend() const
|
||||
{
|
||||
return static_cast<const const_iterator&>(LListBase::cend());
|
||||
}
|
||||
|
||||
inline const_iterator begin() const
|
||||
{
|
||||
return LListBase::begin();
|
||||
}
|
||||
|
||||
inline const const_iterator& end() const
|
||||
{
|
||||
return static_cast<const const_iterator&>(LListBase::end());
|
||||
}
|
||||
|
||||
|
||||
// STL const_reverse_iterator
|
||||
|
||||
@ -298,6 +328,29 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
inline const_reverse_iterator crbegin() const
|
||||
{
|
||||
return LListBase::crbegin();
|
||||
}
|
||||
|
||||
inline const const_reverse_iterator& crend() const
|
||||
{
|
||||
return
|
||||
static_cast<const const_reverse_iterator&>(LListBase::crend());
|
||||
}
|
||||
|
||||
|
||||
inline const_reverse_iterator rbegin() const
|
||||
{
|
||||
return LListBase::rbegin();
|
||||
}
|
||||
|
||||
inline const const_reverse_iterator& rend() const
|
||||
{
|
||||
return
|
||||
static_cast<const const_reverse_iterator&>(LListBase::rend());
|
||||
}
|
||||
|
||||
|
||||
// STL member operators
|
||||
|
||||
|
||||
@ -263,6 +263,7 @@ public:
|
||||
inline const_iterator begin() const;
|
||||
inline const const_iterator& end() const;
|
||||
|
||||
|
||||
// STL const_reverse_iterator
|
||||
|
||||
//- An STL-conforming const_reverse_iterator
|
||||
@ -300,6 +301,7 @@ public:
|
||||
inline const_reverse_iterator rbegin() const;
|
||||
inline const const_reverse_iterator& rend() const;
|
||||
|
||||
|
||||
private:
|
||||
|
||||
//- Iterator returned by end()
|
||||
@ -310,7 +312,6 @@ private:
|
||||
|
||||
//- const_reverse_iterator returned by end()
|
||||
static const_reverse_iterator endConstRevIter_;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -58,12 +58,6 @@ public:
|
||||
DLPtrList()
|
||||
{}
|
||||
|
||||
//- Construct given initial T
|
||||
DLPtrList(T a)
|
||||
:
|
||||
LPtrList<DLListBase, T>(a)
|
||||
{}
|
||||
|
||||
//- Construct from Istream using given Istream constructor class
|
||||
template<class INew>
|
||||
DLPtrList(Istream& is, const INew& inewt)
|
||||
|
||||
Reference in New Issue
Block a user