multiphaseEulerFoam/.../diameterModels: Removed caching

The previous changes to reactions mean that caching the surface area
density field is no longer necessary. The diameter models have had their
caching functionality removed, which has simplified both the
implementation and the user interface.
This commit is contained in:
Will Bainbridge
2021-02-11 10:42:30 +00:00
parent 3f64e27f46
commit 27b92bb2f6
14 changed files with 163 additions and 322 deletions

View File

@ -48,17 +48,11 @@ namespace diameterModels
}
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
// * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * //
Foam::tmp<Foam::volScalarField> Foam::diameterModels::IATE::calcD() const
Foam::tmp<Foam::volScalarField> Foam::diameterModels::IATE::dsm() const
{
return d_;
}
Foam::tmp<Foam::volScalarField> Foam::diameterModels::IATE::calcA() const
{
return phase()*kappai_;
return max(6/max(kappai_, 6/dMax_), dMin_);
}
@ -86,11 +80,9 @@ Foam::diameterModels::IATE::IATE
dMax_("dMax", dimLength, diameterProperties),
dMin_("dMin", dimLength, diameterProperties),
residualAlpha_("residualAlpha", dimless, diameterProperties),
d_(dRef()),
d_(IOobject::groupName("d", phase.name()), dsm()),
sources_(diameterProperties.lookup("sources"), IATEsource::iNew(*this))
{
d_ = dsm();
}
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
@ -101,13 +93,19 @@ Foam::diameterModels::IATE::~IATE()
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
Foam::tmp<Foam::volScalarField> Foam::diameterModels::IATE::dsm() const
Foam::tmp<Foam::volScalarField> Foam::diameterModels::IATE::d() const
{
return max(6/max(kappai_, 6/dMax_), dMin_);
return d_;
}
void Foam::diameterModels::IATE::correctNoStore()
Foam::tmp<Foam::volScalarField> Foam::diameterModels::IATE::a() const
{
return phase()*kappai_;
}
void Foam::diameterModels::IATE::correct()
{
volScalarField alphaAv
(

View File

@ -83,7 +83,7 @@ class IATE
dimensionedScalar residualAlpha_;
//- The Sauter-mean diameter of the phase
volScalarField& d_;
volScalarField d_;
//- IATE sources
PtrList<IATEsource> sources_;
@ -94,17 +94,6 @@ class IATE
tmp<volScalarField> dsm() const;
protected:
// Protected Member Functions
//- Get the diameter field
virtual tmp<volScalarField> calcD() const;
//- Get the surface area per unit volume field
virtual tmp<volScalarField> calcA() const;
public:
friend class IATEsource;
@ -115,7 +104,7 @@ public:
// Constructors
//- Construct from components
//- Construct from dictionary and phase
IATE
(
const dictionary& diameterProperties,
@ -135,8 +124,14 @@ public:
return kappai_;
}
//- Correct the diameter field
virtual void correctNoStore();
//- Get the diameter field
virtual tmp<volScalarField> d() const;
//- Get the surface area per unit volume field
virtual tmp<volScalarField> a() const;
//- Correct the model
virtual void correct();
//- Read phaseProperties dictionary
virtual bool read(const dictionary& phaseProperties);

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -38,19 +38,6 @@ namespace diameterModels
}
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
Foam::tmp<Foam::volScalarField> Foam::diameterModels::constant::calcD() const
{
return volScalarField::New
(
IOobject::groupName("d", phase().name()),
phase().mesh(),
d_
);
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::diameterModels::constant::constant
@ -72,6 +59,17 @@ Foam::diameterModels::constant::~constant()
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
Foam::tmp<Foam::volScalarField> Foam::diameterModels::constant::d() const
{
return volScalarField::New
(
IOobject::groupName("d", phase().name()),
phase().mesh(),
d_
);
}
bool Foam::diameterModels::constant::read(const dictionary& phaseProperties)
{
spherical::read(phaseProperties);

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -58,14 +58,6 @@ class constant
dimensionedScalar d_;
protected:
// Protected Member Functions
//- Get the diameter field
virtual tmp<volScalarField> calcD() const;
public:
//- Runtime type information
@ -74,7 +66,7 @@ public:
// Constructors
//- Construct from components
//- Construct from dictionary and phase
constant
(
const dictionary& diameterProperties,
@ -88,6 +80,9 @@ public:
// Member Functions
//- Get the diameter field
virtual tmp<volScalarField> d() const;
//- Read diameterProperties dictionary
virtual bool read(const dictionary& diameterProperties);
};

View File

@ -34,56 +34,6 @@ namespace Foam
}
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
Foam::volScalarField& Foam::diameterModel::dRef()
{
if (!dPtr_.valid())
{
dPtr_.reset
(
new volScalarField
(
IOobject
(
IOobject::groupName("d", phase_.name()),
phase_.time().timeName(),
phase_.mesh()
),
phase_.mesh(),
dimensionedScalar(dimLength, 0)
)
);
}
return dPtr_();
}
Foam::volScalarField& Foam::diameterModel::aRef()
{
if (!aPtr_.valid())
{
aPtr_.reset
(
new volScalarField
(
IOobject
(
IOobject::groupName("a", phase_.name()),
phase_.time().timeName(),
phase_.mesh()
),
phase_.mesh(),
dimensionedScalar(dimless/dimLength, 0)
)
);
}
return aPtr_();
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::diameterModel::diameterModel
@ -93,19 +43,8 @@ Foam::diameterModel::diameterModel
)
:
diameterProperties_(diameterProperties),
phase_(phase),
dPtr_(nullptr),
aPtr_(nullptr)
{
if (diameterProperties.lookupOrDefault("storeD", false))
{
dRef();
}
if (diameterProperties.lookupOrDefault("storeA", false))
{
aRef();
}
}
phase_(phase)
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
@ -116,57 +55,8 @@ Foam::diameterModel::~diameterModel()
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
Foam::tmp<Foam::volScalarField> Foam::diameterModel::d() const
{
if (dPtr_.valid())
{
return dPtr_();
}
else
{
return calcD();
}
}
Foam::tmp<Foam::volScalarField> Foam::diameterModel::a() const
{
if (aPtr_.valid())
{
return aPtr_();
}
else
{
return calcA();
}
}
void Foam::diameterModel::correctNoStore()
{}
void Foam::diameterModel::correct()
{
correctNoStore();
if (dPtr_.valid())
{
tmp<volScalarField> td = calcD();
if (td.isTmp())
{
dPtr_() = td;
}
}
if (aPtr_.valid())
{
tmp<volScalarField> tA = calcA();
if (tA.isTmp())
{
aPtr_() = tA;
}
}
}
{}
bool Foam::diameterModel::read(const dictionary& phaseProperties)

View File

@ -59,29 +59,6 @@ class diameterModel
//- The phase that this model applies
const phaseModel& phase_;
//- Optionally stored diameter field
autoPtr<volScalarField> dPtr_;
//- Optionally stored surface area per unit volume field
autoPtr<volScalarField> aPtr_;
protected:
// Access
//- Get a reference to the stored diameter field
volScalarField& dRef();
//- Get a reference to the stored surface area per unit volume field
volScalarField& aRef();
//- Get the diameter field
virtual tmp<volScalarField> calcD() const = 0;
//- Get the surface area per unit volume field
virtual tmp<volScalarField> calcA() const = 0;
public:
@ -106,6 +83,7 @@ public:
// Constructors
//- Construct from dictionary and phase
diameterModel
(
const dictionary& diameterProperties,
@ -119,6 +97,7 @@ public:
// Selectors
//- Select from dictionary and phase
static autoPtr<diameterModel> New
(
const dictionary& diameterProperties,
@ -141,16 +120,13 @@ public:
}
//- Return the diameter
tmp<volScalarField> d() const;
virtual tmp<volScalarField> d() const = 0;
//- Return the surface area per unit volume
tmp<volScalarField> a() const;
virtual tmp<volScalarField> a() const = 0;
//- Correct the diameter field
virtual void correctNoStore();
//- Correct the diameter field and optionally store the results
void correct();
//- Correct the model
virtual void correct();
//- Read phaseProperties dictionary
virtual bool read(const dictionary& phaseProperties);

View File

@ -38,14 +38,6 @@ namespace diameterModels
}
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
Foam::tmp<Foam::volScalarField> Foam::diameterModels::isothermal::calcD() const
{
return d_;
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::diameterModels::isothermal::isothermal
@ -57,10 +49,18 @@ Foam::diameterModels::isothermal::isothermal
spherical(diameterProperties, phase),
d0_("d0", dimLength, diameterProperties),
p0_("p0", dimPressure, diameterProperties),
d_(dRef())
{
d_ = d0_;
}
d_
(
IOobject
(
IOobject::groupName("d", phase.name()),
phase.time().timeName(),
phase.mesh()
),
phase.mesh(),
d0_
)
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
@ -71,7 +71,13 @@ Foam::diameterModels::isothermal::~isothermal()
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::diameterModels::isothermal::correctNoStore()
Foam::tmp<Foam::volScalarField> Foam::diameterModels::isothermal::d() const
{
return d_;
}
void Foam::diameterModels::isothermal::correct()
{
const volScalarField& p = phase().db().lookupObject<volScalarField>("p");

View File

@ -61,15 +61,7 @@ class isothermal
dimensionedScalar p0_;
//- Diameter field
volScalarField& d_;
protected:
// Protected Member Functions
//- Get the diameter field
virtual tmp<volScalarField> calcD() const;
volScalarField d_;
public:
@ -80,7 +72,7 @@ public:
// Constructors
//- Construct from components
//- Construct from dictionary and phase
isothermal
(
const dictionary& diameterProperties,
@ -94,8 +86,11 @@ public:
// Member Functions
//- Correct the diameter field
virtual void correctNoStore();
//- Get the diameter field
virtual tmp<volScalarField> d() const;
//- Correct the model
virtual void correct();
//- Read phaseProperties dictionary
virtual bool read(const dictionary& phaseProperties);

View File

@ -40,14 +40,6 @@ namespace diameterModels
}
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
Foam::tmp<Foam::volScalarField> Foam::diameterModels::linearTsub::calcD() const
{
return d_;
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::diameterModels::linearTsub::linearTsub
@ -77,10 +69,18 @@ Foam::diameterModels::linearTsub::linearTsub
dimTemperature,
diameterProperties.lookupOrDefault("Tsub1", 13.5)
),
d_(dRef())
{
d_ = d1_;
}
d_
(
IOobject
(
IOobject::groupName("d", phase.name()),
phase.time().timeName(),
phase.mesh()
),
phase.mesh(),
d1_
)
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
@ -91,7 +91,13 @@ Foam::diameterModels::linearTsub::~linearTsub()
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::diameterModels::linearTsub::correctNoStore()
Foam::tmp<Foam::volScalarField> Foam::diameterModels::linearTsub::d() const
{
return d_;
}
void Foam::diameterModels::linearTsub::correct()
{
// Lookup the fluid model
const phaseSystem& fluid =

View File

@ -81,15 +81,7 @@ class linearTsub
dimensionedScalar Tsub1_;
//- Diameter field
volScalarField& d_;
protected:
// Protected Member Functions
//- Get the diameter field
virtual tmp<volScalarField> calcD() const;
volScalarField d_;
public:
@ -100,7 +92,7 @@ public:
// Constructors
//- Construct from components
//- Construct from dictionary and phase
linearTsub
(
const dictionary& diameterProperties,
@ -114,8 +106,11 @@ public:
// Member Functions
//- Correct the diameter field
virtual void correctNoStore();
//- Get the diameter field
virtual tmp<volScalarField> d() const;
//- Correct the model
virtual void correct();
//- Read phaseProperties dictionary
virtual bool read(const dictionary& phaseProperties);

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -37,15 +37,6 @@ namespace diameterModels
}
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
Foam::tmp<Foam::volScalarField>
Foam::diameterModels::spherical::calcA() const
{
return 6*phase()/d();
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::diameterModels::spherical::spherical
@ -58,6 +49,14 @@ Foam::diameterModels::spherical::spherical
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
Foam::tmp<Foam::volScalarField> Foam::diameterModels::spherical::a() const
{
return 6*phase()/d();
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::diameterModels::spherical::~spherical()

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -53,14 +53,6 @@ class spherical
:
public diameterModel
{
protected:
// Protected Member Functions
//- Get the diameter field
virtual tmp<volScalarField> calcA() const;
public:
//- Runtime type information
@ -69,6 +61,7 @@ public:
// Constructors
//- Construct from dictionary and phase
spherical
(
const dictionary& diameterProperties,
@ -78,6 +71,12 @@ public:
//- Destructor
virtual ~spherical();
// Member Functions
//- Get the surface area per unit volume field
virtual tmp<volScalarField> a() const;
};

View File

@ -135,41 +135,6 @@ void Foam::diameterModels::velocityGroup::scale()
}
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
Foam::tmp<Foam::volScalarField>
Foam::diameterModels::velocityGroup::calcD() const
{
return d_;
}
Foam::tmp<Foam::volScalarField>
Foam::diameterModels::velocityGroup::calcA() const
{
tmp<volScalarField> tA
(
volScalarField::New
(
"a",
phase().mesh(),
dimensionedScalar(inv(dimLength), Zero)
)
);
volScalarField& a = tA.ref();
forAll(sizeGroups_, i)
{
const sizeGroup& fi = sizeGroups_[i];
a += fi.a()*fi/fi.x();
}
return phase()*a;
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::diameterModels::velocityGroup::velocityGroup
@ -205,10 +170,8 @@ Foam::diameterModels::velocityGroup::velocityGroup
diameterProperties.lookup("sizeGroups"),
sizeGroup::iNew(phase, *this)
),
d_(dRef())
{
d_ = dsm();
}
d_(IOobject::groupName("d", phase.name()), dsm())
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
@ -219,7 +182,38 @@ Foam::diameterModels::velocityGroup::~velocityGroup()
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::diameterModels::velocityGroup::correctNoStore()
Foam::tmp<Foam::volScalarField> Foam::diameterModels::velocityGroup::d() const
{
return d_;
}
Foam::tmp<Foam::volScalarField> Foam::diameterModels::velocityGroup::a() const
{
tmp<volScalarField> tA
(
volScalarField::New
(
"a",
phase().mesh(),
dimensionedScalar(inv(dimLength), Zero)
)
);
volScalarField& a = tA.ref();
forAll(sizeGroups_, i)
{
const sizeGroup& fi = sizeGroups_[i];
a += fi.a()*fi/fi.x();
}
return phase()*a;
}
void Foam::diameterModels::velocityGroup::correct()
{
forAll(sizeGroups_, i)
{

View File

@ -108,7 +108,7 @@ class velocityGroup
PtrList<sizeGroup> sizeGroups_;
//- Sauter-mean diameter of the phase
volScalarField& d_;
volScalarField d_;
// Private Member Functions
@ -122,17 +122,6 @@ class velocityGroup
void scale();
protected:
// Protected Member Functions
//- Get the diameter field
virtual tmp<volScalarField> calcD() const;
//- Get the surface area per unit volume field
virtual tmp<volScalarField> calcA() const;
public:
//- Runtime type information
@ -141,7 +130,7 @@ public:
// Constructors
//- Construct from components
//- Construct from dictionary and phase
velocityGroup
(
const dictionary& diameterProperties,
@ -164,8 +153,14 @@ public:
//- Return sizeGroups belonging to this velocityGroup
inline const PtrList<sizeGroup>& sizeGroups() const;
//- Correct the diameter field
virtual void correctNoStore();
//- Get the diameter field
virtual tmp<volScalarField> d() const;
//- Get the surface area per unit volume field
virtual tmp<volScalarField> a() const;
//- Correct the model
virtual void correct();
//- Read diameterProperties dictionary
virtual bool read(const dictionary& diameterProperties);