mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: Improvements to the turbulenceFields function object
This commit is contained in:
@ -85,20 +85,6 @@ bool Foam::turbulenceFields::compressible()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Foam::IOobject Foam::turbulenceFields::io(const word& fieldName) const
|
|
||||||
{
|
|
||||||
return
|
|
||||||
IOobject
|
|
||||||
(
|
|
||||||
fieldName,
|
|
||||||
obr_.time().timeName(),
|
|
||||||
obr_,
|
|
||||||
IOobject::READ_IF_PRESENT,
|
|
||||||
IOobject::NO_WRITE
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
Foam::turbulenceFields::turbulenceFields
|
Foam::turbulenceFields::turbulenceFields
|
||||||
@ -147,7 +133,22 @@ void Foam::turbulenceFields::read(const dictionary& dict)
|
|||||||
{
|
{
|
||||||
if (active_)
|
if (active_)
|
||||||
{
|
{
|
||||||
dict.lookup("fields") >> fieldSet_;
|
fieldSet_.insert(wordList(dict.lookup("fields")));
|
||||||
|
|
||||||
|
Info<< type() << ": ";
|
||||||
|
if (fieldSet_.size())
|
||||||
|
{
|
||||||
|
Info<< "storing fields:" << nl;
|
||||||
|
forAllConstIter(wordHashSet, fieldSet_, iter)
|
||||||
|
{
|
||||||
|
Info<< " " << modelName << "::" << iter.key() << nl;
|
||||||
|
}
|
||||||
|
Info<< endl;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Info<< "no fields requested to be stored" << nl << endl;
|
||||||
|
}
|
||||||
|
|
||||||
execute();
|
execute();
|
||||||
}
|
}
|
||||||
@ -168,9 +169,9 @@ void Foam::turbulenceFields::execute()
|
|||||||
const compressible::turbulenceModel& model =
|
const compressible::turbulenceModel& model =
|
||||||
obr_.lookupObject<compressible::turbulenceModel>(modelName);
|
obr_.lookupObject<compressible::turbulenceModel>(modelName);
|
||||||
|
|
||||||
forAll(fieldSet_, fieldI)
|
forAllConstIter(wordHashSet, fieldSet_, iter)
|
||||||
{
|
{
|
||||||
const word& f = fieldSet_[fieldI];
|
const word& f = iter.key();
|
||||||
switch (compressibleFieldNames_[f])
|
switch (compressibleFieldNames_[f])
|
||||||
{
|
{
|
||||||
case cfR:
|
case cfR:
|
||||||
@ -216,9 +217,9 @@ void Foam::turbulenceFields::execute()
|
|||||||
const incompressible::turbulenceModel& model =
|
const incompressible::turbulenceModel& model =
|
||||||
obr_.lookupObject<incompressible::turbulenceModel>(modelName);
|
obr_.lookupObject<incompressible::turbulenceModel>(modelName);
|
||||||
|
|
||||||
forAll(fieldSet_, fieldI)
|
forAllConstIter(wordHashSet, fieldSet_, iter)
|
||||||
{
|
{
|
||||||
const word& f = fieldSet_[fieldI];
|
const word& f = iter.key();
|
||||||
switch (incompressibleFieldNames_[f])
|
switch (incompressibleFieldNames_[f])
|
||||||
{
|
{
|
||||||
case ifR:
|
case ifR:
|
||||||
|
|||||||
@ -27,16 +27,20 @@ Class
|
|||||||
Description
|
Description
|
||||||
Stores turbulence fields on the mesh database for further manipulation.
|
Stores turbulence fields on the mesh database for further manipulation.
|
||||||
|
|
||||||
|
Fields are stored as copies of the original, with the prefix
|
||||||
|
"tubulenceModel::", e.g.
|
||||||
|
|
||||||
|
turbulenceModel::R
|
||||||
|
|
||||||
SourceFiles
|
SourceFiles
|
||||||
turbulenceFields.C
|
turbulenceFields.C
|
||||||
IOturbulenceFields.H
|
|
||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#ifndef turbulenceFields_H
|
#ifndef turbulenceFields_H
|
||||||
#define turbulenceFields_H
|
#define turbulenceFields_H
|
||||||
|
|
||||||
#include "wordList.H"
|
#include "HashSet.H"
|
||||||
#include "IOobject.H"
|
#include "IOobject.H"
|
||||||
#include "NamedEnum.H"
|
#include "NamedEnum.H"
|
||||||
#include "pointField.H"
|
#include "pointField.H"
|
||||||
@ -96,7 +100,7 @@ protected:
|
|||||||
bool active_;
|
bool active_;
|
||||||
|
|
||||||
//- Fields to load
|
//- Fields to load
|
||||||
wordList fieldSet_;
|
wordHashSet fieldSet_;
|
||||||
|
|
||||||
|
|
||||||
// Protected Member Functions
|
// Protected Member Functions
|
||||||
@ -110,15 +114,12 @@ protected:
|
|||||||
//- Return true if compressible turbulence model is identified
|
//- Return true if compressible turbulence model is identified
|
||||||
bool compressible();
|
bool compressible();
|
||||||
|
|
||||||
//- Helper function to return IOobject
|
|
||||||
IOobject io(const word& fieldName) const;
|
|
||||||
|
|
||||||
//- Process the turbulence field
|
//- Process the turbulence field
|
||||||
template<class Type>
|
template<class Type>
|
||||||
void processField
|
void processField
|
||||||
(
|
(
|
||||||
const word& fieldName,
|
const word& fieldName,
|
||||||
const GeometricField<Type, fvPatchField, volMesh>& value
|
const tmp<GeometricField<Type, fvPatchField, volMesh> >& tvalue
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -31,19 +31,49 @@ template<class Type>
|
|||||||
void Foam::turbulenceFields::processField
|
void Foam::turbulenceFields::processField
|
||||||
(
|
(
|
||||||
const word& fieldName,
|
const word& fieldName,
|
||||||
const GeometricField<Type, fvPatchField, volMesh>& value
|
const tmp<GeometricField<Type, fvPatchField, volMesh> >& tvalue
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
typedef GeometricField<Type, fvPatchField, volMesh> FieldType;
|
typedef GeometricField<Type, fvPatchField, volMesh> FieldType;
|
||||||
if (obr_.foundObject<FieldType>(fieldName))
|
|
||||||
|
const word scopedName = modelName + "::" + fieldName;
|
||||||
|
|
||||||
|
if (obr_.foundObject<FieldType>(scopedName))
|
||||||
{
|
{
|
||||||
FieldType& fld =
|
FieldType& fld =
|
||||||
const_cast<FieldType&>(obr_.lookupObject<FieldType>(fieldName));
|
const_cast<FieldType&>(obr_.lookupObject<FieldType>(fieldName));
|
||||||
fld == value;
|
fld == tvalue();
|
||||||
|
}
|
||||||
|
else if (obr_.found(scopedName))
|
||||||
|
{
|
||||||
|
WarningIn
|
||||||
|
(
|
||||||
|
"void Foam::turbulenceFields::processField"
|
||||||
|
"("
|
||||||
|
"const word&, "
|
||||||
|
"const tmp<GeometricField<Type, fvPatchField, volMesh> >&"
|
||||||
|
")"
|
||||||
|
) << "Cannot store turbulence field " << scopedName
|
||||||
|
<< " since an object with that name already exists"
|
||||||
|
<< nl << endl;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
obr_.store(new FieldType(io(fieldName), value));
|
obr_.store
|
||||||
|
(
|
||||||
|
new FieldType
|
||||||
|
(
|
||||||
|
IOobject
|
||||||
|
(
|
||||||
|
scopedName,
|
||||||
|
obr_.time().timeName(),
|
||||||
|
obr_,
|
||||||
|
IOobject::READ_IF_PRESENT,
|
||||||
|
IOobject::NO_WRITE
|
||||||
|
),
|
||||||
|
tvalue
|
||||||
|
)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user