diff --git a/src/postProcessing/functionObjects/IO/writeRegisteredObject/writeRegisteredObject.C b/src/postProcessing/functionObjects/IO/writeRegisteredObject/writeRegisteredObject.C index e9357407de..0f02f40194 100644 --- a/src/postProcessing/functionObjects/IO/writeRegisteredObject/writeRegisteredObject.C +++ b/src/postProcessing/functionObjects/IO/writeRegisteredObject/writeRegisteredObject.C @@ -67,28 +67,6 @@ void Foam::writeRegisteredObject::read(const dictionary& dict) if (active_) { dict.lookup("objectNames") >> objectNames_; - - forAll(objectNames_, i) - { - if (obr_.foundObject(objectNames_[i])) - { - regIOobject& obj = - const_cast - ( - obr_.lookupObject(objectNames_[i]) - ); - obj.writeOpt() = IOobject::NO_WRITE; - } - else - { - FatalErrorIn - ( - "Foam::writeRegisteredObject::read(const dictionary&)" - ) << "Object " << objectNames_[i] << " not found in " - << "database. Available objects are:" << nl << obr_.toc() - << nl << exit(FatalError); - } - } } } @@ -111,9 +89,27 @@ void Foam::writeRegisteredObject::write() { forAll(objectNames_, i) { - const regIOobject& obj = - obr_.lookupObject(objectNames_[i]); - obj.write(); + if (obr_.foundObject(objectNames_[i])) + { + regIOobject& obj = + const_cast + ( + obr_.lookupObject(objectNames_[i]) + ); + // Switch off automatic writing to prevent double write + obj.writeOpt() = IOobject::NO_WRITE; + obj.write(); + } + else + { + WarningIn + ( + "Foam::writeRegisteredObject::read(const dictionary&)" + ) << "Object " << objectNames_[i] << " not found in " + << "database. Available objects are:" << nl << obr_.toc() + << endl; + } + } } } diff --git a/src/postProcessing/functionObjects/field/fieldValues/cellSource/cellSource.C b/src/postProcessing/functionObjects/field/fieldValues/cellSource/cellSource.C index f722119859..ddeaf583b5 100644 --- a/src/postProcessing/functionObjects/field/fieldValues/cellSource/cellSource.C +++ b/src/postProcessing/functionObjects/field/fieldValues/cellSource/cellSource.C @@ -45,13 +45,14 @@ namespace Foam fieldValues::cellSource::sourceTypeNames_; template<> - const char* NamedEnum:: + const char* NamedEnum:: names[] = { - "none", "sum", "volAverage", "volIntegrate", "weightedAverage" + "none", "sum", "volAverage", + "volIntegrate", "weightedAverage", "min", "max" }; - const NamedEnum + const NamedEnum fieldValues::cellSource::operationTypeNames_; } diff --git a/src/postProcessing/functionObjects/field/fieldValues/cellSource/cellSource.H b/src/postProcessing/functionObjects/field/fieldValues/cellSource/cellSource.H index 8cea808737..8108f7891c 100644 --- a/src/postProcessing/functionObjects/field/fieldValues/cellSource/cellSource.H +++ b/src/postProcessing/functionObjects/field/fieldValues/cellSource/cellSource.H @@ -103,11 +103,13 @@ public: opSum, opVolAverage, opVolIntegrate, - opWeightedAverage + opWeightedAverage, + opMin, + opMax }; //- Operation type names - static const NamedEnum operationTypeNames_; + static const NamedEnum operationTypeNames_; private: diff --git a/src/postProcessing/functionObjects/field/fieldValues/cellSource/cellSourceTemplates.C b/src/postProcessing/functionObjects/field/fieldValues/cellSource/cellSourceTemplates.C index 7e4746e939..6791db7fc2 100644 --- a/src/postProcessing/functionObjects/field/fieldValues/cellSource/cellSourceTemplates.C +++ b/src/postProcessing/functionObjects/field/fieldValues/cellSource/cellSourceTemplates.C @@ -91,6 +91,16 @@ Type Foam::fieldValues::cellSource::processValues result = sum(values*weightField)/sum(weightField); break; } + case opMin: + { + result = min(values); + break; + } + case opMax: + { + result = max(values); + break; + } default: { // Do nothing diff --git a/src/postProcessing/functionObjects/field/fieldValues/controlDict b/src/postProcessing/functionObjects/field/fieldValues/controlDict index 7d9ab1f656..f4edb29be0 100644 --- a/src/postProcessing/functionObjects/field/fieldValues/controlDict +++ b/src/postProcessing/functionObjects/field/fieldValues/controlDict @@ -51,14 +51,23 @@ functions { type faceSource; functionObjectLibs ("libfieldFunctionObjects.so"); + enabled true; outputControl outputTime; + + // Output to log&file (true) or to file only log true; + + // Output field values as well valueOutput true; + + // Patch or faceZone to sample source patch; sourceName movingWall; // source faceZone; // sourceName f0; + + // Operation: areaAverage/sum/weightedAverage ... operation areaAverage; fields ( diff --git a/src/postProcessing/functionObjects/field/fieldValues/faceSource/faceSource.C b/src/postProcessing/functionObjects/field/fieldValues/faceSource/faceSource.C index 219200ea70..62b977f2f0 100644 --- a/src/postProcessing/functionObjects/field/fieldValues/faceSource/faceSource.C +++ b/src/postProcessing/functionObjects/field/fieldValues/faceSource/faceSource.C @@ -49,13 +49,14 @@ namespace Foam fieldValues::faceSource::sourceTypeNames_; template<> - const char* NamedEnum:: + const char* NamedEnum:: names[] = { - "none", "sum", "areaAverage", "areaIntegrate", "weightedAverage" + "none", "sum", "areaAverage", + "areaIntegrate", "weightedAverage", "min", "max" }; - const NamedEnum + const NamedEnum fieldValues::faceSource::operationTypeNames_; } diff --git a/src/postProcessing/functionObjects/field/fieldValues/faceSource/faceSource.H b/src/postProcessing/functionObjects/field/fieldValues/faceSource/faceSource.H index b938c70dc1..e80e1b31ea 100644 --- a/src/postProcessing/functionObjects/field/fieldValues/faceSource/faceSource.H +++ b/src/postProcessing/functionObjects/field/fieldValues/faceSource/faceSource.H @@ -106,11 +106,13 @@ public: opSum, opAreaAverage, opAreaIntegrate, - opWeightedAverage + opWeightedAverage, + opMin, + opMax }; //- Operation type names - static const NamedEnum operationTypeNames_; + static const NamedEnum operationTypeNames_; private: diff --git a/src/postProcessing/functionObjects/field/fieldValues/faceSource/faceSourceTemplates.C b/src/postProcessing/functionObjects/field/fieldValues/faceSource/faceSourceTemplates.C index e2527e84d0..85390a1e99 100644 --- a/src/postProcessing/functionObjects/field/fieldValues/faceSource/faceSourceTemplates.C +++ b/src/postProcessing/functionObjects/field/fieldValues/faceSource/faceSourceTemplates.C @@ -103,6 +103,16 @@ Type Foam::fieldValues::faceSource::processValues result = sum(values*weightField)/sum(weightField); break; } + case opMin: + { + result = min(values); + break; + } + case opMax: + { + result = max(values); + break; + } default: { // Do nothing diff --git a/src/postProcessing/functionObjects/field/readFields/readFields.C b/src/postProcessing/functionObjects/field/readFields/readFields.C index 17b46f1a52..fa1e9e7ac0 100644 --- a/src/postProcessing/functionObjects/field/readFields/readFields.C +++ b/src/postProcessing/functionObjects/field/readFields/readFields.C @@ -89,14 +89,29 @@ void Foam::readFields::read(const dictionary& dict) void Foam::readFields::execute() { - Info<< type() << " " << name_ << ":" << nl; + //Info<< type() << " " << name_ << ":" << nl; + + // Clear out any previously loaded fields + vsf_.clear(); + vvf_.clear(); + vSpheretf_.clear(); + vSymmtf_.clear(); + vtf_.clear(); + + ssf_.clear(); + svf_.clear(); + sSpheretf_.clear(); + sSymmtf_.clear(); + stf_.clear(); + forAll(fieldSet_, fieldI) { - setField(fieldSet_[fieldI]); - setField(fieldSet_[fieldI]); - setField(fieldSet_[fieldI]); - setField(fieldSet_[fieldI]); - setField(fieldSet_[fieldI]); + // If necessary load field + loadField(fieldSet_[fieldI], vsf_, ssf_); + loadField(fieldSet_[fieldI], vvf_, svf_); + loadField(fieldSet_[fieldI], vSpheretf_, sSpheretf_); + loadField(fieldSet_[fieldI], vSymmtf_, sSymmtf_); + loadField(fieldSet_[fieldI], vtf_, stf_); } } diff --git a/src/postProcessing/functionObjects/field/readFields/readFields.H b/src/postProcessing/functionObjects/field/readFields/readFields.H index 52ee6a47ae..01fced3ead 100644 --- a/src/postProcessing/functionObjects/field/readFields/readFields.H +++ b/src/postProcessing/functionObjects/field/readFields/readFields.H @@ -39,6 +39,8 @@ SourceFiles #include "OFstream.H" #include "pointFieldFwd.H" +#include "volFields.H" +#include "surfaceFields.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -68,9 +70,22 @@ protected: //- on/off switch bool active_; - //- Fields to assess min/max + //- Fields to load wordList fieldSet_; + //- Loaded fields + PtrList vsf_; + PtrList vvf_; + PtrList vSpheretf_; + PtrList vSymmtf_; + PtrList vtf_; + + PtrList ssf_; + PtrList svf_; + PtrList sSpheretf_; + PtrList sSymmtf_; + PtrList stf_; + // Protected Member Functions @@ -81,7 +96,12 @@ protected: void operator=(const readFields&); template - void setField(const word& fieldName); + void loadField + ( + const word&, + PtrList >&, + PtrList >& + ) const; public: diff --git a/src/postProcessing/functionObjects/field/readFields/readFieldsTemplates.C b/src/postProcessing/functionObjects/field/readFields/readFieldsTemplates.C index f78859d769..62797b2aff 100644 --- a/src/postProcessing/functionObjects/field/readFields/readFieldsTemplates.C +++ b/src/postProcessing/functionObjects/field/readFields/readFieldsTemplates.C @@ -31,7 +31,12 @@ License // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // template -void Foam::readFields::setField(const word& fieldName) +void Foam::readFields::loadField +( + const word& fieldName, + PtrList >& vflds, + PtrList >& sflds +) const { typedef GeometricField vfType; typedef GeometricField sfType; @@ -40,53 +45,55 @@ void Foam::readFields::setField(const word& fieldName) { if (debug) { - Info<< "Field " << fieldName << " already in database" << endl; + Info<< "readFields : Field " << fieldName << " already in database" + << endl; } - - vfType& vf = const_cast(obr_.lookupObject(fieldName)); - vf.checkOut(); } - if (obr_.foundObject(fieldName)) + else if (obr_.foundObject(fieldName)) { if (debug) { - Info<< "Field " << fieldName << " already in database" << endl; + Info<< "readFields : Field " << fieldName << " already in database" + << endl; } - - sfType& sf = const_cast(obr_.lookupObject(fieldName)); - sf.checkOut(); } - - const fvMesh& mesh = refCast(obr_); - - IOobject fieldHeader - ( - fieldName, - mesh.time().timeName(), - mesh, - IOobject::MUST_READ, - IOobject::NO_WRITE - ); - - if - ( - fieldHeader.headerOk() - && fieldHeader.headerClassName() == vfType::typeName - ) + else { - // store field on the mesh database - Info<< " Reading " << fieldName << endl; - obr_.store(new vfType(fieldHeader, mesh)); - } - else if - ( - fieldHeader.headerOk() - && fieldHeader.headerClassName() == sfType::typeName - ) - { - // store field on the mesh database - Info<< " Reading " << fieldName << endl; - obr_.store(new sfType(fieldHeader, mesh)); + const fvMesh& mesh = refCast(obr_); + + IOobject fieldHeader + ( + fieldName, + mesh.time().timeName(), + mesh, + IOobject::MUST_READ, + IOobject::NO_WRITE + ); + + if + ( + fieldHeader.headerOk() + && fieldHeader.headerClassName() == vfType::typeName + ) + { + // store field locally + Info<< " Reading " << fieldName << endl; + label sz = vflds.size(); + vflds.setSize(sz+1); + vflds.set(sz, new vfType(fieldHeader, mesh)); + } + else if + ( + fieldHeader.headerOk() + && fieldHeader.headerClassName() == sfType::typeName + ) + { + // store field locally + Info<< " Reading " << fieldName << endl; + label sz = sflds.size(); + sflds.setSize(sz+1); + sflds.set(sz, new sfType(fieldHeader, mesh)); + } } } diff --git a/src/postProcessing/functionObjects/field/surfaceInterpolateFields/IOsurfaceInterpolateFields.H b/src/postProcessing/functionObjects/field/surfaceInterpolateFields/IOsurfaceInterpolateFields.H new file mode 100644 index 0000000000..8fb5387236 --- /dev/null +++ b/src/postProcessing/functionObjects/field/surfaceInterpolateFields/IOsurfaceInterpolateFields.H @@ -0,0 +1,49 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2010-2010 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see . + +Typedef + Foam::IOsurfaceInterpolateFields + +Description + Instance of the generic IOOutputFilter for surfaceInterpolateFields. + +\*---------------------------------------------------------------------------*/ + +#ifndef IOsurfaceInterpolateFields_H +#define IOsurfaceInterpolateFields_H + +#include "surfaceInterpolateFields.H" +#include "IOOutputFilter.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + typedef IOOutputFilter IOsurfaceInterpolateFields; +} + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/field/surfaceInterpolateFields/surfaceInterpolateFields.C b/src/postProcessing/functionObjects/field/surfaceInterpolateFields/surfaceInterpolateFields.C new file mode 100644 index 0000000000..1e785b8479 --- /dev/null +++ b/src/postProcessing/functionObjects/field/surfaceInterpolateFields/surfaceInterpolateFields.C @@ -0,0 +1,121 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2010-2010 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see . + +\*---------------------------------------------------------------------------*/ + +#include "surfaceInterpolateFields.H" +//#include "dictionary.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ + defineTypeNameAndDebug(surfaceInterpolateFields, 0); +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::surfaceInterpolateFields::surfaceInterpolateFields +( + const word& name, + const objectRegistry& obr, + const dictionary& dict, + const bool loadFromFiles +) +: + name_(name), + obr_(obr), + active_(true), + fieldSet_() +{ + // Check if the available mesh is an fvMesh otherise deactivate + if (!isA(obr_)) + { + active_ = false; + WarningIn + ( + "surfaceInterpolateFields::surfaceInterpolateFields" + "(" + "const word&, " + "const objectRegistry&, " + "const dictionary&, " + "const bool" + ")" + ) << "No fvMesh available, deactivating." + << endl; + } + + read(dict); +} + + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + +Foam::surfaceInterpolateFields::~surfaceInterpolateFields() +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +void Foam::surfaceInterpolateFields::read(const dictionary& dict) +{ + if (active_) + { + dict.lookup("fields") >> fieldSet_; + } +} + + +void Foam::surfaceInterpolateFields::execute() +{ + //Info<< type() << " " << name_ << ":" << nl; + + // Clear out any previously loaded fields + ssf_.clear(); + svf_.clear(); + sSpheretf_.clear(); + sSymmtf_.clear(); + stf_.clear(); + + interpolateFields(ssf_); + interpolateFields(svf_); + interpolateFields(sSpheretf_); + interpolateFields(sSymmtf_); + interpolateFields(stf_); +} + + +void Foam::surfaceInterpolateFields::end() +{ + // Do nothing +} + + +void Foam::surfaceInterpolateFields::write() +{ + // Do nothing +} + + +// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/field/surfaceInterpolateFields/surfaceInterpolateFields.H b/src/postProcessing/functionObjects/field/surfaceInterpolateFields/surfaceInterpolateFields.H new file mode 100644 index 0000000000..ef804d755c --- /dev/null +++ b/src/postProcessing/functionObjects/field/surfaceInterpolateFields/surfaceInterpolateFields.H @@ -0,0 +1,167 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2010-2010 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see . + +Class + Foam::surfaceInterpolateFields + +Description + Reads fields from the time folders and adds them to the mesh database + for further post-processing. + +SourceFiles + surfaceInterpolateFields.C + IOsurfaceInterpolateFields.H + +\*---------------------------------------------------------------------------*/ + +#ifndef surfaceInterpolateFields_H +#define surfaceInterpolateFields_H + +#include "OFstream.H" +//#include "pointFieldFwd.H" +#include "surfaceFields.H" +#include "Tuple2.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// Forward declaration of classes +class objectRegistry; +class dictionary; +class mapPolyMesh; + +/*---------------------------------------------------------------------------*\ + Class surfaceInterpolateFields Declaration +\*---------------------------------------------------------------------------*/ + +class surfaceInterpolateFields +{ +protected: + + // Protected data + + //- Name of this set of surfaceInterpolateFields object + word name_; + + const objectRegistry& obr_; + + //- on/off switch + bool active_; + + //- Fields to process + //wordList fieldSet_; + List > fieldSet_; + + //- Locally constructed fields + PtrList ssf_; + PtrList svf_; + PtrList sSpheretf_; + PtrList sSymmtf_; + PtrList stf_; + + + // Protected Member Functions + + //- Disallow default bitwise copy construct + surfaceInterpolateFields(const surfaceInterpolateFields&); + + //- Disallow default bitwise assignment + void operator=(const surfaceInterpolateFields&); + + template + void interpolateFields + ( + PtrList >& + ) const; + + +public: + + //- Runtime type information + TypeName("surfaceInterpolateFields"); + + + // Constructors + + //- Construct for given objectRegistry and dictionary. + // Allow the possibility to load fields from files + surfaceInterpolateFields + ( + const word& name, + const objectRegistry&, + const dictionary&, + const bool loadFromFiles = false + ); + + + //- Destructor + virtual ~surfaceInterpolateFields(); + + + // Member Functions + + //- Return name of the surfaceInterpolateFields object + virtual const word& name() const + { + return name_; + } + + //- Read the field min/max data + virtual void read(const dictionary&); + + //- Execute, currently does nothing + virtual void execute(); + + //- Execute at the final time-loop, currently does nothing + virtual void end(); + + //- Write + virtual void write(); + + //- Update for changes of mesh + virtual void updateMesh(const mapPolyMesh&) + {} + + //- Update for changes of mesh + virtual void movePoints(const pointField&) + {} +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#ifdef NoRepository +# include "surfaceInterpolateFieldsTemplates.C" +#endif + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/field/surfaceInterpolateFields/surfaceInterpolateFieldsFunctionObject.C b/src/postProcessing/functionObjects/field/surfaceInterpolateFields/surfaceInterpolateFieldsFunctionObject.C new file mode 100644 index 0000000000..c535a02b09 --- /dev/null +++ b/src/postProcessing/functionObjects/field/surfaceInterpolateFields/surfaceInterpolateFieldsFunctionObject.C @@ -0,0 +1,42 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2010-2010 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see . + +\*---------------------------------------------------------------------------*/ + +#include "surfaceInterpolateFieldsFunctionObject.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ + defineNamedTemplateTypeNameAndDebug(surfaceInterpolateFieldsFunctionObject, 0); + + addToRunTimeSelectionTable + ( + functionObject, + surfaceInterpolateFieldsFunctionObject, + dictionary + ); +} + +// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/field/surfaceInterpolateFields/surfaceInterpolateFieldsFunctionObject.H b/src/postProcessing/functionObjects/field/surfaceInterpolateFields/surfaceInterpolateFieldsFunctionObject.H new file mode 100644 index 0000000000..eb5546a8be --- /dev/null +++ b/src/postProcessing/functionObjects/field/surfaceInterpolateFields/surfaceInterpolateFieldsFunctionObject.H @@ -0,0 +1,54 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2010-2010 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see . + +Typedef + Foam::surfaceInterpolateFieldsFunctionObject + +Description + FunctionObject wrapper around surfaceInterpolateFields to allow them to be created via + the functions entry within controlDict. + +SourceFiles + surfaceInterpolateFieldsFunctionObject.C + +\*---------------------------------------------------------------------------*/ + +#ifndef surfaceInterpolateFieldsFunctionObject_H +#define surfaceInterpolateFieldsFunctionObject_H + +#include "surfaceInterpolateFields.H" +#include "OutputFilterFunctionObject.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + typedef OutputFilterFunctionObject + surfaceInterpolateFieldsFunctionObject; +} + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/field/surfaceInterpolateFields/surfaceInterpolateFieldsTemplates.C b/src/postProcessing/functionObjects/field/surfaceInterpolateFields/surfaceInterpolateFieldsTemplates.C new file mode 100644 index 0000000000..5db07d02ba --- /dev/null +++ b/src/postProcessing/functionObjects/field/surfaceInterpolateFields/surfaceInterpolateFieldsTemplates.C @@ -0,0 +1,79 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2010-2010 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see . + +\*---------------------------------------------------------------------------*/ + +#include "surfaceInterpolateFields.H" +#include "volFields.H" +#include "linear.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +template +void Foam::surfaceInterpolateFields::interpolateFields +( + PtrList >& sflds +) const +{ + typedef GeometricField vfType; + typedef GeometricField sfType; + + // Convert field to map + HashTable fieldMap(2*fieldSet_.size()); + forAll(fieldSet_, i) + { + fieldMap.insert(fieldSet_[i].first(), fieldSet_[i].second()); + } + + + HashTable flds(obr_.lookupClass()); + + forAllConstIter(typename HashTable, flds, iter) + { + const vfType& fld = *iter(); + + if (fieldMap.found(fld.name())) + { + //const word sName = "interpolate(" + fld.name() + ')'; + const word& sName = fieldMap[fld.name()]; + + if (obr_.found(sName)) + { + Info<< " a surfaceField " << sName << " already exists" + << endl; + } + else + { + label sz = sflds.size(); + sflds.setSize(sz+1); + sflds.set(sz, new sfType(sName, linearInterpolate(fld))); + + Info<< " interpolated " << fld.name() << " to create " + << sflds[sz].name() << endl; + } + } + } +} + + +// ************************************************************************* //