diff --git a/src/functionObjects/field/turbulenceFields/turbulenceFields.C b/src/functionObjects/field/turbulenceFields/turbulenceFields.C index c445161ddbf835d57192403c47b46da9293fbc48..b8bf12f982293a1a6c08cfb4b1f518337a55b81b 100644 --- a/src/functionObjects/field/turbulenceFields/turbulenceFields.C +++ b/src/functionObjects/field/turbulenceFields/turbulenceFields.C @@ -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; diff --git a/src/functionObjects/field/turbulenceFields/turbulenceFields.H b/src/functionObjects/field/turbulenceFields/turbulenceFields.H index f796e1e753e143bbe9bfb95e4f0e0474a14200f8..de483bfa3c4ef83cf7c7b28f4a615e36f910d508 100644 --- a/src/functionObjects/field/turbulenceFields/turbulenceFields.H +++ b/src/functionObjects/field/turbulenceFields/turbulenceFields.H @@ -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_; diff --git a/src/functionObjects/field/turbulenceFields/turbulenceFieldsTemplates.C b/src/functionObjects/field/turbulenceFields/turbulenceFieldsTemplates.C index 45df782cd4bbe7a327444ec005330477a8c0b859..6d4cc9065863c6103a995a58d314a833cd78e157 100644 --- a/src/functionObjects/field/turbulenceFields/turbulenceFieldsTemplates.C +++ b/src/functionObjects/field/turbulenceFields/turbulenceFieldsTemplates.C @@ -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,