mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: turbulenceFields: enable custom prefix for output fields
This commit is contained in:
committed by
Andrew Heather
parent
2e703543ff
commit
14b328d990
@ -94,12 +94,12 @@ void Foam::functionObjects::turbulenceFields::initialise()
|
||||
{
|
||||
for (const word& f : fieldSet_)
|
||||
{
|
||||
const word scopedName(modelName_ + ':' + f);
|
||||
const word localName(IOobject::scopedName(prefix_, f));
|
||||
|
||||
if (obr_.found(scopedName))
|
||||
if (obr_.found(localName))
|
||||
{
|
||||
WarningInFunction
|
||||
<< "Cannot store turbulence field " << scopedName
|
||||
<< "Cannot store turbulence field " << localName
|
||||
<< " since an object with that name already exists"
|
||||
<< nl << endl;
|
||||
|
||||
@ -141,6 +141,7 @@ Foam::functionObjects::turbulenceFields::turbulenceFields
|
||||
:
|
||||
fvMeshFunctionObject(name, runTime, dict),
|
||||
initialised_(false),
|
||||
prefix_(dict.getOrDefault<word>("prefix", "turbulenceProperties")),
|
||||
fieldSet_()
|
||||
{
|
||||
read(dict);
|
||||
@ -153,6 +154,8 @@ bool Foam::functionObjects::turbulenceFields::read(const dictionary& dict)
|
||||
{
|
||||
if (fvMeshFunctionObject::read(dict))
|
||||
{
|
||||
dict.readIfPresent("prefix", prefix_);
|
||||
|
||||
if (dict.found("field"))
|
||||
{
|
||||
fieldSet_.insert(dict.get<word>("field"));
|
||||
@ -168,7 +171,7 @@ bool Foam::functionObjects::turbulenceFields::read(const dictionary& dict)
|
||||
Info<< "storing fields:" << nl;
|
||||
for (const word& f : fieldSet_)
|
||||
{
|
||||
Info<< " " << modelName_ << ':' << f << nl;
|
||||
Info<< " " << IOobject::scopedName(prefix_, f) << nl;
|
||||
}
|
||||
Info<< endl;
|
||||
}
|
||||
@ -348,9 +351,9 @@ bool Foam::functionObjects::turbulenceFields::write()
|
||||
{
|
||||
for (const word& f : fieldSet_)
|
||||
{
|
||||
const word scopedName(modelName_ + ':' + f);
|
||||
const word localName(IOobject::scopedName(prefix_, f));
|
||||
|
||||
writeObject(scopedName);
|
||||
writeObject(localName);
|
||||
}
|
||||
Info<< endl;
|
||||
|
||||
|
||||
@ -35,8 +35,8 @@ Description
|
||||
output during calculations, and stores/writes them on the mesh database
|
||||
for further manipulation.
|
||||
|
||||
Fields are stored as copies of the original, with the prefix
|
||||
"turbulenceModel:", e.g.:
|
||||
Fields are stored as copies of the original with a user-defined prefix
|
||||
e.g. a prefix of \c turbulenceModel yields the following for field \c R:
|
||||
|
||||
\verbatim
|
||||
turbulenceModel:R
|
||||
@ -79,6 +79,9 @@ Usage
|
||||
// Option-2
|
||||
field R;
|
||||
|
||||
// Optional entries (runtime modifiable)
|
||||
prefix <word>;
|
||||
|
||||
// Inherited entries
|
||||
...
|
||||
}
|
||||
@ -91,6 +94,7 @@ Usage
|
||||
libs | Library name: fieldFunctionObjects | word | yes | -
|
||||
fields | Names of fields to store (see below) | wordList | yes | -
|
||||
field | Name of a field to store (see below) | word | yes | -
|
||||
prefix | Name of output-field prefix | word | no | turbulenceProperties
|
||||
\endtable
|
||||
|
||||
where \c fields can include:
|
||||
@ -213,6 +217,9 @@ protected:
|
||||
//- Flag to track initialisation
|
||||
bool initialised_;
|
||||
|
||||
//- Name of output-field prefix
|
||||
word prefix_;
|
||||
|
||||
//- Fields to load
|
||||
wordHashSet fieldSet_;
|
||||
|
||||
|
||||
@ -39,9 +39,9 @@ void Foam::functionObjects::turbulenceFields::processField
|
||||
{
|
||||
typedef GeometricField<Type, fvPatchField, volMesh> FieldType;
|
||||
|
||||
const word scopedName(modelName_ + ':' + fieldName);
|
||||
const word localName(IOobject::scopedName(prefix_, fieldName));
|
||||
|
||||
FieldType* fldPtr = obr_.getObjectPtr<FieldType>(scopedName);
|
||||
FieldType* fldPtr = obr_.getObjectPtr<FieldType>(localName);
|
||||
|
||||
if (fldPtr)
|
||||
{
|
||||
@ -55,7 +55,7 @@ void Foam::functionObjects::turbulenceFields::processField
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
scopedName,
|
||||
localName,
|
||||
obr_.time().timeName(),
|
||||
obr_,
|
||||
IOobject::READ_IF_PRESENT,
|
||||
|
||||
Reference in New Issue
Block a user