From 218afb645a492b2071f47028b134762421be513a Mon Sep 17 00:00:00 2001 From: Kutalmis Bercin <kutalmis.bercin@esi-group.com> Date: Fri, 25 Jun 2021 18:49:00 +0100 Subject: [PATCH] ENH: turbulenceFields: enable custom prefix for output fields --- .../field/turbulenceFields/turbulenceFields.C | 9 ++++++--- .../field/turbulenceFields/turbulenceFields.H | 14 +++++++------- .../turbulenceFields/turbulenceFieldsTemplates.C | 2 +- 3 files changed, 14 insertions(+), 11 deletions(-) diff --git a/src/functionObjects/field/turbulenceFields/turbulenceFields.C b/src/functionObjects/field/turbulenceFields/turbulenceFields.C index c445161ddbf..894f8adf8f8 100644 --- a/src/functionObjects/field/turbulenceFields/turbulenceFields.C +++ b/src/functionObjects/field/turbulenceFields/turbulenceFields.C @@ -94,7 +94,7 @@ void Foam::functionObjects::turbulenceFields::initialise() { for (const word& f : fieldSet_) { - const word scopedName(modelName_ + ':' + f); + const word scopedName(prefix_ + f); if (obr_.found(scopedName)) { @@ -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<< " " << prefix_ << f << nl; } Info<< endl; } @@ -348,7 +351,7 @@ bool Foam::functionObjects::turbulenceFields::write() { for (const word& f : fieldSet_) { - const word scopedName(modelName_ + ':' + f); + const word scopedName(prefix_ + f); writeObject(scopedName); } diff --git a/src/functionObjects/field/turbulenceFields/turbulenceFields.H b/src/functionObjects/field/turbulenceFields/turbulenceFields.H index 01b6d0fd1c2..05ed772e476 100644 --- a/src/functionObjects/field/turbulenceFields/turbulenceFields.H +++ b/src/functionObjects/field/turbulenceFields/turbulenceFields.H @@ -35,13 +35,6 @@ 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.: - - \verbatim - turbulenceModel:R - \endverbatim - Operands: \table Operand | Type | Location @@ -85,6 +78,9 @@ Usage // Option-2 field R; + // Optional entries (runtime modifiable) + prefix <word>; + // Inherited entries ... } @@ -97,6 +93,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: @@ -214,6 +211,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 eff64c673ce..a5452640d57 100644 --- a/src/functionObjects/field/turbulenceFields/turbulenceFieldsTemplates.C +++ b/src/functionObjects/field/turbulenceFields/turbulenceFieldsTemplates.C @@ -40,7 +40,7 @@ void Foam::functionObjects::turbulenceFields::processField { typedef GeometricField<Type, fvPatchField, volMesh> FieldType; - const word scopedName(modelName_ + ':' + fieldName); + const word scopedName(prefix_ + fieldName); FieldType* fldPtr = obr_.getObjectPtr<FieldType>(scopedName); -- GitLab