diff --git a/src/finiteVolume/fields/fvPatchFields/derived/fanPressure/fanPressureFvPatchScalarField.C b/src/finiteVolume/fields/fvPatchFields/derived/fanPressure/fanPressureFvPatchScalarField.C index 9cf87f4f9586c1d1aff7dc04241dbc38446651f2..9e0726e6ac2f3df28f7eb2490a8cc5de1f9bb642 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/fanPressure/fanPressureFvPatchScalarField.C +++ b/src/finiteVolume/fields/fvPatchFields/derived/fanPressure/fanPressureFvPatchScalarField.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -134,17 +134,17 @@ void Foam::fanPressureFvPatchScalarField::updateCoeffs() int dir = 2*direction_ - 1; // Average volumetric flow rate - scalar aveFlowRate = 0; + scalar volFlowRate = 0; if (phi.dimensions() == dimVelocity*dimArea) { - aveFlowRate = dir*gSum(phip)/gSum(patch().magSf()); + volFlowRate = dir*gSum(phip); } else if (phi.dimensions() == dimVelocity*dimArea*dimDensity) { const scalarField& rhop = patch().lookupPatchField<volScalarField, scalar>(rhoName()); - aveFlowRate = dir*gSum(phip/rhop)/gSum(patch().magSf()); + volFlowRate = dir*gSum(phip/rhop); } else { @@ -157,7 +157,7 @@ void Foam::fanPressureFvPatchScalarField::updateCoeffs() } // Pressure drop for this flow rate - const scalar pdFan = fanCurve_(max(aveFlowRate, 0.0)); + const scalar pdFan = fanCurve_(max(volFlowRate, 0.0)); totalPressureFvPatchScalarField::updateCoeffs ( diff --git a/src/postProcessing/functionObjects/IO/removeRegisteredObject/removeRegisteredObject.C b/src/postProcessing/functionObjects/IO/removeRegisteredObject/removeRegisteredObject.C index f89aebd28e8287cec2a032fe7d2ad9d9e9580945..a2103db6e585262b3e865364ec9be28e7de06bf6 100644 --- a/src/postProcessing/functionObjects/IO/removeRegisteredObject/removeRegisteredObject.C +++ b/src/postProcessing/functionObjects/IO/removeRegisteredObject/removeRegisteredObject.C @@ -79,14 +79,6 @@ void Foam::removeRegisteredObject::execute() delete &obj; } } - else - { - WarningIn("Foam::removeRegisteredObject::write()") - << "Object " << objectNames_[i] << " not found in " - << "database. Available objects:" << nl << obr_.sortedToc() - << endl; - } - } } diff --git a/src/postProcessing/functionObjects/field/turbulenceFields/turbulenceFields.C b/src/postProcessing/functionObjects/field/turbulenceFields/turbulenceFields.C index ab21ab2242cf77639648386b09121424c30bae12..74fe73b80ca346c82928b93c4a7e1c96accf80e1 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<compressible::turbulenceModel>(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<incompressible::turbulenceModel>(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 1d33b65792235b69a69cdb61ae52365b1712dcd2..e62ee5b17439e749296d6b36d8e4aab0d95e2683 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<class Type> void processField ( const word& fieldName, - const GeometricField<Type, fvPatchField, volMesh>& value + const tmp<GeometricField<Type, fvPatchField, volMesh> >& tvalue ); diff --git a/src/postProcessing/functionObjects/field/turbulenceFields/turbulenceFieldsTemplates.C b/src/postProcessing/functionObjects/field/turbulenceFields/turbulenceFieldsTemplates.C index 44cd320c5fd30f3f62c87cfcc37c2d43fc74d0f7..67ac423e1fad1e33ccdbb87f49423740c834bfb2 100644 --- a/src/postProcessing/functionObjects/field/turbulenceFields/turbulenceFieldsTemplates.C +++ b/src/postProcessing/functionObjects/field/turbulenceFields/turbulenceFieldsTemplates.C @@ -31,19 +31,49 @@ template<class Type> void Foam::turbulenceFields::processField ( const word& fieldName, - const GeometricField<Type, fvPatchField, volMesh>& value + const tmp<GeometricField<Type, fvPatchField, volMesh> >& tvalue ) { typedef GeometricField<Type, fvPatchField, volMesh> FieldType; - if (obr_.foundObject<FieldType>(fieldName)) + + const word scopedName = modelName + "::" + fieldName; + + if (obr_.foundObject<FieldType>(scopedName)) { FieldType& fld = - const_cast<FieldType&>(obr_.lookupObject<FieldType>(fieldName)); - fld == value; + const_cast<FieldType&>(obr_.lookupObject<FieldType>(scopedName)); + fld == tvalue(); + } + else if (obr_.found(scopedName)) + { + WarningIn + ( + "void Foam::turbulenceFields::processField" + "(" + "const word&, " + "const tmp<GeometricField<Type, fvPatchField, volMesh> >&" + ")" + ) << "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 + ) + ); } }