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

INT: turbulenceFields: add phase support

ENH: turbulenceFields: add const specifier to compressible func
parent 0066746b
No related merge requests found
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com \\ / A nd | www.openfoam.com
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2013-2016 OpenFOAM Foundation Copyright (C) 2013-2020 OpenFOAM Foundation
Copyright (C) 2015-2021 OpenCFD Ltd. Copyright (C) 2015-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
...@@ -94,7 +94,10 @@ void Foam::functionObjects::turbulenceFields::initialise() ...@@ -94,7 +94,10 @@ void Foam::functionObjects::turbulenceFields::initialise()
{ {
for (const word& f : fieldSet_) for (const word& f : fieldSet_)
{ {
const word scopedName(prefix_ + f); const word scopedName
(
IOobject::groupName(prefix_ + f, phaseName_)
);
if (obr_.found(scopedName)) if (obr_.found(scopedName))
{ {
...@@ -111,13 +114,16 @@ void Foam::functionObjects::turbulenceFields::initialise() ...@@ -111,13 +114,16 @@ void Foam::functionObjects::turbulenceFields::initialise()
} }
bool Foam::functionObjects::turbulenceFields::compressible() bool Foam::functionObjects::turbulenceFields::compressible
(
const word& modelName
) const
{ {
if (obr_.foundObject<compressible::turbulenceModel>(modelName_)) if (obr_.foundObject<compressible::turbulenceModel>(modelName))
{ {
return true; return true;
} }
else if (obr_.foundObject<incompressible::turbulenceModel>(modelName_)) else if (obr_.foundObject<incompressible::turbulenceModel>(modelName))
{ {
return false; return false;
} }
...@@ -142,6 +148,7 @@ Foam::functionObjects::turbulenceFields::turbulenceFields ...@@ -142,6 +148,7 @@ Foam::functionObjects::turbulenceFields::turbulenceFields
fvMeshFunctionObject(name, runTime, dict), fvMeshFunctionObject(name, runTime, dict),
initialised_(false), initialised_(false),
prefix_(dict.getOrDefault<word>("prefix", "turbulenceProperties:")), prefix_(dict.getOrDefault<word>("prefix", "turbulenceProperties:")),
phaseName_(dict.getOrDefault<word>("phase", word::null)),
fieldSet_() fieldSet_()
{ {
read(dict); read(dict);
...@@ -155,6 +162,7 @@ bool Foam::functionObjects::turbulenceFields::read(const dictionary& dict) ...@@ -155,6 +162,7 @@ bool Foam::functionObjects::turbulenceFields::read(const dictionary& dict)
if (fvMeshFunctionObject::read(dict)) if (fvMeshFunctionObject::read(dict))
{ {
dict.readIfPresent("prefix", prefix_); dict.readIfPresent("prefix", prefix_);
dict.readIfPresent("phase", phaseName_);
if (dict.found("field")) if (dict.found("field"))
{ {
...@@ -171,7 +179,9 @@ bool Foam::functionObjects::turbulenceFields::read(const dictionary& dict) ...@@ -171,7 +179,9 @@ bool Foam::functionObjects::turbulenceFields::read(const dictionary& dict)
Info<< "storing fields:" << nl; Info<< "storing fields:" << nl;
for (const word& f : fieldSet_) for (const word& f : fieldSet_)
{ {
Info<< " " << prefix_ << f << nl; Info<< " "
<< IOobject::groupName(prefix_ + f, phaseName_)
<< nl;
} }
Info<< endl; Info<< endl;
} }
...@@ -196,12 +206,17 @@ bool Foam::functionObjects::turbulenceFields::execute() ...@@ -196,12 +206,17 @@ bool Foam::functionObjects::turbulenceFields::execute()
initialise(); initialise();
} }
const bool comp = compressible(); const word modelName
(
IOobject::groupName(modelName_, phaseName_)
);
const bool comp = compressible(modelName);
if (comp) if (comp)
{ {
const auto& model = const auto& model =
obr_.lookupObject<compressible::turbulenceModel>(modelName_); obr_.lookupObject<compressible::turbulenceModel>(modelName);
for (const word& f : fieldSet_) for (const word& f : fieldSet_)
{ {
...@@ -278,7 +293,7 @@ bool Foam::functionObjects::turbulenceFields::execute() ...@@ -278,7 +293,7 @@ bool Foam::functionObjects::turbulenceFields::execute()
else else
{ {
const auto& model = const auto& model =
obr_.lookupObject<incompressible::turbulenceModel>(modelName_); obr_.lookupObject<incompressible::turbulenceModel>(modelName);
for (const word& f : fieldSet_) for (const word& f : fieldSet_)
{ {
...@@ -351,7 +366,10 @@ bool Foam::functionObjects::turbulenceFields::write() ...@@ -351,7 +366,10 @@ bool Foam::functionObjects::turbulenceFields::write()
{ {
for (const word& f : fieldSet_) for (const word& f : fieldSet_)
{ {
const word scopedName(prefix_ + f); const word scopedName
(
IOobject::groupName(prefix_ + f, phaseName_)
);
writeObject(scopedName); writeObject(scopedName);
} }
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com \\ / A nd | www.openfoam.com
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2013-2016 OpenFOAM Foundation Copyright (C) 2013-2020 OpenFOAM Foundation
Copyright (C) 2015-2021 OpenCFD Ltd. Copyright (C) 2015-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
...@@ -65,6 +65,7 @@ Usage ...@@ -65,6 +65,7 @@ Usage
// Optional entries (runtime modifiable) // Optional entries (runtime modifiable)
prefix <word>; prefix <word>;
phase <word>;
// Inherited entries // Inherited entries
... ...
...@@ -79,6 +80,7 @@ Usage ...@@ -79,6 +80,7 @@ Usage
fields | Names of fields to store (see below) | wordList | yes | - fields | Names of fields to store (see below) | wordList | yes | -
field | Name of a field to store (see below) | word | yes | - field | Name of a field to store (see below) | word | yes | -
prefix | Name of output-field prefix | word | no | turbulenceProperties: prefix | Name of output-field prefix | word | no | turbulenceProperties:
phase | Name of operand phase | word | no | -
\endtable \endtable
where \c fields can include: where \c fields can include:
...@@ -199,6 +201,9 @@ protected: ...@@ -199,6 +201,9 @@ protected:
//- Name of output-field prefix //- Name of output-field prefix
word prefix_; word prefix_;
//- Name of operand phase
word phaseName_;
//- Fields to load //- Fields to load
wordHashSet fieldSet_; wordHashSet fieldSet_;
...@@ -209,7 +214,7 @@ protected: ...@@ -209,7 +214,7 @@ protected:
void initialise(); void initialise();
//- Return true if compressible turbulence model is identified //- Return true if compressible turbulence model is identified
bool compressible(); bool compressible(const word& modelName) const;
//- Process the turbulence field //- Process the turbulence field
template<class Type> template<class Type>
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com \\ / A nd | www.openfoam.com
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2012-2016 OpenFOAM Foundation Copyright (C) 2012-2020 OpenFOAM Foundation
Copyright (C) 2018-2021 OpenCFD Ltd. Copyright (C) 2018-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
...@@ -39,7 +39,10 @@ void Foam::functionObjects::turbulenceFields::processField ...@@ -39,7 +39,10 @@ void Foam::functionObjects::turbulenceFields::processField
{ {
typedef GeometricField<Type, fvPatchField, volMesh> FieldType; typedef GeometricField<Type, fvPatchField, volMesh> FieldType;
const word scopedName(prefix_ + fieldName); const word scopedName
(
IOobject::groupName(prefix_ + fieldName, phaseName_)
);
FieldType* fldPtr = obr_.getObjectPtr<FieldType>(scopedName); FieldType* fldPtr = obr_.getObjectPtr<FieldType>(scopedName);
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment