reactingMultiphaseEulerFoam: Optimize the handling of optional forces

This commit is contained in:
Henry Weller 2015-09-18 18:55:21 +01:00
parent 1979194f36
commit 29cea780e1
4 changed files with 112 additions and 50 deletions

View File

@ -511,17 +511,12 @@ Foam::MomentumTransferPhaseSystem<BasePhaseSystem>::momentumTransfer() const
template<class BasePhaseSystem> template<class BasePhaseSystem>
Foam::autoPtr<Foam::PtrList<Foam::volVectorField> > Foam::volVectorField& Foam::MomentumTransferPhaseSystem<BasePhaseSystem>::setF
Foam::MomentumTransferPhaseSystem<BasePhaseSystem>::Fs() const (
PtrList<volVectorField>& Fs, const label phasei
) const
{ {
autoPtr<PtrList<volVectorField> > tFs if (!Fs.set(phasei))
(
new PtrList<volVectorField>(this->phases().size())
);
PtrList<volVectorField>& Fs = tFs();
forAll(Fs, phasei)
{ {
Fs.set Fs.set
( (
@ -543,6 +538,20 @@ Foam::MomentumTransferPhaseSystem<BasePhaseSystem>::Fs() const
); );
} }
return Fs[phasei];
}
template<class BasePhaseSystem>
Foam::autoPtr<Foam::PtrList<Foam::volVectorField> >
Foam::MomentumTransferPhaseSystem<BasePhaseSystem>::Fs() const
{
autoPtr<PtrList<volVectorField> > tFs
(
new PtrList<volVectorField>(this->phases().size())
);
PtrList<volVectorField>& Fs = tFs();
// Add the lift force // Add the lift force
forAllConstIter forAllConstIter
( (
@ -555,8 +564,8 @@ Foam::MomentumTransferPhaseSystem<BasePhaseSystem>::Fs() const
const phasePair& pair(this->phasePairs_[liftModelIter.key()]); const phasePair& pair(this->phasePairs_[liftModelIter.key()]);
Fs[pair.phase1().index()] += F; setF(Fs, pair.phase1().index()) += F;
Fs[pair.phase2().index()] -= F; setF(Fs, pair.phase2().index()) -= F;
} }
// Add the wall lubrication force // Add the wall lubrication force
@ -572,8 +581,8 @@ Foam::MomentumTransferPhaseSystem<BasePhaseSystem>::Fs() const
const phasePair& const phasePair&
pair(this->phasePairs_[wallLubricationModelIter.key()]); pair(this->phasePairs_[wallLubricationModelIter.key()]);
Fs[pair.phase1().index()] += F; setF(Fs, pair.phase1().index()) += F;
Fs[pair.phase2().index()] -= F; setF(Fs, pair.phase2().index()) -= F;
} }
return tFs; return tFs;
@ -581,20 +590,13 @@ Foam::MomentumTransferPhaseSystem<BasePhaseSystem>::Fs() const
template<class BasePhaseSystem> template<class BasePhaseSystem>
Foam::autoPtr<Foam::PtrList<Foam::surfaceScalarField> > Foam::surfaceScalarField&
Foam::MomentumTransferPhaseSystem<BasePhaseSystem>::phiDs Foam::MomentumTransferPhaseSystem<BasePhaseSystem>::setPhiD
( (
const PtrList<volScalarField>& rAUs PtrList<surfaceScalarField>& phiDs, const label phasei
) const ) const
{ {
autoPtr<PtrList<surfaceScalarField> > tphiDs if (!phiDs.set(phasei))
(
new PtrList<surfaceScalarField>(this->phases().size())
);
PtrList<surfaceScalarField>& phiDs = tphiDs();
forAll(phiDs, phasei)
{ {
phiDs.set phiDs.set
( (
@ -603,7 +605,7 @@ Foam::MomentumTransferPhaseSystem<BasePhaseSystem>::phiDs
( (
IOobject IOobject
( (
liftModel::typeName + ":F", turbulentDispersionModel::typeName + ":phiD",
this->mesh_.time().timeName(), this->mesh_.time().timeName(),
this->mesh_, this->mesh_,
IOobject::NO_READ, IOobject::NO_READ,
@ -621,6 +623,23 @@ Foam::MomentumTransferPhaseSystem<BasePhaseSystem>::phiDs
); );
} }
return phiDs[phasei];
}
template<class BasePhaseSystem>
Foam::autoPtr<Foam::PtrList<Foam::surfaceScalarField> >
Foam::MomentumTransferPhaseSystem<BasePhaseSystem>::phiDs
(
const PtrList<volScalarField>& rAUs
) const
{
autoPtr<PtrList<surfaceScalarField> > tphiDs
(
new PtrList<surfaceScalarField>(this->phases().size())
);
PtrList<surfaceScalarField>& phiDs = tphiDs();
// Add the turbulent dispersion force // Add the turbulent dispersion force
forAllConstIter forAllConstIter
( (
@ -638,9 +657,9 @@ Foam::MomentumTransferPhaseSystem<BasePhaseSystem>::phiDs
fvc::snGrad(pair.phase1())*this->mesh_.magSf() fvc::snGrad(pair.phase1())*this->mesh_.magSf()
); );
phiDs[pair.phase1().index()] += setPhiD(phiDs, pair.phase1().index()) +=
fvc::interpolate(rAUs[pair.phase1().index()]*D)*snGradAlpha1; fvc::interpolate(rAUs[pair.phase1().index()]*D)*snGradAlpha1;
phiDs[pair.phase2().index()] -= setPhiD(phiDs, pair.phase2().index()) -=
fvc::interpolate(rAUs[pair.phase2().index()]*D)*snGradAlpha1; fvc::interpolate(rAUs[pair.phase2().index()]*D)*snGradAlpha1;
} }

View File

@ -133,6 +133,20 @@ private:
//- Turbulent dispersion models //- Turbulent dispersion models
turbulentDispersionModelTable turbulentDispersionModels_; turbulentDispersionModelTable turbulentDispersionModels_;
//- Construct element phasei of Fs if not set and return
// Used by Fs()
volVectorField& setF
(
PtrList<volVectorField>& Fs, const label phasei
) const;
//- Construct element phasei of phiDs if not set and return
// Used by phiDs()
surfaceScalarField& setPhiD
(
PtrList<surfaceScalarField>& phiDs, const label phasei
) const;
public: public:

View File

@ -38,22 +38,51 @@ forAll(phases, phasei)
PtrList<surfaceScalarField> phiFs(phases.size()); PtrList<surfaceScalarField> phiFs(phases.size());
{ {
autoPtr<PtrList<volVectorField> > Fs = fluid.Fs(); autoPtr<PtrList<volVectorField> > Fs = fluid.Fs();
forAll(phases, phasei)
{
phaseModel& phase = phases[phasei];
if (Fs().set(phasei))
{
phiFs.set
(
phasei,
new surfaceScalarField
(
IOobject::groupName("phiF", phase.name()),
(fvc::interpolate(rAUs[phasei]*Fs()[phasei]) & mesh.Sf())
)
);
}
}
}
{
autoPtr<PtrList<surfaceScalarField> > phiDs = fluid.phiDs(rAUs); autoPtr<PtrList<surfaceScalarField> > phiDs = fluid.phiDs(rAUs);
forAll(phases, phasei) forAll(phases, phasei)
{ {
phaseModel& phase = phases[phasei]; phaseModel& phase = phases[phasei];
phiFs.set if (phiDs().set(phasei))
( {
phasei, if (phiFs.set(phasei))
new surfaceScalarField {
( phiFs[phasei] += phiDs()[phasei];
IOobject::groupName("phiF", phase.name()), }
(fvc::interpolate(rAUs[phasei]*Fs()[phasei]) & mesh.Sf()) else
+ phiDs()[phasei] {
) phiFs.set
); (
phasei,
new surfaceScalarField
(
IOobject::groupName("phiF", phase.name()),
phiDs()[phasei]
)
);
}
}
} }
} }
@ -101,12 +130,12 @@ while (pimple.correct())
ghf*fvc::snGrad(rho)*mesh.magSf() ghf*fvc::snGrad(rho)*mesh.magSf()
); );
PtrList<surfaceScalarField> phigs(phases.size()); PtrList<surfaceScalarField> phigFs(phases.size());
forAll(phases, phasei) forAll(phases, phasei)
{ {
phaseModel& phase = phases[phasei]; phaseModel& phase = phases[phasei];
phigs.set phigFs.set
( (
phasei, phasei,
( (
@ -118,6 +147,11 @@ while (pimple.correct())
) )
).ptr() ).ptr()
); );
if (phiFs.set(phasei))
{
phigFs[phasei] += phiFs[phasei];
}
} }
PtrList<surfaceScalarField> phiHbyAs(phases.size()); PtrList<surfaceScalarField> phiHbyAs(phases.size());
@ -177,8 +211,7 @@ while (pimple.correct())
MRF.absolute(phase.phi().oldTime()) MRF.absolute(phase.phi().oldTime())
- (fvc::interpolate(phase.U().oldTime()) & mesh.Sf()) - (fvc::interpolate(phase.U().oldTime()) & mesh.Sf())
)/runTime.deltaT() )/runTime.deltaT()
- phiFs[phasei] - phigFs[phasei]
- phigs[phasei]
) )
); );
@ -389,8 +422,7 @@ while (pimple.correct())
+ fvc::reconstruct + fvc::reconstruct
( (
alpharAUfs[phasei]*mSfGradp alpharAUfs[phasei]*mSfGradp
- phiFs[phasei] - phigFs[phasei]
- phigs[phasei]
); );
phase.U().correctBoundaryConditions(); phase.U().correctBoundaryConditions();
fvOptions.correct(phase.U()); fvOptions.correct(phase.U());

View File

@ -151,16 +151,13 @@ heatTransfer
); );
lift lift
( ();
);
wallLubrication wallLubrication
( ();
);
turbulentDispersion turbulentDispersion
( ();
);
// Minimum allowable pressure // Minimum allowable pressure
pMin 10000; pMin 10000;