Commit 30291b8f authored by Mark Olesen's avatar Mark Olesen

ENH: refactor to use coeffDict for the models

- note: could also code to obtain values directly from the
  transportProperties IOdictionary.
parent f0a8404e
......@@ -12,17 +12,17 @@ IOdictionary transportProperties
autoPtr<frictionModel> friction
(
frictionModel::New("frictionModel", transportProperties, Us, h, pb)
frictionModel::New(transportProperties, Us, h, pb)
);
autoPtr<entrainmentModel> entrainment
(
entrainmentModel::New("entrainment", transportProperties, Us, h, hentrain, pb, tau)
entrainmentModel::New(transportProperties, Us, h, hentrain, pb, tau)
);
autoPtr<depositionModel> deposition
(
depositionModel::New("deposition", transportProperties, Us, h, hentrain, pb, tau)
depositionModel::New(transportProperties, Us, h, hentrain, pb, tau)
);
dimensionedScalar hmin(transportProperties.lookup("hmin"));
......
......@@ -47,18 +47,17 @@ namespace depositionModels
Foam::depositionModels::Stopingprofile::Stopingprofile
(
const word& name,
const dictionary& depositionProperties,
const areaVectorField &Us,
const areaScalarField &h,
const areaScalarField &hentrain,
const areaScalarField &pb,
const areaVectorField &tau
const areaVectorField& Us,
const areaScalarField& h,
const areaScalarField& hentrain,
const areaScalarField& pb,
const areaVectorField& tau
)
:
depositionModel(name, depositionProperties, Us, h, hentrain, pb, tau),
ud_(depositionProperties.subDict("StopingprofileCoeffs").lookup("ud")),
ad_(depositionProperties.subDict("StopingprofileCoeffs").lookup("ad")),
depositionModel(type(), depositionProperties, Us, h, hentrain, pb, tau),
ud_(coeffDict_.lookup("ud")),
ad_(coeffDict_.lookup("ad")),
gs_(Us.db().lookupObject<areaVectorField>("gs")),
gn_(Us.db().lookupObject<areaScalarField>("gn"))
{
......@@ -69,8 +68,8 @@ Foam::depositionModels::Stopingprofile::Stopingprofile
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
const Foam::areaScalarField &Foam::depositionModels::Stopingprofile::Sd() const
const Foam::areaScalarField&
Foam::depositionModels::Stopingprofile::Sd() const
{
const dimensionedScalar smallVel("small", dimVelocity, SMALL);
......@@ -97,15 +96,16 @@ const Foam::areaScalarField &Foam::depositionModels::Stopingprofile::Sd() const
return Sd_;
}
bool Foam::depositionModels::Stopingprofile::read
(
const dictionary& depositionProperties
)
{
depositionModel::read(depositionProperties);
readDict(type(), depositionProperties);
depositionProperties_.lookup("ud") >> ud_;
depositionProperties_.lookup("ad") >> ad_;
coeffDict_.lookup("ud") >> ud_;
coeffDict_.lookup("ad") >> ad_;
return true;
}
......
......@@ -67,10 +67,10 @@ class Stopingprofile
{
// Private data
//Deposion velocity parameter u_d
//- Deposition velocity parameter u_d
dimensionedScalar ud_;
//Formfactor for deposition curve
//- Form-factor for deposition curve
dimensionedScalar ad_;
//- Reference to the gravitation fields
......@@ -88,7 +88,6 @@ public:
//- Construct from components
Stopingprofile
(
const word& name,
const dictionary& frictionProperties,
const areaVectorField& Us,
const areaScalarField& h,
......@@ -103,8 +102,9 @@ public:
// Member Functions
//- Return Sink by deposition
virtual const areaScalarField &Sd() const;
virtual const areaScalarField& Sd() const;
//- Read depositionProperties dictionary
virtual bool read(const dictionary& depositionProperties);
......
......@@ -39,21 +39,38 @@ namespace Foam
}
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
void Foam::depositionModel::readDict
(
const word& type,
const dictionary& dict
)
{
depositionProperties_ = dict;
coeffDict_ = depositionProperties_.optionalSubDict(type + "Coeffs");
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::depositionModel::depositionModel
(
const word& name,
const word& type,
const dictionary& depositionProperties,
const areaVectorField &Us,
const areaScalarField &h,
const areaScalarField &hentrain,
const areaScalarField &pb,
const areaVectorField &tau
const areaVectorField& Us,
const areaScalarField& h,
const areaScalarField& hentrain,
const areaScalarField& pb,
const areaVectorField& tau
)
:
name_(name),
rho_(depositionProperties.lookup("rho")),
depositionProperties_(depositionProperties),
coeffDict_
(
depositionProperties_.optionalSubDict(type + "Coeffs")
),
rho_(depositionProperties_.lookup("rho")),
Us_(Us),
h_(h),
hentrain_(hentrain),
......@@ -78,14 +95,4 @@ Foam::depositionModel::depositionModel
}
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
bool Foam::depositionModel::read(const dictionary& depositionProperties)
{
depositionProperties_ = depositionProperties;
return true;
}
// ************************************************************************* //
......@@ -70,10 +70,11 @@ protected:
// Protected data
word name_;
dictionary depositionProperties_;
//- Model coefficients dictionary
dictionary coeffDict_;
//- The density
dimensionedScalar rho_;
......@@ -96,7 +97,11 @@ protected:
mutable areaScalarField Sd_;
// Private Member Functions
// Protected Member Functions
//- Read/update the depositionProperties and coeffDict dictionaries
void readDict(const word& type, const dictionary& dict);
//- Disallow copy construct
depositionModel(const depositionModel&) = delete;
......@@ -120,7 +125,6 @@ public:
depositionModel,
dictionary,
(
const word& name,
const dictionary& depositionProperties,
const areaVectorField& Us,
const areaScalarField& h,
......@@ -128,7 +132,7 @@ public:
const areaScalarField& pb,
const areaVectorField& tau
),
(name, depositionProperties, Us, h, hentrain, pb, tau)
(depositionProperties, Us, h, hentrain, pb, tau)
);
#endif
......@@ -138,7 +142,6 @@ public:
//- Return a reference to the selected deposition model
static autoPtr<depositionModel> New
(
const word& name,
const dictionary& depositionProperties,
const areaVectorField& Us,
const areaScalarField& h,
......@@ -153,7 +156,7 @@ public:
//- Construct from components
depositionModel
(
const word& name,
const word& type,
const dictionary& depositionProperties,
const areaVectorField& Us,
const areaScalarField& h,
......@@ -169,17 +172,25 @@ public:
// Member Functions
//- Return Sink by deposition
virtual const areaScalarField& Sd() const = 0;
//- Read depositionProperties dictionary
virtual bool read(const dictionary& depositionProperties) = 0;
//- Return the deposition properties dictionary
//- Return the friction properties dictionary
const dictionary& depositionProperties() const
{
return depositionProperties_;
}
//- Read depositionProperties dictionary
virtual bool read(const dictionary& depositionProperties) = 0;
//- Const access to the model coefficients dictionary
virtual const dictionary& coeffDict() const
{
return coeffDict_;
}
//- Return Sink by deposition
virtual const areaScalarField& Sd() const = 0;
};
......
......@@ -30,50 +30,38 @@ Author
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
autoPtr<depositionModel> depositionModel::New
Foam::autoPtr<Foam::depositionModel> Foam::depositionModel::New
(
const word& name,
const dictionary& deposition,
const areaVectorField &Us,
const areaScalarField &h,
const areaScalarField &hentrain,
const areaScalarField &pb,
const areaVectorField &tau
const areaVectorField& Us,
const areaScalarField& h,
const areaScalarField& hentrain,
const areaScalarField& pb,
const areaVectorField& tau
)
{
word depositionModelTypeName(deposition.lookup("depositionModel"));
const word modelName(deposition.lookup("depositionModel"));
Info<< "Selecting deposition model "
<< depositionModelTypeName << endl;
<< modelName << endl;
dictionaryConstructorTable::iterator cstrIter =
dictionaryConstructorTablePtr_->find(depositionModelTypeName);
auto cstrIter = dictionaryConstructorTablePtr_->cfind(modelName);
if (cstrIter == dictionaryConstructorTablePtr_->end())
if (!cstrIter.found())
{
FatalErrorIn
(
"depositionModel::New(...)"
) << "Unknown depositionModel type "
<< depositionModelTypeName << endl << endl
<< "Valid depositionModels are : " << endl
FatalErrorInFunction
<< "Unknown depositionModel " << modelName << nl << nl
<< "Valid types :" << nl
<< dictionaryConstructorTablePtr_->sortedToc()
<< exit(FatalError);
}
return autoPtr<depositionModel>
(cstrIter()(name, deposition, Us, h, hentrain, pb, tau));
(
cstrIter()(deposition, Us, h, hentrain, pb, tau)
);
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //
......@@ -44,34 +44,36 @@ namespace depositionModels
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::depositionModels::depositionOff::depositionOff
(const word& name,
(
const dictionary& depositionProperties,
const areaVectorField &Us,
const areaScalarField &h,
const areaScalarField &hentrain,
const areaScalarField &pb,
const areaVectorField &tau
const areaVectorField& Us,
const areaScalarField& h,
const areaScalarField& hentrain,
const areaScalarField& pb,
const areaVectorField& tau
)
:
depositionModel(name, depositionProperties, Us, h, hentrain, pb, tau)
depositionModel(type(), depositionProperties, Us, h, hentrain, pb, tau)
{
Info<< " deposition is Off" << endl << endl;
Info<< " deposition is Off" << nl << endl;
}
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
const Foam::areaScalarField &Foam::depositionModels::depositionOff::Sd() const
const Foam::areaScalarField&
Foam::depositionModels::depositionOff::Sd() const
{
return Sd_;
}
bool Foam::depositionModels::depositionOff::read
(
const dictionary& depositionProperties
)
{
depositionModel::read(depositionProperties);
readDict(type(), depositionProperties);
return true;
}
......
......@@ -46,7 +46,6 @@ Author
#include "autoPtr.H"
#include "faMatrices.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
......@@ -62,8 +61,6 @@ class depositionOff
:
public depositionModel
{
// Private data
public:
//- Runtime type information
......@@ -72,10 +69,9 @@ public:
// Constructors
//- construct from components
//- Construct from components
depositionOff
(
const word& name,
const dictionary& frictionProperties,
const areaVectorField& Us,
const areaScalarField& h,
......@@ -91,9 +87,8 @@ public:
// Member Functions
//- Return Sink by deposition
virtual const areaScalarField &Sd() const;
virtual const areaScalarField& Sd() const;
//- Read depositionProperties dictionary
virtual bool read(const dictionary& depositionProperties);
......
......@@ -47,29 +47,27 @@ namespace entrainmentModels
Foam::entrainmentModels::Erosionenergy::Erosionenergy
(
const word& name,
const dictionary& entrainmentProperties,
const areaVectorField &Us,
const areaScalarField &h,
const areaScalarField &hentrain,
const areaScalarField &pb,
const areaVectorField &tau
const areaVectorField& Us,
const areaScalarField& h,
const areaScalarField& hentrain,
const areaScalarField& pb,
const areaVectorField& tau
)
:
entrainmentModel(name, entrainmentProperties, Us, h, hentrain, pb, tau),
eb_(entrainmentProperties.subDict("ErosionenergyCoeffs").lookup("eb")),
entrainmentModel(type(), entrainmentProperties, Us, h, hentrain, pb, tau),
eb_(coeffDict_.lookup("eb")),
gs_(Us_.db().lookupObject<areaVectorField>("gs")),
gn_(Us_.db().lookupObject<areaScalarField>("gn"))
{
Info << " " << eb_ << endl << endl;
Info << " " << eb_ << nl << endl;
}
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
const Foam::areaScalarField &Foam::entrainmentModels::Erosionenergy::Sm() const
const Foam::areaScalarField&
Foam::entrainmentModels::Erosionenergy::Sm() const
{
Sm_ = (tau_&Us_)/eb_/rho_;
Sm_ = min(Sm_, hentrain_/Us_.db().time().deltaT());
......@@ -77,14 +75,15 @@ const Foam::areaScalarField &Foam::entrainmentModels::Erosionenergy::Sm() const
return Sm_;
}
bool Foam::entrainmentModels::Erosionenergy::read
(
const dictionary& entrainmentProperties
)
{
entrainmentModel::read(entrainmentProperties);
readDict(type(), entrainmentProperties);
entrainmentProperties_.lookup("eb") >> eb_;
coeffDict_.lookup("eb") >> eb_;
return true;
}
......
......@@ -51,7 +51,6 @@ Author
#include "faMatrices.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
......@@ -87,13 +86,12 @@ public:
//- Construct from components
Erosionenergy
(
const word& name,
const dictionary& frictionProperties,
const areaVectorField &Us,
const areaScalarField &h,
const areaScalarField &hentrain,
const areaScalarField &pb,
const areaVectorField &tau
const areaVectorField& Us,
const areaScalarField& h,
const areaScalarField& hentrain,
const areaScalarField& pb,
const areaVectorField& tau
);
......@@ -104,7 +102,7 @@ public:
// Member Functions
//- Return the Source by entrainment
virtual const areaScalarField &Sm() const;
virtual const areaScalarField& Sm() const;
//- Read entrainmentProperties dictionary
virtual bool read(const dictionary& entrainmentProperties);
......
......@@ -47,7 +47,6 @@ namespace entrainmentModels
Foam::entrainmentModels::Front::Front
(
const word& name,
const dictionary& entrainmentProperties,
const areaVectorField& Us,
const areaScalarField& h,
......@@ -56,18 +55,17 @@ Foam::entrainmentModels::Front::Front
const areaVectorField& tau
)
:
entrainmentModel(name, entrainmentProperties, Us, h, hentrain, pb, tau),
htrigger_(entrainmentProperties.subDict("FrontCoeffs").lookup("htrigger"))
entrainmentModel(type(), entrainmentProperties, Us, h, hentrain, pb, tau),
htrigger_(coeffDict_.lookup("htrigger"))
{
Info << " " << htrigger_ << endl << endl;
}
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
const Foam::areaScalarField& Foam::entrainmentModels::Front::Sm() const
const Foam::areaScalarField&
Foam::entrainmentModels::Front::Sm() const
{
const areaScalarField eflag(pos(h_-htrigger_));
......@@ -82,9 +80,9 @@ bool Foam::entrainmentModels::Front::read
const dictionary& entrainmentProperties
)
{
entrainmentModel::read(entrainmentProperties);
readDict(type(), entrainmentProperties);
entrainmentProperties_.lookup("htrigger") >> htrigger_;
coeffDict_.lookup("htrigger") >> htrigger_;
return true;
}
......
......@@ -82,7 +82,6 @@ public:
//- construct from components
Front
(
const word& name,
const dictionary& frictionProperties,
const areaVectorField& Us,
const areaScalarField& h,
......@@ -99,7 +98,7 @@ public:
// Member Functions
//- Return the Source by entrainment
virtual const areaScalarField &Sm() const;
virtual const areaScalarField& Sm() const;
//- Read entrainmentProperties dictionary
virtual bool read(const dictionary& entrainmentProperties);
......
......@@ -47,20 +47,19 @@ namespace entrainmentModels
Foam::entrainmentModels::IsslerFC::IsslerFC
(
const word& name,
const dictionary& entrainmentProperties,
const areaVectorField &Us,
const areaScalarField &h,
const areaScalarField &hentrain,
const areaScalarField &pb,
const areaVectorField &tau
const areaVectorField& Us,
const areaScalarField& h,
const areaScalarField& hentrain,
const areaScalarField& pb,
const areaVectorField& tau
)
:
entrainmentModel(name, entrainmentProperties, Us, h, hentrain, pb, tau),
tauc_(entrainmentProperties.subDict("IsslerFCCoeffs").lookup("tauc")),
mu_(entrainmentProperties.subDict("IsslerFCCoeffs").lookup("mu")),
entrainmentModel(type(), entrainmentProperties, Us, h, hentrain, pb, tau),
tauc_(coeffDict_.lookup("tauc")),
mu_(coeffDict_.lookup("mu")),
K_(entrainmentProperties.subDict("IsslerFCCoeffs").lookup("K")),
K_(coeffDict_.lookup("K")),
gs_(Us.db().lookupObject<areaVectorField>("gs")),
gn_(Us.db().lookupObject<areaScalarField>("gn"))
{
......@@ -70,8 +69,8 @@ Foam::entrainmentModels::IsslerFC::IsslerFC
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
const Foam::areaScalarField &Foam::entrainmentModels::IsslerFC::Sm() const
const Foam::areaScalarField&
Foam::entrainmentModels::IsslerFC::Sm() const
{
const dimensionedScalar smallVel("small", dimVelocity, SMALL);
......@@ -106,14 +105,15 @@ const Foam::areaScalarField &Foam::entrainmentModels::IsslerFC::Sm() const
return Sm_;
}
bool Foam::entrainmentModels::IsslerFC::read
(
const dictionary& entrainmentProperties
)
{
entrainmentModel::read(entrainmentProperties);
readDict(type(), entrainmentProperties);
entrainmentProperties_.lookup("tauc") >> tauc_;
coeffDict_.lookup("tauc") >> tauc_;
return true;
}
......
......@@ -49,8 +49,6 @@ Author
#include "autoPtr.H"
#include "faMatrices.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
......@@ -92,7 +90,6 @@ public:
//- Construct from components
IsslerFC
(
const word& name,
const dictionary& frictionProperties,
const areaVectorField& Us,
const areaScalarField& h,
......@@ -109,7 +106,7 @@ public:
// Member Functions
//- Return the Source by entrainment
virtual const areaScalarField &Sm() const;
virtual const areaScalarField& Sm() const;
//- Read entrainmentProperties dictionary
virtual bool read(const dictionary& entrainmentProperties);
......
......@@ -21,7 +21,6 @@ License
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Author
Matthias Rauter matthias.rauter@uibk.ac.at
......@@ -48,7 +47,6 @@ namespace entrainmentModels
Foam::entrainmentModels::Medina::Medina
(
const word& name,
const dictionary& entrainmentProperties,
const areaVectorField& Us,
const areaScalarField& h,
......@@ -57,9 +55,9 @@ Foam::entrainmentModels::Medina::Medina
const areaVectorField& tau
)
:
entrainmentModel(name, entrainmentProperties, Us, h, hentrain, pb, tau),
tauc_(entrainmentProperties.subDict("MedinaCoeffs").lookup("tauc")),
mu_(entrainmentProperties.subDict("MedinaCoeffs").lookup("mu")),
entrainmentModel(type(), entrainmentProperties, Us, h, hentrain, pb, tau),
tauc_(coeffDict_.lookup("tauc")),
mu_(coeffDict_.lookup("mu")),
gs_(Us_.db().lookupObject<areaVectorField>("gs")),
gn_(Us_.db().lookupObject<areaScalarField>("gn"))
{
......@@ -70,13 +68,14 @@ Foam::entrainmentModels::Medina::Medina
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
const Foam::areaScalarField &Foam::entrainmentModels::Medina::Sm() const
const Foam::areaScalarField&
Foam::entrainmentModels::Medina::Sm() const
{
areaScalarField taures(tauc_ + pb_*mu_);
//no entrainment in "dry" areas:
areaScalarField eflag(pos(h_*rho_*gn_-tauc_/10.));
areaScalarField hent(eflag*(mag(tau_) - taures)/(rho_*(gn_*mu_-mag(gs_))));
Sm_ = hent/Us_.db().time().deltaT();
Sm_ = max(Sm_, dimensionedScalar(dimVelocity));
......@@ -85,15 +84,16 @@ const Foam::areaScalarField &Foam::entrainmentModels::Medina::Sm() const
return Sm_;
}