diff --git a/src/postProcessing/functionObjects/field/turbulenceFields/turbulenceFields.C b/src/postProcessing/functionObjects/field/turbulenceFields/turbulenceFields.C index ab21ab2242..74fe73b80c 100644 --- a/src/postProcessing/functionObjects/field/turbulenceFields/turbulenceFields.C +++ b/src/postProcessing/functionObjects/field/turbulenceFields/turbulenceFields.C @@ -85,20 +85,6 @@ bool Foam::turbulenceFields::compressible() } -Foam::IOobject Foam::turbulenceFields::io(const word& fieldName) const -{ - return - IOobject - ( - fieldName, - obr_.time().timeName(), - obr_, - IOobject::READ_IF_PRESENT, - IOobject::NO_WRITE - ); -} - - // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // Foam::turbulenceFields::turbulenceFields @@ -147,7 +133,22 @@ void Foam::turbulenceFields::read(const dictionary& dict) { if (active_) { - dict.lookup("fields") >> fieldSet_; + fieldSet_.insert(wordList(dict.lookup("fields"))); + + Info<< type() << ": "; + if (fieldSet_.size()) + { + Info<< "storing fields:" << nl; + forAllConstIter(wordHashSet, fieldSet_, iter) + { + Info<< " " << modelName << "::" << iter.key() << nl; + } + Info<< endl; + } + else + { + Info<< "no fields requested to be stored" << nl << endl; + } execute(); } @@ -168,9 +169,9 @@ void Foam::turbulenceFields::execute() const compressible::turbulenceModel& model = obr_.lookupObject(modelName); - forAll(fieldSet_, fieldI) + forAllConstIter(wordHashSet, fieldSet_, iter) { - const word& f = fieldSet_[fieldI]; + const word& f = iter.key(); switch (compressibleFieldNames_[f]) { case cfR: @@ -216,9 +217,9 @@ void Foam::turbulenceFields::execute() const incompressible::turbulenceModel& model = obr_.lookupObject(modelName); - forAll(fieldSet_, fieldI) + forAllConstIter(wordHashSet, fieldSet_, iter) { - const word& f = fieldSet_[fieldI]; + const word& f = iter.key(); switch (incompressibleFieldNames_[f]) { case ifR: diff --git a/src/postProcessing/functionObjects/field/turbulenceFields/turbulenceFields.H b/src/postProcessing/functionObjects/field/turbulenceFields/turbulenceFields.H index 1d33b65792..e62ee5b174 100644 --- a/src/postProcessing/functionObjects/field/turbulenceFields/turbulenceFields.H +++ b/src/postProcessing/functionObjects/field/turbulenceFields/turbulenceFields.H @@ -27,16 +27,20 @@ Class Description Stores turbulence fields on the mesh database for further manipulation. + Fields are stored as copies of the original, with the prefix + "tubulenceModel::", e.g. + + turbulenceModel::R + SourceFiles turbulenceFields.C - IOturbulenceFields.H \*---------------------------------------------------------------------------*/ #ifndef turbulenceFields_H #define turbulenceFields_H -#include "wordList.H" +#include "HashSet.H" #include "IOobject.H" #include "NamedEnum.H" #include "pointField.H" @@ -96,7 +100,7 @@ protected: bool active_; //- Fields to load - wordList fieldSet_; + wordHashSet fieldSet_; // Protected Member Functions @@ -110,15 +114,12 @@ protected: //- Return true if compressible turbulence model is identified bool compressible(); - //- Helper function to return IOobject - IOobject io(const word& fieldName) const; - //- Process the turbulence field template void processField ( const word& fieldName, - const GeometricField& value + const tmp >& tvalue ); diff --git a/src/postProcessing/functionObjects/field/turbulenceFields/turbulenceFieldsTemplates.C b/src/postProcessing/functionObjects/field/turbulenceFields/turbulenceFieldsTemplates.C index 44cd320c5f..03768c982d 100644 --- a/src/postProcessing/functionObjects/field/turbulenceFields/turbulenceFieldsTemplates.C +++ b/src/postProcessing/functionObjects/field/turbulenceFields/turbulenceFieldsTemplates.C @@ -31,19 +31,49 @@ template void Foam::turbulenceFields::processField ( const word& fieldName, - const GeometricField& value + const tmp >& tvalue ) { typedef GeometricField FieldType; - if (obr_.foundObject(fieldName)) + + const word scopedName = modelName + "::" + fieldName; + + if (obr_.foundObject(scopedName)) { FieldType& fld = const_cast(obr_.lookupObject(fieldName)); - fld == value; + fld == tvalue(); + } + else if (obr_.found(scopedName)) + { + WarningIn + ( + "void Foam::turbulenceFields::processField" + "(" + "const word&, " + "const tmp >&" + ")" + ) << "Cannot store turbulence field " << scopedName + << " since an object with that name already exists" + << nl << endl; } else { - obr_.store(new FieldType(io(fieldName), value)); + obr_.store + ( + new FieldType + ( + IOobject + ( + scopedName, + obr_.time().timeName(), + obr_, + IOobject::READ_IF_PRESENT, + IOobject::NO_WRITE + ), + tvalue + ) + ); } }