Skip to content
Snippets Groups Projects
Commit 18905342 authored by Kutalmış Berçin's avatar Kutalmış Berçin
Browse files

STYLE: turbulenceFields: apply more recent OpenFOAM-coding practices

parent 4243291c
No related branches found
No related tags found
No related merge requests found
......@@ -129,43 +129,46 @@ Foam::functionObjects::turbulenceFields::turbulenceFields
bool Foam::functionObjects::turbulenceFields::read(const dictionary& dict)
{
fvMeshFunctionObject::read(dict);
if (dict.found("field"))
{
fieldSet_.insert(dict.get<word>("field"));
}
else
if (fvMeshFunctionObject::read(dict))
{
fieldSet_.insert(dict.get<wordList>("fields"));
}
if (dict.found("field"))
{
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_)
Info<< type() << " " << name() << ": ";
if (fieldSet_.size())
{
Info<< " " << modelName_ << ':' << f << nl;
Info<< "storing fields:" << nl;
for (const word& f : fieldSet_)
{
Info<< " " << modelName_ << ':' << f << nl;
}
Info<< endl;
}
Info<< endl;
}
else
{
Info<< "no fields requested to be stored" << nl << 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;
}
......
......@@ -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)
);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment