STYLE: turbulenceFields: apply more recent OpenFOAM-coding practices

This commit is contained in:
Kutalmis Bercin
2021-06-23 17:24:15 +01:00
committed by Andrew Heather
parent 99291a7ac5
commit c6c575052f
2 changed files with 36 additions and 34 deletions

View File

@ -129,43 +129,46 @@ Foam::functionObjects::turbulenceFields::turbulenceFields
bool Foam::functionObjects::turbulenceFields::read(const dictionary& dict)
{
fvMeshFunctionObject::read(dict);
if (dict.found("field"))
if (fvMeshFunctionObject::read(dict))
{
fieldSet_.insert(dict.get<word>("field"));
}
else
{
fieldSet_.insert(dict.get<wordList>("fields"));
}
Info<< type() << " " << name() << ": ";
if (fieldSet_.size())
{
Info<< "storing fields:" << nl;
for (const word& f : fieldSet_)
if (dict.found("field"))
{
Info<< " " << modelName_ << ':' << f << nl;
fieldSet_.insert(dict.get<word>("field"));
}
Info<< endl;
}
else
{
Info<< "no fields requested to be stored" << nl << endl;
else
{
fieldSet_.insert(dict.get<wordList>("fields"));
}
Info<< type() << " " << name() << ": ";
if (fieldSet_.size())
{
Info<< "storing fields:" << nl;
for (const word& f : fieldSet_)
{
Info<< " " << modelName_ << ':' << f << nl;
}
Info<< endl;
}
else
{
Info<< "no fields requested to be stored" << nl << endl;
}
return true;
}
return true;
return false;
}
bool Foam::functionObjects::turbulenceFields::execute()
{
bool comp = compressible();
const bool comp = compressible();
if (comp)
{
const compressible::turbulenceModel& model =
const auto& model =
obr_.lookupObject<compressible::turbulenceModel>(modelName_);
for (const word& f : fieldSet_)
@ -242,7 +245,7 @@ bool Foam::functionObjects::turbulenceFields::execute()
}
else
{
const incompressible::turbulenceModel& model =
const auto& model =
obr_.lookupObject<incompressible::turbulenceModel>(modelName_);
for (const word& f : fieldSet_)
@ -316,9 +319,11 @@ bool Foam::functionObjects::turbulenceFields::write()
{
for (const word& f : fieldSet_)
{
const word fieldName = modelName_ + ':' + f;
writeObject(fieldName);
const word scopedName(modelName_ + ':' + f);
writeObject(scopedName);
}
Info<< endl;
return true;
}

View File

@ -39,7 +39,7 @@ void Foam::functionObjects::turbulenceFields::processField
{
typedef GeometricField<Type, fvPatchField, volMesh> FieldType;
const word scopedName = modelName_ + ':' + fieldName;
const word scopedName(modelName_ + ':' + fieldName);
FieldType* fldPtr = obr_.getObjectPtr<FieldType>(scopedName);
@ -99,17 +99,14 @@ Foam::functionObjects::turbulenceFields::L
const Model& model
) const
{
const scalar Cmu = 0.09;
// Assume k and epsilon are available
const volScalarField k(model.k());
const volScalarField epsilon(model.epsilon());
const dimensionedScalar eps0("eps0", epsilon.dimensions(), SMALL);
const scalar Cmu = 0.09;
const dimensionedScalar eps0(sqr(dimVelocity)/dimTime, SMALL);
return tmp<volScalarField>::New
(
"L.tmp",
pow(Cmu, 0.75)*pow(k, 1.5)/(epsilon + eps0)
pow(Cmu, 0.75)*pow(model.k(), 1.5)/(model.epsilon() + eps0)
);
}