functionObjects::turbulenceFields: The field name prefix "turbulenceProperties:" is now optional

By default the prefix is no longer added to the field names but the previous
behaviour can be reproduced by setting the optional "prefix" entry to "on" or
"yes".
This commit is contained in:
Henry Weller
2018-10-26 11:41:08 +01:00
parent 2249f8ad5c
commit fc3861dacf
3 changed files with 19 additions and 5 deletions

View File

@ -133,13 +133,22 @@ bool Foam::functionObjects::turbulenceFields::read(const dictionary& dict)
fieldSet_.insert(wordList(dict.lookup("fields"))); fieldSet_.insert(wordList(dict.lookup("fields")));
} }
if (dict.lookupOrDefault<Switch>("prefix", false))
{
prefix_ = modelName() + ':';
}
else
{
prefix_ = word::null;
}
Info<< type() << " " << name() << ": "; Info<< type() << " " << name() << ": ";
if (fieldSet_.size()) if (fieldSet_.size())
{ {
Info<< "storing fields:" << nl; Info<< "storing fields:" << nl;
forAllConstIter(wordHashSet, fieldSet_, iter) forAllConstIter(wordHashSet, fieldSet_, iter)
{ {
Info<< " " << modelName() << ':' << iter.key() << nl; Info<< " " << prefix_ + iter.key() << nl;
} }
Info<< endl; Info<< endl;
} }
@ -338,7 +347,7 @@ bool Foam::functionObjects::turbulenceFields::write()
{ {
forAllConstIter(wordHashSet, fieldSet_, iter) forAllConstIter(wordHashSet, fieldSet_, iter)
{ {
const word fieldName = modelName() + ':' + iter.key(); const word fieldName = prefix_ + iter.key();
writeObject(fieldName); writeObject(fieldName);
} }

View File

@ -52,8 +52,9 @@ Description
Usage Usage
\table \table
Property | Description | Required | Default value Property | Description | Required | Default value
type | type name: processorField | yes | type | Type name: processorField | yes |
fields | fields to store (see below) | yes | fields | Fields to store (see below) | yes |
prefix | If true prefix fields | no | no
\endtable \endtable
Where \c fields can include: Where \c fields can include:
@ -140,6 +141,10 @@ protected:
//- Fields to load //- Fields to load
wordHashSet fieldSet_; wordHashSet fieldSet_;
//- Optional field prefix to avoid name clashes
// Defaults to null
word prefix_;
// Protected Member Functions // Protected Member Functions

View File

@ -36,7 +36,7 @@ void Foam::functionObjects::turbulenceFields::processField
{ {
typedef GeometricField<Type, fvPatchField, volMesh> FieldType; typedef GeometricField<Type, fvPatchField, volMesh> FieldType;
const word scopedName = modelName() + ':' + fieldName; const word scopedName = prefix_ + fieldName;
if (obr_.foundObject<FieldType>(scopedName)) if (obr_.foundObject<FieldType>(scopedName))
{ {