Commit c31789c3 authored by Henry Weller's avatar Henry Weller
Browse files

reactingEulerFoam: Use PtrListDictionary for list/table of phases

This makes looping over the phases much simpler which maintaining
support for phase-name lookup.
parent 7b5d6114
......@@ -270,7 +270,7 @@ Foam::HeatAndMassTransferPhaseSystem<BasePhaseSystem>::heatTransfer() const
forAllConstIter
(
phaseSystem::phaseModelTable,
phaseSystem::phaseModelList,
this->phaseModels_,
phaseModelIter
)
......
......@@ -122,7 +122,7 @@ Foam::HeatTransferPhaseSystem<BasePhaseSystem>::heatTransfer() const
forAllConstIter
(
phaseSystem::phaseModelTable,
phaseSystem::phaseModelList,
this->phaseModels_,
phaseModelIter
)
......
......@@ -71,7 +71,7 @@ massTransfer() const
forAllConstIter
(
phaseSystem::phaseModelTable,
phaseSystem::phaseModelList,
this->phaseModels_,
phaseModelIter
)
......
......@@ -415,7 +415,7 @@ Foam::MomentumTransferPhaseSystem<BasePhaseSystem>::momentumTransfer() const
forAllConstIter
(
phaseSystem::phaseModelTable,
phaseSystem::phaseModelList,
this->phaseModels_,
phaseModelIter
)
......
......@@ -66,7 +66,7 @@ Foam::ThermalPhaseChangePhaseSystem<BasePhaseSystem>::massTransfer() const
forAllConstIter
(
phaseSystem::phaseModelTable,
phaseSystem::phaseModelList,
this->phaseModels_,
phaseModelIter
)
......
......@@ -43,10 +43,10 @@ const Foam::word Foam::phaseSystem::propertiesName("phaseProperties");
Foam::tmp<Foam::surfaceScalarField> Foam::phaseSystem::calcPhi
(
const phaseModelTable& phaseModels
const phaseModelList& phaseModels
) const
{
phaseModelTable::const_iterator phaseModelIter = phaseModels.begin();
phaseModelList::const_iterator phaseModelIter = phaseModels.begin();
tmp<surfaceScalarField> tmpPhi
(
......@@ -196,7 +196,7 @@ Foam::phaseSystem::~phaseSystem()
Foam::tmp<Foam::volScalarField> Foam::phaseSystem::rho() const
{
phaseModelTable::const_iterator phaseModelIter = phaseModels_.begin();
phaseModelList::const_iterator phaseModelIter = phaseModels_.begin();
tmp<volScalarField> tmpRho
(
......@@ -214,7 +214,7 @@ Foam::tmp<Foam::volScalarField> Foam::phaseSystem::rho() const
Foam::tmp<Foam::volVectorField> Foam::phaseSystem::U() const
{
phaseModelTable::const_iterator phaseModelIter = phaseModels_.begin();
phaseModelList::const_iterator phaseModelIter = phaseModels_.begin();
tmp<volVectorField> tmpU
(
......@@ -266,7 +266,7 @@ void Foam::phaseSystem::solve()
void Foam::phaseSystem::correct()
{
forAllIter(phaseModelTable, phaseModels_, phaseModelIter)
forAllIter(phaseModelList, phaseModels_, phaseModelIter)
{
phaseModelIter().correct();
}
......@@ -277,7 +277,7 @@ void Foam::phaseSystem::correctKinematics()
{
bool updateDpdt = false;
forAllIter(phaseModelTable, phaseModels_, phaseModelIter)
forAllIter(phaseModelList, phaseModels_, phaseModelIter)
{
phaseModelIter().correctKinematics();
......@@ -287,14 +287,14 @@ void Foam::phaseSystem::correctKinematics()
// Update the pressure time-derivative if required
if (updateDpdt)
{
dpdt_ = fvc::ddt(phaseModels_.begin()()->thermo().p());
dpdt_ = fvc::ddt(phaseModels_.begin()().thermo().p());
}
}
void Foam::phaseSystem::correctThermo()
{
forAllIter(phaseModelTable, phaseModels_, phaseModelIter)
forAllIter(phaseModelList, phaseModels_, phaseModelIter)
{
phaseModelIter().correctThermo();
}
......@@ -303,7 +303,7 @@ void Foam::phaseSystem::correctThermo()
void Foam::phaseSystem::correctTurbulence()
{
forAllIter(phaseModelTable, phaseModels_, phaseModelIter)
forAllIter(phaseModelList, phaseModels_, phaseModelIter)
{
phaseModelIter().correctTurbulence();
}
......@@ -312,7 +312,7 @@ void Foam::phaseSystem::correctTurbulence()
void Foam::phaseSystem::correctEnergyTransport()
{
forAllIter(phaseModelTable, phaseModels_, phaseModelIter)
forAllIter(phaseModelList, phaseModels_, phaseModelIter)
{
phaseModelIter().correctEnergyTransport();
}
......@@ -325,7 +325,7 @@ bool Foam::phaseSystem::read()
{
bool readOK = true;
forAllIter(phaseModelTable, phaseModels_, phaseModelIter)
forAllIter(phaseModelList, phaseModels_, phaseModelIter)
{
readOK &= phaseModelIter().read();
}
......
......@@ -42,7 +42,7 @@ SourceFiles
#include "phasePair.H"
#include "orderedPhasePair.H"
#include "HashPtrTable.H"
#include "PtrDictionary.H"
#include "PtrListDictionary.H"
#include "IOMRFZoneList.H"
#include "fvIOoptionList.H"
......@@ -118,7 +118,7 @@ public:
>
massTransferTable;
typedef PtrDictionary<phaseModel> phaseModelTable;
typedef PtrListDictionary<phaseModel> phaseModelList;
protected:
......@@ -162,7 +162,7 @@ protected:
const fvMesh& mesh_;
//- Phase models
phaseModelTable phaseModels_;
phaseModelList phaseModels_;
//- Phase pairs
phasePairTable phasePairs_;
......@@ -197,7 +197,7 @@ protected:
//- Calculate and return the mixture flux
tmp<surfaceScalarField> calcPhi
(
const phaseModelTable& phaseModels
const phaseModelList& phaseModels
) const;
//- Generate pairs
......@@ -284,10 +284,10 @@ public:
inline const fvMesh& mesh() const;
//- Constant access the phase models
inline const phaseModelTable& phases() const;
inline const phaseModelList& phases() const;
//- Access the phase models
inline phaseModelTable& phases();
inline phaseModelList& phases();
//- Constant access the phase pairs
inline const phasePairTable& phasePairs() const;
......
......@@ -31,14 +31,14 @@ inline const Foam::fvMesh& Foam::phaseSystem::mesh() const
}
inline const Foam::phaseSystem::phaseModelTable&
inline const Foam::phaseSystem::phaseModelList&
Foam::phaseSystem::phases() const
{
return phaseModels_;
}
inline Foam::phaseSystem::phaseModelTable&
inline Foam::phaseSystem::phaseModelList&
Foam::phaseSystem::phases()
{
return phaseModels_;
......
......@@ -151,7 +151,7 @@ void Foam::phaseSystem::generatePairsAndSubModels
HashTable<autoPtr<modelType>, phasePairKey, phasePairKey::hash>
modelTypeTable;
forAllConstIter(phaseModelTable, phaseModels_, phaseModelIter)
forAllConstIter(phaseModelList, phaseModels_, phaseModelIter)
{
modelTypeTable tempModels;
generatePairsAndSubModels
......
......@@ -39,12 +39,12 @@ if (mesh.nInternalFaces())
fvc::surfaceSum(mag(phi))().internalField()
);
forAllIter(PtrDictionary<phaseModel>, fluid.phases(), iter)
forAll(fluid.phases(), phasei)
{
sumPhi = max
(
sumPhi,
fvc::surfaceSum(mag(iter().phi()))().internalField()
fvc::surfaceSum(mag(fluid.phases()[phasei].phi()))().internalField()
);
}
......
......@@ -6,9 +6,10 @@
phaseSystem::heatTransferTable& heatTransfer = heatTransferPtr();
forAllIter(PtrDictionary<phaseModel>, fluid.phases(), iter)
forAll(fluid.phases(), phasei)
{
phaseModel& phase = iter();
phaseModel& phase = fluid.phases()[phasei];
const volScalarField& alpha = phase;
const volScalarField& rho = phase.rho();
const volVectorField& U = phase.U();
......@@ -35,9 +36,9 @@
fluid.correctThermo();
forAllIter(PtrDictionary<phaseModel>, fluid.phases(), iter)
forAll(fluid.phases(), phasei)
{
phaseModel& phase = iter();
phaseModel& phase = fluid.phases()[phasei];
Info<< phase.name() << " min/max T "
<< min(phase.thermo().T()).value()
......
......@@ -5,9 +5,10 @@
phaseSystem::massTransferTable&
massTransfer(massTransferPtr());
forAllIter(PtrDictionary<phaseModel>, fluid.phases(), iter)
forAll(fluid.phases(), phasei)
{
phaseModel& phase = iter();
phaseModel& phase = fluid.phases()[phasei];
PtrList<volScalarField>& Y = phase.Y();
const volScalarField& alpha = phase;
const volScalarField& rho = phase.rho();
......
......@@ -59,9 +59,9 @@ void Foam::multiphaseSystem::calcAlphas()
scalar level = 0.0;
alphas_ == 0.0;
forAllIter(PtrDictionary<phaseModel>, phases(), iter)
forAll(phases(), i)
{
alphas_ += level*iter();
alphas_ += level*phases()[i];
level += 1.0;
}
......@@ -72,11 +72,9 @@ void Foam::multiphaseSystem::calcAlphas()
void Foam::multiphaseSystem::solveAlphas()
{
PtrList<surfaceScalarField> alphaPhiCorrs(phases().size());
int phasei = 0;
forAllIter(PtrDictionary<phaseModel>, phases(), iter)
forAll(phases(), phasei)
{
phaseModel& phase = iter();
phaseModel& phase = phases()[phasei];
volScalarField& alpha1 = phase;
phase.alphaPhi() =
......@@ -99,9 +97,9 @@ void Foam::multiphaseSystem::solveAlphas()
surfaceScalarField& alphaPhiCorr = alphaPhiCorrs[phasei];
forAllIter(PtrDictionary<phaseModel>, phases(), iter2)
forAll(phases(), phasej)
{
phaseModel& phase2 = iter2();
phaseModel& phase2 = phases()[phasej];
volScalarField& alpha2 = phase2;
if (&phase2 == &phase) continue;
......@@ -170,8 +168,6 @@ void Foam::multiphaseSystem::solveAlphas()
0,
true
);
phasei++;
}
MULES::limitSum(alphaPhiCorrs);
......@@ -191,10 +187,9 @@ void Foam::multiphaseSystem::solveAlphas()
volScalarField divU(fvc::div(fvc::absolute(phi_, phases().first().U())));
phasei = 0;
forAllIter(PtrDictionary<phaseModel>, phases(), iter)
forAll(phases(), phasei)
{
phaseModel& phase = iter();
phaseModel& phase = phases()[phasei];
volScalarField& alpha = phase;
surfaceScalarField& alphaPhic = alphaPhiCorrs[phasei];
......@@ -245,9 +240,9 @@ void Foam::multiphaseSystem::solveAlphas()
}
}
forAllConstIter(PtrDictionary<phaseModel>, phases(), iter2)
forAll(phases(), phasej)
{
const phaseModel& phase2 = iter2();
const phaseModel& phase2 = phases()[phasej];
const volScalarField& alpha2 = phase2;
if (&phase2 == &phase) continue;
......@@ -294,8 +289,6 @@ void Foam::multiphaseSystem::solveAlphas()
<< endl;
sumAlpha += phase;
phasei++;
}
Info<< "Phase-sum volume fraction, min, max = "
......@@ -506,9 +499,9 @@ Foam::multiphaseSystem::multiphaseSystem
1e-8/pow(average(mesh.V()), 1.0/3.0)
)
{
forAllIter(phaseSystem::phaseModelTable, phases(), iter)
forAll(phases(), phasei)
{
volScalarField& alphai = iter();
volScalarField& alphai = phases()[phasei];
mesh.setFluxRequired(alphai.name());
}
}
......@@ -547,9 +540,9 @@ Foam::tmp<Foam::surfaceScalarField> Foam::multiphaseSystem::surfaceTension
)
);
forAllConstIter(PtrDictionary<phaseModel>, phases(), iter)
forAll(phases(), phasej)
{
const phaseModel& phase2 = iter();
const phaseModel& phase2 = phases()[phasej];
if (&phase2 != &phase1)
{
......@@ -591,9 +584,13 @@ Foam::multiphaseSystem::nearInterface() const
)
);
forAllConstIter(PtrDictionary<phaseModel>, phases(), iter)
forAll(phases(), phasei)
{
tnearInt() = max(tnearInt(), pos(iter() - 0.01)*pos(0.99 - iter()));
tnearInt() = max
(
tnearInt(),
pos(phases()[phasei] - 0.01)*pos(0.99 - phases()[phasei])
);
}
return tnearInt;
......@@ -625,10 +622,9 @@ void Foam::multiphaseSystem::solve()
PtrList<volScalarField> alpha0s(phases().size());
PtrList<surfaceScalarField> phiSums(phases().size());
int phasei = 0;
forAllIter(PtrDictionary<phaseModel>, phases(), iter)
forAll(phases(), phasei)
{
phaseModel& phase = iter();
phaseModel& phase = phases()[phasei];
volScalarField& alpha = phase;
alpha0s.set
......@@ -652,8 +648,6 @@ void Foam::multiphaseSystem::solve()
dimensionedScalar("0", dimensionSet(0, 3, -1, 0, 0), 0)
)
);
phasei++;
}
for
......@@ -668,18 +662,15 @@ void Foam::multiphaseSystem::solve()
{
solveAlphas();
int phasei = 0;
forAllIter(PtrDictionary<phaseModel>, phases(), iter)
forAll(phases(), phasei)
{
phiSums[phasei] += iter().phi();
phasei++;
phiSums[phasei] += phases()[phasei].phi();
}
}
phasei = 0;
forAllIter(PtrDictionary<phaseModel>, phases(), iter)
forAll(phases(), phasei)
{
phaseModel& phase = iter();
phaseModel& phase = phases()[phasei];
volScalarField& alpha = phase;
phase.phi() = phiSums[phasei]/nAlphaSubCycles;
......@@ -691,8 +682,6 @@ void Foam::multiphaseSystem::solve()
// Reset the old-time field value
alpha.oldTime() = alpha0s[phasei];
alpha.oldTime().timeIndex() = runTime.timeIndex();
phasei++;
}
}
else
......@@ -700,9 +689,9 @@ void Foam::multiphaseSystem::solve()
solveAlphas();
}
forAllIter(PtrDictionary<phaseModel>, phases(), iter)
forAll(phases(), phasei)
{
phaseModel& phase = iter();
phaseModel& phase = phases()[phasei];
phase.alphaRhoPhi() = fvc::interpolate(phase.rho())*phase.alphaPhi();
}
......
......@@ -9,10 +9,10 @@ PtrList<fvVectorMatrix> UEqns(fluid.phases().size());
phaseSystem::momentumTransferTable&
momentumTransfer(momentumTransferPtr());
int phasei = 0;
forAllIter(PtrDictionary<phaseModel>, fluid.phases(), iter)
forAll(fluid.phases(), phasei)
{
phaseModel& phase = iter();
phaseModel& phase = fluid.phases()[phasei];
const volScalarField& alpha = phase;
const volScalarField& rho = phase.rho();
volVectorField& U = phase.U();
......@@ -31,7 +31,5 @@ PtrList<fvVectorMatrix> UEqns(fluid.phases().size());
UEqns[phasei].relax();
fvOptions.constrain(UEqns[phasei]);
phasei++;
}
}
......@@ -2,10 +2,9 @@ PtrList<surfaceScalarField> alphafs(fluid.phases().size());
PtrList<volScalarField> rAUs(fluid.phases().size());
PtrList<surfaceScalarField> alpharAUfs(fluid.phases().size());
int phasei = 0;
forAllIter(PtrDictionary<phaseModel>, fluid.phases(), iter)
forAll(fluid.phases(), phasei)
{
phaseModel& phase = iter();
phaseModel& phase = fluid.phases()[phasei];
const volScalarField& alpha = phase;
alphafs.set(phasei, fvc::interpolate(alpha).ptr());
......@@ -33,8 +32,6 @@ forAllIter(PtrDictionary<phaseModel>, fluid.phases(), iter)
fvc::interpolate(max(alpha, phase.residualAlpha())*rAUs[phasei])
).ptr()
);
phasei++;
}
// Turbulent diffusion, particle-pressure, lift and wall-lubrication fluxes
......@@ -42,10 +39,9 @@ PtrList<surfaceScalarField> phiFs(fluid.phases().size());
{
autoPtr<PtrList<volVectorField> > Fs = fluid.Fs();
phasei = 0;
forAllIter(PtrDictionary<phaseModel>, fluid.phases(), iter)
forAll(fluid.phases(), phasei)
{
phaseModel& phase = iter();
phaseModel& phase = fluid.phases()[phasei];
phiFs.set
(
......@@ -56,8 +52,6 @@ PtrList<surfaceScalarField> phiFs(fluid.phases().size());
(fvc::interpolate(rAUs[phasei]*Fs()[phasei]) & mesh.Sf())
)
);
phasei++;
}
}
......@@ -69,10 +63,9 @@ while (pimple.correct())
PtrList<volVectorField> HbyAs(fluid.phases().size());
phasei = 0;
forAllIter(PtrDictionary<phaseModel>, fluid.phases(), iter)
forAll(fluid.phases(), phasei)
{
phaseModel& phase = iter();
phaseModel& phase = fluid.phases()[phasei];
const volScalarField& alpha = phase;
// Correct fixed-flux BCs to be consistent with the velocity BCs
......@@ -95,8 +88,6 @@ while (pimple.correct())
+ max(phase.residualAlpha() - alpha, scalar(0))
*phase.rho()*phase.U().oldTime()/runTime.deltaT()
);
phasei++;
}
// Mean density for buoyancy force and p_rgh -> p
......@@ -109,10 +100,9 @@ while (pimple.correct())
);
PtrList<surfaceScalarField> phigs(fluid.phases().size());
phasei = 0;
forAllIter(PtrDictionary<phaseModel>, fluid.phases(), iter)
forAll(fluid.phases(), phasei)
{
phaseModel& phase = iter();
phaseModel& phase = fluid.phases()[phasei];
phigs.set
(
......@@ -126,8 +116,6 @@ while (pimple.correct())
)
).ptr()
);
phasei++;
}
PtrList<surfaceScalarField> phiHbyAs(fluid.phases().size());
......@@ -146,10 +134,9 @@ while (pimple.correct())
dimensionedScalar("phiHbyA", dimArea*dimVelocity, 0)
);
phasei = 0;
forAllIter(PtrDictionary<phaseModel>, fluid.phases(), iter)
forAll(fluid.phases(), phasei)
{
phaseModel& phase = iter();
phaseModel& phase = fluid.phases()[phasei];
const volScalarField& alpha = phase;