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")));
}
if (dict.lookupOrDefault<Switch>("prefix", false))
{
prefix_ = modelName() + ':';
}
else
{
prefix_ = word::null;
}
Info<< type() << " " << name() << ": ";
if (fieldSet_.size())
{
Info<< "storing fields:" << nl;
forAllConstIter(wordHashSet, fieldSet_, iter)
{
Info<< " " << modelName() << ':' << iter.key() << nl;
Info<< " " << prefix_ + iter.key() << nl;
}
Info<< endl;
}
@ -338,7 +347,7 @@ bool Foam::functionObjects::turbulenceFields::write()
{
forAllConstIter(wordHashSet, fieldSet_, iter)
{
const word fieldName = modelName() + ':' + iter.key();
const word fieldName = prefix_ + iter.key();
writeObject(fieldName);
}

View File

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

View File

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