diff --git a/applications/utilities/postProcessing/dataConversion/foamToVTK/Make/options b/applications/utilities/postProcessing/dataConversion/foamToVTK/Make/options index 5980905c0679a8745d7d460b0895613561dc065e..c2445fd549946f440c1fa285d82253acae97ac3e 100644 --- a/applications/utilities/postProcessing/dataConversion/foamToVTK/Make/options +++ b/applications/utilities/postProcessing/dataConversion/foamToVTK/Make/options @@ -2,11 +2,11 @@ EXE_INC = \ -IfoamToVTK/lnInclude \ -I$(LIB_SRC)/lagrangian/basic/lnInclude \ -I$(LIB_SRC)/finiteVolume/lnInclude \ + -I$(LIB_SRC)/dynamicMesh/lnInclude \ -I$(LIB_SRC)/meshTools/lnInclude EXE_LIBS = \ -lfoamToVTK \ - -lfiniteVolume \ + -ldynamicMesh \ -llagrangian \ - -lgenericPatchFields \ - -lmeshTools + -lgenericPatchFields diff --git a/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK/Make/files b/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK/Make/files index c0df3f1993df8461263c428d69061286774da0b4..4deaaa68f07c4ac1117eb8673149c90d195bc8f2 100644 --- a/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK/Make/files +++ b/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK/Make/files @@ -10,6 +10,5 @@ vtkMesh.C vtkTopo.C writeVTK/writeVTK.C -writeVTK/writeVTKFunctionObject.C LIB = $(FOAM_LIBBIN)/libfoamToVTK diff --git a/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK/Make/options b/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK/Make/options index 12747a2730c7b53bc8ed7b013df51acc783adf5a..f10e4ec1d6bc0688e938d10ec287995f5efb0119 100644 --- a/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK/Make/options +++ b/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK/Make/options @@ -1,10 +1,10 @@ EXE_INC = \ -I$(LIB_SRC)/lagrangian/basic/lnInclude \ -I$(LIB_SRC)/finiteVolume/lnInclude \ + -I$(LIB_SRC)/dynamicMesh/lnInclude \ -I$(LIB_SRC)/meshTools/lnInclude LIB_LIBS = \ - -lfiniteVolume \ + -ldynamicMesh \ -llagrangian \ - -lgenericPatchFields \ - -lmeshTools + -lgenericPatchFields diff --git a/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK/writeVTK/writeVTK.C b/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK/writeVTK/writeVTK.C index 9513a64a1518238da3436e08102bb7c1533ded15..5cc6f2213e1030949b53052dc7cbf45e12336371 100644 --- a/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK/writeVTK/writeVTK.C +++ b/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK/writeVTK/writeVTK.C @@ -28,6 +28,7 @@ License #include "Time.H" #include "vtkMesh.H" #include "internalWriter.H" +#include "addToRunTimeSelectionTable.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -36,6 +37,7 @@ namespace Foam namespace functionObjects { defineTypeNameAndDebug(writeVTK, 0); + addToRunTimeSelectionTable(functionObject, writeVTK, dictionary); } } @@ -45,16 +47,22 @@ namespace functionObjects Foam::functionObjects::writeVTK::writeVTK ( const word& name, - const objectRegistry& obr, - const dictionary& dict, - const bool loadFromFiles + const Time& t, + const dictionary& dict ) : - name_(name), - obr_(obr), + functionObject(name), + time_(t), + obr_ + ( + time_.lookupObject<objectRegistry> + ( + dict.lookupOrDefault("region", polyMesh::defaultRegion) + ) + ), objectNames_() { - if (!isA<fvMesh>(obr)) + if (!isA<fvMesh>(obr_)) { FatalErrorInFunction << "objectRegistry is not an fvMesh" << exit(FatalError); @@ -72,27 +80,23 @@ Foam::functionObjects::writeVTK::~writeVTK() // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -void Foam::functionObjects::writeVTK::read(const dictionary& dict) +bool Foam::functionObjects::writeVTK::read(const dictionary& dict) { dict.lookup("objectNames") >> objectNames_; -} - - -void Foam::functionObjects::writeVTK::execute() -{} - -void Foam::functionObjects::writeVTK::end() -{} + return true; +} -void Foam::functionObjects::writeVTK::timeSet() -{} +bool Foam::functionObjects::writeVTK::execute(const bool postProcess) +{ + return true; +} -void Foam::functionObjects::writeVTK::write() +bool Foam::functionObjects::writeVTK::write(const bool postProcess) { - Info<< type() << " " << name_ << " output:" << nl; + Info<< type() << " " << name() << " output:" << nl; fvMesh& mesh = const_cast<fvMesh&>(refCast<const fvMesh>(obr_)); @@ -162,6 +166,8 @@ void Foam::functionObjects::writeVTK::write() writer.write(vsptf); writer.write(vstf); writer.write(vtf); + + return true; } diff --git a/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK/writeVTK/writeVTK.H b/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK/writeVTK/writeVTK.H index d230d7726d3b36aedc58e2c76b85df350306c6e8..2df7cb328d8a11d83fd7969aaaebec778c452318 100644 --- a/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK/writeVTK/writeVTK.H +++ b/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK/writeVTK/writeVTK.H @@ -55,7 +55,7 @@ Description SeeAlso Foam::functionObject - Foam::OutputFilterFunctionObject + Foam::functionObjects::timeControl SourceFiles writeVTK.C @@ -66,8 +66,8 @@ SourceFiles #ifndef functionObjects_writeVTK_H #define functionObjects_writeVTK_H +#include "functionObject.H" #include "wordReList.H" -#include "runTimeSelectionTables.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -75,10 +75,8 @@ namespace Foam { // Forward declaration of classes +class Time; class objectRegistry; -class dictionary; -class polyMesh; -class mapPolyMesh; namespace functionObjects { @@ -88,13 +86,15 @@ namespace functionObjects \*---------------------------------------------------------------------------*/ class writeVTK +: + public functionObject { // Private data - //- Name of this set of writeVTK - word name_; + //- Reference to the Time + const Time& time_; - //- Refererence to Db + //- Refererence to objectRegistry const objectRegistry& obr_; //- Names of objects @@ -121,14 +121,12 @@ public: // Constructors - //- Construct for given objectRegistry and dictionary. - // Allow the possibility to load fields from files + //- Construct from Time and dictionary writeVTK ( const word& name, - const objectRegistry&, - const dictionary&, - const bool loadFromFiles = false + const Time& t, + const dictionary& ); @@ -138,34 +136,14 @@ public: // Member Functions - //- Return name of the writeVTK - virtual const word& name() const - { - return name_; - } - //- Read the writeVTK data - virtual void read(const dictionary&); + virtual bool read(const dictionary&); //- Execute, currently does nothing - virtual void execute(); - - //- Execute at the final time-loop, currently does nothing - virtual void end(); - - //- Called when time was set at the end of the Time::operator++ - virtual void timeSet(); + virtual bool execute(const bool postProcess = false); //- Write the writeVTK - virtual void write(); - - //- Update for changes of mesh - virtual void updateMesh(const mapPolyMesh&) - {} - - //- Update for changes of mesh - virtual void movePoints(const polyMesh&) - {} + virtual bool write(const bool postProcess = false); }; diff --git a/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK/writeVTK/writeVTKFunctionObject.C b/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK/writeVTK/writeVTKFunctionObject.C deleted file mode 100644 index 804d7156b7284cbd4f73bace73d16a64d62f6505..0000000000000000000000000000000000000000 --- a/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK/writeVTK/writeVTKFunctionObject.C +++ /dev/null @@ -1,46 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2016 OpenFOAM Foundation - \\/ 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 <http://www.gnu.org/licenses/>. - -\*---------------------------------------------------------------------------*/ - -#include "writeVTKFunctionObject.H" - -// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // - -namespace Foam -{ - defineNamedTemplateTypeNameAndDebug - ( - writeVTKFunctionObject, - 0 - ); - - addToRunTimeSelectionTable - ( - functionObject, - writeVTKFunctionObject, - dictionary - ); -} - -// ************************************************************************* // diff --git a/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK/writeVTK/writeVTKFunctionObject.H b/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK/writeVTK/writeVTKFunctionObject.H deleted file mode 100644 index 7033928ccbd350f961ed3f2f1b14064fb1d1fdcc..0000000000000000000000000000000000000000 --- a/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK/writeVTK/writeVTKFunctionObject.H +++ /dev/null @@ -1,54 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2016 OpenFOAM Foundation - \\/ 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 <http://www.gnu.org/licenses/>. - -Typedef - Foam::writeVTKFunctionObject - -Description - FunctionObject wrapper around writeVTK to allow them to be - created via the functions entry within controlDict. - -SourceFiles - writeVTKFunctionObject.C - -\*---------------------------------------------------------------------------*/ - -#ifndef writeVTKFunctionObject_H -#define writeVTKFunctionObject_H - -#include "writeVTK.H" -#include "OutputFilterFunctionObject.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - typedef OutputFilterFunctionObject<functionObjects::writeVTK> - writeVTKFunctionObject; -} - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#endif - -// ************************************************************************* // diff --git a/applications/utilities/postProcessing/miscellaneous/dsmcFieldsCalc/Make/files b/applications/utilities/postProcessing/miscellaneous/dsmcFieldsCalc/Make/files deleted file mode 100644 index 5cba9c270defeec056f43baa38061d3d77c2e936..0000000000000000000000000000000000000000 --- a/applications/utilities/postProcessing/miscellaneous/dsmcFieldsCalc/Make/files +++ /dev/null @@ -1,3 +0,0 @@ -dsmcFieldsCalc.C - -EXE = $(FOAM_APPBIN)/dsmcFieldsCalc diff --git a/applications/utilities/postProcessing/miscellaneous/dsmcFieldsCalc/Make/options b/applications/utilities/postProcessing/miscellaneous/dsmcFieldsCalc/Make/options deleted file mode 100644 index 8411a01ed22bc779ff3bee5718212e309c49ea8c..0000000000000000000000000000000000000000 --- a/applications/utilities/postProcessing/miscellaneous/dsmcFieldsCalc/Make/options +++ /dev/null @@ -1,15 +0,0 @@ -EXE_INC = \ - -I$(LIB_SRC)/postProcessing/postCalc \ - -I$(LIB_SRC)/finiteVolume/lnInclude \ - -I$(LIB_SRC)/lagrangian/basic/lnInclude \ - -I$(LIB_SRC)/postProcessing/functionObjects/utilities/lnInclude \ - -I$(LIB_SRC)/lagrangian/DSMC/lnInclude \ - -I$(LIB_SRC)/meshTools/lnInclude - -EXE_LIBS = \ - $(FOAM_LIBBIN)/postCalc.o \ - -lmeshTools \ - -lfiniteVolume \ - -lutilityFunctionObjects \ - -llagrangian \ - -lDSMC diff --git a/applications/utilities/postProcessing/miscellaneous/dsmcFieldsCalc/dsmcFieldsCalc.C b/applications/utilities/postProcessing/miscellaneous/dsmcFieldsCalc/dsmcFieldsCalc.C deleted file mode 100644 index ecd4b4f1edef681987239a87f71b10c42e53f38d..0000000000000000000000000000000000000000 --- a/applications/utilities/postProcessing/miscellaneous/dsmcFieldsCalc/dsmcFieldsCalc.C +++ /dev/null @@ -1,155 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation - \\/ 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 <http://www.gnu.org/licenses/>. - -Application - dsmcFieldsCalc - -Description - Calculate intensive fields (U and T) from averaged extensive fields from a - DSMC calculation. - -\*---------------------------------------------------------------------------*/ - -#include "calc.H" -#include "fvc.H" -#include "dsmcCloud.H" -#include "dsmcFields.H" -#include "IOobjectList.H" - - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - template<class Type> - bool addFieldsToList - ( - const fvMesh& mesh, - PtrList<GeometricField<Type, fvPatchField, volMesh>>& list, - const wordList& fieldNames - ) - { - typedef GeometricField<Type, fvPatchField, volMesh> fieldType; - - label index = 0; - forAll(fieldNames, i) - { - IOobject obj - ( - fieldNames[i], - mesh.time().timeName(), - mesh, - IOobject::MUST_READ - ); - - if (obj.headerOk() && obj.headerClassName() == fieldType::typeName) - { - list.set(index++, new fieldType(obj, mesh)); - } - else - { - Info<< "Could not find " << fieldNames[i] << endl; - - return false; - } - } - - return true; - } -} - - -void Foam::calc(const argList& args, const Time& runTime, const fvMesh& mesh) -{ - bool writeResults = !args.optionFound("noWrite"); - - wordList extensiveVSFNames - ( - IStringStream - ( - "( \ - rhoNMean \ - rhoMMean \ - linearKEMean \ - internalEMean \ - iDofMean \ - )" - )() - ); - - PtrList<volScalarField> extensiveVSFs(extensiveVSFNames.size()); - - if - ( - !addFieldsToList - ( - mesh, - extensiveVSFs, - extensiveVSFNames - ) - ) - { - return; - } - - wordList extensiveVVFNames - ( - IStringStream - ( - "( \ - momentumMean \ - fDMean \ - )" - )() - ); - - PtrList<volVectorField> extensiveVVFs(extensiveVVFNames.size()); - - if - ( - !addFieldsToList - ( - mesh, - extensiveVVFs, - extensiveVVFNames - ) - ) - { - return; - } - - functionObjects::dsmcFields dF - ( - "dsmcFieldsUtility", - mesh, - dictionary::null, - false - ); - - if (writeResults) - { - dF.write(); - } -} - -// ************************************************************************* // diff --git a/applications/utilities/postProcessing/noise/noise.C b/applications/utilities/postProcessing/noise/noise.C index 24eda6383f2bc2794d03178f388377323b8a5b8c..323bfbf2b05b38ac948cad7caff486038f464783 100644 --- a/applications/utilities/postProcessing/noise/noise.C +++ b/applications/utilities/postProcessing/noise/noise.C @@ -82,7 +82,7 @@ SeeAlso #include "noiseFFT.H" #include "argList.H" #include "Time.H" -#include "functionObjectFiles.H" +#include "writeFiles.H" #include "CSV.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/etc/codeTemplates/dynamicCode/FilterFunctionObjectTemplate.C b/etc/codeTemplates/dynamicCode/FilterFunctionObjectTemplate.C deleted file mode 100644 index 8d7d11a91dcf8325bc210cead37e8da9d3f8d327..0000000000000000000000000000000000000000 --- a/etc/codeTemplates/dynamicCode/FilterFunctionObjectTemplate.C +++ /dev/null @@ -1,65 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation - \\/ 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 <http://www.gnu.org/licenses/>. - -\*---------------------------------------------------------------------------*/ - -#include "FilterFunctionObjectTemplate.H" - -// * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * // - -extern "C" -{ - // dynamicCode: - // SHA1 = ${SHA1sum} - // - // unique function name that can be checked if the correct library version - // has been loaded - void ${typeName}_${SHA1sum}(bool load) - { - if (load) - { - // code that can be explicitly executed after loading - } - else - { - // code that can be explicitly executed before unloading - } - } -} - -// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // - -namespace Foam -{ - defineNamedTemplateTypeNameAndDebug(${typeName}FilterFunctionObject, 0); - - //addToRunTimeSelectionTable - addRemovableToRunTimeSelectionTable - ( - functionObject, - ${typeName}FilterFunctionObject, - dictionary - ); -} - -// ************************************************************************* // diff --git a/etc/codeTemplates/dynamicCode/FilterFunctionObjectTemplate.H b/etc/codeTemplates/dynamicCode/FilterFunctionObjectTemplate.H deleted file mode 100644 index 00239a941efbe34b58f3f130fb4b15efe18de2ff..0000000000000000000000000000000000000000 --- a/etc/codeTemplates/dynamicCode/FilterFunctionObjectTemplate.H +++ /dev/null @@ -1,51 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation - \\/ 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 <http://www.gnu.org/licenses/>. - -Description - FunctionObject wrapper around functionObjectTemplate to allow them - to be created via the functions entry within controlDict. - -SourceFiles - FilterFunctionObject.C - -\*---------------------------------------------------------------------------*/ - -#ifndef FilterFunctionObject_H -#define FilterFunctionObject_H - -#include "functionObjectTemplate.H" -#include "OutputFilterFunctionObject.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - typedef OutputFilterFunctionObject<${typeName}FunctionObject> - ${typeName}FilterFunctionObject; -} - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#endif - -// ************************************************************************* // diff --git a/etc/codeTemplates/dynamicCode/functionObjectTemplate.C b/etc/codeTemplates/dynamicCode/functionObjectTemplate.C index fae5975f59537e083d89be4bdecef79434ce9ede..28706d175ef570da4e7397c22098119d5d678a1e 100644 --- a/etc/codeTemplates/dynamicCode/functionObjectTemplate.C +++ b/etc/codeTemplates/dynamicCode/functionObjectTemplate.C @@ -24,9 +24,9 @@ License \*---------------------------------------------------------------------------*/ #include "functionObjectTemplate.H" -#include "Time.H" #include "fvCFD.H" #include "unitConversion.H" +#include "addToRunTimeSelectionTable.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -37,6 +37,36 @@ namespace Foam defineTypeNameAndDebug(${typeName}FunctionObject, 0); +addRemovableToRunTimeSelectionTable +( + functionObject, + ${typeName}FunctionObject, + dictionary +); + + +// * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * // + +extern "C" +{ + // dynamicCode: + // SHA1 = ${SHA1sum} + // + // unique function name that can be checked if the correct library version + // has been loaded + void ${typeName}_${SHA1sum}(bool load) + { + if (load) + { + // code that can be explicitly executed after loading + } + else + { + // code that can be explicitly executed before unloading + } + } +} + // * * * * * * * * * * * * * * * Local Functions * * * * * * * * * * * * * * // @@ -64,13 +94,18 @@ const fvMesh& ${typeName}FunctionObject::mesh() const ${typeName}FunctionObject::${typeName}FunctionObject ( const word& name, - const objectRegistry& obr, - const dictionary& dict, - const bool + const Time& runTime, + const dictionary& dict ) : - name_(name), - obr_(obr) + functionObject(name), + obr_ + ( + runTime.lookupObject<objectRegistry> + ( + dict.lookupOrDefault("region", polyMesh::defaultRegion) + ) + ) { read(dict); } @@ -84,7 +119,7 @@ ${typeName}FunctionObject::~${typeName}FunctionObject() // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -void ${typeName}FunctionObject::read(const dictionary& dict) +bool ${typeName}FunctionObject::read(const dictionary& dict) { if (${verbose:-false}) { @@ -94,10 +129,12 @@ void ${typeName}FunctionObject::read(const dictionary& dict) //{{{ begin code ${codeRead} //}}} end code + + return true; } -void ${typeName}FunctionObject::execute() +bool ${typeName}FunctionObject::execute(const bool postProcess) { if (${verbose:-false}) { @@ -107,10 +144,12 @@ void ${typeName}FunctionObject::execute() //{{{ begin code ${codeExecute} //}}} end code + + return true; } -void ${typeName}FunctionObject::end() +bool ${typeName}FunctionObject::end() { if (${verbose:-false}) { @@ -120,10 +159,12 @@ void ${typeName}FunctionObject::end() //{{{ begin code ${codeEnd} //}}} end code + + return true; } -void ${typeName}FunctionObject::timeSet() +bool ${typeName}FunctionObject::timeSet() { if (${verbose:-false}) { @@ -133,10 +174,12 @@ void ${typeName}FunctionObject::timeSet() //{{{ begin codeTime ${codeTimeSet} //}}} end code + + return true; } -void ${typeName}FunctionObject::write() +bool ${typeName}FunctionObject::write(const bool postProcess) { if (${verbose:-false}) { @@ -146,11 +189,13 @@ void ${typeName}FunctionObject::write() //{{{ begin code ${code} //}}} end code + + return true; } + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // } // End namespace Foam - // ************************************************************************* // diff --git a/etc/codeTemplates/dynamicCode/functionObjectTemplate.H b/etc/codeTemplates/dynamicCode/functionObjectTemplate.H index 60f04091a6f7c39700fdb99a6f8118381af6d33a..32fcc6884a894c2412d8e25b953e40f2be599b55 100644 --- a/etc/codeTemplates/dynamicCode/functionObjectTemplate.H +++ b/etc/codeTemplates/dynamicCode/functionObjectTemplate.H @@ -33,8 +33,7 @@ SourceFiles #ifndef functionObjectTemplate_H #define functionObjectTemplate_H -#include "stringList.H" -#include "pointField.H" +#include "functionObject.H" //{{{ begin codeInclude ${codeInclude} @@ -47,9 +46,6 @@ namespace Foam // Forward declaration of classes class objectRegistry; -class dictionary; -class polyMesh; -class mapPolyMesh; class fvMesh; /*---------------------------------------------------------------------------*\ @@ -57,13 +53,12 @@ class fvMesh; \*---------------------------------------------------------------------------*/ class ${typeName}FunctionObject +: + public functionObject { // Private data - //- Name of this set of system calls - word name_; - - //- Registry + //- Reference to the objectRegistry const objectRegistry& obr_; //{{{ begin codeData @@ -92,14 +87,12 @@ public: // Constructors - //- Construct for given objectRegistry and dictionary. - // Allow the possibility to load fields from files + //- Construct from Time and dictionary ${typeName}FunctionObject ( const word& name, - const objectRegistry& unused, - const dictionary&, - const bool loadFromFilesUnused = false + const Time& runTime, + const dictionary& ); @@ -109,34 +102,20 @@ public: // Member Functions - //- Return name of the system call set - virtual const word& name() const - { - return name_; - } - //- Read the system calls - virtual void read(const dictionary&); + virtual bool read(const dictionary&); //- Execute the "executeCalls" at each time-step - virtual void execute(); + virtual bool execute(const bool postProcess = false); //- Execute the "endCalls" at the final time-loop - virtual void end(); + virtual bool end(); //- Write, execute the "writeCalls" - virtual void write(); + virtual bool write(const bool postProcess = false); //- Called when time was set at the end of the Time::operator++ - virtual void timeSet(); - - //- Update for changes of mesh - virtual void updateMesh(const mapPolyMesh&) - {} - - //- Update for changes of mesh - virtual void movePoints(const polyMesh&) - {} + virtual bool timeSet(); }; diff --git a/etc/codeTemplates/functionObject/FUNCTIONOBJECTFunctionObject.H b/etc/codeTemplates/functionObject/FUNCTIONOBJECTFunctionObject.H deleted file mode 100644 index 78e6a7f0b96cc1e2d3d31980574b42e9f77c7a50..0000000000000000000000000000000000000000 --- a/etc/codeTemplates/functionObject/FUNCTIONOBJECTFunctionObject.H +++ /dev/null @@ -1,54 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2016 OpenFOAM Foundation - \\/ 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 <http://www.gnu.org/licenses/>. - -Typedef - Foam::FUNCTIONOBJECTFunctionObject - -Description - FunctionObject wrapper around FUNCTIONOBJECT to allow them to be - created via the functions entry within controlDict. - -SourceFiles - FUNCTIONOBJECTFunctionObject.C - -\*---------------------------------------------------------------------------*/ - -#ifndef FUNCTIONOBJECTFunctionObject_H -#define FUNCTIONOBJECTFunctionObject_H - -#include "FUNCTIONOBJECT.H" -#include "OutputFilterFunctionObject.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - typedef OutputFilterFunctionObject<FUNCTIONOBJECT> - FUNCTIONOBJECTFunctionObject; -} - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#endif - -// ************************************************************************* // diff --git a/src/OpenFOAM/db/functionObjects/OutputFilterFunctionObject/OutputFilterFunctionObject.C b/src/OpenFOAM/db/functionObjects/OutputFilterFunctionObject/OutputFilterFunctionObject.C deleted file mode 100644 index 459bc5492d864bd91ee4cc738092f327cd8e46db..0000000000000000000000000000000000000000 --- a/src/OpenFOAM/db/functionObjects/OutputFilterFunctionObject/OutputFilterFunctionObject.C +++ /dev/null @@ -1,245 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation - \\/ 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 <http://www.gnu.org/licenses/>. - -\*---------------------------------------------------------------------------*/ - -#include "OutputFilterFunctionObject.H" -#include "polyMesh.H" -#include "mapPolyMesh.H" -#include "addToRunTimeSelectionTable.H" - -// * * * * * * * * * * * * * * * Private Members * * * * * * * * * * * * * * // - -template<class OutputFilter> -void Foam::OutputFilterFunctionObject<OutputFilter>::readControls() -{ - dict_.readIfPresent("timeStart", timeStart_); - dict_.readIfPresent("timeEnd", timeEnd_); - dict_.readIfPresent("nStepsToStartTimeChange", nStepsToStartTimeChange_); -} - - -template<class OutputFilter> -bool Foam::OutputFilterFunctionObject<OutputFilter>::active() const -{ - return - time_.value() >= timeStart_ - && time_.value() <= timeEnd_; -} - - -// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // - -template<class OutputFilter> -Foam::OutputFilterFunctionObject<OutputFilter>::OutputFilterFunctionObject -( - const word& name, - const Time& t, - const dictionary& dict -) -: - functionObject(name), - time_(t), - dict_(dict), - timeStart_(-VGREAT), - timeEnd_(VGREAT), - nStepsToStartTimeChange_ - ( - dict.lookupOrDefault("nStepsToStartTimeChange", 3) - ), - writeControl_(t, dict, "write"), - evaluateControl_(t, dict, "evaluate"), - filter_ - ( - name, - time_.lookupObject<objectRegistry> - ( - dict.lookupOrDefault("region", polyMesh::defaultRegion) - ), - dict_ - ) -{ - readControls(); -} - - -// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // - -template<class OutputFilter> -bool Foam::OutputFilterFunctionObject<OutputFilter>::execute -( - const bool postProcess -) -{ - if (active()) - { - if (postProcess || evaluateControl_.execute()) - { - filter_.execute(); - } - } - - return true; -} - - -template<class OutputFilter> -bool Foam::OutputFilterFunctionObject<OutputFilter>::write -( - const bool postProcess -) -{ - if (active()) - { - if (postProcess || writeControl_.execute()) - { - filter_.write(); - } - } - - return true; -} - - -template<class OutputFilter> -bool Foam::OutputFilterFunctionObject<OutputFilter>::end() -{ - filter_.end(); - - if (writeControl_.execute()) - { - filter_.write(); - } - - return true; -} - - -template<class OutputFilter> -bool Foam::OutputFilterFunctionObject<OutputFilter>::timeSet() -{ - if (active()) - { - filter_.timeSet(); - } - - return true; -} - - -template<class OutputFilter> -bool Foam::OutputFilterFunctionObject<OutputFilter>::adjustTimeStep() -{ - if - ( - active() - && writeControl_.control() - == timeControl::ocAdjustableRunTime - ) - { - const label writeTimeIndex = writeControl_.executionIndex(); - const scalar writeInterval = writeControl_.interval(); - - scalar timeToNextWrite = max - ( - 0.0, - (writeTimeIndex + 1)*writeInterval - - (time_.value() - time_.startTime().value()) - ); - - scalar deltaT = time_.deltaTValue(); - - scalar nSteps = timeToNextWrite/deltaT - SMALL; - - // functionObjects modify deltaT within nStepsToStartTimeChange - // NOTE: Potential problems arise if two function objects dump within - // the same interval - if (nSteps < nStepsToStartTimeChange_) - { - label nStepsToNextWrite = label(nSteps) + 1; - - scalar newDeltaT = timeToNextWrite/nStepsToNextWrite; - - // Adjust time step - if (newDeltaT < deltaT) - { - deltaT = max(newDeltaT, 0.2*deltaT); - const_cast<Time&>(time_).setDeltaT(deltaT, false); - } - } - } - - return true; -} - - -template<class OutputFilter> -bool Foam::OutputFilterFunctionObject<OutputFilter>::read -( - const dictionary& dict -) -{ - if (dict != dict_) - { - dict_ = dict; - - writeControl_.read(dict); - evaluateControl_.read(dict); - readControls(); - - return true; - } - else - { - return false; - } -} - - -template<class OutputFilter> -void Foam::OutputFilterFunctionObject<OutputFilter>::updateMesh -( - const mapPolyMesh& mpm -) -{ - if (active()) - { - filter_.updateMesh(mpm); - } -} - - -template<class OutputFilter> -void Foam::OutputFilterFunctionObject<OutputFilter>::movePoints -( - const polyMesh& mesh -) -{ - if (active()) - { - filter_.movePoints(mesh); - } -} - - -// ************************************************************************* // diff --git a/src/OpenFOAM/db/functionObjects/OutputFilterFunctionObject/OutputFilterFunctionObject.H b/src/OpenFOAM/db/functionObjects/OutputFilterFunctionObject/OutputFilterFunctionObject.H deleted file mode 100644 index 6aa998052f4df66c1d662616b98b69aec385f1c8..0000000000000000000000000000000000000000 --- a/src/OpenFOAM/db/functionObjects/OutputFilterFunctionObject/OutputFilterFunctionObject.H +++ /dev/null @@ -1,197 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation - \\/ 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 <http://www.gnu.org/licenses/>. - -Class - Foam::OutputFilterFunctionObject - -Description - A functionObject wrapper around OutputFilter to allow them to be - created via the functions entry within controlDict. - -Note - Since the timeIndex is used directly from Foam::Time, it is unaffected - by user-time conversions. For example, Foam::engineTime might cause \a - writeInterval to be degrees crank angle, but the functionObject - execution \a interval would still be in timestep. - -SourceFiles - OutputFilterFunctionObject.C - -\*---------------------------------------------------------------------------*/ - -#ifndef OutputFilterFunctionObject_H -#define OutputFilterFunctionObject_H - -#include "functionObject.H" -#include "dictionary.H" -#include "timeControl.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - -/*---------------------------------------------------------------------------*\ - Class OutputFilterFunctionObject Declaration -\*---------------------------------------------------------------------------*/ - -template<class OutputFilter> -class OutputFilterFunctionObject -: - public functionObject -{ - // Private data - - //- Reference to the time database - const Time& time_; - - //- Input dictionary - dictionary dict_; - - - // Optional user inputs - - //- Activation time - defaults to -VGREAT - scalar timeStart_; - - //- De-activation time - defaults to VGREAT - scalar timeEnd_; - - //- Number of steps before the dump-time during which deltaT - // may be changed (valid for adjustableRunTime) - label nStepsToStartTimeChange_; - - - //- Output controls - timeControl writeControl_; - - //- Evaluate controls - timeControl evaluateControl_; - - //- The output filter - OutputFilter filter_; - - - // Private Member Functions - - //- Read relevant dictionary entries - void readControls(); - - //- Returns true if within time bounds - bool active() const; - - //- Disallow default bitwise copy construct - OutputFilterFunctionObject(const OutputFilterFunctionObject&); - - //- Disallow default bitwise assignment - void operator=(const OutputFilterFunctionObject&); - - -public: - - //- Runtime type information - TypeName(OutputFilter::typeName_()); - - - // Constructors - - //- Construct from components - OutputFilterFunctionObject - ( - const word& name, - const Time&, - const dictionary& - ); - - - // Member Functions - - // Access - - //- Return time database - inline const Time& time() const; - - //- Return the input dictionary - inline const dictionary& dict() const; - - //- Return the region name - inline const word& regionName() const; - - //- Return the output control object - inline const timeControl& writeControl() const; - - //- Return the output filter - inline const OutputFilter& outputFilter() const; - - - // Function object control - - //- Called at each ++ or += of the time-loop. - // postProcess overrides the usual executeControl behaviour and - // forces execution (used in post-processing mode) - virtual bool execute(const bool postProcess = false); - - //- Called at each ++ or += of the time-loop. - // postProcess overrides the usual writeControl behaviour and - // forces writing (used in post-processing mode) - virtual bool write(const bool postProcess = false); - - //- Called when Time::run() determines that the time-loop exits - virtual bool end(); - - //- Called when time was set at the end of the Time::operator++ - virtual bool timeSet(); - - //- Called at the end of Time::adjustDeltaT() if adjustTime is true - virtual bool adjustTimeStep(); - - //- Read and set the function object if its data have changed - virtual bool read(const dictionary&); - - //- Update for changes of mesh - virtual void updateMesh(const mapPolyMesh& mpm); - - //- Update for changes of mesh - virtual void movePoints(const polyMesh& mesh); -}; - - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace Foam - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#include "OutputFilterFunctionObjectI.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#ifdef NoRepository - #include "OutputFilterFunctionObject.C" -#endif - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#endif - -// ************************************************************************* // diff --git a/src/OpenFOAM/db/functionObjects/OutputFilterFunctionObject/OutputFilterFunctionObjectI.H b/src/OpenFOAM/db/functionObjects/OutputFilterFunctionObject/OutputFilterFunctionObjectI.H deleted file mode 100644 index 42ea890c80a424cc3052e867ffefe9d0d7a15b73..0000000000000000000000000000000000000000 --- a/src/OpenFOAM/db/functionObjects/OutputFilterFunctionObject/OutputFilterFunctionObjectI.H +++ /dev/null @@ -1,60 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2016 OpenFOAM Foundation - \\/ 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 <http://www.gnu.org/licenses/>. - -\*---------------------------------------------------------------------------*/ - -// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // - -template<class OutputFilter> -inline const Foam::Time& -Foam::OutputFilterFunctionObject<OutputFilter>::time() const -{ - return time_; -} - - -template<class OutputFilter> -inline const Foam::dictionary& -Foam::OutputFilterFunctionObject<OutputFilter>::dict() const -{ - return dict_; -} - - -template<class OutputFilter> -inline const Foam::timeControl& -Foam::OutputFilterFunctionObject<OutputFilter>::writeControl() const -{ - return writeControl_; -} - - -template<class OutputFilter> -inline const OutputFilter& -Foam::OutputFilterFunctionObject<OutputFilter>::outputFilter() const -{ - return filter_; -} - - -// ************************************************************************* // diff --git a/src/OpenFOAM/db/functionObjects/functionObject/functionObject.C b/src/OpenFOAM/db/functionObjects/functionObject/functionObject.C index 07ad55ad9a708af20b0d01f89b6d846c9c8390bf..791a8139b0d7204af6f8ff70a1030f1d068cf723 100644 --- a/src/OpenFOAM/db/functionObjects/functionObject/functionObject.C +++ b/src/OpenFOAM/db/functionObjects/functionObject/functionObject.C @@ -51,10 +51,10 @@ Foam::autoPtr<Foam::functionObject> Foam::functionObject::New ( const word& name, const Time& t, - const dictionary& functionDict + const dictionary& dict ) { - const word functionType(functionDict.lookup("type")); + const word functionType(dict.lookup("type")); if (debug) { @@ -63,7 +63,7 @@ Foam::autoPtr<Foam::functionObject> Foam::functionObject::New const_cast<Time&>(t).libs().open ( - functionDict, + dict, "functionObjectLibs", dictionaryConstructorTablePtr_ ); @@ -90,7 +90,7 @@ Foam::autoPtr<Foam::functionObject> Foam::functionObject::New << exit(FatalError); } - return autoPtr<functionObject>(cstrIter()(name, t, functionDict)); + return autoPtr<functionObject>(cstrIter()(name, t, dict)); } @@ -126,4 +126,12 @@ bool Foam::functionObject::adjustTimeStep() } +void Foam::functionObject::updateMesh(const mapPolyMesh&) +{} + + +void Foam::functionObject::movePoints(const polyMesh&) +{} + + // ************************************************************************* // diff --git a/src/OpenFOAM/db/functionObjects/functionObject/functionObject.H b/src/OpenFOAM/db/functionObjects/functionObject/functionObject.H index 2b2a0c94d092d21100f62f3ec985be7a026308e7..e730c2a6f58f9f09cae57b749c11ffea6c36a6e2 100644 --- a/src/OpenFOAM/db/functionObjects/functionObject/functionObject.H +++ b/src/OpenFOAM/db/functionObjects/functionObject/functionObject.H @@ -99,7 +99,8 @@ Description Abstract base-class for Time/database function objects. See Also - Foam::OutputFilterFunctionObject + Foam::functionObjectList + Foam::functionObjects::timeControl SourceFiles functionObject.C @@ -194,8 +195,11 @@ public: // Member Functions - //- Name - virtual const word& name() const; + //- Return the name of this functionObject + const word& name() const; + + //- Read and set the function object if its data have changed + virtual bool read(const dictionary&) = 0; //- Called at each ++ or += of the time-loop. // postProcess overrides the usual executeControl behaviour and @@ -217,14 +221,11 @@ public: //- Called at the end of Time::adjustDeltaT() if adjustTime is true virtual bool adjustTimeStep(); - //- Read and set the function object if its data have changed - virtual bool read(const dictionary&) = 0; - //- Update for changes of mesh - virtual void updateMesh(const mapPolyMesh& mpm) = 0; + virtual void updateMesh(const mapPolyMesh& mpm); //- Update for changes of mesh - virtual void movePoints(const polyMesh& mesh) = 0; + virtual void movePoints(const polyMesh& mesh); }; diff --git a/src/OpenFOAM/db/functionObjects/functionObjectList/functionObjectList.C b/src/OpenFOAM/db/functionObjects/functionObjectList/functionObjectList.C index 606ce67eb4ffbf95d747e932ffaa266568283b4c..0655deb73018f479aef3595b0ee93007af3b4d4b 100644 --- a/src/OpenFOAM/db/functionObjects/functionObjectList/functionObjectList.C +++ b/src/OpenFOAM/db/functionObjects/functionObjectList/functionObjectList.C @@ -27,6 +27,7 @@ License #include "Time.H" #include "mapPolyMesh.H" #include "argList.H" +#include "timeControlFunctionObject.H" // * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * // @@ -354,7 +355,21 @@ bool Foam::functionObjectList::read() FatalIOError.throwExceptions(); try { - foPtr = functionObject::New(key, time_, dict); + if + ( + dict.found("writeControl") + || dict.found("outputControl") + ) + { + foPtr.set + ( + new functionObjects::timeControl(key, time_, dict) + ); + } + else + { + foPtr = functionObject::New(key, time_, dict); + } } catch (Foam::IOerror& ioErr) { diff --git a/src/OpenFOAM/db/functionObjects/functionObjectList/functionObjectList.H b/src/OpenFOAM/db/functionObjects/functionObjectList/functionObjectList.H index 686b5d2393e6c13cc0fe11dc165597a47f98814d..17dab0083d79984eaf3d3ddfeb8379d88a94f97a 100644 --- a/src/OpenFOAM/db/functionObjects/functionObjectList/functionObjectList.H +++ b/src/OpenFOAM/db/functionObjects/functionObjectList/functionObjectList.H @@ -29,7 +29,8 @@ Description that is called for each object. See Also - Foam::functionObject and Foam::OutputFilterFunctionObject + Foam::functionObject + Foam::functionObjects::timeControl SourceFiles functionObjectList.C @@ -158,6 +159,9 @@ public: //- Find the ID of a given function object by name label findObjectID(const word& name) const; + //- Read and set the function objects if their data have changed + bool read(); + //- Switch the function objects on void on(); @@ -184,9 +188,6 @@ public: //- Called at the end of Time::adjustDeltaT() if adjustTime is true bool adjustTimeStep(); - //- Read and set the function objects if their data have changed - bool read(); - //- Update for changes of mesh void updateMesh(const mapPolyMesh& mpm); diff --git a/src/OpenFOAM/db/functionObjects/functionObjectFile/functionObjectFile.C b/src/OpenFOAM/db/functionObjects/writeFile/writeFile.C similarity index 66% rename from src/OpenFOAM/db/functionObjects/functionObjectFile/functionObjectFile.C rename to src/OpenFOAM/db/functionObjects/writeFile/writeFile.C index 74819971382512b464a874c3eb188302476a2693..b2434f0cbfbb74044d71d525b9c3e36f1f5fe93c 100644 --- a/src/OpenFOAM/db/functionObjects/functionObjectFile/functionObjectFile.C +++ b/src/OpenFOAM/db/functionObjects/writeFile/writeFile.C @@ -23,27 +23,31 @@ License \*---------------------------------------------------------------------------*/ -#include "functionObjectFile.H" +#include "writeFile.H" #include "Time.H" #include "polyMesh.H" #include "IOmanip.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // -const Foam::word Foam::functionObjectFile::outputPrefix = "postProcessing"; -Foam::label Foam::functionObjectFile::addChars = 7; +const Foam::word Foam::functionObjects::writeFile::outputPrefix +( + "postProcessing" +); + +Foam::label Foam::functionObjects::writeFile::addChars = 7; // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * // -void Foam::functionObjectFile::initStream(Ostream& os) const +void Foam::functionObjects::writeFile::initStream(Ostream& os) const { os.setf(ios_base::scientific, ios_base::floatfield); os.width(charWidth()); } -Foam::fileName Foam::functionObjectFile::baseFileDir() const +Foam::fileName Foam::functionObjects::writeFile::baseFileDir() const { fileName baseDir = obr_.time().path(); @@ -72,17 +76,20 @@ Foam::fileName Foam::functionObjectFile::baseFileDir() const } -Foam::fileName Foam::functionObjectFile::baseTimeDir() const +Foam::fileName Foam::functionObjects::writeFile::baseTimeDir() const { return baseFileDir()/prefix_/obr_.time().timeName(); } -void Foam::functionObjectFile::writeFileHeader(const label i) +void Foam::functionObjects::writeFile::writeFileHeader(const label i) {} -Foam::Omanip<int> Foam::functionObjectFile::valueWidth(const label offset) const +Foam::Omanip<int> Foam::functionObjects::writeFile::valueWidth +( + const label offset +) const { return setw(IOstream::defaultPrecision() + addChars + offset); } @@ -90,32 +97,67 @@ Foam::Omanip<int> Foam::functionObjectFile::valueWidth(const label offset) const // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // -Foam::functionObjectFile::functionObjectFile +Foam::functionObjects::writeFile::writeFile +( + const word& name, + const Time& t, + const dictionary& dict, + const word& prefix +) +: + functionObject(name), + time_(t), + obr_ + ( + time_.lookupObject<objectRegistry> + ( + dict.lookupOrDefault("region", polyMesh::defaultRegion) + ) + ), + prefix_(prefix), + log_(true) +{} + + +Foam::functionObjects::writeFile::writeFile ( + const word& name, const objectRegistry& obr, + const dictionary& dict, const word& prefix ) : + functionObject(name), + time_(obr.time()), obr_(obr), - prefix_(prefix) + prefix_(prefix), + log_(true) {} // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // -Foam::functionObjectFile::~functionObjectFile() +Foam::functionObjects::writeFile::~writeFile() {} // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -Foam::label Foam::functionObjectFile::charWidth() const +bool Foam::functionObjects::writeFile::read(const dictionary& dict) +{ + log_ = dict.lookupOrDefault<Switch>("log", true); + + return true; +} + + +Foam::label Foam::functionObjects::writeFile::charWidth() const { return IOstream::defaultPrecision() + addChars; } -void Foam::functionObjectFile::writeCommented +void Foam::functionObjects::writeFile::writeCommented ( Ostream& os, const string& str @@ -126,7 +168,7 @@ void Foam::functionObjectFile::writeCommented } -void Foam::functionObjectFile::writeTabbed +void Foam::functionObjects::writeFile::writeTabbed ( Ostream& os, const string& str @@ -136,7 +178,7 @@ void Foam::functionObjectFile::writeTabbed } -void Foam::functionObjectFile::writeHeader +void Foam::functionObjects::writeFile::writeHeader ( Ostream& os, const string& str @@ -147,7 +189,7 @@ void Foam::functionObjectFile::writeHeader } -void Foam::functionObjectFile::writeTime(Ostream& os) const +void Foam::functionObjects::writeFile::writeTime(Ostream& os) const { os << setw(charWidth()) << obr_.time().timeName(); } diff --git a/src/OpenFOAM/db/functionObjects/functionObjectFile/functionObjectFile.H b/src/OpenFOAM/db/functionObjects/writeFile/writeFile.H similarity index 73% rename from src/OpenFOAM/db/functionObjects/functionObjectFile/functionObjectFile.H rename to src/OpenFOAM/db/functionObjects/writeFile/writeFile.H index a48747452d2f335539d06b1fb620bf1f454104d3..5c5f2df6e55bdbfe24771652d87481bc33d1cd63 100644 --- a/src/OpenFOAM/db/functionObjects/functionObjectFile/functionObjectFile.H +++ b/src/OpenFOAM/db/functionObjects/writeFile/writeFile.H @@ -22,10 +22,10 @@ License along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. Class - Foam::functionObjectFile + Foam::functionObjects::writeFile Description - Base class for output file data handling + functionObject base class for writing single files See Also Foam::functionObject @@ -36,34 +36,45 @@ SourceFiles \*---------------------------------------------------------------------------*/ -#ifndef functionObjectFile_H -#define functionObjectFile_H +#ifndef functionObjects_writeFile_H +#define functionObjects_writeFile_H -#include "objectRegistry.H" +#include "functionObject.H" +#include "Time.H" #include "IOmanip.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // namespace Foam { +namespace functionObjects +{ /*---------------------------------------------------------------------------*\ Class functionObjectFile Declaration \*---------------------------------------------------------------------------*/ -class functionObjectFile +class writeFile +: + public functionObject { protected: // Protected data + //- Reference to the Time + const Time& time_; + //- Reference to the objectRegistry const objectRegistry& obr_; //- Prefix const word prefix_; + //- Switch to send output to Info as well as to file + Switch log_; + // Protected Member Functions @@ -83,10 +94,10 @@ protected: virtual Omanip<int> valueWidth(const label offset = 0) const; //- Disallow default bitwise copy construct - functionObjectFile(const functionObjectFile&); + writeFile(const writeFile&); //- Disallow default bitwise assignment - void operator=(const functionObjectFile&); + void operator=(const writeFile&); public: @@ -100,36 +111,42 @@ public: // Constructors - //- Construct from objectRegistry - functionObjectFile(const objectRegistry& obr, const word& prefix); + //- Construct from name, Time, dictionary and prefix + writeFile + ( + const word& name, + const Time& t, + const dictionary& dict, + const word& prefix + ); + + //- Construct from name, objectRegistry, dictionary and prefix + writeFile + ( + const word& name, + const objectRegistry& obr, + const dictionary& dict, + const word& prefix + ); //- Destructor - virtual ~functionObjectFile(); + virtual ~writeFile(); // Member Functions + //- Read optional controls + virtual bool read(const dictionary&); + //- Write a commented string to stream - void writeCommented - ( - Ostream& os, - const string& str - ) const; + void writeCommented(Ostream& os, const string& str) const; //- Write a tabbed string to stream - void writeTabbed - ( - Ostream& os, - const string& str - ) const; + void writeTabbed(Ostream& os, const string& str) const; //- Write a commented header to stream - void writeHeader - ( - Ostream& os, - const string& str - ) const; + void writeHeader(Ostream& os, const string& str) const; //- Write the current time to stream void writeTime(Ostream& os) const; @@ -150,12 +167,13 @@ public: // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // +} // End namespace functionObjects } // End namespace Foam // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // #ifdef NoRepository - #include "functionObjectFileTemplates.C" + #include "writeFileTemplates.C" #endif // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/src/OpenFOAM/db/functionObjects/functionObjectFile/functionObjectFileTemplates.C b/src/OpenFOAM/db/functionObjects/writeFile/writeFileTemplates.C similarity index 96% rename from src/OpenFOAM/db/functionObjects/functionObjectFile/functionObjectFileTemplates.C rename to src/OpenFOAM/db/functionObjects/writeFile/writeFileTemplates.C index d0acfb8552b285b40cd40fa661d02f66b0711a2c..e5f7209b7baaeabd58bb07c61566fcfe3b00e0c8 100644 --- a/src/OpenFOAM/db/functionObjects/functionObjectFile/functionObjectFileTemplates.C +++ b/src/OpenFOAM/db/functionObjects/writeFile/writeFileTemplates.C @@ -26,7 +26,7 @@ License // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // template<class Type> -void Foam::functionObjectFile::writeHeaderValue +void Foam::functionObjects::writeFile::writeHeaderValue ( Ostream& os, const string& property, diff --git a/src/OpenFOAM/db/functionObjects/functionObjectFiles/functionObjectFiles.C b/src/OpenFOAM/db/functionObjects/writeFiles/writeFiles.C similarity index 73% rename from src/OpenFOAM/db/functionObjects/functionObjectFiles/functionObjectFiles.C rename to src/OpenFOAM/db/functionObjects/writeFiles/writeFiles.C index efaf20902a990c9c52558d3c25cb71fa04cd0dfa..c907c2f9b403b88b3a9729f6a21dcd06082397bc 100644 --- a/src/OpenFOAM/db/functionObjects/functionObjectFiles/functionObjectFiles.C +++ b/src/OpenFOAM/db/functionObjects/writeFiles/writeFiles.C @@ -23,13 +23,13 @@ License \*---------------------------------------------------------------------------*/ -#include "functionObjectFiles.H" +#include "writeFiles.H" #include "Time.H" #include "IFstream.H" // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * // -void Foam::functionObjectFiles::createFiles() +void Foam::functionObjects::writeFiles::createFiles() { if (Pstream::master()) { @@ -64,13 +64,13 @@ void Foam::functionObjectFiles::createFiles() } -void Foam::functionObjectFiles::write() +void Foam::functionObjects::writeFiles::write() { createFiles(); } -void Foam::functionObjectFiles::resetNames(const wordList& names) +void Foam::functionObjects::writeFiles::resetNames(const wordList& names) { names_.clear(); names_.append(names); @@ -79,13 +79,11 @@ void Foam::functionObjectFiles::resetNames(const wordList& names) { filePtrs_.clear(); filePtrs_.setSize(names_.size()); - - createFiles(); } } -void Foam::functionObjectFiles::resetName(const word& name) +void Foam::functionObjects::writeFiles::resetName(const word& name) { names_.clear(); names_.append(name); @@ -94,87 +92,55 @@ void Foam::functionObjectFiles::resetName(const word& name) { filePtrs_.clear(); filePtrs_.setSize(1); - - createFiles(); } } // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // -Foam::functionObjectFiles::functionObjectFiles +Foam::functionObjects::writeFiles::writeFiles ( - const objectRegistry& obr, + const word& name, + const Time& time, + const dictionary& dict, const word& prefix ) : - functionObjectFile(obr, prefix), + writeFile(name, time, dict, prefix), names_(), filePtrs_() {} -Foam::functionObjectFiles::functionObjectFiles +Foam::functionObjects::writeFiles::writeFiles ( + const word& name, const objectRegistry& obr, - const word& prefix, - const word& name + const dictionary& dict, + const word& prefix ) : - functionObjectFile(obr, prefix), + writeFile(name, obr, dict, prefix), names_(), filePtrs_() -{ - names_.clear(); - names_.append(name); - if (Pstream::master()) - { - filePtrs_.clear(); - filePtrs_.setSize(1); - - // Cannot create files - need to access virtual function - } -} - - -Foam::functionObjectFiles::functionObjectFiles -( - const objectRegistry& obr, - const word& prefix, - const wordList& names -) -: - functionObjectFile(obr, prefix), - names_(names), - filePtrs_() -{ - names_.clear(); - names_.append(names); - if (Pstream::master()) - { - filePtrs_.clear(); - filePtrs_.setSize(names_.size()); - - // Cannot create files - need to access virtual function - } -} +{} // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // -Foam::functionObjectFiles::~functionObjectFiles() +Foam::functionObjects::writeFiles::~writeFiles() {} // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -const Foam::wordList& Foam::functionObjectFiles::names() const +const Foam::wordList& Foam::functionObjects::writeFiles::names() const { return names_; } -Foam::OFstream& Foam::functionObjectFiles::file() +Foam::OFstream& Foam::functionObjects::writeFiles::file() { if (!Pstream::master()) { @@ -201,7 +167,7 @@ Foam::OFstream& Foam::functionObjectFiles::file() } -Foam::PtrList<Foam::OFstream>& Foam::functionObjectFiles::files() +Foam::PtrList<Foam::OFstream>& Foam::functionObjects::writeFiles::files() { if (!Pstream::master()) { @@ -214,7 +180,7 @@ Foam::PtrList<Foam::OFstream>& Foam::functionObjectFiles::files() } -Foam::OFstream& Foam::functionObjectFiles::file(const label i) +Foam::OFstream& Foam::functionObjects::writeFiles::file(const label i) { if (!Pstream::master()) { diff --git a/src/OpenFOAM/db/functionObjects/functionObjectFiles/functionObjectFiles.H b/src/OpenFOAM/db/functionObjects/writeFiles/writeFiles.H similarity index 77% rename from src/OpenFOAM/db/functionObjects/functionObjectFiles/functionObjectFiles.H rename to src/OpenFOAM/db/functionObjects/writeFiles/writeFiles.H index cf29461add07160fef96e57d81aa8e6fed80f948..8d9831e0a0e9d2736848db56a399f58056de7780 100644 --- a/src/OpenFOAM/db/functionObjects/functionObjectFiles/functionObjectFiles.H +++ b/src/OpenFOAM/db/functionObjects/writeFiles/writeFiles.H @@ -22,10 +22,10 @@ License along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. Class - Foam::functionObjectFiles + Foam::functionObjects::writeFiles Description - Base class for output file data handling + functionObject base class for writing files See Also Foam::functionObject @@ -36,10 +36,10 @@ SourceFiles \*---------------------------------------------------------------------------*/ -#ifndef functionObjectFiles_H -#define functionObjectFiles_H +#ifndef functionObjects_writeFiles_H +#define functionObjects_writeFiles_H -#include "functionObjectFile.H" +#include "writeFile.H" #include "OFstream.H" #include "PtrList.H" @@ -47,15 +47,16 @@ SourceFiles namespace Foam { - +namespace functionObjects +{ /*---------------------------------------------------------------------------*\ - Class functionObjectFiles Declaration + Class writeFiles Declaration \*---------------------------------------------------------------------------*/ -class functionObjectFiles +class writeFiles : - public functionObjectFile + public writeFile { // Private data @@ -83,38 +84,37 @@ protected: virtual void resetName(const word& name); //- Disallow default bitwise copy construct - functionObjectFiles(const functionObjectFiles&); + writeFiles(const writeFiles&); //- Disallow default bitwise assignment - void operator=(const functionObjectFiles&); + void operator=(const writeFiles&); public: // Constructors - //- Construct from objectRegistry - functionObjectFiles(const objectRegistry& obr, const word& prefix); - - //- Construct from components - functionObjectFiles + //- Construct from name, Time, dictionary and prefix + writeFiles ( - const objectRegistry& obr, - const word& prefix, - const word& name + const word& name, + const Time& time, + const dictionary& dict, + const word& prefix ); - //- Construct from components - functionObjectFiles + //- Construct from name, objectRegistry, dictionary and prefix + writeFiles ( + const word& name, const objectRegistry& obr, - const word& prefix, - const wordList& names + const dictionary& dict, + const word& prefix ); //- Destructor - virtual ~functionObjectFiles(); + virtual ~writeFiles(); // Member Functions @@ -135,6 +135,7 @@ public: // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // +} // End namespace functionObjects } // End namespace Foam // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/src/postProcessing/functionObjects/field/Make/files b/src/postProcessing/functionObjects/field/Make/files index 0aa4a5184d701c4cab6288a8311d6cf2f8d701b6..f25f7d5172813348dec97313ddb226e62b997dfa 100644 --- a/src/postProcessing/functionObjects/field/Make/files +++ b/src/postProcessing/functionObjects/field/Make/files @@ -1,61 +1,39 @@ -fieldAverage/fieldAverage/fieldAverage.C +fieldAverage/fieldAverage.C fieldAverage/fieldAverageItem/fieldAverageItem.C fieldAverage/fieldAverageItem/fieldAverageItemIO.C -fieldAverage/fieldAverageFunctionObject/fieldAverageFunctionObject.C fieldCoordinateSystemTransform/fieldCoordinateSystemTransform.C -fieldCoordinateSystemTransform/fieldCoordinateSystemTransformFunctionObject.C - fieldMinMax/fieldMinMax.C -fieldMinMax/fieldMinMaxFunctionObject.C fieldValues/fieldValue/fieldValue.C fieldValues/fieldValue/fieldValueNew.C fieldValues/fieldValueDelta/fieldValueDelta.C -fieldValues/fieldValueDelta/fieldValueDeltaFunctionObject.C -fieldValues/faceSource/faceSource.C -fieldValues/faceSource/faceSourceFunctionObject.C fieldValues/cellSource/cellSource.C -fieldValues/cellSource/cellSourceFunctionObject.C +fieldValues/faceSource/faceSource.C nearWallFields/nearWallFields.C -nearWallFields/nearWallFieldsFunctionObject.C nearWallFields/findCellParticle.C nearWallFields/findCellParticleCloud.C processorField/processorField.C -processorField/processorFieldFunctionObject.C - readFields/readFields.C -readFields/readFieldsFunctionObject.C streamLine/streamLine.C streamLine/streamLineParticle.C streamLine/streamLineParticleCloud.C -streamLine/streamLineFunctionObject.C wallBoundedStreamLine/wallBoundedStreamLine.C -wallBoundedStreamLine/wallBoundedStreamLineFunctionObject.C wallBoundedStreamLine/wallBoundedStreamLineParticle.C wallBoundedStreamLine/wallBoundedStreamLineParticleCloud.C wallBoundedStreamLine/wallBoundedParticle.C surfaceInterpolateFields/surfaceInterpolateFields.C -surfaceInterpolateFields/surfaceInterpolateFieldsFunctionObject.C regionSizeDistribution/regionSizeDistribution.C -regionSizeDistribution/regionSizeDistributionFunctionObject.C - histogram/histogram.C -histogram/histogramFunctionObject.C div/div.C -div/divFunctionObject.C - grad/grad.C -grad/gradFunctionObject.C - mag/mag.C -mag/magFunctionObject.C LIB = $(FOAM_LIBBIN)/libfieldFunctionObjects diff --git a/src/postProcessing/functionObjects/field/div/div.C b/src/postProcessing/functionObjects/field/div/div.C index 599bb1946252c67e74e0f028cf83f16f3f678bac..691ff862c8b171f6630bf3dd29b00394d80c73f4 100644 --- a/src/postProcessing/functionObjects/field/div/div.C +++ b/src/postProcessing/functionObjects/field/div/div.C @@ -25,8 +25,7 @@ License #include "div.H" #include "volFields.H" -#include "dictionary.H" -#include "div.H" +#include "addToRunTimeSelectionTable.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -35,6 +34,7 @@ namespace Foam namespace functionObjects { defineTypeNameAndDebug(div, 0); + addToRunTimeSelectionTable(functionObject, div, dictionary); } } @@ -82,17 +82,22 @@ Foam::volScalarField& Foam::functionObjects::div::divField Foam::functionObjects::div::div ( const word& name, - const objectRegistry& obr, - const dictionary& dict, - const bool loadFromFiles + const Time& runTime, + const dictionary& dict ) : - name_(name), - obr_(obr), + functionObject(name), + obr_ + ( + runTime.lookupObject<objectRegistry> + ( + dict.lookupOrDefault("region", polyMesh::defaultRegion) + ) + ), fieldName_("undefined-fieldName"), resultName_("undefined-resultName") { - if (!isA<fvMesh>(obr)) + if (!isA<fvMesh>(obr_)) { FatalErrorInFunction << "objectRegistry is not an fvMesh" << exit(FatalError); @@ -110,7 +115,7 @@ Foam::functionObjects::div::~div() // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -void Foam::functionObjects::div::read(const dictionary& dict) +bool Foam::functionObjects::div::read(const dictionary& dict) { dict.lookup("fieldName") >> fieldName_; dict.lookup("resultName") >> resultName_; @@ -119,10 +124,12 @@ void Foam::functionObjects::div::read(const dictionary& dict) { resultName_ = "fvc::div(" + fieldName_ + ")"; } + + return true; } -void Foam::functionObjects::div::execute() +bool Foam::functionObjects::div::execute(const bool postProcess) { bool processed = false; @@ -134,31 +141,25 @@ void Foam::functionObjects::div::execute() WarningInFunction << "Unprocessed field " << fieldName_ << endl; } -} - -void Foam::functionObjects::div::end() -{ - execute(); + return true; } -void Foam::functionObjects::div::timeSet() -{} - - -void Foam::functionObjects::div::write() +bool Foam::functionObjects::div::write(const bool postProcess) { if (obr_.foundObject<regIOobject>(resultName_)) { const regIOobject& field = obr_.lookupObject<regIOobject>(resultName_); - Info<< type() << " " << name_ << " output:" << nl + Info<< type() << " " << name() << " output:" << nl << " writing field " << field.name() << nl << endl; field.write(); } + + return true; } diff --git a/src/postProcessing/functionObjects/field/div/div.H b/src/postProcessing/functionObjects/field/div/div.H index 4f7bed7ae4e9d7fbad13e6a4ab8b591f79e64116..5d1df72c420cc3a62746754302a22c054e0587e9 100644 --- a/src/postProcessing/functionObjects/field/div/div.H +++ b/src/postProcessing/functionObjects/field/div/div.H @@ -29,8 +29,8 @@ Group Description This function object calculates the divergence of a field. The operation is - limited to surfaceScalarFields and volumeVector fields, and the output is a - volume scalar field. + limited to surfaceScalarFields and volVectorFields, and the output is a + volScalarField. SourceFiles div.C @@ -40,11 +40,8 @@ SourceFiles #ifndef functionObjects_div_H #define functionObjects_div_H +#include "functionObject.H" #include "volFieldsFwd.H" -#include "surfaceFieldsFwd.H" -#include "pointFieldFwd.H" -#include "OFstream.H" -#include "Switch.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -53,9 +50,6 @@ namespace Foam // Forward declaration of classes class objectRegistry; -class dictionary; -class polyMesh; -class mapPolyMesh; class dimensionSet; namespace functionObjects @@ -66,13 +60,12 @@ namespace functionObjects \*---------------------------------------------------------------------------*/ class div +: + public functionObject { // Private data - //- Name of this div object - word name_; - - //- Reference to the database + //- Reference to the objectRegistry const objectRegistry& obr_; //- Name of field to process @@ -115,14 +108,12 @@ public: // Constructors - //- Construct for given objectRegistry and dictionary. - // Allow the possibility to load fields from files + //- Construct from Time and dictionary div ( const word& name, - const objectRegistry&, - const dictionary&, - const bool loadFromFiles = false + const Time& runTime, + const dictionary& dict ); @@ -132,34 +123,14 @@ public: // Member Functions - //- Return name of the set of div - virtual const word& name() const - { - return name_; - } - //- Read the div 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(); - - //- Called when time was set at the end of the Time::operator++ - virtual void timeSet(); - - //- Calculate the div and write - virtual void write(); + virtual bool read(const dictionary&); - //- Update for changes of mesh - virtual void updateMesh(const mapPolyMesh&) - {} + //- Calculate the divergence field + virtual bool execute(const bool postProcess = false); - //- Update for changes of mesh - virtual void movePoints(const polyMesh&) - {} + //- Write the divergence field + virtual bool write(const bool postProcess = false); }; diff --git a/src/postProcessing/functionObjects/field/div/divFunctionObject.C b/src/postProcessing/functionObjects/field/div/divFunctionObject.C deleted file mode 100644 index 33c4d507a1d03a6ec71c10f56d11a99d37a770c3..0000000000000000000000000000000000000000 --- a/src/postProcessing/functionObjects/field/div/divFunctionObject.C +++ /dev/null @@ -1,42 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2012-2016 OpenFOAM Foundation - \\/ 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 <http://www.gnu.org/licenses/>. - -\*---------------------------------------------------------------------------*/ - -#include "divFunctionObject.H" - -// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // - -namespace Foam -{ - defineNamedTemplateTypeNameAndDebug(divFunctionObject, 0); - - addToRunTimeSelectionTable - ( - functionObject, - divFunctionObject, - dictionary - ); -} - -// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/field/div/divFunctionObject.H b/src/postProcessing/functionObjects/field/div/divFunctionObject.H deleted file mode 100644 index 4ca010f8473d5d3f1c4e20765a2e4b76cd5c8fab..0000000000000000000000000000000000000000 --- a/src/postProcessing/functionObjects/field/div/divFunctionObject.H +++ /dev/null @@ -1,54 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2012-2016 OpenFOAM Foundation - \\/ 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 <http://www.gnu.org/licenses/>. - -Typedef - Foam::divFunctionObject - -Description - FunctionObject wrapper around div to allow it to be created - via the functions entry within controlDict. - -SourceFiles - divFunctionObject.C - -\*---------------------------------------------------------------------------*/ - -#ifndef divFunctionObject_H -#define divFunctionObject_H - -#include "div.H" -#include "OutputFilterFunctionObject.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - typedef OutputFilterFunctionObject<functionObjects::div> - divFunctionObject; -} - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#endif - -// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/field/fieldAverage/fieldAverage/fieldAverage.C b/src/postProcessing/functionObjects/field/fieldAverage/fieldAverage.C similarity index 91% rename from src/postProcessing/functionObjects/field/fieldAverage/fieldAverage/fieldAverage.C rename to src/postProcessing/functionObjects/field/fieldAverage/fieldAverage.C index adfad58cba01ab87a2d2637c28684cf582287e6a..c879832630993d87c4ed591d73df453af8a0785c 100644 --- a/src/postProcessing/functionObjects/field/fieldAverage/fieldAverage/fieldAverage.C +++ b/src/postProcessing/functionObjects/field/fieldAverage/fieldAverage.C @@ -25,8 +25,8 @@ License #include "fieldAverage.H" #include "volFields.H" -#include "Time.H" #include "fieldAverageItem.H" +#include "addToRunTimeSelectionTable.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -35,6 +35,7 @@ namespace Foam namespace functionObjects { defineTypeNameAndDebug(fieldAverage, 0); + addToRunTimeSelectionTable(functionObject, fieldAverage, dictionary); } } @@ -68,7 +69,7 @@ void Foam::functionObjects::fieldAverage::initialize() { resetFields(); - Info<< type() << " " << name_ << ":" << nl; + Info<< type() << " " << name() << ":" << nl; // Add mean fields to the field lists forAll(faItems_, fieldi) @@ -136,7 +137,7 @@ void Foam::functionObjects::fieldAverage::calcAverages() periodIndex_++; } - Info<< type() << " " << name_ << " output:" << nl; + Info<< type() << " " << name() << " output:" << nl; Info<< " Calculating averages" << nl; @@ -259,13 +260,18 @@ void Foam::functionObjects::fieldAverage::readAveragingProperties() Foam::functionObjects::fieldAverage::fieldAverage ( const word& name, - const objectRegistry& obr, - const dictionary& dict, - const bool loadFromFiles + const Time& t, + const dictionary& dict ) : - name_(name), - obr_(obr), + functionObject(name), + obr_ + ( + t.lookupObject<objectRegistry> + ( + dict.lookupOrDefault("region", polyMesh::defaultRegion) + ) + ), prevTimeIndex_(-1), restartOnRestart_(false), restartOnOutput_(false), @@ -277,7 +283,7 @@ Foam::functionObjects::fieldAverage::fieldAverage totalTime_(), periodIndex_(1) { - if (!isA<fvMesh>(obr)) + if (!isA<fvMesh>(obr_)) { FatalErrorInFunction << "objectRegistry is not an fvMesh" << exit(FatalError); @@ -295,11 +301,11 @@ Foam::functionObjects::fieldAverage::~fieldAverage() // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -void Foam::functionObjects::fieldAverage::read(const dictionary& dict) +bool Foam::functionObjects::fieldAverage::read(const dictionary& dict) { initialised_ = false; - Info<< type() << " " << name_ << ":" << nl; + Info<< type() << " " << name() << ":" << nl; dict.readIfPresent("restartOnRestart", restartOnRestart_); dict.readIfPresent("restartOnOutput", restartOnOutput_); @@ -314,28 +320,21 @@ void Foam::functionObjects::fieldAverage::read(const dictionary& dict) readAveragingProperties(); Info<< endl; -} - -void Foam::functionObjects::fieldAverage::execute() -{ - calcAverages(); - Info<< endl; + return true; } -void Foam::functionObjects::fieldAverage::end() +bool Foam::functionObjects::fieldAverage::execute(const bool postProcess) { calcAverages(); Info<< endl; -} - -void Foam::functionObjects::fieldAverage::timeSet() -{} + return true; +} -void Foam::functionObjects::fieldAverage::write() +bool Foam::functionObjects::fieldAverage::write(const bool postProcess) { writeAverages(); writeAveragingProperties(); @@ -346,15 +345,9 @@ void Foam::functionObjects::fieldAverage::write() } Info<< endl; -} - -void Foam::functionObjects::fieldAverage::updateMesh(const mapPolyMesh&) -{} - - -void Foam::functionObjects::fieldAverage::movePoints(const polyMesh&) -{} + return true; +} // ************************************************************************* // diff --git a/src/postProcessing/functionObjects/field/fieldAverage/fieldAverage/fieldAverage.H b/src/postProcessing/functionObjects/field/fieldAverage/fieldAverage.H similarity index 88% rename from src/postProcessing/functionObjects/field/fieldAverage/fieldAverage/fieldAverage.H rename to src/postProcessing/functionObjects/field/fieldAverage/fieldAverage.H index cec06ebcfd9624cb4cf34b4179000814310d34ce..a4bda83f3a08c555284594c3a039206b784bf970 100644 --- a/src/postProcessing/functionObjects/field/fieldAverage/fieldAverage/fieldAverage.H +++ b/src/postProcessing/functionObjects/field/fieldAverage/fieldAverage.H @@ -110,7 +110,6 @@ Note SeeAlso Foam::functionObject - Foam::OutputFilterFunctionObject SourceFiles fieldAverage.C @@ -122,7 +121,7 @@ SourceFiles #ifndef functionObjects_fieldAverage_H #define functionObjects_fieldAverage_H -#include "volFieldsFwd.H" +#include "functionObject.H" #include "Switch.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -132,11 +131,6 @@ namespace Foam // Forward declaration of classes class objectRegistry; -class dictionary; -template<class Type> -class List; -class polyMesh; -class mapPolyMesh; namespace functionObjects { @@ -149,15 +143,14 @@ class fieldAverageItem; \*---------------------------------------------------------------------------*/ class fieldAverage +: + public functionObject { protected: // Protected data - //- Name of this set of field averages. - word name_; - - //- Database this class is registered to + //- Reference to the objectRegistry const objectRegistry& obr_; //- Time at last call, prevents repeated averaging @@ -291,14 +284,12 @@ public: // Constructors - //- Construct for given objectRegistry and dictionary. - // Allow the possibility to load fields from files + //- Construct from Time and dictionary fieldAverage ( const word& name, - const objectRegistry&, - const dictionary&, - const bool loadFromFiles = false + const Time& t, + const dictionary& ); @@ -308,32 +299,14 @@ public: // Member Functions - //- Return name of the set of field averages - virtual const word& name() const - { - return name_; - } - //- Read the field average data - virtual void read(const dictionary&); - - //- Execute the averaging - virtual void execute(); - - //- Execute the averaging at the final time-loop, currently does nothing - virtual void end(); - - //- Called when time was set at the end of the Time::operator++ - virtual void timeSet(); - - //- Calculate the field average data and write - virtual void write(); + virtual bool read(const dictionary&); - //- Update mesh - virtual void updateMesh(const mapPolyMesh&); + //- Calculate the field averages + virtual bool execute(const bool postProcess = false); - //- Move points - virtual void movePoints(const polyMesh&); + //- Write the field averages + virtual bool write(const bool postProcess = false); }; diff --git a/src/postProcessing/functionObjects/field/fieldAverage/fieldAverageFunctionObject/fieldAverageFunctionObject.C b/src/postProcessing/functionObjects/field/fieldAverage/fieldAverageFunctionObject/fieldAverageFunctionObject.C deleted file mode 100644 index 5ecd65a063428a8edefe716b452e70f830df3958..0000000000000000000000000000000000000000 --- a/src/postProcessing/functionObjects/field/fieldAverage/fieldAverageFunctionObject/fieldAverageFunctionObject.C +++ /dev/null @@ -1,42 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation - \\/ 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 <http://www.gnu.org/licenses/>. - -\*---------------------------------------------------------------------------*/ - -#include "fieldAverageFunctionObject.H" - -// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // - -namespace Foam -{ - defineNamedTemplateTypeNameAndDebug(fieldAverageFunctionObject, 0); - - addToRunTimeSelectionTable - ( - functionObject, - fieldAverageFunctionObject, - dictionary - ); -} - -// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/field/fieldAverage/fieldAverageFunctionObject/fieldAverageFunctionObject.H b/src/postProcessing/functionObjects/field/fieldAverage/fieldAverageFunctionObject/fieldAverageFunctionObject.H deleted file mode 100644 index 13e14917538d29381308e125f53d110169dd4ec6..0000000000000000000000000000000000000000 --- a/src/postProcessing/functionObjects/field/fieldAverage/fieldAverageFunctionObject/fieldAverageFunctionObject.H +++ /dev/null @@ -1,54 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation - \\/ 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 <http://www.gnu.org/licenses/>. - -Typedef - Foam::fieldAverageFunctionObject - -Description - FunctionObject wrapper around fieldAverage to allow them to be created - via the functions entry within controlDict. - -SourceFiles - fieldAverageFunctionObject.C - -\*---------------------------------------------------------------------------*/ - -#ifndef fieldAverageFunctionObject_H -#define fieldAverageFunctionObject_H - -#include "fieldAverage.H" -#include "OutputFilterFunctionObject.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - typedef OutputFilterFunctionObject<functionObjects::fieldAverage> - fieldAverageFunctionObject; -} - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#endif - -// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/field/fieldAverage/fieldAverage/fieldAverageTemplates.C b/src/postProcessing/functionObjects/field/fieldAverage/fieldAverageTemplates.C similarity index 100% rename from src/postProcessing/functionObjects/field/fieldAverage/fieldAverage/fieldAverageTemplates.C rename to src/postProcessing/functionObjects/field/fieldAverage/fieldAverageTemplates.C diff --git a/src/postProcessing/functionObjects/field/fieldCoordinateSystemTransform/fieldCoordinateSystemTransform.C b/src/postProcessing/functionObjects/field/fieldCoordinateSystemTransform/fieldCoordinateSystemTransform.C index 7359bea3830ffa12c97dd71d7ba4efaa9bb47e58..702d77983e1c30e2d1bc2240eec491e97f9e7aa2 100644 --- a/src/postProcessing/functionObjects/field/fieldCoordinateSystemTransform/fieldCoordinateSystemTransform.C +++ b/src/postProcessing/functionObjects/field/fieldCoordinateSystemTransform/fieldCoordinateSystemTransform.C @@ -25,6 +25,7 @@ License #include "fieldCoordinateSystemTransform.H" #include "dictionary.H" +#include "addToRunTimeSelectionTable.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -33,6 +34,13 @@ namespace Foam namespace functionObjects { defineTypeNameAndDebug(fieldCoordinateSystemTransform, 0); + + addToRunTimeSelectionTable + ( + functionObject, + fieldCoordinateSystemTransform, + dictionary + ); } } @@ -43,17 +51,22 @@ Foam::functionObjects::fieldCoordinateSystemTransform:: fieldCoordinateSystemTransform ( const word& name, - const objectRegistry& obr, - const dictionary& dict, - const bool loadFromFiles + const Time& runTime, + const dictionary& dict ) : - name_(name), - obr_(obr), + functionObject(name), + obr_ + ( + runTime.lookupObject<objectRegistry> + ( + dict.lookupOrDefault("region", polyMesh::defaultRegion) + ) + ), fieldSet_(), - coordSys_(obr, dict) + coordSys_(obr_, dict) { - if (!isA<fvMesh>(obr)) + if (!isA<fvMesh>(obr_)) { FatalErrorInFunction << "objectRegistry is not an fvMesh" << exit(FatalError); @@ -61,7 +74,7 @@ fieldCoordinateSystemTransform read(dict); - Info<< type() << " " << name_ << ":" << nl + Info<< type() << " " << name << ":" << nl << " Applying transformation from global Cartesian to local " << coordSys_ << nl << endl; } @@ -76,18 +89,23 @@ Foam::functionObjects::fieldCoordinateSystemTransform:: // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -void Foam::functionObjects::fieldCoordinateSystemTransform::read +bool Foam::functionObjects::fieldCoordinateSystemTransform::read ( const dictionary& dict ) { dict.lookup("fields") >> fieldSet_; + + return true; } -void Foam::functionObjects::fieldCoordinateSystemTransform::execute() +bool Foam::functionObjects::fieldCoordinateSystemTransform::execute +( + const bool postProcess +) { - Info<< type() << " " << name_ << " output:" << nl; + Info<< type() << " " << name() << " output:" << nl; forAll(fieldSet_, fieldi) { @@ -98,22 +116,17 @@ void Foam::functionObjects::fieldCoordinateSystemTransform::execute() transform<symmTensor>(fieldSet_[fieldi]); transform<tensor>(fieldSet_[fieldi]); } -} - -void Foam::functionObjects::fieldCoordinateSystemTransform::end() -{ - execute(); + return true; } -void Foam::functionObjects::fieldCoordinateSystemTransform::timeSet() -{} - - -void Foam::functionObjects::fieldCoordinateSystemTransform::write() +bool Foam::functionObjects::fieldCoordinateSystemTransform::write +( + const bool postProcess +) { - Info<< type() << " " << name_ << " output:" << nl; + Info<< type() << " " << name() << " output:" << nl; forAll(fieldSet_, fieldi) { @@ -128,6 +141,8 @@ void Foam::functionObjects::fieldCoordinateSystemTransform::write() } Info<< endl; + + return true; } diff --git a/src/postProcessing/functionObjects/field/fieldCoordinateSystemTransform/fieldCoordinateSystemTransform.H b/src/postProcessing/functionObjects/field/fieldCoordinateSystemTransform/fieldCoordinateSystemTransform.H index 4995caea3bec29350978b4bbe01053647dde18d5..23334db14f3c5199e584b614aac232e0a83b606f 100644 --- a/src/postProcessing/functionObjects/field/fieldCoordinateSystemTransform/fieldCoordinateSystemTransform.H +++ b/src/postProcessing/functionObjects/field/fieldCoordinateSystemTransform/fieldCoordinateSystemTransform.H @@ -64,7 +64,6 @@ Description SeeAlso Foam::functionObject - Foam::OutputFilterFunctionObject Foam::coordinateSystem SourceFiles @@ -76,9 +75,8 @@ SourceFiles #ifndef functionObjects_fieldCoordinateSystemTransform_H #define functionObjects_fieldCoordinateSystemTransform_H -#include "OFstream.H" -#include "volFields.H" -#include "surfaceFields.H" +#include "functionObject.H" +#include "volFieldsFwd.H" #include "coordinateSystem.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -88,9 +86,6 @@ namespace Foam // Forward declaration of classes class objectRegistry; -class dictionary; -class polyMesh; -class mapPolyMesh; namespace functionObjects { @@ -100,14 +95,14 @@ namespace functionObjects \*---------------------------------------------------------------------------*/ class fieldCoordinateSystemTransform +: + public functionObject { protected: // Protected data - //- Name - word name_; - + //- Reference to the objectRegistry const objectRegistry& obr_; //- Fields to transform @@ -145,14 +140,12 @@ public: // Constructors - //- Construct for given objectRegistry and dictionary. - // Allow the possibility to load fields from files + //- Construct from Time and dictionary fieldCoordinateSystemTransform ( const word& name, - const objectRegistry&, - const dictionary&, - const bool loadFromFiles = false + const Time& runTime, + const dictionary& dict ); @@ -162,34 +155,14 @@ public: // Member Functions - //- Return name of the fieldCoordinateSystemTransform object - virtual const word& name() const - { - return name_; - } - //- Read the input data - virtual void read(const dictionary&); + virtual bool read(const dictionary&); //- Execute, currently does nothing - virtual void execute(); - - //- Execute at the final time-loop, currently does nothing - virtual void end(); - - //- Called when time was set at the end of the Time::operator++ - virtual void timeSet(); + virtual bool execute(const bool postProcess = false); //- Write - virtual void write(); - - //- Update for changes of mesh - virtual void updateMesh(const mapPolyMesh&) - {} - - //- Update for changes of mesh - virtual void movePoints(const polyMesh&) - {} + virtual bool write(const bool postProcess = false); }; diff --git a/src/postProcessing/functionObjects/field/fieldCoordinateSystemTransform/fieldCoordinateSystemTransformFunctionObject.C b/src/postProcessing/functionObjects/field/fieldCoordinateSystemTransform/fieldCoordinateSystemTransformFunctionObject.C deleted file mode 100644 index be3f5624b474da841e9ddb374c0aed611ecf4a16..0000000000000000000000000000000000000000 --- a/src/postProcessing/functionObjects/field/fieldCoordinateSystemTransform/fieldCoordinateSystemTransformFunctionObject.C +++ /dev/null @@ -1,45 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation - \\/ 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 <http://www.gnu.org/licenses/>. - -\*---------------------------------------------------------------------------*/ - -#include "fieldCoordinateSystemTransformFunctionObject.H" - -// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // - -namespace Foam -{ - defineNamedTemplateTypeNameAndDebug - ( - fieldCoordinateSystemTransformFunctionObject, 0 - ); - - addToRunTimeSelectionTable - ( - functionObject, - fieldCoordinateSystemTransformFunctionObject, - dictionary - ); -} - -// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/field/fieldCoordinateSystemTransform/fieldCoordinateSystemTransformFunctionObject.H b/src/postProcessing/functionObjects/field/fieldCoordinateSystemTransform/fieldCoordinateSystemTransformFunctionObject.H deleted file mode 100644 index aaa018733337f16048b9db67db6e2b665a7fe1ea..0000000000000000000000000000000000000000 --- a/src/postProcessing/functionObjects/field/fieldCoordinateSystemTransform/fieldCoordinateSystemTransformFunctionObject.H +++ /dev/null @@ -1,56 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation - \\/ 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 <http://www.gnu.org/licenses/>. - -Typedef - Foam::fieldCoordinateSystemTransformFunctionObject - -Description - FunctionObject wrapper around fieldCoordinateSystemTransform to allow - them to be created via the functions entry within controlDict. - -SourceFiles - fieldCoordinateSystemTransformFunctionObject.C - -\*---------------------------------------------------------------------------*/ - -#ifndef fieldCoordinateSystemTransformFunctionObject_H -#define fieldCoordinateSystemTransformFunctionObject_H - -#include "fieldCoordinateSystemTransform.H" -#include "OutputFilterFunctionObject.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - typedef OutputFilterFunctionObject - < - functionObjects::fieldCoordinateSystemTransform - > fieldCoordinateSystemTransformFunctionObject; -} - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#endif - -// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/field/fieldMinMax/fieldMinMax.C b/src/postProcessing/functionObjects/field/fieldMinMax/fieldMinMax.C index a0ab4def64fe8b46f4dd44a4313acabb3dd531be..ec0d25ad143b8fbb8d2fd85155d8325516b18e1f 100644 --- a/src/postProcessing/functionObjects/field/fieldMinMax/fieldMinMax.C +++ b/src/postProcessing/functionObjects/field/fieldMinMax/fieldMinMax.C @@ -25,6 +25,7 @@ License #include "fieldMinMax.H" #include "fieldTypes.H" +#include "addToRunTimeSelectionTable.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -33,6 +34,7 @@ namespace Foam namespace functionObjects { defineTypeNameAndDebug(fieldMinMax, 0); + addToRunTimeSelectionTable(functionObject, fieldMinMax, dictionary); } } @@ -50,51 +52,7 @@ const Foam::NamedEnum > Foam::functionObjects::fieldMinMax::modeTypeNames_; -// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // - -Foam::functionObjects::fieldMinMax::fieldMinMax -( - const word& name, - const objectRegistry& obr, - const dictionary& dict, - const bool loadFromFiles -) -: - functionObjectFiles(obr, name, typeName), - name_(name), - obr_(obr), - log_(true), - location_(true), - mode_(mdMag), - fieldSet_() -{ - if (!isA<fvMesh>(obr)) - { - FatalErrorInFunction - << "objectRegistry is not an fvMesh" << exit(FatalError); - } - - read(dict); -} - - -// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // - -Foam::functionObjects::fieldMinMax::~fieldMinMax() -{} - - -// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // - -void Foam::functionObjects::fieldMinMax::read(const dictionary& dict) -{ - log_ = dict.lookupOrDefault<Switch>("log", true); - location_ = dict.lookupOrDefault<Switch>("location", true); - - mode_ = modeTypeNames_[dict.lookupOrDefault<word>("mode", "magnitude")]; - dict.lookup("fields") >> fieldSet_; -} - +// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // void Foam::functionObjects::fieldMinMax::writeFileHeader(const label i) { @@ -136,24 +94,64 @@ void Foam::functionObjects::fieldMinMax::writeFileHeader(const label i) } -void Foam::functionObjects::fieldMinMax::execute() -{} +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // +Foam::functionObjects::fieldMinMax::fieldMinMax +( + const word& name, + const Time& runTime, + const dictionary& dict +) +: + writeFiles(name, runTime, dict, name), + location_(true), + mode_(mdMag), + fieldSet_() +{ + if (!isA<fvMesh>(obr_)) + { + FatalErrorInFunction + << "objectRegistry is not an fvMesh" << exit(FatalError); + } -void Foam::functionObjects::fieldMinMax::end() -{} + read(dict); + resetName(typeName); +} -void Foam::functionObjects::fieldMinMax::timeSet() +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + +Foam::functionObjects::fieldMinMax::~fieldMinMax() {} -void Foam::functionObjects::fieldMinMax::write() +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +bool Foam::functionObjects::fieldMinMax::read(const dictionary& dict) +{ + writeFiles::read(dict); + + location_ = dict.lookupOrDefault<Switch>("location", true); + + mode_ = modeTypeNames_[dict.lookupOrDefault<word>("mode", "magnitude")]; + dict.lookup("fields") >> fieldSet_; + + return true; +} + + +bool Foam::functionObjects::fieldMinMax::execute(const bool postProcess) { - functionObjectFiles::write(); + return true; +} + + +bool Foam::functionObjects::fieldMinMax::write(const bool postProcess) +{ + writeFiles::write(); if (!location_) writeTime(file()); - if (log_) Info<< type() << " " << name_ << " output:" << nl; + if (log_) Info<< type() << " " << name() << " output:" << nl; forAll(fieldSet_, fieldi) { @@ -166,6 +164,8 @@ void Foam::functionObjects::fieldMinMax::write() if (!location_) file()<< endl; if (log_) Info<< endl; + + return true; } diff --git a/src/postProcessing/functionObjects/field/fieldMinMax/fieldMinMax.H b/src/postProcessing/functionObjects/field/fieldMinMax/fieldMinMax.H index 2f47d58c9d00dd600299ea2d3d5ef67530c09f24..45942bf2b348fcbb07d0a6c6bdfcc84fd1cd18fb 100644 --- a/src/postProcessing/functionObjects/field/fieldMinMax/fieldMinMax.H +++ b/src/postProcessing/functionObjects/field/fieldMinMax/fieldMinMax.H @@ -67,7 +67,7 @@ Description SeeAlso Foam::functionObject - Foam::OutputFilterFunctionObject + Foam::functionObjects::writeFiles SourceFiles fieldMinMax.C @@ -77,21 +77,13 @@ SourceFiles #ifndef functionObjects_fieldMinMax_H #define functionObjects_fieldMinMax_H -#include "functionObjectFiles.H" -#include "Switch.H" +#include "writeFiles.H" #include "vector.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // namespace Foam { - -// Forward declaration of classes -class objectRegistry; -class dictionary; -class polyMesh; -class mapPolyMesh; - namespace functionObjects { @@ -101,7 +93,7 @@ namespace functionObjects class fieldMinMax : - public functionObjectFiles + public writeFiles { public: @@ -118,15 +110,6 @@ protected: //- Mode type names static const NamedEnum<modeType, 2> modeTypeNames_; - //- Name of this set of field min/max - // Also used as the name of the output directory - word name_; - - const objectRegistry& obr_; - - //- Switch to send output to Info as well - Switch log_; - //- Switch to write location of min/max values Switch location_; @@ -159,6 +142,14 @@ protected: //- Disallow default bitwise assignment void operator=(const fieldMinMax&); + //- Calculate the field min/max + template<class Type> + void calcMinMaxFields + ( + const word& fieldName, + const modeType& mode + ); + //- Output file header information virtual void writeFileHeader(const label i); @@ -171,14 +162,12 @@ public: // Constructors - //- Construct for given objectRegistry and dictionary. - // Allow the possibility to load fields from files + //- Construct from Time and dictionary fieldMinMax ( const word& name, - const objectRegistry&, - const dictionary&, - const bool loadFromFiles = false + const Time& runTime, + const dictionary& dict ); @@ -188,42 +177,14 @@ public: // Member Functions - //- Return name of the set of field min/max - virtual const word& name() const - { - return name_; - } - //- Read the field min/max data - virtual void read(const dictionary&); + virtual bool read(const dictionary&); //- Execute, currently does nothing - virtual void execute(); - - //- Execute at the final time-loop, currently does nothing - virtual void end(); - - //- Called when time was set at the end of the Time::operator++ - virtual void timeSet(); - - //- Calculate the field min/max - template<class Type> - void calcMinMaxFields - ( - const word& fieldName, - const modeType& mode - ); + virtual bool execute(const bool postProcess = false); //- Write the fieldMinMax - virtual void write(); - - //- Update for changes of mesh - virtual void updateMesh(const mapPolyMesh&) - {} - - //- Update for changes of mesh - virtual void movePoints(const polyMesh&) - {} + virtual bool write(const bool postProcess = false); }; diff --git a/src/postProcessing/functionObjects/field/fieldMinMax/fieldMinMaxFunctionObject.C b/src/postProcessing/functionObjects/field/fieldMinMax/fieldMinMaxFunctionObject.C deleted file mode 100644 index a7c16ea90bc00fd22446d43c1e9814066e4c5f12..0000000000000000000000000000000000000000 --- a/src/postProcessing/functionObjects/field/fieldMinMax/fieldMinMaxFunctionObject.C +++ /dev/null @@ -1,42 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation - \\/ 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 <http://www.gnu.org/licenses/>. - -\*---------------------------------------------------------------------------*/ - -#include "fieldMinMaxFunctionObject.H" - -// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // - -namespace Foam -{ - defineNamedTemplateTypeNameAndDebug(fieldMinMaxFunctionObject, 0); - - addToRunTimeSelectionTable - ( - functionObject, - fieldMinMaxFunctionObject, - dictionary - ); -} - -// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/field/fieldMinMax/fieldMinMaxFunctionObject.H b/src/postProcessing/functionObjects/field/fieldMinMax/fieldMinMaxFunctionObject.H deleted file mode 100644 index dceaac3bde74b6fcf5cd74640142ea729b0a5278..0000000000000000000000000000000000000000 --- a/src/postProcessing/functionObjects/field/fieldMinMax/fieldMinMaxFunctionObject.H +++ /dev/null @@ -1,54 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation - \\/ 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 <http://www.gnu.org/licenses/>. - -Typedef - Foam::fieldMinMaxFunctionObject - -Description - FunctionObject wrapper around fieldMinMax to allow them to be created via - the functions entry within controlDict. - -SourceFiles - fieldMinMaxFunctionObject.C - -\*---------------------------------------------------------------------------*/ - -#ifndef fieldMinMaxFunctionObject_H -#define fieldMinMaxFunctionObject_H - -#include "fieldMinMax.H" -#include "OutputFilterFunctionObject.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - typedef OutputFilterFunctionObject<functionObjects::fieldMinMax> - fieldMinMaxFunctionObject; -} - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#endif - -// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/field/fieldValues/cellSource/cellSource.C b/src/postProcessing/functionObjects/field/fieldValues/cellSource/cellSource.C index 62e689185ffa45736d147e1ac66707d86b3f0f8a..b4fa1820498eac12cd27f13aa3770b12ec540f4a 100644 --- a/src/postProcessing/functionObjects/field/fieldValues/cellSource/cellSource.C +++ b/src/postProcessing/functionObjects/field/fieldValues/cellSource/cellSource.C @@ -38,6 +38,7 @@ namespace fieldValues { defineTypeNameAndDebug(cellSource, 0); addToRunTimeSelectionTable(fieldValue, cellSource, dictionary); + addToRunTimeSelectionTable(functionObject, cellSource, dictionary); } } } @@ -149,14 +150,14 @@ void Foam::functionObjects::fieldValues::cellSource::initialise if (nCells_ == 0) { FatalErrorInFunction - << type() << " " << name_ << ": " + << type() << " " << name() << ": " << sourceTypeNames_[source_] << "(" << sourceName_ << "):" << nl << " Source has no cells" << exit(FatalError); } volume_ = volume(); - Info<< type() << " " << name_ << ":" + Info<< type() << " " << name() << ":" << sourceTypeNames_[source_] << "(" << sourceName_ << "):" << nl << " total cells = " << nCells_ << nl << " total volume = " << volume_ @@ -202,15 +203,39 @@ void Foam::functionObjects::fieldValues::cellSource::writeFileHeader // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // +Foam::functionObjects::fieldValues::cellSource::cellSource +( + const word& name, + const Time& runTime, + const dictionary& dict +) +: + fieldValue(name, runTime, dict, typeName), + source_(sourceTypeNames_.read(dict.lookup("source"))), + operation_(operationTypeNames_.read(dict.lookup("operation"))), + nCells_(0), + cellId_(), + weightFieldName_("none"), + writeVolume_(dict.lookupOrDefault("writeVolume", false)) +{ + if (!isA<fvMesh>(obr_)) + { + FatalErrorInFunction + << "objectRegistry is not an fvMesh" << exit(FatalError); + } + + read(dict); +} + + Foam::functionObjects::fieldValues::cellSource::cellSource ( const word& name, const objectRegistry& obr, - const dictionary& dict, - const bool loadFromFiles + const dictionary& dict ) : - fieldValue(name, obr, dict, typeName, loadFromFiles), + fieldValue(name, obr, dict, typeName), source_(sourceTypeNames_.read(dict.lookup("source"))), operation_(operationTypeNames_.read(dict.lookup("operation"))), nCells_(0), @@ -218,7 +243,7 @@ Foam::functionObjects::fieldValues::cellSource::cellSource weightFieldName_("none"), writeVolume_(dict.lookupOrDefault("writeVolume", false)) { - if (!isA<fvMesh>(obr)) + if (!isA<fvMesh>(obr_)) { FatalErrorInFunction << "objectRegistry is not an fvMesh" << exit(FatalError); @@ -236,7 +261,7 @@ Foam::functionObjects::fieldValues::cellSource::~cellSource() // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -void Foam::functionObjects::fieldValues::cellSource::read +bool Foam::functionObjects::fieldValues::cellSource::read ( const dictionary& dict ) @@ -245,10 +270,15 @@ void Foam::functionObjects::fieldValues::cellSource::read // No additional info to read initialise(dict); + + return true; } -void Foam::functionObjects::fieldValues::cellSource::write() +bool Foam::functionObjects::fieldValues::cellSource::write +( + const bool postProcess +) { fieldValue::write(); @@ -293,6 +323,8 @@ void Foam::functionObjects::fieldValues::cellSource::write() } if (log_) Info<< endl; + + return true; } diff --git a/src/postProcessing/functionObjects/field/fieldValues/cellSource/cellSource.H b/src/postProcessing/functionObjects/field/fieldValues/cellSource/cellSource.H index 20f984d2c0ce36a5f5e2cee060676d8749ede167..db529bd1723b044e4cfd78c509db202b393bf5a9 100644 --- a/src/postProcessing/functionObjects/field/fieldValues/cellSource/cellSource.H +++ b/src/postProcessing/functionObjects/field/fieldValues/cellSource/cellSource.H @@ -95,7 +95,6 @@ Description SeeAlso Foam::fieldValues Foam::functionObject - Foam::OutputFilterFunctionObject SourceFiles cellSource.C @@ -105,10 +104,8 @@ SourceFiles #ifndef functionObjects_cellSource_H #define functionObjects_cellSource_H -#include "NamedEnum.H" #include "fieldValue.H" -#include "labelList.H" -#include "volFieldsFwd.H" +#include "NamedEnum.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -241,13 +238,20 @@ public: // Constructors - //- Construct from components + //- Construct from name, Time and dictionary + cellSource + ( + const word& name, + const Time& runTime, + const dictionary& dict + ); + + //- Construct from name, objectRegistry and dictionary cellSource ( const word& name, const objectRegistry& obr, - const dictionary& dict, - const bool loadFromFiles = false + const dictionary& dict ); @@ -257,30 +261,25 @@ public: // Public Member Functions - // Access - - //- Return the source type - inline const sourceType& source() const; - - //- Return the local list of cell IDs - inline const labelList& cellId() const; + //- Return the source type + inline const sourceType& source() const; + //- Return the local list of cell IDs + inline const labelList& cellId() const; - // Function object functions - - //- Read from dictionary - virtual void read(const dictionary&); + //- Templated helper function to output field values + template<class Type> + bool writeValues(const word& fieldName); - //- Calculate and write - virtual void write(); + //- Filter a field according to cellIds + template<class Type> + tmp<Field<Type>> filterField(const Field<Type>& field) const; - //- Templated helper function to output field values - template<class Type> - bool writeValues(const word& fieldName); + //- Read from dictionary + virtual bool read(const dictionary&); - //- Filter a field according to cellIds - template<class Type> - tmp<Field<Type>> filterField(const Field<Type>& field) const; + //- Calculate and write + virtual bool write(const bool postProcess = false); }; diff --git a/src/postProcessing/functionObjects/field/fieldValues/cellSource/cellSourceFunctionObject.C b/src/postProcessing/functionObjects/field/fieldValues/cellSource/cellSourceFunctionObject.C deleted file mode 100644 index 17a41c258892ba2b5ceca54739ff80de5a91fe44..0000000000000000000000000000000000000000 --- a/src/postProcessing/functionObjects/field/fieldValues/cellSource/cellSourceFunctionObject.C +++ /dev/null @@ -1,46 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation - \\/ 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 <http://www.gnu.org/licenses/>. - -\*---------------------------------------------------------------------------*/ - -#include "cellSourceFunctionObject.H" - -// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // - -namespace Foam -{ - defineNamedTemplateTypeNameAndDebug - ( - cellSourceFunctionObject, - 0 - ); - - addToRunTimeSelectionTable - ( - functionObject, - cellSourceFunctionObject, - dictionary - ); -} - -// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/field/fieldValues/cellSource/cellSourceFunctionObject.H b/src/postProcessing/functionObjects/field/fieldValues/cellSource/cellSourceFunctionObject.H deleted file mode 100644 index a136d782bc7cfb85829afff8e073f18b266ce570..0000000000000000000000000000000000000000 --- a/src/postProcessing/functionObjects/field/fieldValues/cellSource/cellSourceFunctionObject.H +++ /dev/null @@ -1,56 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation - \\/ 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 <http://www.gnu.org/licenses/>. - -Typedef - Foam::cellSourceFunctionObject - -Description - FunctionObject wrapper around cellSource to allow it to be - created via the functions entry within controlDict. - -SourceFiles - cellSourceFunctionObject.C - -\*---------------------------------------------------------------------------*/ - -#ifndef cellSourceFunctionObject_H -#define cellSourceFunctionObject_H - -#include "cellSource.H" -#include "OutputFilterFunctionObject.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - typedef OutputFilterFunctionObject - < - functionObjects::fieldValues::cellSource - > cellSourceFunctionObject; -} - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#endif - -// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/field/fieldValues/faceSource/faceSource.C b/src/postProcessing/functionObjects/field/fieldValues/faceSource/faceSource.C index 48b8d37a476c11d65d4ca88df6c1d62c505ad4a6..3800b554553ec0c773c0731715d8bf192002f5db 100644 --- a/src/postProcessing/functionObjects/field/fieldValues/faceSource/faceSource.C +++ b/src/postProcessing/functionObjects/field/fieldValues/faceSource/faceSource.C @@ -44,6 +44,7 @@ namespace fieldValues { defineTypeNameAndDebug(faceSource, 0); addToRunTimeSelectionTable(fieldValue, faceSource, dictionary); + addToRunTimeSelectionTable(functionObject, faceSource, dictionary); } } } @@ -106,7 +107,7 @@ void Foam::functionObjects::fieldValues::faceSource::setFaceZoneFaces() if (zoneId < 0) { FatalErrorInFunction - << type() << " " << name_ << ": " + << type() << " " << name() << ": " << sourceTypeNames_[source_] << "(" << sourceName_ << "):" << nl << " Unknown face zone name: " << sourceName_ << ". Valid face zones are: " << mesh().faceZones().names() @@ -191,7 +192,7 @@ void Foam::functionObjects::fieldValues::faceSource::setPatchFaces() if (patchid < 0) { FatalErrorInFunction - << type() << " " << name_ << ": " + << type() << " " << name() << ": " << sourceTypeNames_[source_] << "(" << sourceName_ << "):" << nl << " Unknown patch name: " << sourceName_ << ". Valid patch names are: " @@ -228,7 +229,7 @@ void Foam::functionObjects::fieldValues::faceSource::sampledSurfaceFaces { surfacePtr_ = sampledSurface::New ( - name_, + name(), mesh(), dict.subDict("sampledSurfaceDict") ); @@ -443,7 +444,7 @@ void Foam::functionObjects::fieldValues::faceSource::initialise default: { FatalErrorInFunction - << type() << " " << name_ << ": " + << type() << " " << name() << ": " << sourceTypeNames_[source_] << "(" << sourceName_ << "):" << nl << " Unknown source type. Valid source types are:" << sourceTypeNames_.sortedToc() << nl << exit(FatalError); @@ -453,7 +454,7 @@ void Foam::functionObjects::fieldValues::faceSource::initialise if (nFaces_ == 0) { FatalErrorInFunction - << type() << " " << name_ << ": " + << type() << " " << name() << ": " << sourceTypeNames_[source_] << "(" << sourceName_ << "):" << nl << " Source has no faces" << exit(FatalError); } @@ -465,7 +466,7 @@ void Foam::functionObjects::fieldValues::faceSource::initialise totalArea_ = totalArea(); - Info<< type() << " " << name_ << ":" << nl + Info<< type() << " " << name() << ":" << nl << " total faces = " << nFaces_ << nl << " total area = " << totalArea_ @@ -638,15 +639,44 @@ Foam::vector Foam::functionObjects::fieldValues::faceSource::processValues // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // +Foam::functionObjects::fieldValues::faceSource::faceSource +( + const word& name, + const Time& runTime, + const dictionary& dict +) +: + fieldValue(name, runTime, dict, typeName), + surfaceWriterPtr_(NULL), + source_(sourceTypeNames_.read(dict.lookup("source"))), + operation_(operationTypeNames_.read(dict.lookup("operation"))), + weightFieldName_("none"), + orientWeightField_(false), + orientedFieldsStart_(labelMax), + scaleFactor_(1.0), + writeArea_(dict.lookupOrDefault("writeArea", false)), + nFaces_(0), + faceId_(), + facePatchId_(), + faceSign_() +{ + if (!isA<fvMesh>(obr_)) + { + FatalErrorInFunction + << "objectRegistry is not an fvMesh" << exit(FatalError); + } + + read(dict); +} + Foam::functionObjects::fieldValues::faceSource::faceSource ( const word& name, const objectRegistry& obr, - const dictionary& dict, - const bool loadFromFiles + const dictionary& dict ) : - fieldValue(name, obr, dict, typeName, loadFromFiles), + fieldValue(name, obr, dict, typeName), surfaceWriterPtr_(NULL), source_(sourceTypeNames_.read(dict.lookup("source"))), operation_(operationTypeNames_.read(dict.lookup("operation"))), @@ -660,7 +690,7 @@ Foam::functionObjects::fieldValues::faceSource::faceSource facePatchId_(), faceSign_() { - if (!isA<fvMesh>(obr)) + if (!isA<fvMesh>(obr_)) { FatalErrorInFunction << "objectRegistry is not an fvMesh" << exit(FatalError); @@ -678,17 +708,22 @@ Foam::functionObjects::fieldValues::faceSource::~faceSource() // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -void Foam::functionObjects::fieldValues::faceSource::read +bool Foam::functionObjects::fieldValues::faceSource::read ( const dictionary& dict ) { fieldValue::read(dict); initialise(dict); + + return true; } -void Foam::functionObjects::fieldValues::faceSource::write() +bool Foam::functionObjects::fieldValues::faceSource::write +( + const bool postProcess +) { fieldValue::write(); @@ -757,6 +792,8 @@ void Foam::functionObjects::fieldValues::faceSource::write() } if (log_) Info<< endl; + + return true; } diff --git a/src/postProcessing/functionObjects/field/fieldValues/faceSource/faceSource.H b/src/postProcessing/functionObjects/field/fieldValues/faceSource/faceSource.H index 774fa516ff02ee95ce2e0903d0211717a4c030d9..0d775f01edc0c6986a63e6024724e279fa68f440 100644 --- a/src/postProcessing/functionObjects/field/fieldValues/faceSource/faceSource.H +++ b/src/postProcessing/functionObjects/field/fieldValues/faceSource/faceSource.H @@ -128,7 +128,6 @@ Note SeeAlso Foam::fieldValues Foam::functionObject - Foam::OutputFilterFunctionObject SourceFiles faceSource.C @@ -139,11 +138,8 @@ SourceFiles #ifndef functionObjects_faceSource_H #define functionObjects_faceSource_H -#include "NamedEnum.H" #include "fieldValue.H" -#include "surfaceFieldsFwd.H" -#include "volFieldsFwd.H" -#include "surfaceWriter.H" +#include "NamedEnum.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -151,6 +147,7 @@ namespace Foam { class sampledSurface; +class surfaceWriter; namespace functionObjects { @@ -341,13 +338,20 @@ public: // Constructors - //- Construct from components + //- Construct from name, Time and dictionary + faceSource + ( + const word& name, + const Time& runTime, + const dictionary& dict + ); + + //- Construct from name, objectRegistry and dictionary faceSource ( const word& name, const objectRegistry& obr, - const dictionary& dict, - const bool loadFromFiles = false + const dictionary& dict ); @@ -357,57 +361,52 @@ public: // Public Member Functions - // Access - - //- Return the source type - inline const sourceType& source() const; - - //- Return the local list of face IDs - inline const labelList& faceId() const; - - //- Return the local list of patch ID per face - inline const labelList& facePatch() const; + //- Return the source type + inline const sourceType& source() const; - //- Return the list of +1/-1 representing face flip map - inline const labelList& faceSign() const; + //- Return the local list of face IDs + inline const labelList& faceId() const; + //- Return the local list of patch ID per face + inline const labelList& facePatch() const; - // Function object functions + //- Return the list of +1/-1 representing face flip map + inline const labelList& faceSign() const; - //- Read from dictionary - virtual void read(const dictionary&); + //- Templated helper function to output field values + template<class Type> + bool writeValues + ( + const word& fieldName, + const scalarField& weightField, + const bool orient + ); - //- Calculate and write - virtual void write(); + //- Filter a surface field according to faceIds + template<class Type> + tmp<Field<Type>> filterField + ( + const GeometricField<Type, fvsPatchField, surfaceMesh>& field, + const bool applyOrientation + ) const; - //- Templated helper function to output field values - template<class Type> - bool writeValues - ( - const word& fieldName, - const scalarField& weightField, - const bool orient - ); + //- Filter a volume field according to faceIds + template<class Type> + tmp<Field<Type>> filterField + ( + const GeometricField<Type, fvPatchField, volMesh>& field, + const bool applyOrientation + ) const; - //- Filter a surface field according to faceIds - template<class Type> - tmp<Field<Type>> filterField - ( - const GeometricField<Type, fvsPatchField, surfaceMesh>& field, - const bool applyOrientation - ) const; + //- Read from dictionary + virtual bool read(const dictionary&); - //- Filter a volume field according to faceIds - template<class Type> - tmp<Field<Type>> filterField - ( - const GeometricField<Type, fvPatchField, volMesh>& field, - const bool applyOrientation - ) const; + //- Calculate and write + virtual bool write(const bool postProcess = false); }; -//- Specialisation of processing scalars +//- Specialisation for scalar template<> scalar faceSource::processValues ( @@ -417,7 +416,7 @@ scalar faceSource::processValues ) const; -//- Specialisation of processing vectors +//- Specialisation for vector template<> vector faceSource::processValues ( diff --git a/src/postProcessing/functionObjects/field/fieldValues/faceSource/faceSourceFunctionObject.C b/src/postProcessing/functionObjects/field/fieldValues/faceSource/faceSourceFunctionObject.C deleted file mode 100644 index cc79b73ebc6850bd7ace822349cb84e42a93d269..0000000000000000000000000000000000000000 --- a/src/postProcessing/functionObjects/field/fieldValues/faceSource/faceSourceFunctionObject.C +++ /dev/null @@ -1,46 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation - \\/ 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 <http://www.gnu.org/licenses/>. - -\*---------------------------------------------------------------------------*/ - -#include "faceSourceFunctionObject.H" - -// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // - -namespace Foam -{ - defineNamedTemplateTypeNameAndDebug - ( - faceSourceFunctionObject, - 0 - ); - - addToRunTimeSelectionTable - ( - functionObject, - faceSourceFunctionObject, - dictionary - ); -} - -// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/field/fieldValues/faceSource/faceSourceFunctionObject.H b/src/postProcessing/functionObjects/field/fieldValues/faceSource/faceSourceFunctionObject.H deleted file mode 100644 index e368ea942f80160a9d4254b99b41f4cc183a6d81..0000000000000000000000000000000000000000 --- a/src/postProcessing/functionObjects/field/fieldValues/faceSource/faceSourceFunctionObject.H +++ /dev/null @@ -1,56 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation - \\/ 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 <http://www.gnu.org/licenses/>. - -Typedef - Foam::faceSourceFunctionObject - -Description - FunctionObject wrapper around faceSource to allow it to be - created via the functions entry within controlDict. - -SourceFiles - faceSourceFunctionObject.C - -\*---------------------------------------------------------------------------*/ - -#ifndef faceSourceFunctionObject_H -#define faceSourceFunctionObject_H - -#include "faceSource.H" -#include "OutputFilterFunctionObject.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - typedef OutputFilterFunctionObject - < - functionObjects::fieldValues::faceSource - > faceSourceFunctionObject; -} - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#endif - -// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/field/fieldValues/faceSource/faceSourceTemplates.C b/src/postProcessing/functionObjects/field/fieldValues/faceSource/faceSourceTemplates.C index e11317f57105309fa7a9f3e9292a6579a75c633e..a5047f249c279b6b9af3531645ab4b35ec85235d 100644 --- a/src/postProcessing/functionObjects/field/fieldValues/faceSource/faceSourceTemplates.C +++ b/src/postProcessing/functionObjects/field/fieldValues/faceSource/faceSourceTemplates.C @@ -27,6 +27,7 @@ License #include "surfaceFields.H" #include "volFields.H" #include "sampledSurface.H" +#include "surfaceWriter.H" #include "interpolationCellPoint.H" // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * // @@ -315,7 +316,7 @@ bool Foam::functionObjects::fieldValues::faceSource::writeValues if (Pstream::master()) { fileName outputDir = - baseFileDir()/name_/"surface"/obr_.time().timeName(); + baseFileDir()/name()/"surface"/obr_.time().timeName(); surfaceWriterPtr_->write ( @@ -375,7 +376,7 @@ Foam::functionObjects::fieldValues::faceSource::filterField else { FatalErrorInFunction - << type() << " " << name_ << ": " + << type() << " " << name() << ": " << sourceTypeNames_[source_] << "(" << sourceName_ << "):" << nl << " Unable to process internal faces for volume field " diff --git a/src/postProcessing/functionObjects/field/fieldValues/fieldValue/fieldValue.C b/src/postProcessing/functionObjects/field/fieldValues/fieldValue/fieldValue.C index cc01217794abf50023e9b9a22018b14b99b826e3..602e143fd4653455662142a3edb80651ed68b66d 100644 --- a/src/postProcessing/functionObjects/field/fieldValues/fieldValue/fieldValue.C +++ b/src/postProcessing/functionObjects/field/fieldValues/fieldValue/fieldValue.C @@ -24,90 +24,96 @@ License \*---------------------------------------------------------------------------*/ #include "fieldValue.H" -#include "fvMesh.H" #include "Time.H" #include "addToRunTimeSelectionTable.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // namespace Foam +{ +namespace functionObjects { defineTypeNameAndDebug(fieldValue, 0); defineRunTimeSelectionTable(fieldValue, dictionary); } - - -// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * // - -void Foam::fieldValue::read(const dictionary& dict) -{ - dict_ = dict; - - log_ = dict.lookupOrDefault<Switch>("log", true); - dict.lookup("fields") >> fields_; - dict.lookup("valueOutput") >> valueOutput_; } -void Foam::fieldValue::write() -{ - functionObjectFiles::write(); +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // - if (log_) Info<< type() << " " << name_ << " output:" << nl; +Foam::functionObjects::fieldValue::fieldValue +( + const word& name, + const Time& runTime, + const dictionary& dict, + const word& valueType +) +: + writeFiles(name, runTime, dict, name), + dict_(dict), + sourceName_(word::null), + fields_(dict.lookup("fields")), + valueOutput_(dict.lookup("valueOutput")), + resultDict_(fileName("name"), dictionary::null) +{ + read(dict); + resetName(valueType); } -// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // - -Foam::fieldValue::fieldValue +Foam::functionObjects::fieldValue::fieldValue ( const word& name, const objectRegistry& obr, const dictionary& dict, - const word& valueType, - const bool loadFromFiles + const word& valueType ) : - functionObjectFiles(obr, name, valueType), - name_(name), - obr_(obr), + writeFiles(name, obr, dict, name), dict_(dict), - log_(true), sourceName_(word::null), fields_(dict.lookup("fields")), valueOutput_(dict.lookup("valueOutput")), resultDict_(fileName("name"), dictionary::null) { read(dict); + resetName(valueType); } // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // -Foam::fieldValue::~fieldValue() +Foam::functionObjects::fieldValue::~fieldValue() {} // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -void Foam::fieldValue::execute() -{} - +bool Foam::functionObjects::fieldValue::read(const dictionary& dict) +{ + dict_ = dict; + writeFiles::read(dict); + dict.lookup("fields") >> fields_; + dict.lookup("valueOutput") >> valueOutput_; -void Foam::fieldValue::end() -{} + return true; +} -void Foam::fieldValue::timeSet() -{} +bool Foam::functionObjects::fieldValue::execute(const bool postProcess) +{ + return true; +} -void Foam::fieldValue::updateMesh(const mapPolyMesh&) -{} +bool Foam::functionObjects::fieldValue::write(const bool postProcess) +{ + writeFiles::write(); + if (log_) Info<< type() << " " << name() << " output:" << nl; -void Foam::fieldValue::movePoints(const polyMesh&) -{} + return true; +} // ************************************************************************* // diff --git a/src/postProcessing/functionObjects/field/fieldValues/fieldValue/fieldValue.H b/src/postProcessing/functionObjects/field/fieldValues/fieldValue/fieldValue.H index 399a2574e744dab203e0b76a521180f62ee396ed..450f0179da389f2387c048411007767d2513b896 100644 --- a/src/postProcessing/functionObjects/field/fieldValues/fieldValue/fieldValue.H +++ b/src/postProcessing/functionObjects/field/fieldValues/fieldValue/fieldValue.H @@ -38,12 +38,9 @@ SourceFiles #ifndef functionObjects_fieldValue_H #define functionObjects_fieldValue_H -#include "functionObjectFiles.H" +#include "writeFiles.H" #include "Switch.H" -#include "OFstream.H" -#include "dictionary.H" #include "Field.H" -#include "runTimeSelectionTables.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -51,10 +48,10 @@ namespace Foam { // Forward declaration of classes -class objectRegistry; class fvMesh; -class polyMesh; -class mapPolyMesh; + +namespace functionObjects +{ /*---------------------------------------------------------------------------*\ Class fieldValue Declaration @@ -62,25 +59,16 @@ class mapPolyMesh; class fieldValue : - public functionObjectFiles + public writeFiles { protected: // Protected data - //- Name of this fieldValue object - word name_; - - //- Database this class is registered to - const objectRegistry& obr_; - //- Construction dictionary dictionary dict_; - //- Switch to send output to Info as well as to file - Switch log_; - //- Name of source object word sourceName_; @@ -94,6 +82,17 @@ protected: dictionary resultDict_; + // Protected Member Functions + + //- Combine fields from all processor domains into single field + template<class Type> + void combineFields(Field<Type>& field); + + //- Combine fields from all processor domains into single field + template<class Type> + void combineFields(tmp<Field<Type>>&); + + public: //- Run-time type information @@ -109,103 +108,80 @@ public: ( const word& name, const objectRegistry& obr, - const dictionary& dict, - const bool loadFromFiles + const dictionary& dict ), - (name, obr, dict, loadFromFiles) + (name, obr, dict) ); - //- Construct from components - fieldValue - ( - const word& name, - const objectRegistry& obr, - const dictionary& dict, - const word& valueType, - const bool loadFromFiles = false - ); - - //- Return a reference to the selected fieldValue - static autoPtr<fieldValue> New - ( - const word& name, - const objectRegistry& obr, - const dictionary& dict, - const bool loadFromFiles = false, - const bool output = true - ); - - //- Destructor - virtual ~fieldValue(); - - // Public Member Functions + // Constructors - // Access - - //- Return the name of the geometric source - inline const word& name() const; - - //- Return the reference to the object registry - inline const objectRegistry& obr() const; - - //- Return the reference to the construction dictionary - inline const dictionary& dict() const; - - //- Return the switch to send output to Info as well as to file - inline const Switch& log() const; - - //- Return the source name - inline const word& sourceName() const; + //- Construct from Time and dictionary + fieldValue + ( + const word& name, + const Time& runTime, + const dictionary& dict, + const word& valueType + ); - //- Return the list of field names - inline const wordList& fields() const; + //- Construct from objectRegistry and dictionary + fieldValue + ( + const word& name, + const objectRegistry& obr, + const dictionary& dict, + const word& valueType + ); - //- Return the output field values flag - inline const Switch& valueOutput() const; + //- Return a reference to the selected fieldValue + static autoPtr<fieldValue> New + ( + const word& name, + const objectRegistry& obr, + const dictionary& dict, + const bool output = true + ); - //- Helper function to return the reference to the mesh - inline const fvMesh& mesh() const; - //- Return access to the latest set of results - inline const dictionary& resultDict() const; + //- Destructor + virtual ~fieldValue(); - // Function object functions + // Member Functions - //- Read from dictionary - virtual void read(const dictionary& dict); + //- Return the reference to the construction dictionary + inline const dictionary& dict() const; - //- Write to screen/file - virtual void write(); + //- Return the source name + inline const word& sourceName() const; - //- Execute - virtual void execute(); + //- Return the list of field names + inline const wordList& fields() const; - //- Execute the at the final time-loop, currently does nothing - virtual void end(); + //- Return the output field values flag + inline const Switch& valueOutput() const; - //- Called when time was set at the end of the Time::operator++ - virtual void timeSet(); + //- Helper function to return the reference to the mesh + inline const fvMesh& mesh() const; - //- Update mesh - virtual void updateMesh(const mapPolyMesh&); + //- Return access to the latest set of results + inline const dictionary& resultDict() const; - //- Move points - virtual void movePoints(const polyMesh&); + //- Read from dictionary + virtual bool read(const dictionary& dict); - //- Combine fields from all processor domains into single field - template<class Type> - void combineFields(Field<Type>& field); + //- Execute + virtual bool execute(const bool postProcess = false); - //- Combine fields from all processor domains into single field - template<class Type> - void combineFields(tmp<Field<Type>>&); + //- Write to screen/file + virtual bool write(const bool postProcess = false); }; // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // +} // End namespace functionObjects } // End namespace Foam // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/src/postProcessing/functionObjects/field/fieldValues/fieldValue/fieldValueI.H b/src/postProcessing/functionObjects/field/fieldValues/fieldValue/fieldValueI.H index aac9ba419fbf3aef5ea5f35dc2d2115eaaeba4a8..a5e4c4711514da5e33013b2be2c708c579291ddc 100644 --- a/src/postProcessing/functionObjects/field/fieldValues/fieldValue/fieldValueI.H +++ b/src/postProcessing/functionObjects/field/fieldValues/fieldValue/fieldValueI.H @@ -28,55 +28,39 @@ License // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -inline const Foam::word& Foam::fieldValue::name() const -{ - return name_; -} - - -inline const Foam::objectRegistry& Foam::fieldValue::obr() const -{ - return obr_; -} - - -inline const Foam::dictionary& Foam::fieldValue::dict() const +inline const Foam::dictionary& Foam::functionObjects::fieldValue::dict() const { return dict_; } -inline const Foam::Switch& Foam::fieldValue::log() const -{ - return log_; -} - - -inline const Foam::word& Foam::fieldValue::sourceName() const +inline const Foam::word& Foam::functionObjects::fieldValue::sourceName() const { return sourceName_; } -inline const Foam::wordList& Foam::fieldValue::fields() const +inline const Foam::wordList& Foam::functionObjects::fieldValue::fields() const { return fields_; } -inline const Foam::Switch& Foam::fieldValue::valueOutput() const +inline const Foam::Switch& +Foam::functionObjects::fieldValue::valueOutput() const { return valueOutput_; } -inline const Foam::fvMesh& Foam::fieldValue::mesh() const +inline const Foam::fvMesh& Foam::functionObjects::fieldValue::mesh() const { return refCast<const fvMesh>(obr_); } -inline const Foam::dictionary& Foam::fieldValue::resultDict() const +inline const Foam::dictionary& +Foam::functionObjects::fieldValue::resultDict() const { return resultDict_; } diff --git a/src/postProcessing/functionObjects/field/fieldValues/fieldValue/fieldValueNew.C b/src/postProcessing/functionObjects/field/fieldValues/fieldValue/fieldValueNew.C index 68f272127f0b5a9f0d0f95025366bcec050cf98b..07d96c8ba38e006bd200df4ea31ae428af4b089e 100644 --- a/src/postProcessing/functionObjects/field/fieldValues/fieldValue/fieldValueNew.C +++ b/src/postProcessing/functionObjects/field/fieldValues/fieldValue/fieldValueNew.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2012-2015 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2012-2016 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -27,12 +27,12 @@ License // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -Foam::autoPtr<Foam::fieldValue> Foam::fieldValue::New +Foam::autoPtr<Foam::functionObjects::fieldValue> +Foam::functionObjects::fieldValue::New ( const word& name, const objectRegistry& obr, const dictionary& dict, - const bool loadFromFiles, const bool output ) { @@ -56,16 +56,7 @@ Foam::autoPtr<Foam::fieldValue> Foam::fieldValue::New << exit(FatalError); } - return autoPtr<fieldValue> - ( - cstrIter() - ( - name, - obr, - dict, - loadFromFiles - ) - ); + return autoPtr<fieldValue>(cstrIter()(name, obr, dict)); } diff --git a/src/postProcessing/functionObjects/field/fieldValues/fieldValue/fieldValueTemplates.C b/src/postProcessing/functionObjects/field/fieldValues/fieldValue/fieldValueTemplates.C index 78e3142bd2f70d77f9a3cca12349917658c5ccef..c772ba9777f27500129dc2d95736fed5fcc678fb 100644 --- a/src/postProcessing/functionObjects/field/fieldValues/fieldValue/fieldValueTemplates.C +++ b/src/postProcessing/functionObjects/field/fieldValues/fieldValue/fieldValueTemplates.C @@ -30,7 +30,7 @@ License // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // template<class Type> -void Foam::fieldValue::combineFields(Field<Type>& field) +void Foam::functionObjects::fieldValue::combineFields(Field<Type>& field) { List<Field<Type>> allValues(Pstream::nProcs()); @@ -51,7 +51,7 @@ void Foam::fieldValue::combineFields(Field<Type>& field) template<class Type> -void Foam::fieldValue::combineFields(tmp<Field<Type>>& field) +void Foam::functionObjects::fieldValue::combineFields(tmp<Field<Type>>& field) { combineFields(field()); } diff --git a/src/postProcessing/functionObjects/field/fieldValues/fieldValueDelta/fieldValueDelta.C b/src/postProcessing/functionObjects/field/fieldValues/fieldValueDelta/fieldValueDelta.C index 1c4bda54245e4bbe9ddeedd3a72b4d98b3fddb40..c0f78798a8b8232e3377b4d98f198aab88fc071d 100644 --- a/src/postProcessing/functionObjects/field/fieldValues/fieldValueDelta/fieldValueDelta.C +++ b/src/postProcessing/functionObjects/field/fieldValues/fieldValueDelta/fieldValueDelta.C @@ -24,10 +24,7 @@ License \*---------------------------------------------------------------------------*/ #include "fieldValueDelta.H" -#include "ListOps.H" -#include "Time.H" -#include "volFields.H" -#include "surfaceFields.H" +#include "addToRunTimeSelectionTable.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -38,6 +35,7 @@ namespace functionObjects namespace fieldValues { defineTypeNameAndDebug(fieldValueDelta, 0); + addToRunTimeSelectionTable(functionObject, fieldValueDelta, dictionary); } } } @@ -104,27 +102,23 @@ void Foam::functionObjects::fieldValues::fieldValueDelta::writeFileHeader Foam::functionObjects::fieldValues::fieldValueDelta::fieldValueDelta ( const word& name, - const objectRegistry& obr, - const dictionary& dict, - const bool loadFromFiles + const Time& runTime, + const dictionary& dict ) : - functionObjectFiles(obr, name, typeName), - name_(name), - obr_(obr), - loadFromFiles_(loadFromFiles), - log_(true), + writeFiles(name, runTime, dict, name), operation_(opSubtract), source1Ptr_(NULL), source2Ptr_(NULL) { - if (!isA<fvMesh>(obr)) + if (!isA<fvMesh>(obr_)) { FatalErrorInFunction << "objectRegistry is not an fvMesh" << exit(FatalError); } read(dict); + resetName(typeName); } @@ -136,20 +130,20 @@ Foam::functionObjects::fieldValues::fieldValueDelta::~fieldValueDelta() // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -void Foam::functionObjects::fieldValues::fieldValueDelta::read +bool Foam::functionObjects::fieldValues::fieldValueDelta::read ( const dictionary& dict ) { - log_ = dict.lookupOrDefault<Switch>("log", true); + writeFiles::read(dict); + source1Ptr_.reset ( fieldValue::New ( - name_ + ".source1", + name() + ".source1", obr_, dict.subDict("source1"), - loadFromFiles_, false ).ptr() ); @@ -157,21 +151,25 @@ void Foam::functionObjects::fieldValues::fieldValueDelta::read ( fieldValue::New ( - name_ + ".source2", + name() + ".source2", obr_, dict.subDict("source2"), - loadFromFiles_, false ).ptr() ); operation_ = operationTypeNames_.read(dict.lookup("operation")); + + return true; } -void Foam::functionObjects::fieldValues::fieldValueDelta::write() +bool Foam::functionObjects::fieldValues::fieldValueDelta::write +( + const bool postProcess +) { - functionObjectFiles::write(); + writeFiles::write(); source1Ptr_->write(); source2Ptr_->write(); @@ -181,7 +179,7 @@ void Foam::functionObjects::fieldValues::fieldValueDelta::write() writeTime(file()); } - if (log_) Info<< type() << " " << name_ << " output:" << endl; + if (log_) Info<< type() << " " << name() << " output:" << endl; bool found = false; processFields<scalar>(found); @@ -206,33 +204,18 @@ void Foam::functionObjects::fieldValues::fieldValueDelta::write() Info<< endl; } } -} - - -void Foam::functionObjects::fieldValues::fieldValueDelta::execute() -{} - - -void Foam::functionObjects::fieldValues::fieldValueDelta::end() -{} - -void Foam::functionObjects::fieldValues::fieldValueDelta::timeSet() -{} - - -void Foam::functionObjects::fieldValues::fieldValueDelta::updateMesh -( - const mapPolyMesh& -) -{} + return true; +} -void Foam::functionObjects::fieldValues::fieldValueDelta::movePoints +bool Foam::functionObjects::fieldValues::fieldValueDelta::execute ( - const polyMesh& + const bool postProcess ) -{} +{ + return true; +} // ************************************************************************* // diff --git a/src/postProcessing/functionObjects/field/fieldValues/fieldValueDelta/fieldValueDelta.H b/src/postProcessing/functionObjects/field/fieldValues/fieldValueDelta/fieldValueDelta.H index dcb09c00c7c67d948653b04c528d55efa3bd9f09..f164c8f9efc74105bc1e6c2c8702c1ecf9d67ea7 100644 --- a/src/postProcessing/functionObjects/field/fieldValues/fieldValueDelta/fieldValueDelta.H +++ b/src/postProcessing/functionObjects/field/fieldValues/fieldValueDelta/fieldValueDelta.H @@ -76,9 +76,8 @@ SourceFiles #ifndef functionObjects_fieldValueDelta_H #define functionObjects_fieldValueDelta_H -#include "functionObjectFiles.H" +#include "writeFiles.H" #include "fieldValue.H" -#include "autoPtr.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -95,7 +94,7 @@ namespace fieldValues class fieldValueDelta : - public functionObjectFiles + public writeFiles { public: //- Operation type enumeration @@ -116,18 +115,6 @@ private: // Private data - //- Name of this fieldValue object - word name_; - - //- Database this class is registered to - const objectRegistry& obr_; - - //- Flag to indicate to load from files - bool loadFromFiles_; - - //- Switch to send output to Info as well as to file - Switch log_; - //- Operation to apply to values operationType operation_; @@ -151,7 +138,7 @@ private: protected: - // Functions to be over-ridden from IOoutputFilter class + // Protected Member Functions //- Output file header information virtual void writeFileHeader(const label i); @@ -165,13 +152,12 @@ public: // Constructors - //- Construct from components + //- Construct from Time and dictionary fieldValueDelta ( const word& name, - const objectRegistry& obr, - const dictionary& dict, - const bool loadFromFiles = false + const Time& runTime, + const dictionary& dict ); @@ -181,28 +167,14 @@ public: // Public Member Functions - // Function object functions - - //- Read from dictionary - virtual void read(const dictionary&); - - //- Calculate and write - virtual void write(); - - //- Execute - virtual void execute(); - - //- Execute the at the final time-loop, currently does nothing - virtual void end(); - - //- Called when time was set at the end of the Time::operator++ - virtual void timeSet(); + //- Read from dictionary + virtual bool read(const dictionary&); - //- Update mesh - virtual void updateMesh(const mapPolyMesh&); + //- Do nothing + virtual bool execute(const bool postProcess = false); - //- Move points - virtual void movePoints(const polyMesh&); + //- Calculate and write + virtual bool write(const bool postProcess = false); }; diff --git a/src/postProcessing/functionObjects/field/fieldValues/fieldValueDelta/fieldValueDeltaFunctionObject.C b/src/postProcessing/functionObjects/field/fieldValues/fieldValueDelta/fieldValueDeltaFunctionObject.C deleted file mode 100644 index 7d093c37818aa9a9fd45d2018447500d57fcee1a..0000000000000000000000000000000000000000 --- a/src/postProcessing/functionObjects/field/fieldValues/fieldValueDelta/fieldValueDeltaFunctionObject.C +++ /dev/null @@ -1,46 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2012 OpenFOAM Foundation - \\/ 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 <http://www.gnu.org/licenses/>. - -\*---------------------------------------------------------------------------*/ - -#include "fieldValueDeltaFunctionObject.H" - -// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // - -namespace Foam -{ - defineNamedTemplateTypeNameAndDebug - ( - fieldValueDeltaFunctionObject, - 0 - ); - - addToRunTimeSelectionTable - ( - functionObject, - fieldValueDeltaFunctionObject, - dictionary - ); -} - -// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/field/fieldValues/fieldValueDelta/fieldValueDeltaFunctionObject.H b/src/postProcessing/functionObjects/field/fieldValues/fieldValueDelta/fieldValueDeltaFunctionObject.H deleted file mode 100644 index 3a54e034adcdc11adb6db6ebe2f561ab1c0aeca6..0000000000000000000000000000000000000000 --- a/src/postProcessing/functionObjects/field/fieldValues/fieldValueDelta/fieldValueDeltaFunctionObject.H +++ /dev/null @@ -1,56 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2012-2016 OpenFOAM Foundation - \\/ 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 <http://www.gnu.org/licenses/>. - -Typedef - Foam::fieldValueDeltaFunctionObject - -Description - FunctionObject wrapper around fieldValueDelta to allow it to be - created via the functions entry within controlDict. - -SourceFiles - fieldValueDeltaFunctionObject.C - -\*---------------------------------------------------------------------------*/ - -#ifndef fieldValueDeltaFunctionObject_H -#define fieldValueDeltaFunctionObject_H - -#include "fieldValueDelta.H" -#include "OutputFilterFunctionObject.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - typedef OutputFilterFunctionObject - < - functionObjects::fieldValues::fieldValueDelta - > fieldValueDeltaFunctionObject; -} - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#endif - -// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/field/grad/grad.C b/src/postProcessing/functionObjects/field/grad/grad.C index 0fc2c755189106a7a1b145ffd581a0b96460bbb6..05e0b509b4cf717db889cda31f86105061d011b3 100644 --- a/src/postProcessing/functionObjects/field/grad/grad.C +++ b/src/postProcessing/functionObjects/field/grad/grad.C @@ -25,8 +25,7 @@ License #include "grad.H" #include "volFields.H" -#include "dictionary.H" -#include "grad.H" +#include "addToRunTimeSelectionTable.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -35,6 +34,7 @@ namespace Foam namespace functionObjects { defineTypeNameAndDebug(grad, 0); + addToRunTimeSelectionTable(functionObject, grad, dictionary); } } @@ -44,17 +44,22 @@ namespace functionObjects Foam::functionObjects::grad::grad ( const word& name, - const objectRegistry& obr, - const dictionary& dict, - const bool loadFromFiles + const Time& runTime, + const dictionary& dict ) : - name_(name), - obr_(obr), + functionObject(name), + obr_ + ( + runTime.lookupObject<objectRegistry> + ( + dict.lookupOrDefault("region", polyMesh::defaultRegion) + ) + ), fieldName_("undefined-fieldName"), resultName_("undefined-resultName") { - if (!isA<fvMesh>(obr)) + if (!isA<fvMesh>(obr_)) { FatalErrorInFunction << "objectRegistry is not an fvMesh" << exit(FatalError); @@ -72,7 +77,7 @@ Foam::functionObjects::grad::~grad() // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -void Foam::functionObjects::grad::read(const dictionary& dict) +bool Foam::functionObjects::grad::read(const dictionary& dict) { dict.lookup("fieldName") >> fieldName_; dict.lookup("resultName") >> resultName_; @@ -81,10 +86,12 @@ void Foam::functionObjects::grad::read(const dictionary& dict) { resultName_ = "fvc::grad(" + fieldName_ + ")"; } + + return true; } -void Foam::functionObjects::grad::execute() +bool Foam::functionObjects::grad::execute(const bool postProcess) { bool processed = false; @@ -96,31 +103,25 @@ void Foam::functionObjects::grad::execute() WarningInFunction << "Unprocessed field " << fieldName_ << endl; } -} - -void Foam::functionObjects::grad::end() -{ - execute(); + return true; } -void Foam::functionObjects::grad::timeSet() -{} - - -void Foam::functionObjects::grad::write() +bool Foam::functionObjects::grad::write(const bool postProcess) { if (obr_.foundObject<regIOobject>(resultName_)) { const regIOobject& field = obr_.lookupObject<regIOobject>(resultName_); - Info<< type() << " " << name_ << " output:" << nl + Info<< type() << " " << name() << " output:" << nl << " writing field " << field.name() << nl << endl; field.write(); } + + return true; } diff --git a/src/postProcessing/functionObjects/field/grad/grad.H b/src/postProcessing/functionObjects/field/grad/grad.H index b7f3b60223bf5a29d0a55cf445655ef08c8b77dd..2d092f320a258702577c1c109f0c73a19fb04b16 100644 --- a/src/postProcessing/functionObjects/field/grad/grad.H +++ b/src/postProcessing/functionObjects/field/grad/grad.H @@ -40,11 +40,8 @@ SourceFiles #ifndef functionObjects_grad_H #define functionObjects_grad_H +#include "functionObject.H" #include "volFieldsFwd.H" -#include "surfaceFieldsFwd.H" -#include "pointFieldFwd.H" -#include "OFstream.H" -#include "Switch.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -53,9 +50,6 @@ namespace Foam // Forward declaration of classes class objectRegistry; -class dictionary; -class polyMesh; -class mapPolyMesh; class dimensionSet; namespace functionObjects @@ -66,13 +60,12 @@ namespace functionObjects \*---------------------------------------------------------------------------*/ class grad +: + public functionObject { // Private data - //- Name of this grad object - word name_; - - //- Reference to the database + //- Reference to the objectRegistry const objectRegistry& obr_; //- Name of field to process @@ -118,14 +111,12 @@ public: // Constructors - //- Construct for given objectRegistry and dictionary. - // Allow the possibility to load fields from files + //- Construct from Time and dictionary grad ( const word& name, - const objectRegistry&, - const dictionary&, - const bool loadFromFiles = false + const Time& runTime, + const dictionary& dict ); @@ -135,34 +126,14 @@ public: // Member Functions - //- Return name of the set of grad - virtual const word& name() const - { - return name_; - } - //- Read the grad 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(); - - //- Called when time was set at the end of the Time::operator++ - virtual void timeSet(); - - //- Calculate the grad and write - virtual void write(); + virtual bool read(const dictionary&); - //- Update for changes of mesh - virtual void updateMesh(const mapPolyMesh&) - {} + //- Calculate the gradient field + virtual bool execute(const bool postProcess = false); - //- Update for changes of mesh - virtual void movePoints(const polyMesh&) - {} + //- Write the gradient field + virtual bool write(const bool postProcess = false); }; diff --git a/src/postProcessing/functionObjects/field/grad/gradFunctionObject.C b/src/postProcessing/functionObjects/field/grad/gradFunctionObject.C deleted file mode 100644 index 9a04d491331c254912c5591363343c76cd1a270c..0000000000000000000000000000000000000000 --- a/src/postProcessing/functionObjects/field/grad/gradFunctionObject.C +++ /dev/null @@ -1,42 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2012-2016 OpenFOAM Foundation - \\/ 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 <http://www.gnu.org/licenses/>. - -\*---------------------------------------------------------------------------*/ - -#include "gradFunctionObject.H" - -// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // - -namespace Foam -{ - defineNamedTemplateTypeNameAndDebug(gradFunctionObject, 0); - - addToRunTimeSelectionTable - ( - functionObject, - gradFunctionObject, - dictionary - ); -} - -// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/field/grad/gradFunctionObject.H b/src/postProcessing/functionObjects/field/grad/gradFunctionObject.H deleted file mode 100644 index 776051bebc8f591d6d51d1e98375b646fa4ea021..0000000000000000000000000000000000000000 --- a/src/postProcessing/functionObjects/field/grad/gradFunctionObject.H +++ /dev/null @@ -1,54 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2012-2016 OpenFOAM Foundation - \\/ 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 <http://www.gnu.org/licenses/>. - -Typedef - Foam::gradFunctionObject - -Description - FunctionObject wrapper around grad to allow it to be created - via the functions entry within controlDict. - -SourceFiles - gradFunctionObject.C - -\*---------------------------------------------------------------------------*/ - -#ifndef gradFunctionObject_H -#define gradFunctionObject_H - -#include "grad.H" -#include "OutputFilterFunctionObject.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - typedef OutputFilterFunctionObject<functionObjects::grad> - gradFunctionObject; -} - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#endif - -// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/field/histogram/histogram.C b/src/postProcessing/functionObjects/field/histogram/histogram.C index d797d06f40da41f9815d9cdf81a592a238baecb0..8463f6423ad97dc693aa2dc3371f5e2e9163ffb8 100644 --- a/src/postProcessing/functionObjects/field/histogram/histogram.C +++ b/src/postProcessing/functionObjects/field/histogram/histogram.C @@ -25,6 +25,7 @@ License #include "histogram.H" #include "volFields.H" +#include "addToRunTimeSelectionTable.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -33,6 +34,7 @@ namespace Foam namespace functionObjects { defineTypeNameAndDebug(histogram, 0); + addToRunTimeSelectionTable(functionObject, histogram, dictionary); } } @@ -69,15 +71,13 @@ void Foam::functionObjects::histogram::writeGraph Foam::functionObjects::histogram::histogram ( const word& name, - const objectRegistry& obr, - const dictionary& dict, - const bool loadFromFiles + const Time& runTime, + const dictionary& dict ) : - functionObjectFile(obr, typeName), - name_(name) + writeFile(name, runTime, dict, name) { - if (!isA<fvMesh>(obr)) + if (!isA<fvMesh>(obr_)) { FatalErrorInFunction << "objectRegistry is not an fvMesh" << exit(FatalError); @@ -95,7 +95,7 @@ Foam::functionObjects::histogram::~histogram() // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -void Foam::functionObjects::histogram::read(const dictionary& dict) +bool Foam::functionObjects::histogram::read(const dictionary& dict) { dict.lookup("field") >> fieldName_; dict.lookup("max") >> max_; @@ -104,24 +104,20 @@ void Foam::functionObjects::histogram::read(const dictionary& dict) word format(dict.lookup("setFormat")); formatterPtr_ = writer<scalar>::New(format); -} - - -void Foam::functionObjects::histogram::execute() -{} - -void Foam::functionObjects::histogram::end() -{} + return true; +} -void Foam::functionObjects::histogram::timeSet() -{} +bool Foam::functionObjects::histogram::execute(const bool postProcess) +{ + return true; +} -void Foam::functionObjects::histogram::write() +bool Foam::functionObjects::histogram::write(const bool postProcess) { - Info<< type() << " " << name_ << " output:" << nl; + Info<< type() << " " << name() << " output:" << nl; const fvMesh& mesh = refCast<const fvMesh>(obr_); @@ -201,6 +197,8 @@ void Foam::functionObjects::histogram::write() writeGraph(coords, field.name(), volFrac); } } + + return true; } diff --git a/src/postProcessing/functionObjects/field/histogram/histogram.H b/src/postProcessing/functionObjects/field/histogram/histogram.H index f1201bd37d7b0625e705455e7cf59645408ad433..48f8f2432537826901ec0293401cf2fa62f98329 100644 --- a/src/postProcessing/functionObjects/field/histogram/histogram.H +++ b/src/postProcessing/functionObjects/field/histogram/histogram.H @@ -59,7 +59,7 @@ Description SeeAlso Foam::functionObject - Foam::OutputFilterFunctionObject + Foam::functionObjects::writeFile SourceFiles histogram.C @@ -70,19 +70,12 @@ SourceFiles #define functionObjects_histogram_H #include "writer.H" -#include "volFieldsFwd.H" -#include "functionObjectFile.H" +#include "writeFile.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // namespace Foam { - -// Forward declaration of classes -class objectRegistry; -class mapPolyMesh; -class polyMesh; - namespace functionObjects { @@ -92,13 +85,10 @@ namespace functionObjects class histogram : - public functionObjectFile + public writeFile { // Private data - //- Name of this histogram - word name_; - //- Name of field word fieldName_; @@ -139,52 +129,31 @@ public: // Constructors - //- Construct for given objectRegistry and dictionary. - // Allow the possibility to load fields from files + //- Construct from Time and dictionary histogram ( const word& name, - const objectRegistry&, - const dictionary&, - const bool loadFromFiles = false + const Time& runTime, + const dictionary& dict ); // Destructor - - virtual ~histogram(); + virtual ~histogram(); // Member Functions - //- Return name of the set of histogram - virtual const word& name() const - { - return name_; - } - //- Read the histogram data - virtual void read(const dictionary&); + virtual bool read(const dictionary&); //- Execute, currently does nothing - virtual void execute(); - - //- Execute at the final time-loop, currently does nothing - virtual void end(); - - //- Called when time was set at the end of the Time::operator++ - virtual void timeSet(); - - //- Calculate the histogram and write - virtual void write(); - - //- Update for changes of mesh - virtual void updateMesh(const mapPolyMesh&) - {} + virtual bool execute(const bool postProcess = false); - //- Update for changes of mesh - virtual void movePoints(const polyMesh&) - {} + //- Calculate the histogram and write. + // postProcess overrides the usual writeControl behaviour and + // forces writing always (used in post-processing mode) + virtual bool write(const bool postProcess = false); }; diff --git a/src/postProcessing/functionObjects/field/histogram/histogramFunctionObject.C b/src/postProcessing/functionObjects/field/histogram/histogramFunctionObject.C deleted file mode 100644 index fbbcf34e48f303f0f999339e31969550d7c1624c..0000000000000000000000000000000000000000 --- a/src/postProcessing/functionObjects/field/histogram/histogramFunctionObject.C +++ /dev/null @@ -1,46 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2016 OpenFOAM Foundation - \\/ 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 <http://www.gnu.org/licenses/>. - -\*---------------------------------------------------------------------------*/ - -#include "histogramFunctionObject.H" - -// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // - -namespace Foam -{ - defineNamedTemplateTypeNameAndDebug - ( - histogramFunctionObject, - 0 - ); - - addToRunTimeSelectionTable - ( - functionObject, - histogramFunctionObject, - dictionary - ); -} - -// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/field/histogram/histogramFunctionObject.H b/src/postProcessing/functionObjects/field/histogram/histogramFunctionObject.H deleted file mode 100644 index c246af837e9db87514825d6c8fb0e6a7c099bb0d..0000000000000000000000000000000000000000 --- a/src/postProcessing/functionObjects/field/histogram/histogramFunctionObject.H +++ /dev/null @@ -1,54 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2016 OpenFOAM Foundation - \\/ 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 <http://www.gnu.org/licenses/>. - -Typedef - Foam::histogramFunctionObject - -Description - FunctionObject wrapper around histogram to allow it to be - created via the functions list within controlDict. - -SourceFiles - histogramFunctionObject.C - -\*---------------------------------------------------------------------------*/ - -#ifndef histogramFunctionObject_H -#define histogramFunctionObject_H - -#include "histogram.H" -#include "OutputFilterFunctionObject.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - typedef OutputFilterFunctionObject<functionObjects::histogram> - histogramFunctionObject; -} - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#endif - -// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/field/mag/mag.C b/src/postProcessing/functionObjects/field/mag/mag.C index 9816f50df209e5c7785273399e39c7f225aaeacc..a51aad91ae020594ac7d6e47ab461f8764b15263 100644 --- a/src/postProcessing/functionObjects/field/mag/mag.C +++ b/src/postProcessing/functionObjects/field/mag/mag.C @@ -25,8 +25,7 @@ License #include "mag.H" #include "volFields.H" -#include "dictionary.H" -#include "mag.H" +#include "addToRunTimeSelectionTable.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -35,6 +34,7 @@ namespace Foam namespace functionObjects { defineTypeNameAndDebug(mag, 0); + addToRunTimeSelectionTable(functionObject, mag, dictionary); } } @@ -44,17 +44,22 @@ namespace functionObjects Foam::functionObjects::mag::mag ( const word& name, - const objectRegistry& obr, - const dictionary& dict, - const bool loadFromFiles + const Time& runTime, + const dictionary& dict ) : - name_(name), - obr_(obr), + functionObject(name), + obr_ + ( + runTime.lookupObject<objectRegistry> + ( + dict.lookupOrDefault("region", polyMesh::defaultRegion) + ) + ), fieldName_("undefined-fieldName"), resultName_("undefined-resultName") { - if (!isA<fvMesh>(obr)) + if (!isA<fvMesh>(obr_)) { FatalErrorInFunction << "objectRegistry is not an fvMesh" << exit(FatalError); @@ -72,7 +77,7 @@ Foam::functionObjects::mag::~mag() // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -void Foam::functionObjects::mag::read(const dictionary& dict) +bool Foam::functionObjects::mag::read(const dictionary& dict) { dict.lookup("fieldName") >> fieldName_; dict.lookup("resultName") >> resultName_; @@ -81,10 +86,12 @@ void Foam::functionObjects::mag::read(const dictionary& dict) { resultName_ = "mag(" + fieldName_ + ")"; } + + return true; } -void Foam::functionObjects::mag::execute() +bool Foam::functionObjects::mag::execute(const bool postProcess) { bool processed = false; @@ -99,31 +106,25 @@ void Foam::functionObjects::mag::execute() WarningInFunction << "Unprocessed field " << fieldName_ << endl; } -} - -void Foam::functionObjects::mag::end() -{ - execute(); + return true; } -void Foam::functionObjects::mag::timeSet() -{} - - -void Foam::functionObjects::mag::write() +bool Foam::functionObjects::mag::write(const bool postProcess) { if (obr_.foundObject<regIOobject>(resultName_)) { const regIOobject& field = obr_.lookupObject<regIOobject>(resultName_); - Info<< type() << " " << name_ << " output:" << nl + Info<< type() << " " << name() << " output:" << nl << " writing field " << field.name() << nl << endl; field.write(); } + + return true; } diff --git a/src/postProcessing/functionObjects/field/mag/mag.H b/src/postProcessing/functionObjects/field/mag/mag.H index 215b3c7ae3df7f3c4a6d848a0bd8e803189f0566..dd4dc1f4f595473c0db31caa7f8741072688114d 100644 --- a/src/postProcessing/functionObjects/field/mag/mag.H +++ b/src/postProcessing/functionObjects/field/mag/mag.H @@ -40,11 +40,8 @@ SourceFiles #ifndef functionObjects_mag_H #define functionObjects_mag_H +#include "functionObject.H" #include "volFieldsFwd.H" -#include "surfaceFieldsFwd.H" -#include "pointFieldFwd.H" -#include "OFstream.H" -#include "Switch.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -53,9 +50,6 @@ namespace Foam // Forward declaration of classes class objectRegistry; -class dictionary; -class polyMesh; -class mapPolyMesh; class dimensionSet; namespace functionObjects @@ -66,13 +60,12 @@ namespace functionObjects \*---------------------------------------------------------------------------*/ class mag +: + public functionObject { // Private data - //- Name of this mag object - word name_; - - //- Reference to the database + //- Reference to the objectRegistry const objectRegistry& obr_; //- Name of field to process @@ -112,14 +105,12 @@ public: // Constructors - //- Construct for given objectRegistry and dictionary. - // Allow the possibility to load fields from files + //- Construct from Time and dictionary mag ( const word& name, - const objectRegistry&, - const dictionary&, - const bool loadFromFiles = false + const Time& runTime, + const dictionary& dict ); @@ -129,34 +120,14 @@ public: // Member Functions - //- Return name of the set of mag - virtual const word& name() const - { - return name_; - } - //- Read the mag 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(); - - //- Called when time was set at the end of the Time::operator++ - virtual void timeSet(); - - //- Calculate the mag and write - virtual void write(); + virtual bool read(const dictionary&); - //- Update for changes of mesh - virtual void updateMesh(const mapPolyMesh&) - {} + //- Calculate the magnitude field + virtual bool execute(const bool postProcess = false); - //- Update for changes of mesh - virtual void movePoints(const polyMesh&) - {} + //- Write the magnitude field + virtual bool write(const bool postProcess = false); }; diff --git a/src/postProcessing/functionObjects/field/mag/magFunctionObject.C b/src/postProcessing/functionObjects/field/mag/magFunctionObject.C deleted file mode 100644 index b615fb89750ee4880fd6c38cc65960a46f7eba34..0000000000000000000000000000000000000000 --- a/src/postProcessing/functionObjects/field/mag/magFunctionObject.C +++ /dev/null @@ -1,42 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2012-2016 OpenFOAM Foundation - \\/ 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 <http://www.gnu.org/licenses/>. - -\*---------------------------------------------------------------------------*/ - -#include "magFunctionObject.H" - -// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // - -namespace Foam -{ - defineNamedTemplateTypeNameAndDebug(magFunctionObject, 0); - - addToRunTimeSelectionTable - ( - functionObject, - magFunctionObject, - dictionary - ); -} - -// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/field/mag/magFunctionObject.H b/src/postProcessing/functionObjects/field/mag/magFunctionObject.H deleted file mode 100644 index f518dd5130ec7e881d535ef6be70561474612952..0000000000000000000000000000000000000000 --- a/src/postProcessing/functionObjects/field/mag/magFunctionObject.H +++ /dev/null @@ -1,54 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2012-2016 OpenFOAM Foundation - \\/ 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 <http://www.gnu.org/licenses/>. - -Typedef - Foam::magFunctionObject - -Description - FunctionObject wrapper around mag to allow it to be created - via the functions entry within controlDict. - -SourceFiles - magFunctionObject.C - -\*---------------------------------------------------------------------------*/ - -#ifndef magFunctionObject_H -#define magFunctionObject_H - -#include "mag.H" -#include "OutputFilterFunctionObject.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - typedef OutputFilterFunctionObject<functionObjects::mag> - magFunctionObject; -} - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#endif - -// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/field/nearWallFields/nearWallFields.C b/src/postProcessing/functionObjects/field/nearWallFields/nearWallFields.C index a0549bfe66c82d8a9de285e458a3cf3e238cf4ac..2bf8fb2537e0e4d41ab2f8da479302a447532e09 100644 --- a/src/postProcessing/functionObjects/field/nearWallFields/nearWallFields.C +++ b/src/postProcessing/functionObjects/field/nearWallFields/nearWallFields.C @@ -28,6 +28,7 @@ License #include "findCellParticle.H" #include "mappedPatchBase.H" #include "OBJstream.H" +#include "addToRunTimeSelectionTable.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -36,6 +37,7 @@ namespace Foam namespace functionObjects { defineTypeNameAndDebug(nearWallFields, 0); + addToRunTimeSelectionTable(functionObject, nearWallFields, dictionary); } } @@ -224,16 +226,21 @@ void Foam::functionObjects::nearWallFields::calcAddressing() Foam::functionObjects::nearWallFields::nearWallFields ( const word& name, - const objectRegistry& obr, - const dictionary& dict, - const bool loadFromFiles + const Time& runTime, + const dictionary& dict ) : - name_(name), - obr_(obr), + functionObject(name), + obr_ + ( + runTime.lookupObject<objectRegistry> + ( + dict.lookupOrDefault("region", polyMesh::defaultRegion) + ) + ), fieldSet_() { - if (!isA<fvMesh>(obr)) + if (!isA<fvMesh>(obr_)) { FatalErrorInFunction << "objectRegistry is not an fvMesh" << exit(FatalError); @@ -256,7 +263,7 @@ Foam::functionObjects::nearWallFields::~nearWallFields() // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -void Foam::functionObjects::nearWallFields::read(const dictionary& dict) +bool Foam::functionObjects::nearWallFields::read(const dictionary& dict) { if (debug) { @@ -295,15 +302,17 @@ void Foam::functionObjects::nearWallFields::read(const dictionary& dict) reverseFieldMap_.insert(sampleFldName, fldName); } - Info<< type() << " " << name_ << ": Sampling " << fieldMap_.size() + Info<< type() << " " << name() << ": Sampling " << fieldMap_.size() << " fields" << endl; // Do analysis calcAddressing(); + + return true; } -void Foam::functionObjects::nearWallFields::execute() +bool Foam::functionObjects::nearWallFields::execute(const bool postProcess) { if (debug) { @@ -320,7 +329,7 @@ void Foam::functionObjects::nearWallFields::execute() && vtf_.empty() ) { - Info<< type() << " " << name_ << ": Creating " << fieldMap_.size() + Info<< type() << " " << name() << ": Creating " << fieldMap_.size() << " fields" << endl; createFields(vsf_); @@ -332,7 +341,7 @@ void Foam::functionObjects::nearWallFields::execute() Info<< endl; } - Info<< type() << " " << name_ << " output:" << nl; + Info<< type() << " " << name() << " output:" << nl; Info<< " Sampling fields to " << obr_.time().timeName() << endl; @@ -342,25 +351,12 @@ void Foam::functionObjects::nearWallFields::execute() sampleFields(vSpheretf_); sampleFields(vSymmtf_); sampleFields(vtf_); -} - -void Foam::functionObjects::nearWallFields::end() -{ - if (debug) - { - InfoInFunction << endl; - } - - execute(); + return true; } -void Foam::functionObjects::nearWallFields::timeSet() -{} - - -void Foam::functionObjects::nearWallFields::write() +bool Foam::functionObjects::nearWallFields::write(const bool postProcess) { if (debug) { @@ -392,6 +388,8 @@ void Foam::functionObjects::nearWallFields::write() } Info<< endl; + + return true; } diff --git a/src/postProcessing/functionObjects/field/nearWallFields/nearWallFields.H b/src/postProcessing/functionObjects/field/nearWallFields/nearWallFields.H index f6638756e47a119763a743440f534066ddffc0fa..4ea6f13fd56d4bf00071d86f5558b5d1ea16b475 100644 --- a/src/postProcessing/functionObjects/field/nearWallFields/nearWallFields.H +++ b/src/postProcessing/functionObjects/field/nearWallFields/nearWallFields.H @@ -62,7 +62,6 @@ Description SeeAlso Foam::functionObject - Foam::OutputFilterFunctionObject SourceFiles nearWallFields.C @@ -72,7 +71,7 @@ SourceFiles #ifndef functionObjects_nearWallFields_H #define functionObjects_nearWallFields_H -#include "OFstream.H" +#include "functionObject.H" #include "volFields.H" #include "Tuple2.H" #include "interpolationCellPoint.H" @@ -84,8 +83,6 @@ namespace Foam // Forward declaration of classes class objectRegistry; -class dictionary; -class mapPolyMesh; namespace functionObjects { @@ -95,14 +92,14 @@ namespace functionObjects \*---------------------------------------------------------------------------*/ class nearWallFields +: + public functionObject { protected: // Protected data - //- Name of this set of nearWallFields object - word name_; - + //- Reference to the objectRegistry const objectRegistry& obr_; // Read from dictionary @@ -191,9 +188,8 @@ public: nearWallFields ( const word& name, - const objectRegistry&, - const dictionary&, - const bool loadFromFiles = false + const Time& runTime, + const dictionary& dict ); @@ -203,34 +199,14 @@ public: // Member Functions - //- Return name of the nearWallFields object - virtual const word& name() const - { - return name_; - } - //- Read the controls - virtual void read(const dictionary&); - - //- Execute, currently does nothing - virtual void execute(); - - //- Execute at the final time-loop, currently does nothing - virtual void end(); - - //- Called when time was set at the end of the Time::operator++ - virtual void timeSet(); - - //- Write - virtual void write(); + virtual bool read(const dictionary&); - //- Update for changes of mesh - virtual void updateMesh(const mapPolyMesh&) - {} + //- Calculate the near-wall fields + virtual bool execute(const bool postProcess = false); - //- Update for changes of mesh - virtual void movePoints(const polyMesh&) - {} + //- Write the near-wall fields + virtual bool write(const bool postProcess = false); }; diff --git a/src/postProcessing/functionObjects/field/nearWallFields/nearWallFieldsFunctionObject.C b/src/postProcessing/functionObjects/field/nearWallFields/nearWallFieldsFunctionObject.C deleted file mode 100644 index 062354f52ab6945d3062faee5cc8db05133e529a..0000000000000000000000000000000000000000 --- a/src/postProcessing/functionObjects/field/nearWallFields/nearWallFieldsFunctionObject.C +++ /dev/null @@ -1,46 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation - \\/ 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 <http://www.gnu.org/licenses/>. - -\*---------------------------------------------------------------------------*/ - -#include "nearWallFieldsFunctionObject.H" - -// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // - -namespace Foam -{ - defineNamedTemplateTypeNameAndDebug - ( - nearWallFieldsFunctionObject, - 0 - ); - - addToRunTimeSelectionTable - ( - functionObject, - nearWallFieldsFunctionObject, - dictionary - ); -} - -// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/field/nearWallFields/nearWallFieldsFunctionObject.H b/src/postProcessing/functionObjects/field/nearWallFields/nearWallFieldsFunctionObject.H deleted file mode 100644 index 16146c153cf5dae4d5233b32a47886569f028c50..0000000000000000000000000000000000000000 --- a/src/postProcessing/functionObjects/field/nearWallFields/nearWallFieldsFunctionObject.H +++ /dev/null @@ -1,54 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation - \\/ 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 <http://www.gnu.org/licenses/>. - -Typedef - Foam::nearWallFieldsFunctionObject - -Description - FunctionObject wrapper around nearWallFields to allow - them to be created via the functions entry within controlDict. - -SourceFiles - nearWallFieldsFunctionObject.C - -\*---------------------------------------------------------------------------*/ - -#ifndef nearWallFieldsFunctionObject_H -#define nearWallFieldsFunctionObject_H - -#include "nearWallFields.H" -#include "OutputFilterFunctionObject.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - typedef OutputFilterFunctionObject<functionObjects::nearWallFields> - nearWallFieldsFunctionObject; -} - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#endif - -// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/field/processorField/processorField.C b/src/postProcessing/functionObjects/field/processorField/processorField.C index 1647afa2e8ba6a8f061cdecca163af0bb0e1bc55..3a0f57ed27cd79061054bf6181b91f1d98b1525d 100644 --- a/src/postProcessing/functionObjects/field/processorField/processorField.C +++ b/src/postProcessing/functionObjects/field/processorField/processorField.C @@ -24,8 +24,8 @@ License \*---------------------------------------------------------------------------*/ #include "processorField.H" -#include "dictionary.H" -#include "Pstream.H" +#include "volFields.H" +#include "addToRunTimeSelectionTable.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -34,6 +34,7 @@ namespace Foam namespace functionObjects { defineTypeNameAndDebug(processorField, 0); + addToRunTimeSelectionTable(functionObject, processorField, dictionary); } } @@ -43,15 +44,20 @@ namespace functionObjects Foam::functionObjects::processorField::processorField ( const word& name, - const objectRegistry& obr, - const dictionary& dict, - const bool loadFromFiles + const Time& runTime, + const dictionary& dict ) : - name_(name), - obr_(obr) + functionObject(name), + obr_ + ( + runTime.lookupObject<objectRegistry> + ( + dict.lookupOrDefault("region", polyMesh::defaultRegion) + ) + ) { - if (!isA<fvMesh>(obr)) + if (!isA<fvMesh>(obr_)) { FatalErrorInFunction << "objectRegistry is not an fvMesh" << exit(FatalError); @@ -90,36 +96,32 @@ Foam::functionObjects::processorField::~processorField() // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -void Foam::functionObjects::processorField::read(const dictionary& dict) -{} +bool Foam::functionObjects::processorField::read(const dictionary& dict) +{ + return true; +} -void Foam::functionObjects::processorField::execute() +bool Foam::functionObjects::processorField::execute(const bool postProcess) { const volScalarField& procField = obr_.lookupObject<volScalarField>("processorID"); const_cast<volScalarField&>(procField) == dimensionedScalar("proci", dimless, Pstream::myProcNo()); -} - -void Foam::functionObjects::processorField::end() -{ - execute(); + return true; } -void Foam::functionObjects::processorField::timeSet() -{} - - -void Foam::functionObjects::processorField::write() +bool Foam::functionObjects::processorField::write(const bool postProcess) { const volScalarField& procField = obr_.lookupObject<volScalarField>("processorID"); procField.write(); + + return true; } diff --git a/src/postProcessing/functionObjects/field/processorField/processorField.H b/src/postProcessing/functionObjects/field/processorField/processorField.H index 478a47184e2e1617217bc1e40431e8d09786db03..5e9138f45a77496653ddce246493e830f15f11ba 100644 --- a/src/postProcessing/functionObjects/field/processorField/processorField.H +++ b/src/postProcessing/functionObjects/field/processorField/processorField.H @@ -49,7 +49,6 @@ Description SeeAlso Foam::functionObject - Foam::OutputFilterFunctionObject SourceFiles processorField.C @@ -59,11 +58,7 @@ SourceFiles #ifndef functionObjects_processorField_H #define functionObjects_processorField_H -#include "OFstream.H" -#include "pointFieldFwd.H" -#include "volFields.H" -#include "surfaceFields.H" -#include "coordinateSystem.H" +#include "functionObject.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -72,8 +67,6 @@ namespace Foam // Forward declaration of classes class objectRegistry; -class dictionary; -class mapPolyMesh; namespace functionObjects { @@ -83,15 +76,14 @@ namespace functionObjects \*---------------------------------------------------------------------------*/ class processorField +: + public functionObject { protected: // Protected data - //- Name of this set of nearWallFields object - word name_; - - //- Reference to the database + //- Reference to the objectRegistry const objectRegistry& obr_; @@ -114,14 +106,12 @@ public: // Constructors - //- Construct for given objectRegistry and dictionary. - // Allow the possibility to load fields from files + //- Construct from Time and dictionary processorField ( const word& name, - const objectRegistry&, - const dictionary&, - const bool loadFromFiles = false + const Time& runTime, + const dictionary& dict ); @@ -131,34 +121,14 @@ public: // Member Functions - //- Return name of the processorField object - virtual const word& name() const - { - return name_; - } - //- Read the input 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(); - - //- Called when time was set at the end of the Time::operator++ - virtual void timeSet(); - - //- Write - virtual void write(); + virtual bool read(const dictionary&); - //- Update for changes of mesh - virtual void updateMesh(const mapPolyMesh&) - {} + //- Calculate the processorID field + virtual bool execute(const bool postProcess = false); - //- Update for changes of mesh - virtual void movePoints(const polyMesh&) - {} + //- Write the processorID field + virtual bool write(const bool postProcess = false); }; diff --git a/src/postProcessing/functionObjects/field/processorField/processorFieldFunctionObject.C b/src/postProcessing/functionObjects/field/processorField/processorFieldFunctionObject.C deleted file mode 100644 index 52fb9eafce1558a949edc603f094d9e8dd4da6f8..0000000000000000000000000000000000000000 --- a/src/postProcessing/functionObjects/field/processorField/processorFieldFunctionObject.C +++ /dev/null @@ -1,42 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation - \\/ 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 <http://www.gnu.org/licenses/>. - -\*---------------------------------------------------------------------------*/ - -#include "processorFieldFunctionObject.H" - -// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // - -namespace Foam -{ - defineNamedTemplateTypeNameAndDebug(processorFieldFunctionObject, 0); - - addToRunTimeSelectionTable - ( - functionObject, - processorFieldFunctionObject, - dictionary - ); -} - -// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/field/processorField/processorFieldFunctionObject.H b/src/postProcessing/functionObjects/field/processorField/processorFieldFunctionObject.H deleted file mode 100644 index 98d6b5f090401caa9efba7ddf7cd4afe12ea7884..0000000000000000000000000000000000000000 --- a/src/postProcessing/functionObjects/field/processorField/processorFieldFunctionObject.H +++ /dev/null @@ -1,54 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation - \\/ 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 <http://www.gnu.org/licenses/>. - -Typedef - Foam::processorFieldFunctionObject - -Description - FunctionObject wrapper around processorField to allow - them to be created via the functions entry within controlDict. - -SourceFiles - processorFieldFunctionObject.C - -\*---------------------------------------------------------------------------*/ - -#ifndef processorFieldFunctionObject_H -#define processorFieldFunctionObject_H - -#include "processorField.H" -#include "OutputFilterFunctionObject.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - typedef OutputFilterFunctionObject<functionObjects::processorField> - processorFieldFunctionObject; -} - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#endif - -// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/field/readFields/readFields.C b/src/postProcessing/functionObjects/field/readFields/readFields.C index 4648c252bd36eaad092102419f42ac7dfce0fab8..6014a7d31ccfc35b79b6056f2b0ce5e665b684f3 100644 --- a/src/postProcessing/functionObjects/field/readFields/readFields.C +++ b/src/postProcessing/functionObjects/field/readFields/readFields.C @@ -24,7 +24,9 @@ License \*---------------------------------------------------------------------------*/ #include "readFields.H" -#include "dictionary.H" +#include "volFields.H" +#include "surfaceFields.H" +#include "addToRunTimeSelectionTable.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -33,6 +35,7 @@ namespace Foam namespace functionObjects { defineTypeNameAndDebug(readFields, 0); + addToRunTimeSelectionTable(functionObject, readFields, dictionary); } } @@ -42,16 +45,21 @@ namespace functionObjects Foam::functionObjects::readFields::readFields ( const word& name, - const objectRegistry& obr, - const dictionary& dict, - const bool loadFromFiles + const Time& runTime, + const dictionary& dict ) : - name_(name), - obr_(obr), + functionObject(name), + obr_ + ( + runTime.lookupObject<objectRegistry> + ( + dict.lookupOrDefault("region", polyMesh::defaultRegion) + ) + ), fieldSet_() { - if (!isA<fvMesh>(obr)) + if (!isA<fvMesh>(obr_)) { FatalErrorInFunction << "objectRegistry is not an fvMesh" << exit(FatalError); @@ -69,13 +77,15 @@ Foam::functionObjects::readFields::~readFields() // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -void Foam::functionObjects::readFields::read(const dictionary& dict) +bool Foam::functionObjects::readFields::read(const dictionary& dict) { dict.lookup("fields") >> fieldSet_; + + return true; } -void Foam::functionObjects::readFields::execute() +bool Foam::functionObjects::readFields::execute(const bool postProcess) { // Clear out any previously loaded fields vsf_.clear(); @@ -101,21 +111,15 @@ void Foam::functionObjects::readFields::execute() loadField<symmTensor>(fieldName, vSymmtf_, sSymmtf_); loadField<tensor>(fieldName, vtf_, stf_); } + + return true; } -void Foam::functionObjects::readFields::end() +bool Foam::functionObjects::readFields::write(const bool postProcess) { - execute(); + return true; } -void Foam::functionObjects::readFields::timeSet() -{} - - -void Foam::functionObjects::readFields::write() -{} - - // ************************************************************************* // diff --git a/src/postProcessing/functionObjects/field/readFields/readFields.H b/src/postProcessing/functionObjects/field/readFields/readFields.H index ed6b0489fd60f8161f37f538b92f3d5b81627846..d82ecdf44bfa48c226fba6a53fd2303dc4dd1402 100644 --- a/src/postProcessing/functionObjects/field/readFields/readFields.H +++ b/src/postProcessing/functionObjects/field/readFields/readFields.H @@ -55,7 +55,6 @@ Description SeeAlso Foam::functionObject - Foam::OutputFilterFunctionObject SourceFiles readFields.C @@ -65,10 +64,9 @@ SourceFiles #ifndef functionObjects_readFields_H #define functionObjects_readFields_H -#include "OFstream.H" -#include "pointFieldFwd.H" -#include "volFields.H" -#include "surfaceFields.H" +#include "functionObject.H" +#include "volFieldsFwd.H" +#include "surfaceFieldsFwd.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -77,8 +75,6 @@ namespace Foam // Forward declaration of classes class objectRegistry; -class dictionary; -class mapPolyMesh; namespace functionObjects { @@ -88,14 +84,14 @@ namespace functionObjects \*---------------------------------------------------------------------------*/ class readFields +: + public functionObject { protected: // Protected data - //- Name of this set of readFields object - word name_; - + //- Reference to the objectRegistry const objectRegistry& obr_; //- Fields to load @@ -150,9 +146,8 @@ public: readFields ( const word& name, - const objectRegistry&, - const dictionary&, - const bool loadFromFiles = false + const Time& runTime, + const dictionary& dict ); @@ -162,34 +157,14 @@ public: // Member Functions - //- Return name of the readFields object - virtual const word& name() const - { - return name_; - } - //- Read the set of fields from dictionary - virtual void read(const dictionary&); - - //- Execute, currently does nothing - virtual void execute(); - - //- Execute at the final time-loop, currently does nothing - virtual void end(); - - //- Called when time was set at the end of the Time::operator++ - virtual void timeSet(); - - //- Write - virtual void write(); + virtual bool read(const dictionary&); - //- Update for changes of mesh - virtual void updateMesh(const mapPolyMesh&) - {} + //- Read the fields + virtual bool execute(const bool postProcess = false); - //- Update for changes of mesh - virtual void movePoints(const polyMesh&) - {} + //- Do nothing + virtual bool write(const bool postProcess = false); }; diff --git a/src/postProcessing/functionObjects/field/readFields/readFieldsFunctionObject.C b/src/postProcessing/functionObjects/field/readFields/readFieldsFunctionObject.C deleted file mode 100644 index 31f2542eb268cde608ff31c4c0c9b78d6668f8cc..0000000000000000000000000000000000000000 --- a/src/postProcessing/functionObjects/field/readFields/readFieldsFunctionObject.C +++ /dev/null @@ -1,42 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation - \\/ 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 <http://www.gnu.org/licenses/>. - -\*---------------------------------------------------------------------------*/ - -#include "readFieldsFunctionObject.H" - -// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // - -namespace Foam -{ - defineNamedTemplateTypeNameAndDebug(readFieldsFunctionObject, 0); - - addToRunTimeSelectionTable - ( - functionObject, - readFieldsFunctionObject, - dictionary - ); -} - -// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/field/readFields/readFieldsFunctionObject.H b/src/postProcessing/functionObjects/field/readFields/readFieldsFunctionObject.H deleted file mode 100644 index 0256ca3d50b2a19f650b6041974e6f4f6964e479..0000000000000000000000000000000000000000 --- a/src/postProcessing/functionObjects/field/readFields/readFieldsFunctionObject.H +++ /dev/null @@ -1,54 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation - \\/ 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 <http://www.gnu.org/licenses/>. - -Typedef - Foam::readFieldsFunctionObject - -Description - FunctionObject wrapper around readFields to allow them to be created via - the functions entry within controlDict. - -SourceFiles - readFieldsFunctionObject.C - -\*---------------------------------------------------------------------------*/ - -#ifndef readFieldsFunctionObject_H -#define readFieldsFunctionObject_H - -#include "readFields.H" -#include "OutputFilterFunctionObject.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - typedef OutputFilterFunctionObject<functionObjects::readFields> - readFieldsFunctionObject; -} - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#endif - -// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/field/regionSizeDistribution/regionSizeDistribution.C b/src/postProcessing/functionObjects/field/regionSizeDistribution/regionSizeDistribution.C index 7987c141b621f13d10995392d2bae12a2ec56774..2e869137b0840fbe0c37f67abe572186b9c5aca2 100644 --- a/src/postProcessing/functionObjects/field/regionSizeDistribution/regionSizeDistribution.C +++ b/src/postProcessing/functionObjects/field/regionSizeDistribution/regionSizeDistribution.C @@ -24,11 +24,8 @@ License \*---------------------------------------------------------------------------*/ #include "regionSizeDistribution.H" -#include "volFields.H" -#include "regionSplit.H" #include "fvcVolumeIntegrate.H" -#include "mathematicalConstants.H" -#include "stringListOps.H" +#include "addToRunTimeSelectionTable.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -37,6 +34,13 @@ namespace Foam namespace functionObjects { defineTypeNameAndDebug(regionSizeDistribution, 0); + + addToRunTimeSelectionTable + ( + functionObject, + regionSizeDistribution, + dictionary + ); } //- Plus op for FixedList<scalar> @@ -322,18 +326,15 @@ void Foam::functionObjects::regionSizeDistribution::writeGraphs Foam::functionObjects::regionSizeDistribution::regionSizeDistribution ( const word& name, - const objectRegistry& obr, - const dictionary& dict, - const bool loadFromFiles + const Time& runTime, + const dictionary& dict ) : - functionObjectFiles(obr, name, typeName), - name_(name), - obr_(obr), + writeFile(name, runTime, dict, name), alphaName_(dict.lookup("field")), patchNames_(dict.lookup("patches")) { - if (!isA<fvMesh>(obr)) + if (!isA<fvMesh>(obr_)) { FatalErrorInFunction << "objectRegistry is not an fvMesh" << exit(FatalError); @@ -351,7 +352,7 @@ Foam::functionObjects::regionSizeDistribution::~regionSizeDistribution() // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -void Foam::functionObjects::regionSizeDistribution::read(const dictionary& dict) +bool Foam::functionObjects::regionSizeDistribution::read(const dictionary& dict) { dict.lookup("field") >> alphaName_; dict.lookup("patches") >> patchNames_; @@ -372,24 +373,26 @@ void Foam::functionObjects::regionSizeDistribution::read(const dictionary& dict) Info<< "Transforming all vectorFields with coordinate system " << coordSysPtr_().name() << endl; } -} - -void Foam::functionObjects::regionSizeDistribution::execute() -{} - - -void Foam::functionObjects::regionSizeDistribution::end() -{} + return true; +} -void Foam::functionObjects::regionSizeDistribution::timeSet() -{} +bool Foam::functionObjects::regionSizeDistribution::execute +( + const bool postProcess +) +{ + return true; +} -void Foam::functionObjects::regionSizeDistribution::write() +bool Foam::functionObjects::regionSizeDistribution::write +( + const bool postProcess +) { - Info<< type() << " " << name_ << " output:" << nl; + Info<< type() << " " << name() << " output:" << nl; const fvMesh& mesh = refCast<const fvMesh>(obr_); @@ -846,6 +849,8 @@ void Foam::functionObjects::regionSizeDistribution::write() } } } + + return true; } diff --git a/src/postProcessing/functionObjects/field/regionSizeDistribution/regionSizeDistribution.H b/src/postProcessing/functionObjects/field/regionSizeDistribution/regionSizeDistribution.H index 18b4e36e21f9a8fd6933916237dccc08b213ef3b..039db7e35b4476615f2954afbea0a9ad68827b1c 100644 --- a/src/postProcessing/functionObjects/field/regionSizeDistribution/regionSizeDistribution.H +++ b/src/postProcessing/functionObjects/field/regionSizeDistribution/regionSizeDistribution.H @@ -96,7 +96,7 @@ Description SeeAlso Foam::functionObject - Foam::OutputFilterFunctionObject + Foam::functionObjects::writeFile SourceFiles regionSizeDistribution.C @@ -106,8 +106,7 @@ SourceFiles #ifndef functionObjects_regionSizeDistribution_H #define functionObjects_regionSizeDistribution_H -#include "functionObjectFiles.H" -#include "pointFieldFwd.H" +#include "writeFile.H" #include "writer.H" #include "Map.H" #include "volFieldsFwd.H" @@ -121,10 +120,7 @@ namespace Foam // Forward declaration of classes class objectRegistry; -class dictionary; -class mapPolyMesh; class regionSplit; -class polyMesh; namespace functionObjects { @@ -135,15 +131,10 @@ namespace functionObjects class regionSizeDistribution : - public functionObjectFiles + public writeFile { // Private data - //- Name of this set of regionSizeDistribution objects - word name_; - - const objectRegistry& obr_; - //- Name of field word alphaName_; @@ -250,9 +241,8 @@ public: regionSizeDistribution ( const word& name, - const objectRegistry&, - const dictionary&, - const bool loadFromFiles = false + const Time& runTime, + const dictionary& ); @@ -263,34 +253,14 @@ public: // Member Functions - //- Return name of the set of regionSizeDistribution - virtual const word& name() const - { - return name_; - } - //- Read the regionSizeDistribution data - virtual void read(const dictionary&); + virtual bool read(const dictionary&); - //- Execute, currently does nothing - virtual void execute(); - - //- Execute at the final time-loop, currently does nothing - virtual void end(); - - //- Called when time was set at the end of the Time::operator++ - virtual void timeSet(); + //- Do nothing + virtual bool execute(const bool postProcess = false); //- Calculate the regionSizeDistribution and write - virtual void write(); - - //- Update for changes of mesh - virtual void updateMesh(const mapPolyMesh&) - {} - - //- Update for changes of mesh - virtual void movePoints(const polyMesh&) - {} + virtual bool write(const bool postProcess = false); }; diff --git a/src/postProcessing/functionObjects/field/regionSizeDistribution/regionSizeDistributionFunctionObject.C b/src/postProcessing/functionObjects/field/regionSizeDistribution/regionSizeDistributionFunctionObject.C deleted file mode 100644 index 21e25fd6b2d85ea0e221672857fb5892bb6ea9e5..0000000000000000000000000000000000000000 --- a/src/postProcessing/functionObjects/field/regionSizeDistribution/regionSizeDistributionFunctionObject.C +++ /dev/null @@ -1,46 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2012 OpenFOAM Foundation - \\/ 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 <http://www.gnu.org/licenses/>. - -\*---------------------------------------------------------------------------*/ - -#include "regionSizeDistributionFunctionObject.H" - -// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // - -namespace Foam -{ - defineNamedTemplateTypeNameAndDebug - ( - regionSizeDistributionFunctionObject, - 0 - ); - - addToRunTimeSelectionTable - ( - functionObject, - regionSizeDistributionFunctionObject, - dictionary - ); -} - -// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/field/regionSizeDistribution/regionSizeDistributionFunctionObject.H b/src/postProcessing/functionObjects/field/regionSizeDistribution/regionSizeDistributionFunctionObject.H deleted file mode 100644 index adb23034ab9511aacc975904debdc6b9eefcc8f8..0000000000000000000000000000000000000000 --- a/src/postProcessing/functionObjects/field/regionSizeDistribution/regionSizeDistributionFunctionObject.H +++ /dev/null @@ -1,54 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2012-2016 OpenFOAM Foundation - \\/ 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 <http://www.gnu.org/licenses/>. - -Typedef - Foam::regionSizeDistributionFunctionObject - -Description - FunctionObject wrapper around regionSizeDistribution to allow it to be - created via the functions list within controlDict. - -SourceFiles - regionSizeDistributionFunctionObject.C - -\*---------------------------------------------------------------------------*/ - -#ifndef regionSizeDistributionFunctionObject_H -#define regionSizeDistributionFunctionObject_H - -#include "regionSizeDistribution.H" -#include "OutputFilterFunctionObject.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - typedef OutputFilterFunctionObject<functionObjects::regionSizeDistribution> - regionSizeDistributionFunctionObject; -} - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#endif - -// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/field/streamLine/streamLine.C b/src/postProcessing/functionObjects/field/streamLine/streamLine.C index 84d985a1d62fa21c3666cc19b90f41329e404437..67d576f916fd78a15d6fa0eb2e5d236105430896 100644 --- a/src/postProcessing/functionObjects/field/streamLine/streamLine.C +++ b/src/postProcessing/functionObjects/field/streamLine/streamLine.C @@ -36,6 +36,7 @@ License #include "interpolationCellPoint.H" #include "PatchTools.H" #include "mapPolyMesh.H" +#include "addToRunTimeSelectionTable.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -44,6 +45,7 @@ namespace Foam namespace functionObjects { defineTypeNameAndDebug(streamLine, 0); + addToRunTimeSelectionTable(functionObject, streamLine, dictionary); } } @@ -101,7 +103,6 @@ Foam::functionObjects::streamLine::wallPatch() const void Foam::functionObjects::streamLine::track() { - const Time& runTime = obr_.time(); const fvMesh& mesh = dynamic_cast<const fvMesh&>(obr_); IDLList<streamLineParticle> initialParticles; @@ -140,116 +141,74 @@ void Foam::functionObjects::streamLine::track() label UIndex = -1; - if (loadFromFiles_) - { - IOobjectList allObjects(mesh, runTime.timeName()); + label nScalar = 0; + label nVector = 0; - IOobjectList objects(2*fields_.size()); - forAll(fields_, i) + forAll(fields_, i) + { + if (mesh.foundObject<volScalarField>(fields_[i])) + { + nScalar++; + } + else if (mesh.foundObject<volVectorField>(fields_[i])) + { + nVector++; + } + else { - objects.add(*allObjects[fields_[i]]); + FatalErrorInFunction + << "Cannot find field " << fields_[i] << nl + << "Valid scalar fields are:" + << mesh.names(volScalarField::typeName) << nl + << "Valid vector fields are:" + << mesh.names(volVectorField::typeName) + << exit(FatalError); } + } + vsInterp.setSize(nScalar); + nScalar = 0; + vvInterp.setSize(nVector); + nVector = 0; - ReadFields(mesh, objects, vsFlds); - vsInterp.setSize(vsFlds.size()); - forAll(vsFlds, i) + forAll(fields_, i) + { + if (mesh.foundObject<volScalarField>(fields_[i])) { + const volScalarField& f = mesh.lookupObject<volScalarField> + ( + fields_[i] + ); vsInterp.set ( - i, + nScalar++, interpolation<scalar>::New ( interpolationScheme_, - vsFlds[i] + f ) ); } - ReadFields(mesh, objects, vvFlds); - vvInterp.setSize(vvFlds.size()); - forAll(vvFlds, i) + else if (mesh.foundObject<volVectorField>(fields_[i])) { - vvInterp.set + const volVectorField& f = mesh.lookupObject<volVectorField> ( - i, - interpolation<vector>::New - ( - interpolationScheme_, - vvFlds[i] - ) + fields_[i] ); - } - } - else - { - label nScalar = 0; - label nVector = 0; - - forAll(fields_, i) - { - if (mesh.foundObject<volScalarField>(fields_[i])) - { - nScalar++; - } - else if (mesh.foundObject<volVectorField>(fields_[i])) - { - nVector++; - } - else - { - FatalErrorInFunction - << "Cannot find field " << fields_[i] << nl - << "Valid scalar fields are:" - << mesh.names(volScalarField::typeName) << nl - << "Valid vector fields are:" - << mesh.names(volVectorField::typeName) - << exit(FatalError); - } - } - vsInterp.setSize(nScalar); - nScalar = 0; - vvInterp.setSize(nVector); - nVector = 0; - forAll(fields_, i) - { - if (mesh.foundObject<volScalarField>(fields_[i])) + if (f.name() == UName_) { - const volScalarField& f = mesh.lookupObject<volScalarField> - ( - fields_[i] - ); - vsInterp.set - ( - nScalar++, - interpolation<scalar>::New - ( - interpolationScheme_, - f - ) - ); + UIndex = nVector; } - else if (mesh.foundObject<volVectorField>(fields_[i])) - { - const volVectorField& f = mesh.lookupObject<volVectorField> - ( - fields_[i] - ); - - if (f.name() == UName_) - { - UIndex = nVector; - } - vvInterp.set + vvInterp.set + ( + nVector++, + interpolation<vector>::New ( - nVector++, - interpolation<vector>::New - ( - interpolationScheme_, - f - ) - ); - } + interpolationScheme_, + f + ) + ); } } @@ -327,18 +286,22 @@ void Foam::functionObjects::streamLine::track() Foam::functionObjects::streamLine::streamLine ( const word& name, - const objectRegistry& obr, - const dictionary& dict, - const bool loadFromFiles + const Time& runTime, + const dictionary& dict ) : + functionObject(name), + obr_ + ( + runTime.lookupObject<objectRegistry> + ( + dict.lookupOrDefault("region", polyMesh::defaultRegion) + ) + ), dict_(dict), - name_(name), - obr_(obr), - loadFromFiles_(loadFromFiles), nSubCycle_(0) { - if (!isA<fvMesh>(obr)) + if (!isA<fvMesh>(obr_)) { FatalErrorInFunction << "objectRegistry is not an fvMesh" << exit(FatalError); @@ -356,9 +319,9 @@ Foam::functionObjects::streamLine::~streamLine() // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -void Foam::functionObjects::streamLine::read(const dictionary& dict) +bool Foam::functionObjects::streamLine::read(const dictionary& dict) { - Info<< type() << " " << name_ << ":" << nl; + Info<< type() << " " << name() << ":" << nl; dict.lookup("fields") >> fields_; if (dict.found("UName")) @@ -455,24 +418,20 @@ void Foam::functionObjects::streamLine::read(const dictionary& dict) scalarFormatterPtr_ = writer<scalar>::New(dict.lookup("setFormat")); vectorFormatterPtr_ = writer<vector>::New(dict.lookup("setFormat")); -} - - -void Foam::functionObjects::streamLine::execute() -{} - -void Foam::functionObjects::streamLine::end() -{} + return true; +} -void Foam::functionObjects::streamLine::timeSet() -{} +bool Foam::functionObjects::streamLine::execute(const bool postProcess) +{ + return true; +} -void Foam::functionObjects::streamLine::write() +bool Foam::functionObjects::streamLine::write(const bool postProcess) { - Info<< type() << " " << name_ << " output:" << nl; + Info<< type() << " " << name() << " output:" << nl; const Time& runTime = obr_.time(); const fvMesh& mesh = dynamic_cast<const fvMesh&>(obr_); @@ -527,41 +486,54 @@ void Foam::functionObjects::streamLine::write() // Distribute the track positions. Note: use scheduled comms // to prevent buffering. - mapDistribute::distribute + mapDistributeBase::distribute ( Pstream::scheduled, distMap.schedule(), distMap.constructSize(), distMap.subMap(), + false, distMap.constructMap(), - allTracks_ + false, + allTracks_, + flipOp() ); // Distribute the scalars forAll(allScalars_, scalarI) { - mapDistribute::distribute + allScalars_[scalarI].shrink(); + mapDistributeBase::distribute ( Pstream::scheduled, distMap.schedule(), distMap.constructSize(), distMap.subMap(), + false, distMap.constructMap(), - allScalars_[scalarI] + false, + allScalars_[scalarI], + flipOp() ); + allScalars_[scalarI].setCapacity(allScalars_[scalarI].size()); } // Distribute the vectors forAll(allVectors_, vectorI) { - mapDistribute::distribute + allVectors_[vectorI].shrink(); + mapDistributeBase::distribute ( Pstream::scheduled, distMap.schedule(), distMap.constructSize(), distMap.subMap(), + false, distMap.constructMap(), - allVectors_[vectorI] + false, + allVectors_[vectorI], + flipOp() ); + allVectors_[vectorI].setCapacity(allVectors_[vectorI].size()); } } @@ -695,6 +667,8 @@ void Foam::functionObjects::streamLine::write() ); } } + + return true; } diff --git a/src/postProcessing/functionObjects/field/streamLine/streamLine.H b/src/postProcessing/functionObjects/field/streamLine/streamLine.H index c47bb9f8cde33391848756c51811a26a236a7932..5a577e666dd3334b5bac6da9f3e9f340546a72ff 100644 --- a/src/postProcessing/functionObjects/field/streamLine/streamLine.H +++ b/src/postProcessing/functionObjects/field/streamLine/streamLine.H @@ -91,7 +91,7 @@ Note SeeAlso Foam::functionObject - Foam::OutputFilterFunctionObject + Foam::functionObjects::timeControl Foam::sampledSet Foam::wallBoundedStreamLine @@ -103,13 +103,11 @@ SourceFiles #ifndef functionObjects_streamLine_H #define functionObjects_streamLine_H +#include "functionObject.H" #include "volFieldsFwd.H" -#include "pointFieldFwd.H" -#include "Switch.H" #include "DynamicList.H" #include "scalarList.H" #include "vectorList.H" -#include "polyMesh.H" #include "writer.H" #include "indirectPrimitivePatch.H" @@ -120,8 +118,6 @@ namespace Foam // Forward declaration of classes class objectRegistry; -class dictionary; -class mapPolyMesh; class meshSearch; class sampledSet; @@ -133,20 +129,16 @@ namespace functionObjects \*---------------------------------------------------------------------------*/ class streamLine +: + public functionObject { // Private data - //- Input dictionary - dictionary dict_; - - //- Name of this set of field averages. - word name_; - //- Database this class is registered to const objectRegistry& obr_; - //- Load fields from files (not from objectRegistry) - bool loadFromFiles_; + //- Input dictionary + dictionary dict_; //- List of fields to sample wordList fields_; @@ -233,14 +225,12 @@ public: // Constructors - //- Construct for given objectRegistry and dictionary. - // Allow the possibility to load fields from files + //- Construct from Time and dictionary streamLine ( const word& name, - const objectRegistry&, - const dictionary&, - const bool loadFromFiles = false + const Time& runTime, + const dictionary& dict ); @@ -250,26 +240,14 @@ public: // Member Functions - //- Return name of the set of field averages - virtual const word& name() const - { - return name_; - } - //- Read the field average data - virtual void read(const dictionary&); - - //- Execute the averaging - virtual void execute(); - - //- Execute the averaging at the final time-loop, currently does nothing - virtual void end(); + virtual bool read(const dictionary&); - //- Called when time was set at the end of the Time::operator++ - virtual void timeSet(); + //- Do nothing + virtual bool execute(const bool postProcess = false); - //- Calculate the field average data and write - virtual void write(); + //- Calculate and write the steamlines + virtual bool write(const bool postProcess = false); //- Update for changes of mesh virtual void updateMesh(const mapPolyMesh&); diff --git a/src/postProcessing/functionObjects/field/streamLine/streamLineFunctionObject.C b/src/postProcessing/functionObjects/field/streamLine/streamLineFunctionObject.C deleted file mode 100644 index 0838c78b9d8d3dce7c88df0089543a4ac42d4958..0000000000000000000000000000000000000000 --- a/src/postProcessing/functionObjects/field/streamLine/streamLineFunctionObject.C +++ /dev/null @@ -1,42 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation - \\/ 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 <http://www.gnu.org/licenses/>. - -\*---------------------------------------------------------------------------*/ - -#include "streamLineFunctionObject.H" - -// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // - -namespace Foam -{ - defineNamedTemplateTypeNameAndDebug(streamLineFunctionObject, 0); - - addToRunTimeSelectionTable - ( - functionObject, - streamLineFunctionObject, - dictionary - ); -} - -// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/field/streamLine/streamLineFunctionObject.H b/src/postProcessing/functionObjects/field/streamLine/streamLineFunctionObject.H deleted file mode 100644 index b40fe13c3f9c35561f17ceaa6c2bf3ae3d89d1af..0000000000000000000000000000000000000000 --- a/src/postProcessing/functionObjects/field/streamLine/streamLineFunctionObject.H +++ /dev/null @@ -1,54 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation - \\/ 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 <http://www.gnu.org/licenses/>. - -Typedef - Foam::streamLineFunctionObject - -Description - FunctionObject wrapper around streamLines to allow them to be created via - the functions entry within controlDict. - -SourceFiles - streamLineFunctionObject.C - -\*---------------------------------------------------------------------------*/ - -#ifndef streamLineFunctionObject_H -#define streamLineFunctionObject_H - -#include "streamLine.H" -#include "OutputFilterFunctionObject.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - typedef OutputFilterFunctionObject<functionObjects::streamLine> - streamLineFunctionObject; -} - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#endif - -// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/field/surfaceInterpolateFields/surfaceInterpolateFields.C b/src/postProcessing/functionObjects/field/surfaceInterpolateFields/surfaceInterpolateFields.C index 5093b9056f6c5fb61137407dbbd75255addd41e2..728aafcb5caff59a1b95dd00a32010395a1857dd 100644 --- a/src/postProcessing/functionObjects/field/surfaceInterpolateFields/surfaceInterpolateFields.C +++ b/src/postProcessing/functionObjects/field/surfaceInterpolateFields/surfaceInterpolateFields.C @@ -24,6 +24,8 @@ License \*---------------------------------------------------------------------------*/ #include "surfaceInterpolateFields.H" +#include "surfaceFields.H" +#include "addToRunTimeSelectionTable.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -32,6 +34,13 @@ namespace Foam namespace functionObjects { defineTypeNameAndDebug(surfaceInterpolateFields, 0); + + addToRunTimeSelectionTable + ( + functionObject, + surfaceInterpolateFields, + dictionary + ); } } @@ -41,16 +50,21 @@ namespace functionObjects Foam::functionObjects::surfaceInterpolateFields::surfaceInterpolateFields ( const word& name, - const objectRegistry& obr, - const dictionary& dict, - const bool loadFromFiles + const Time& runTime, + const dictionary& dict ) : - name_(name), - obr_(obr), + functionObject(name), + obr_ + ( + runTime.lookupObject<objectRegistry> + ( + dict.lookupOrDefault("region", polyMesh::defaultRegion) + ) + ), fieldSet_() { - if (!isA<fvMesh>(obr)) + if (!isA<fvMesh>(obr_)) { FatalErrorInFunction << "objectRegistry is not an fvMesh" << exit(FatalError); @@ -68,18 +82,23 @@ Foam::functionObjects::surfaceInterpolateFields::~surfaceInterpolateFields() // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -void Foam::functionObjects::surfaceInterpolateFields::read +bool Foam::functionObjects::surfaceInterpolateFields::read ( const dictionary& dict ) { dict.lookup("fields") >> fieldSet_; + + return true; } -void Foam::functionObjects::surfaceInterpolateFields::execute() +bool Foam::functionObjects::surfaceInterpolateFields::execute +( + const bool postProcess +) { - Info<< type() << " " << name_ << " output:" << nl; + Info<< type() << " " << name() << " output:" << nl; // Clear out any previously loaded fields ssf_.clear(); @@ -95,22 +114,17 @@ void Foam::functionObjects::surfaceInterpolateFields::execute() interpolateFields<tensor>(stf_); Info<< endl; -} - -void Foam::functionObjects::surfaceInterpolateFields::end() -{ - execute(); + return true; } -void Foam::functionObjects::surfaceInterpolateFields::timeSet() -{} - - -void Foam::functionObjects::surfaceInterpolateFields::write() +bool Foam::functionObjects::surfaceInterpolateFields::write +( + const bool postProcess +) { - Info<< type() << " " << name_ << " output:" << nl; + Info<< type() << " " << name() << " output:" << nl; Info<< " Writing interpolated surface fields to " << obr_.time().timeName() << endl; @@ -135,6 +149,8 @@ void Foam::functionObjects::surfaceInterpolateFields::write() { stf_[i].write(); } + + return true; } diff --git a/src/postProcessing/functionObjects/field/surfaceInterpolateFields/surfaceInterpolateFields.H b/src/postProcessing/functionObjects/field/surfaceInterpolateFields/surfaceInterpolateFields.H index d86d5b5ae77036c09561d0d625732fa2dc19d518..eef1c591f8e6e82e0aa1acfde1773563e4b1c172 100644 --- a/src/postProcessing/functionObjects/field/surfaceInterpolateFields/surfaceInterpolateFields.H +++ b/src/postProcessing/functionObjects/field/surfaceInterpolateFields/surfaceInterpolateFields.H @@ -59,7 +59,7 @@ Description SeeAlso Foam::functionObject - Foam::OutputFilterFunctionObject + Foam::functionObjects::timeControl SourceFiles surfaceInterpolateFields.C @@ -69,8 +69,8 @@ SourceFiles #ifndef functionObjects_surfaceInterpolateFields_H #define functionObjects_surfaceInterpolateFields_H -#include "OFstream.H" -#include "surfaceFields.H" +#include "functionObject.H" +#include "surfaceFieldsFwd.H" #include "Tuple2.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -91,18 +91,17 @@ namespace functionObjects \*---------------------------------------------------------------------------*/ class surfaceInterpolateFields +: + public functionObject { protected: // Protected data - //- Name of this set of surfaceInterpolateFields object - word name_; - + //- Reference to the objectRegistry const objectRegistry& obr_; //- Fields to process - //wordList fieldSet_; List<Tuple2<word, word>> fieldSet_; //- Locally constructed fields @@ -146,9 +145,8 @@ public: surfaceInterpolateFields ( const word& name, - const objectRegistry&, - const dictionary&, - const bool loadFromFiles = false + const Time& runTime, + const dictionary& dict ); @@ -158,34 +156,14 @@ public: // Member Functions - //- Return name of the surfaceInterpolateFields object - virtual const word& name() const - { - return name_; - } - //- Read the controls - virtual void read(const dictionary&); - - //- Execute, currently does nothing - virtual void execute(); - - //- Execute at the final time-loop, currently does nothing - virtual void end(); - - //- Called when time was set at the end of the Time::operator++ - virtual void timeSet(); - - //- Write - virtual void write(); + virtual bool read(const dictionary&); - //- Update for changes of mesh - virtual void updateMesh(const mapPolyMesh&) - {} + //- Calculate the interpolated fields + virtual bool execute(const bool postProcess = false); - //- Update for changes of mesh - virtual void movePoints(const polyMesh&) - {} + //- Write the interpolated fields + virtual bool write(const bool postProcess = false); }; diff --git a/src/postProcessing/functionObjects/field/surfaceInterpolateFields/surfaceInterpolateFieldsFunctionObject.C b/src/postProcessing/functionObjects/field/surfaceInterpolateFields/surfaceInterpolateFieldsFunctionObject.C deleted file mode 100644 index 35e7dedc9c973bcf6037029464d1374060d194d4..0000000000000000000000000000000000000000 --- a/src/postProcessing/functionObjects/field/surfaceInterpolateFields/surfaceInterpolateFieldsFunctionObject.C +++ /dev/null @@ -1,46 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation - \\/ 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 <http://www.gnu.org/licenses/>. - -\*---------------------------------------------------------------------------*/ - -#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 deleted file mode 100644 index fa10e067811f53de79a6dfac204f0921ffad7ee2..0000000000000000000000000000000000000000 --- a/src/postProcessing/functionObjects/field/surfaceInterpolateFields/surfaceInterpolateFieldsFunctionObject.H +++ /dev/null @@ -1,56 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation - \\/ 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 <http://www.gnu.org/licenses/>. - -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 - < - functionObjects::surfaceInterpolateFields - > surfaceInterpolateFieldsFunctionObject; -} - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#endif - -// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/field/wallBoundedStreamLine/wallBoundedStreamLine.C b/src/postProcessing/functionObjects/field/wallBoundedStreamLine/wallBoundedStreamLine.C index 6c42012f92770f1625dc094ccefa3964bf652409..20724ed84cca787e7644a1ba36e1fa98250e3f03 100644 --- a/src/postProcessing/functionObjects/field/wallBoundedStreamLine/wallBoundedStreamLine.C +++ b/src/postProcessing/functionObjects/field/wallBoundedStreamLine/wallBoundedStreamLine.C @@ -38,6 +38,7 @@ License #include "meshSearchMeshObject.H" #include "faceSet.H" #include "mapPolyMesh.H" +#include "addToRunTimeSelectionTable.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -46,6 +47,13 @@ namespace Foam namespace functionObjects { defineTypeNameAndDebug(wallBoundedStreamLine, 0); + + addToRunTimeSelectionTable + ( + functionObject, + wallBoundedStreamLine, + dictionary + ); } } @@ -162,7 +170,6 @@ Foam::tetIndices Foam::functionObjects::wallBoundedStreamLine::findNearestTet void Foam::functionObjects::wallBoundedStreamLine::track() { - const Time& runTime = obr_.time(); const fvMesh& mesh = dynamic_cast<const fvMesh&>(obr_); @@ -250,116 +257,75 @@ void Foam::functionObjects::wallBoundedStreamLine::track() label UIndex = -1; - if (loadFromFiles_) - { - IOobjectList allObjects(mesh, runTime.timeName()); + label nScalar = 0; + label nVector = 0; - IOobjectList objects(2*fields_.size()); - forAll(fields_, i) + forAll(fields_, i) + { + if (mesh.foundObject<volScalarField>(fields_[i])) + { + nScalar++; + } + else if (mesh.foundObject<volVectorField>(fields_[i])) + { + nVector++; + } + else { - objects.add(*allObjects[fields_[i]]); + FatalErrorInFunction + << "Cannot find field " << fields_[i] << endl + << "Valid scalar fields are:" + << mesh.names(volScalarField::typeName) << endl + << "Valid vector fields are:" + << mesh.names(volVectorField::typeName) + << exit(FatalError); } + } + + vsInterp.setSize(nScalar); + nScalar = 0; + vvInterp.setSize(nVector); + nVector = 0; - ReadFields(mesh, objects, vsFlds); - vsInterp.setSize(vsFlds.size()); - forAll(vsFlds, i) + forAll(fields_, i) + { + if (mesh.foundObject<volScalarField>(fields_[i])) { + const volScalarField& f = mesh.lookupObject<volScalarField> + ( + fields_[i] + ); vsInterp.set ( - i, + nScalar++, interpolation<scalar>::New ( interpolationScheme_, - vsFlds[i] + f ) ); } - ReadFields(mesh, objects, vvFlds); - vvInterp.setSize(vvFlds.size()); - forAll(vvFlds, i) + else if (mesh.foundObject<volVectorField>(fields_[i])) { - vvInterp.set + const volVectorField& f = mesh.lookupObject<volVectorField> ( - i, - interpolation<vector>::New - ( - interpolationScheme_, - vvFlds[i] - ) + fields_[i] ); - } - } - else - { - label nScalar = 0; - label nVector = 0; - - forAll(fields_, i) - { - if (mesh.foundObject<volScalarField>(fields_[i])) - { - nScalar++; - } - else if (mesh.foundObject<volVectorField>(fields_[i])) - { - nVector++; - } - else - { - FatalErrorInFunction - << "Cannot find field " << fields_[i] << endl - << "Valid scalar fields are:" - << mesh.names(volScalarField::typeName) << endl - << "Valid vector fields are:" - << mesh.names(volVectorField::typeName) - << exit(FatalError); - } - } - vsInterp.setSize(nScalar); - nScalar = 0; - vvInterp.setSize(nVector); - nVector = 0; - forAll(fields_, i) - { - if (mesh.foundObject<volScalarField>(fields_[i])) + if (f.name() == UName_) { - const volScalarField& f = mesh.lookupObject<volScalarField> - ( - fields_[i] - ); - vsInterp.set - ( - nScalar++, - interpolation<scalar>::New - ( - interpolationScheme_, - f - ) - ); + UIndex = nVector; } - else if (mesh.foundObject<volVectorField>(fields_[i])) - { - const volVectorField& f = mesh.lookupObject<volVectorField> - ( - fields_[i] - ); - - if (f.name() == UName_) - { - UIndex = nVector; - } - vvInterp.set + vvInterp.set + ( + nVector++, + interpolation<vector>::New ( - nVector++, - interpolation<vector>::New - ( - interpolationScheme_, - f - ) - ); - } + interpolationScheme_, + f + ) + ); } } @@ -439,17 +405,21 @@ void Foam::functionObjects::wallBoundedStreamLine::track() Foam::functionObjects::wallBoundedStreamLine::wallBoundedStreamLine ( const word& name, - const objectRegistry& obr, - const dictionary& dict, - const bool loadFromFiles + const Time& runTime, + const dictionary& dict ) : - dict_(dict), - name_(name), - obr_(obr), - loadFromFiles_(loadFromFiles) + functionObject(name), + obr_ + ( + runTime.lookupObject<objectRegistry> + ( + dict.lookupOrDefault("region", polyMesh::defaultRegion) + ) + ), + dict_(dict) { - if (!isA<fvMesh>(obr)) + if (!isA<fvMesh>(obr_)) { FatalErrorInFunction << "objectRegistry is not an fvMesh" << exit(FatalError); @@ -467,7 +437,7 @@ Foam::functionObjects::wallBoundedStreamLine::~wallBoundedStreamLine() // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -void Foam::functionObjects::wallBoundedStreamLine::read(const dictionary& dict) +bool Foam::functionObjects::wallBoundedStreamLine::read(const dictionary& dict) { //dict_ = dict; dict.lookup("fields") >> fields_; @@ -613,22 +583,21 @@ void Foam::functionObjects::wallBoundedStreamLine::read(const dictionary& dict) } } } -} - - -void Foam::functionObjects::wallBoundedStreamLine::execute() -{} - -void Foam::functionObjects::wallBoundedStreamLine::end() -{} + return true; +} -void Foam::functionObjects::wallBoundedStreamLine::timeSet() -{} +bool Foam::functionObjects::wallBoundedStreamLine::execute +( + const bool postProcess +) +{ + return true; +} -void Foam::functionObjects::wallBoundedStreamLine::write() +bool Foam::functionObjects::wallBoundedStreamLine::write(const bool postProcess) { const Time& runTime = obr_.time(); const fvMesh& mesh = dynamic_cast<const fvMesh&>(obr_); @@ -680,44 +649,57 @@ void Foam::functionObjects::wallBoundedStreamLine::write() recvMap.xfer() ); - // Distribute the track positions. Note: use scheduled comms // to prevent buffering. - mapDistribute::distribute + allTracks_.shrink(); + mapDistributeBase::distribute ( Pstream::scheduled, distMap.schedule(), distMap.constructSize(), distMap.subMap(), + false, distMap.constructMap(), - allTracks_ + false, + allTracks_, + flipOp() ); // Distribute the scalars forAll(allScalars_, scalarI) { - mapDistribute::distribute + allScalars_[scalarI].shrink(); + mapDistributeBase::distribute ( Pstream::scheduled, distMap.schedule(), distMap.constructSize(), distMap.subMap(), + false, distMap.constructMap(), - allScalars_[scalarI] + false, + allScalars_[scalarI], + flipOp() ); + allScalars_[scalarI].setCapacity(allScalars_[scalarI].size()); } // Distribute the vectors forAll(allVectors_, vectorI) { - mapDistribute::distribute + allVectors_[vectorI].shrink(); + mapDistributeBase::distribute ( Pstream::scheduled, distMap.schedule(), distMap.constructSize(), distMap.subMap(), + false, distMap.constructMap(), - allVectors_[vectorI] + false, + allVectors_[vectorI], + flipOp() ); + allVectors_[vectorI].setCapacity(allVectors_[vectorI].size()); } } @@ -850,6 +832,8 @@ void Foam::functionObjects::wallBoundedStreamLine::write() ); } } + + return true; } diff --git a/src/postProcessing/functionObjects/field/wallBoundedStreamLine/wallBoundedStreamLine.H b/src/postProcessing/functionObjects/field/wallBoundedStreamLine/wallBoundedStreamLine.H index 1a2f7dc4e4ab79e0fdf4fb7b6a3c3fe55d5749d5..0a76cb120deb02b4f00204c53c61d94cc62557b5 100644 --- a/src/postProcessing/functionObjects/field/wallBoundedStreamLine/wallBoundedStreamLine.H +++ b/src/postProcessing/functionObjects/field/wallBoundedStreamLine/wallBoundedStreamLine.H @@ -91,7 +91,7 @@ Note SeeAlso Foam::functionObject - Foam::OutputFilterFunctionObject + Foam::functionObjects::timeControl Foam::sampledSet Foam::streamLine @@ -103,18 +103,15 @@ SourceFiles #ifndef functionObjects_wallBoundedStreamLine_H #define functionObjects_wallBoundedStreamLine_H +#include "functionObject.H" #include "volFieldsFwd.H" -#include "pointFieldFwd.H" -#include "Switch.H" #include "DynamicList.H" #include "scalarList.H" #include "vectorList.H" -#include "polyMesh.H" #include "writer.H" #include "indirectPrimitivePatch.H" #include "tetIndices.H" - // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // namespace Foam @@ -122,8 +119,6 @@ namespace Foam // Forward declaration of classes class objectRegistry; -class dictionary; -class mapPolyMesh; class meshSearch; class sampledSet; @@ -135,20 +130,16 @@ namespace functionObjects \*---------------------------------------------------------------------------*/ class wallBoundedStreamLine +: + public functionObject { // Private data - //- Input dictionary - dictionary dict_; - - //- Name of this set of field averages. - word name_; - //- Database this class is registered to const objectRegistry& obr_; - //- Load fields from files (not from objectRegistry) - bool loadFromFiles_; + //- Input dictionary + dictionary dict_; //- List of fields to sample wordList fields_; @@ -239,14 +230,12 @@ public: // Constructors - //- Construct for given objectRegistry and dictionary. - // Allow the possibility to load fields from files + //- Construct from Time and dictionary wallBoundedStreamLine ( const word& name, - const objectRegistry&, - const dictionary&, - const bool loadFromFiles = false + const Time& runTime, + const dictionary& dict ); @@ -256,26 +245,14 @@ public: // Member Functions - //- Return name of the set of field averages - virtual const word& name() const - { - return name_; - } - //- Read the field average data - virtual void read(const dictionary&); - - //- Execute the averaging - virtual void execute(); - - //- Execute the averaging at the final time-loop, currently does nothing - virtual void end(); + virtual bool read(const dictionary&); - //- Called when time was set at the end of the Time::operator++ - virtual void timeSet(); + //- Do nothing + virtual bool execute(const bool postProcess = false); - //- Calculate the field average data and write - virtual void write(); + //- Calculate and write the wall-bounded streamlines + virtual bool write(const bool postProcess = false); //- Update for changes of mesh virtual void updateMesh(const mapPolyMesh&); diff --git a/src/postProcessing/functionObjects/field/wallBoundedStreamLine/wallBoundedStreamLineFunctionObject.C b/src/postProcessing/functionObjects/field/wallBoundedStreamLine/wallBoundedStreamLineFunctionObject.C deleted file mode 100644 index eaa1cc7eaebbe0a7951ce5a1918021b7a51c21c2..0000000000000000000000000000000000000000 --- a/src/postProcessing/functionObjects/field/wallBoundedStreamLine/wallBoundedStreamLineFunctionObject.C +++ /dev/null @@ -1,42 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation - \\/ 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 <http://www.gnu.org/licenses/>. - -\*---------------------------------------------------------------------------*/ - -#include "wallBoundedStreamLineFunctionObject.H" - -// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // - -namespace Foam -{ - defineNamedTemplateTypeNameAndDebug(wallBoundedStreamLineFunctionObject, 0); - - addToRunTimeSelectionTable - ( - functionObject, - wallBoundedStreamLineFunctionObject, - dictionary - ); -} - -// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/field/wallBoundedStreamLine/wallBoundedStreamLineFunctionObject.H b/src/postProcessing/functionObjects/field/wallBoundedStreamLine/wallBoundedStreamLineFunctionObject.H deleted file mode 100644 index 5461d29e6999f3258330b87afc402add9fe2e551..0000000000000000000000000000000000000000 --- a/src/postProcessing/functionObjects/field/wallBoundedStreamLine/wallBoundedStreamLineFunctionObject.H +++ /dev/null @@ -1,55 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation - \\/ 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 <http://www.gnu.org/licenses/>. - -Typedef - Foam::wallBoundedStreamLineFunctionObject - -Description - FunctionObject wrapper around wallBoundedStreamLines - to allow them to be created via - the functions entry within controlDict. - -SourceFiles - wallBoundedStreamLineFunctionObject.C - -\*---------------------------------------------------------------------------*/ - -#ifndef wallBoundedStreamLineFunctionObject_H -#define wallBoundedStreamLineFunctionObject_H - -#include "wallBoundedStreamLine.H" -#include "OutputFilterFunctionObject.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - typedef OutputFilterFunctionObject<functionObjects::wallBoundedStreamLine> - wallBoundedStreamLineFunctionObject; -} - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#endif - -// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/forces/Make/files b/src/postProcessing/functionObjects/forces/Make/files index f1384ada7c639a1e71b61d4d6f5d6b1674d624d1..1e8ec75d099a074fb55b1788faa77d73012a604f 100644 --- a/src/postProcessing/functionObjects/forces/Make/files +++ b/src/postProcessing/functionObjects/forces/Make/files @@ -1,13 +1,6 @@ pressureTools/pressureTools.C -pressureTools/pressureToolsFunctionObject.C - wallShearStress/wallShearStress.C -wallShearStress/wallShearStressFunctionObject.C - forces/forces.C -forces/forcesFunctionObject.C - forceCoeffs/forceCoeffs.C -forceCoeffs/forceCoeffsFunctionObject.C LIB = $(FOAM_LIBBIN)/libforces diff --git a/src/postProcessing/functionObjects/forces/forceCoeffs/forceCoeffs.C b/src/postProcessing/functionObjects/forces/forceCoeffs/forceCoeffs.C index 18fec8f25c687254c94b94505463b43f2290d0aa..733b77def8b1b251a6a34a5ccfb021f1077774ad 100644 --- a/src/postProcessing/functionObjects/forces/forceCoeffs/forceCoeffs.C +++ b/src/postProcessing/functionObjects/forces/forceCoeffs/forceCoeffs.C @@ -24,11 +24,7 @@ License \*---------------------------------------------------------------------------*/ #include "forceCoeffs.H" -#include "dictionary.H" -#include "Time.H" -#include "fvMesh.H" -#include "Pstream.H" -#include "IOmanip.H" +#include "addToRunTimeSelectionTable.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -37,6 +33,7 @@ namespace Foam namespace functionObjects { defineTypeNameAndDebug(forceCoeffs, 0); + addToRunTimeSelectionTable(functionObject, forceCoeffs, dictionary); } } @@ -126,12 +123,11 @@ void Foam::functionObjects::forceCoeffs::writeFileHeader(const label i) Foam::functionObjects::forceCoeffs::forceCoeffs ( const word& name, - const objectRegistry& obr, - const dictionary& dict, - const bool loadFromFiles + const Time& runTime, + const dictionary& dict ) : - forces(name, obr, dict, loadFromFiles, false), + forces(name, runTime, dict), liftDir_(Zero), dragDir_(Zero), pitchAxis_(Zero), @@ -139,12 +135,6 @@ Foam::functionObjects::forceCoeffs::forceCoeffs lRef_(0.0), Aref_(0.0) { - if (!isA<fvMesh>(obr)) - { - FatalErrorInFunction - << "objectRegistry is not an fvMesh" << exit(FatalError); - } - read(dict); } @@ -157,7 +147,7 @@ Foam::functionObjects::forceCoeffs::~forceCoeffs() // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -void Foam::functionObjects::forceCoeffs::read(const dictionary& dict) +bool Foam::functionObjects::forceCoeffs::read(const dictionary& dict) { forces::read(dict); @@ -172,28 +162,24 @@ void Foam::functionObjects::forceCoeffs::read(const dictionary& dict) // Reference length and area scales dict.lookup("lRef") >> lRef_; dict.lookup("Aref") >> Aref_; -} - - -void Foam::functionObjects::forceCoeffs::execute() -{} - -void Foam::functionObjects::forceCoeffs::end() -{} + return true; +} -void Foam::functionObjects::forceCoeffs::timeSet() -{} +bool Foam::functionObjects::forceCoeffs::execute(const bool postProcess) +{ + return true; +} -void Foam::functionObjects::forceCoeffs::write() +bool Foam::functionObjects::forceCoeffs::write(const bool postProcess) { forces::calcForcesMoment(); if (Pstream::master()) { - functionObjectFiles::write(); + writeFiles::write(); scalar pDyn = 0.5*rhoRef_*magUInf_*magUInf_; @@ -222,7 +208,7 @@ void Foam::functionObjects::forceCoeffs::write() << tab << Cm << tab << Cd << tab << Cl << tab << Clf << tab << Clr << endl; - if (log_) Info<< type() << " " << name_ << " output:" << nl + if (log_) Info<< type() << " " << name() << " output:" << nl << " Cm = " << Cm << nl << " Cd = " << Cd << nl << " Cl = " << Cl << nl @@ -256,6 +242,8 @@ void Foam::functionObjects::forceCoeffs::write() if (log_) Info<< endl; } + + return true; } diff --git a/src/postProcessing/functionObjects/forces/forceCoeffs/forceCoeffs.H b/src/postProcessing/functionObjects/forces/forceCoeffs/forceCoeffs.H index be1a3d385d810214f5eb1f86d05a295650f8d32a..1470d5784ceeafd0bd82925f7e490226607efe98 100644 --- a/src/postProcessing/functionObjects/forces/forceCoeffs/forceCoeffs.H +++ b/src/postProcessing/functionObjects/forces/forceCoeffs/forceCoeffs.H @@ -81,8 +81,8 @@ Description SeeAlso Foam::functionObject - Foam::OutputFilterFunctionObject - Foam::forces + Foam::functionObjects::timeControl + Foam::functionObjects::forces SourceFiles forceCoeffs.C @@ -161,14 +161,12 @@ public: // Constructors - //- Construct for given objectRegistry and dictionary. - // Allow the possibility to load fields from files + //- Construct from Time and dictionary forceCoeffs ( const word& name, - const objectRegistry&, - const dictionary&, - const bool loadFromFiles = false + const Time& runTime, + const dictionary& ); @@ -179,19 +177,13 @@ public: // Member Functions //- Read the forces data - virtual void read(const dictionary&); + virtual bool read(const dictionary&); //- Execute, currently does nothing - virtual void execute(); - - //- Execute at the final time-loop, currently does nothing - virtual void end(); - - //- Called when time was set at the end of the Time::operator++ - virtual void timeSet(); + virtual bool execute(const bool postProcess = false); //- Write the forces - virtual void write(); + virtual bool write(const bool postProcess = false); }; diff --git a/src/postProcessing/functionObjects/forces/forceCoeffs/forceCoeffsFunctionObject.C b/src/postProcessing/functionObjects/forces/forceCoeffs/forceCoeffsFunctionObject.C deleted file mode 100644 index 1d2b11a528e559aafc81f63dafe8414cddfba53a..0000000000000000000000000000000000000000 --- a/src/postProcessing/functionObjects/forces/forceCoeffs/forceCoeffsFunctionObject.C +++ /dev/null @@ -1,42 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation - \\/ 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 <http://www.gnu.org/licenses/>. - -\*---------------------------------------------------------------------------*/ - -#include "forceCoeffsFunctionObject.H" - -// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // - -namespace Foam -{ - defineNamedTemplateTypeNameAndDebug(forceCoeffsFunctionObject, 0); - - addToRunTimeSelectionTable - ( - functionObject, - forceCoeffsFunctionObject, - dictionary - ); -} - -// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/forces/forceCoeffs/forceCoeffsFunctionObject.H b/src/postProcessing/functionObjects/forces/forceCoeffs/forceCoeffsFunctionObject.H deleted file mode 100644 index 7be6eb561afc3d496f2d7eefca9a4d86b5194ad9..0000000000000000000000000000000000000000 --- a/src/postProcessing/functionObjects/forces/forceCoeffs/forceCoeffsFunctionObject.H +++ /dev/null @@ -1,54 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation - \\/ 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 <http://www.gnu.org/licenses/>. - -Typedef - Foam::forceCoeffsFunctionObject - -Description - FunctionObject wrapper around forceCoeffs to allow them to be created via - the functions entry within controlDict. - -SourceFiles - forceCoeffsFunctionObject.C - -\*---------------------------------------------------------------------------*/ - -#ifndef forceCoeffsFunctionObject_H -#define forceCoeffsFunctionObject_H - -#include "forceCoeffs.H" -#include "OutputFilterFunctionObject.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - typedef OutputFilterFunctionObject<functionObjects::forceCoeffs> - forceCoeffsFunctionObject; -} - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#endif - -// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/forces/forces/forces.C b/src/postProcessing/functionObjects/forces/forces/forces.C index 5ff699f35356a971cddcd9c3d7c1ab3ebbff75c2..b0fe879e93db6ca2e1d7a7d24c7aeac5b73d4c60 100644 --- a/src/postProcessing/functionObjects/forces/forces/forces.C +++ b/src/postProcessing/functionObjects/forces/forces/forces.C @@ -24,14 +24,11 @@ License \*---------------------------------------------------------------------------*/ #include "forces.H" -#include "volFields.H" -#include "dictionary.H" -#include "Time.H" -#include "wordReList.H" #include "fvcGrad.H" #include "porosityModel.H" #include "turbulentTransportModel.H" #include "turbulentFluidThermoModel.H" +#include "addToRunTimeSelectionTable.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -40,6 +37,8 @@ namespace Foam namespace functionObjects { defineTypeNameAndDebug(forces, 0); + + addToRunTimeSelectionTable(functionObject, forces, dictionary); } } @@ -395,7 +394,7 @@ void Foam::functionObjects::forces::applyBins void Foam::functionObjects::forces::writeForces() { if (log_) Info - << type() << " " << name_ << " output:" << nl + << type() << " " << name() << " output:" << nl << " sum of forces:" << nl << " pressure : " << sum(force_[0]) << nl << " viscous : " << sum(force_[1]) << nl @@ -522,16 +521,11 @@ void Foam::functionObjects::forces::writeBins() Foam::functionObjects::forces::forces ( const word& name, - const objectRegistry& obr, - const dictionary& dict, - const bool loadFromFiles, - const bool readFields + const Time& runTime, + const dictionary& dict ) : - functionObjectFiles(obr, name, createFileNames(dict)), - name_(name), - obr_(obr), - log_(true), + writeFiles(name, runTime, dict, name), force_(3), moment_(3), patchSet_(), @@ -553,16 +547,14 @@ Foam::functionObjects::forces::forces binCumulative_(true), initialised_(false) { - if (!isA<fvMesh>(obr)) + if (!isA<fvMesh>(obr_)) { FatalErrorInFunction << "objectRegistry is not an fvMesh" << exit(FatalError); } - if (readFields) - { - read(dict); - } + read(dict); + resetNames(createFileNames(dict)); } @@ -570,30 +562,21 @@ Foam::functionObjects::forces::forces ( const word& name, const objectRegistry& obr, - const labelHashSet& patchSet, - const word& pName, - const word& UName, - const word& rhoName, - const scalar rhoInf, - const scalar pRef, - const coordinateSystem& coordSys + const dictionary& dict ) : - functionObjectFiles(obr, name, typeName), - name_(name), - obr_(obr), - log_(true), + writeFiles(name, obr, dict, name), force_(3), moment_(3), - patchSet_(patchSet), - pName_(pName), - UName_(UName), - rhoName_(rhoName), + patchSet_(), + pName_(word::null), + UName_(word::null), + rhoName_(word::null), directForceDensity_(false), fDName_(""), - rhoRef_(rhoInf), - pRef_(pRef), - coordSys_(coordSys), + rhoRef_(VGREAT), + pRef_(0), + coordSys_(), localSystem_(false), porosity_(false), nBin_(1), @@ -604,11 +587,14 @@ Foam::functionObjects::forces::forces binCumulative_(true), initialised_(false) { - forAll(force_, i) + if (!isA<fvMesh>(obr_)) { - force_[i].setSize(nBin_); - moment_[i].setSize(nBin_); + FatalErrorInFunction + << "objectRegistry is not an fvMesh" << exit(FatalError); } + + read(dict); + resetNames(createFileNames(dict)); } @@ -620,13 +606,13 @@ Foam::functionObjects::forces::~forces() // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -void Foam::functionObjects::forces::read(const dictionary& dict) +bool Foam::functionObjects::forces::read(const dictionary& dict) { - initialised_ = false; + writeFiles::read(dict); - log_ = dict.lookupOrDefault<Switch>("log", false); + initialised_ = false; - if (log_) Info<< type() << " " << name_ << ":" << nl; + if (log_) Info<< type() << " " << name() << ":" << nl; directForceDensity_ = dict.lookupOrDefault("directForceDensity", false); @@ -747,35 +733,8 @@ void Foam::functionObjects::forces::read(const dictionary& dict) moment_[1].setSize(1); moment_[2].setSize(1); } -} - -void Foam::functionObjects::forces::execute() -{} - - -void Foam::functionObjects::forces::end() -{} - - -void Foam::functionObjects::forces::timeSet() -{} - - -void Foam::functionObjects::forces::write() -{ - calcForcesMoment(); - - if (Pstream::master()) - { - functionObjectFiles::write(); - - writeForces(); - - writeBins(); - - if (log_) Info<< endl; - } + return true; } @@ -931,4 +890,29 @@ Foam::vector Foam::functionObjects::forces::momentEff() const } +bool Foam::functionObjects::forces::execute(const bool postProcess) +{ + return true; +} + + +bool Foam::functionObjects::forces::write(const bool postProcess) +{ + calcForcesMoment(); + + if (Pstream::master()) + { + writeFiles::write(); + + writeForces(); + + writeBins(); + + if (log_) Info<< endl; + } + + return true; +} + + // ************************************************************************* // diff --git a/src/postProcessing/functionObjects/forces/forces/forces.H b/src/postProcessing/functionObjects/forces/forces/forces.H index 449f2f62008522abc5e8120f9925657042df65ff..b8270eba3cddfd079c6776638fe8dc1b8873c6a4 100644 --- a/src/postProcessing/functionObjects/forces/forces/forces.H +++ b/src/postProcessing/functionObjects/forces/forces/forces.H @@ -101,7 +101,8 @@ Note SeeAlso Foam::functionObject - Foam::OutputFilterFunctionObject + Foam::functionObjects::writeFiles + Foam::functionObjects::timeControl Foam::forceCoeffs SourceFiles @@ -112,28 +113,15 @@ SourceFiles #ifndef functionObjects_forces_H #define functionObjects_forces_H -#include "functionObjectFiles.H" +#include "writeFiles.H" #include "coordinateSystem.H" -#include "coordinateSystems.H" -#include "primitiveFieldsFwd.H" #include "volFieldsFwd.H" #include "HashSet.H" -#include "Tuple2.H" -#include "OFstream.H" -#include "Switch.H" -#include "writer.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // namespace Foam { - -// Forward declaration of classes -class objectRegistry; -class dictionary; -class polyMesh; -class mapPolyMesh; - namespace functionObjects { @@ -143,21 +131,12 @@ namespace functionObjects class forces : - public functionObjectFiles + public writeFiles { protected: // Protected data - //- Name of this set of forces, - // Also used as the name of the probes directory. - word name_; - - const objectRegistry& obr_; - - //- Switch to send output to Info as well as to file - Switch log_; - //- Pressure, viscous and porous force per bin List<Field<vector>> force_; @@ -281,29 +260,20 @@ public: // Constructors - //- Construct for given objectRegistry and dictionary. - // Allow the possibility to load fields from files + //- Construct from Time and dictionary forces ( const word& name, - const objectRegistry&, - const dictionary&, - const bool loadFromFiles = false, - const bool readFields = true + const Time& runTime, + const dictionary& dict ); - //- Construct from components + //- Construct from objectRegistry and dictionary forces ( const word& name, - const objectRegistry&, - const labelHashSet& patchSet, - const word& pName, - const word& UName, - const word& rhoName, - const scalar rhoInf, - const scalar pRef, - const coordinateSystem& coordSys + const objectRegistry& obr, + const dictionary& ); @@ -313,26 +283,8 @@ public: // Member Functions - //- Return name of the set of forces - virtual const word& name() const - { - return name_; - } - //- Read the forces 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(); - - //- Called when time was set at the end of the Time::operator++ - virtual void timeSet(); - - //- Write the forces - virtual void write(); + virtual bool read(const dictionary&); //- Calculate the forces and moments virtual void calcForcesMoment(); @@ -343,13 +295,11 @@ public: //- Return the total moment virtual vector momentEff() const; - //- Update for changes of mesh - virtual void updateMesh(const mapPolyMesh&) - {} + //- Execute, currently does nothing + virtual bool execute(const bool postProcess = false); - //- Update for changes of mesh - virtual void movePoints(const polyMesh&) - {} + //- Write the forces + virtual bool write(const bool postProcess = false); }; diff --git a/src/postProcessing/functionObjects/forces/forces/forcesFunctionObject.C b/src/postProcessing/functionObjects/forces/forces/forcesFunctionObject.C deleted file mode 100644 index 066e59b95f1d9f80cb55a3aa5db444ae6cfca0e1..0000000000000000000000000000000000000000 --- a/src/postProcessing/functionObjects/forces/forces/forcesFunctionObject.C +++ /dev/null @@ -1,42 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation - \\/ 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 <http://www.gnu.org/licenses/>. - -\*---------------------------------------------------------------------------*/ - -#include "forcesFunctionObject.H" - -// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // - -namespace Foam -{ - defineNamedTemplateTypeNameAndDebug(forcesFunctionObject, 0); - - addToRunTimeSelectionTable - ( - functionObject, - forcesFunctionObject, - dictionary - ); -} - -// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/forces/forces/forcesFunctionObject.H b/src/postProcessing/functionObjects/forces/forces/forcesFunctionObject.H deleted file mode 100644 index 518815cc718548792dcb8612eb30e6a7770fc9fc..0000000000000000000000000000000000000000 --- a/src/postProcessing/functionObjects/forces/forces/forcesFunctionObject.H +++ /dev/null @@ -1,54 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation - \\/ 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 <http://www.gnu.org/licenses/>. - -Typedef - Foam::forcesFunctionObject - -Description - FunctionObject wrapper around forces to allow them to be created via the - functions entry within controlDict. - -SourceFiles - forcesFunctionObject.C - -\*---------------------------------------------------------------------------*/ - -#ifndef forcesFunctionObject_H -#define forcesFunctionObject_H - -#include "forces.H" -#include "OutputFilterFunctionObject.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - typedef OutputFilterFunctionObject<functionObjects::forces> - forcesFunctionObject; -} - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#endif - -// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/forces/pressureTools/pressureTools.C b/src/postProcessing/functionObjects/forces/pressureTools/pressureTools.C index b256dafe7bb7492e2dcc0ecb234dc6bb52e9066e..97ab1ddd63f56600ef19fef81983d6e02f40115b 100644 --- a/src/postProcessing/functionObjects/forces/pressureTools/pressureTools.C +++ b/src/postProcessing/functionObjects/forces/pressureTools/pressureTools.C @@ -25,7 +25,7 @@ License #include "pressureTools.H" #include "volFields.H" -#include "dictionary.H" +#include "addToRunTimeSelectionTable.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -34,6 +34,7 @@ namespace Foam namespace functionObjects { defineTypeNameAndDebug(pressureTools, 0); + addToRunTimeSelectionTable(functionObject, pressureTools, dictionary); } } @@ -186,13 +187,18 @@ Foam::functionObjects::pressureTools::convertToCoeff Foam::functionObjects::pressureTools::pressureTools ( const word& name, - const objectRegistry& obr, - const dictionary& dict, - const bool loadFromFiles + const Time& runTime, + const dictionary& dict ) : - name_(name), - obr_(obr), + functionObject(name), + obr_ + ( + runTime.lookupObject<objectRegistry> + ( + dict.lookupOrDefault("region", polyMesh::defaultRegion) + ) + ), pName_("p"), UName_("U"), rhoName_("rho"), @@ -203,7 +209,7 @@ Foam::functionObjects::pressureTools::pressureTools UInf_(Zero), rhoInf_(0.0) { - if (!isA<fvMesh>(obr)) + if (!isA<fvMesh>(obr_)) { FatalErrorInFunction << "objectRegistry is not an fvMesh" << exit(FatalError); @@ -249,7 +255,7 @@ Foam::functionObjects::pressureTools::~pressureTools() // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -void Foam::functionObjects::pressureTools::read(const dictionary& dict) +bool Foam::functionObjects::pressureTools::read(const dictionary& dict) { dict.readIfPresent("pName", pName_); dict.readIfPresent("UName", UName_); @@ -278,16 +284,18 @@ void Foam::functionObjects::pressureTools::read(const dictionary& dict) if (mag(zeroCheck) < ROOTVSMALL) { WarningInFunction - << type() << " " << name_ << ": " + << type() << " " << name() << ": " << "Coefficient calculation requested, but reference " << "pressure level is zero. Please check the supplied " << "values of pInf, UInf and rhoInf" << endl; } } + + return true; } -void Foam::functionObjects::pressureTools::execute() +bool Foam::functionObjects::pressureTools::execute(const bool postProcess) { const volScalarField& p = obr_.lookupObject<volScalarField>(pName_); @@ -297,29 +305,23 @@ void Foam::functionObjects::pressureTools::execute() ); pResult == convertToCoeff(rhoScale(p)*p + pDyn(p) + pRef()); -} - -void Foam::functionObjects::pressureTools::end() -{ - execute(); + return true; } -void Foam::functionObjects::pressureTools::timeSet() -{} - - -void Foam::functionObjects::pressureTools::write() +bool Foam::functionObjects::pressureTools::write(const bool postProcess) { const volScalarField& pResult = obr_.lookupObject<volScalarField>(pName()); - Info<< type() << " " << name_ << " output:" << nl + Info<< type() << " " << name() << " output:" << nl << " writing field " << pResult.name() << nl << endl; pResult.write(); + + return true; } diff --git a/src/postProcessing/functionObjects/forces/pressureTools/pressureTools.H b/src/postProcessing/functionObjects/forces/pressureTools/pressureTools.H index 404c140c6407a3ff930f635da0eb0a4840e3afb2..ff3fd37adb951de55e30a0ced32c884ffa163a59 100644 --- a/src/postProcessing/functionObjects/forces/pressureTools/pressureTools.H +++ b/src/postProcessing/functionObjects/forces/pressureTools/pressureTools.H @@ -108,6 +108,7 @@ SourceFiles #ifndef functionObjects_pressureTools_H #define functionObjects_pressureTools_H +#include "functionObject.H" #include "volFieldsFwd.H" #include "dimensionedScalar.H" @@ -118,9 +119,6 @@ namespace Foam // Forward declaration of classes class objectRegistry; -class dictionary; -class polyMesh; -class mapPolyMesh; namespace functionObjects { @@ -130,13 +128,12 @@ namespace functionObjects \*---------------------------------------------------------------------------*/ class pressureTools +: + public functionObject { // Private data - //- Name of this set of pressureTools objects - word name_; - - //- Reference to the database + //- Reference to the objectRegistry const objectRegistry& obr_; //- Name of pressure field, default is "p" @@ -208,14 +205,12 @@ public: // Constructors - //- Construct for given objectRegistry and dictionary. - // Allow the possibility to load fields from files + //- Construct from Time and dictionary pressureTools ( const word& name, - const objectRegistry&, - const dictionary&, - const bool loadFromFiles = false + const Time& runTime, + const dictionary& ); @@ -225,34 +220,14 @@ public: // Member Functions - //- Return name of the set of pressureTools - virtual const word& name() const - { - return name_; - } - //- Read the pressureTools data - virtual void read(const dictionary&); + virtual bool read(const dictionary&); //- Execute, currently does nothing - virtual void execute(); - - //- Execute at the final time-loop, currently does nothing - virtual void end(); - - //- Called when time was set at the end of the Time::operator++ - virtual void timeSet(); + virtual bool execute(const bool postProcess = false); //- Calculate the pressureTools and write - virtual void write(); - - //- Update for changes of mesh - virtual void updateMesh(const mapPolyMesh&) - {} - - //- Update for changes of mesh - virtual void movePoints(const polyMesh&) - {} + virtual bool write(const bool postProcess = false); }; diff --git a/src/postProcessing/functionObjects/forces/pressureTools/pressureToolsFunctionObject.C b/src/postProcessing/functionObjects/forces/pressureTools/pressureToolsFunctionObject.C deleted file mode 100644 index e4dedce24a722a686f3d7dd118513e18b03b10fb..0000000000000000000000000000000000000000 --- a/src/postProcessing/functionObjects/forces/pressureTools/pressureToolsFunctionObject.C +++ /dev/null @@ -1,42 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2012-2016 OpenFOAM Foundation - \\/ 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 <http://www.gnu.org/licenses/>. - -\*---------------------------------------------------------------------------*/ - -#include "pressureToolsFunctionObject.H" - -// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // - -namespace Foam -{ - defineNamedTemplateTypeNameAndDebug(pressureToolsFunctionObject, 0); - - addToRunTimeSelectionTable - ( - functionObject, - pressureToolsFunctionObject, - dictionary - ); -} - -// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/forces/pressureTools/pressureToolsFunctionObject.H b/src/postProcessing/functionObjects/forces/pressureTools/pressureToolsFunctionObject.H deleted file mode 100644 index 39141da9f92aa2ac298dad676a1dd84dba0283b5..0000000000000000000000000000000000000000 --- a/src/postProcessing/functionObjects/forces/pressureTools/pressureToolsFunctionObject.H +++ /dev/null @@ -1,54 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2012-2016 OpenFOAM Foundation - \\/ 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 <http://www.gnu.org/licenses/>. - -Typedef - Foam::pressureToolsFunctionObject - -Description - FunctionObject wrapper around pressureTools to allow it to be created via - the functions entry within controlDict. - -SourceFiles - pressureToolsFunctionObject.C - -\*---------------------------------------------------------------------------*/ - -#ifndef pressureToolsFunctionObject_H -#define pressureToolsFunctionObject_H - -#include "pressureTools.H" -#include "OutputFilterFunctionObject.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - typedef OutputFilterFunctionObject<functionObjects::pressureTools> - pressureToolsFunctionObject; -} - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#endif - -// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/forces/wallShearStress/wallShearStress.C b/src/postProcessing/functionObjects/forces/wallShearStress/wallShearStress.C index 85e605533a626208ce2cddce2656a2d842014dae..e86266f20bb4703a55e189694b0ea9c448773820 100644 --- a/src/postProcessing/functionObjects/forces/wallShearStress/wallShearStress.C +++ b/src/postProcessing/functionObjects/forces/wallShearStress/wallShearStress.C @@ -29,6 +29,7 @@ License #include "turbulentTransportModel.H" #include "turbulentFluidThermoModel.H" #include "wallPolyPatch.H" +#include "addToRunTimeSelectionTable.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -37,6 +38,7 @@ namespace Foam namespace functionObjects { defineTypeNameAndDebug(wallShearStress, 0); + addToRunTimeSelectionTable(functionObject, wallShearStress, dictionary); } } @@ -97,18 +99,14 @@ void Foam::functionObjects::wallShearStress::calcShearStress Foam::functionObjects::wallShearStress::wallShearStress ( const word& name, - const objectRegistry& obr, - const dictionary& dict, - const bool loadFromFiles + const Time& runTime, + const dictionary& dict ) : - functionObjectFiles(obr, name, typeName), - name_(name), - obr_(obr), - log_(true), + writeFiles(name, runTime, dict, name), patchSet_() { - if (!isA<fvMesh>(obr)) + if (!isA<fvMesh>(obr_)) { FatalErrorInFunction << "objectRegistry is not an fvMesh" << exit(FatalError); @@ -141,6 +139,7 @@ Foam::functionObjects::wallShearStress::wallShearStress mesh.objectRegistry::store(wallShearStressPtr); read(dict); + resetName(typeName); } @@ -152,9 +151,9 @@ Foam::functionObjects::wallShearStress::~wallShearStress() // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -void Foam::functionObjects::wallShearStress::read(const dictionary& dict) +bool Foam::functionObjects::wallShearStress::read(const dictionary& dict) { - log_ = dict.lookupOrDefault<Switch>("log", true); + writeFiles::read(dict); const fvMesh& mesh = refCast<const fvMesh>(obr_); const polyBoundaryMesh& pbm = mesh.boundaryMesh(); @@ -165,7 +164,7 @@ void Foam::functionObjects::wallShearStress::read(const dictionary& dict) wordReList(dict.lookupOrDefault("patches", wordReList())) ); - Info<< type() << " " << name_ << ":" << nl; + Info<< type() << " " << name() << ":" << nl; if (patchSet_.empty()) { @@ -203,15 +202,17 @@ void Foam::functionObjects::wallShearStress::read(const dictionary& dict) patchSet_ = filteredPatchSet; } + + return true; } -void Foam::functionObjects::wallShearStress::execute() +bool Foam::functionObjects::wallShearStress::execute(const bool postProcess) { typedef compressible::turbulenceModel cmpModel; typedef incompressible::turbulenceModel icoModel; - functionObjectFiles::write(); + writeFiles::write(); const fvMesh& mesh = refCast<const fvMesh>(obr_); @@ -221,7 +222,7 @@ void Foam::functionObjects::wallShearStress::execute() mesh.lookupObject<volVectorField>(type()) ); - if (log_) Info<< type() << " " << name_ << " output:" << nl; + if (log_) Info<< type() << " " << name() << " output:" << nl; tmp<volSymmTensorField> Reff; @@ -247,31 +248,25 @@ void Foam::functionObjects::wallShearStress::execute() } calcShearStress(mesh, Reff(), wallShearStress); -} - -void Foam::functionObjects::wallShearStress::end() -{ - execute(); + return true; } -void Foam::functionObjects::wallShearStress::timeSet() -{} - - -void Foam::functionObjects::wallShearStress::write() +bool Foam::functionObjects::wallShearStress::write(const bool postProcess) { - functionObjectFiles::write(); + writeFiles::write(); const volVectorField& wallShearStress = obr_.lookupObject<volVectorField>(type()); - if (log_) Info<< type() << " " << name_ << " output:" << nl + if (log_) Info<< type() << " " << name() << " output:" << nl << " writing field " << wallShearStress.name() << nl << endl; wallShearStress.write(); + + return true; } diff --git a/src/postProcessing/functionObjects/forces/wallShearStress/wallShearStress.H b/src/postProcessing/functionObjects/forces/wallShearStress/wallShearStress.H index 486351bffa657ac4264dcdabe25eb628513e0f18..8c2ffef6e1661f33dc2a7b21ea8c2fb23f732a76 100644 --- a/src/postProcessing/functionObjects/forces/wallShearStress/wallShearStress.H +++ b/src/postProcessing/functionObjects/forces/wallShearStress/wallShearStress.H @@ -64,6 +64,12 @@ Description patches | list of patches to process | no | all wall patches \endtable +SeeAlso + Foam::functionObject + Foam::functionObjects::writeFiles + Foam::functionObjects::pressureTools + Foam::functionObjects::timeControl + SourceFiles wallShearStress.C @@ -72,9 +78,8 @@ SourceFiles #ifndef functionObjects_wallShearStress_H #define functionObjects_wallShearStress_H -#include "functionObjectFiles.H" +#include "writeFiles.H" #include "volFieldsFwd.H" -#include "Switch.H" #include "HashSet.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -83,10 +88,6 @@ namespace Foam { // Forward declaration of classes -class objectRegistry; -class dictionary; -class polyMesh; -class mapPolyMesh; class fvMesh; namespace functionObjects @@ -98,20 +99,12 @@ namespace functionObjects class wallShearStress : - public functionObjectFiles + public writeFiles { protected: // Protected data - //- Name of this set of wallShearStress object - word name_; - - const objectRegistry& obr_; - - //- Switch to send output to Info as well as to file - Switch log_; - //- Optional list of patches to process labelHashSet patchSet_; @@ -149,14 +142,12 @@ public: // Constructors - //- Construct for given objectRegistry and dictionary. - // Allow the possibility to load fields from files + //- Construct from Time and dictionary wallShearStress ( const word& name, - const objectRegistry&, - const dictionary&, - const bool loadFromFiles = false + const Time& runTime, + const dictionary& ); @@ -166,34 +157,14 @@ public: // Member Functions - //- Return name of the set of wallShearStress - virtual const word& name() const - { - return name_; - } - //- Read the wallShearStress 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(); - - //- Called when time was set at the end of the Time::operator++ - virtual void timeSet(); - - //- Calculate the wallShearStress and write - virtual void write(); + virtual bool read(const dictionary&); - //- Update for changes of mesh - virtual void updateMesh(const mapPolyMesh&) - {} + //- Calculate the wall shear-stress + virtual bool execute(const bool postProcess = false); - //- Update for changes of mesh - virtual void movePoints(const polyMesh&) - {} + //- Write the wall shear-stress + virtual bool write(const bool postProcess = false); }; diff --git a/src/postProcessing/functionObjects/forces/wallShearStress/wallShearStressFunctionObject.C b/src/postProcessing/functionObjects/forces/wallShearStress/wallShearStressFunctionObject.C deleted file mode 100644 index a8a05500e18b071c1d67913cc9740b2ab0901c67..0000000000000000000000000000000000000000 --- a/src/postProcessing/functionObjects/forces/wallShearStress/wallShearStressFunctionObject.C +++ /dev/null @@ -1,42 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2012-2016 OpenFOAM Foundation - \\/ 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 <http://www.gnu.org/licenses/>. - -\*---------------------------------------------------------------------------*/ - -#include "wallShearStressFunctionObject.H" - -// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // - -namespace Foam -{ - defineNamedTemplateTypeNameAndDebug(wallShearStressFunctionObject, 0); - - addToRunTimeSelectionTable - ( - functionObject, - wallShearStressFunctionObject, - dictionary - ); -} - -// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/forces/wallShearStress/wallShearStressFunctionObject.H b/src/postProcessing/functionObjects/forces/wallShearStress/wallShearStressFunctionObject.H deleted file mode 100644 index 5e15293c548da2ff003335b5049fe25b4e9a7b99..0000000000000000000000000000000000000000 --- a/src/postProcessing/functionObjects/forces/wallShearStress/wallShearStressFunctionObject.H +++ /dev/null @@ -1,54 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2012-2016 OpenFOAM Foundation - \\/ 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 <http://www.gnu.org/licenses/>. - -Typedef - Foam::wallShearStressFunctionObject - -Description - FunctionObject wrapper around wallShearStress to allow it to be created - via the functions entry within controlDict. - -SourceFiles - wallShearStressFunctionObject.C - -\*---------------------------------------------------------------------------*/ - -#ifndef wallShearStressFunctionObject_H -#define wallShearStressFunctionObject_H - -#include "wallShearStress.H" -#include "OutputFilterFunctionObject.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - typedef OutputFilterFunctionObject<functionObjects::wallShearStress> - wallShearStressFunctionObject; -} - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#endif - -// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/lagrangian/Make/files b/src/postProcessing/functionObjects/lagrangian/Make/files index 3445d2f6288df79f71c8cec490e5b2f1f9c0464a..1301f29b442c32e4ee33c22d285b668eaf007b49 100644 --- a/src/postProcessing/functionObjects/lagrangian/Make/files +++ b/src/postProcessing/functionObjects/lagrangian/Make/files @@ -1,4 +1,3 @@ cloudInfo/cloudInfo.C -cloudInfo/cloudInfoFunctionObject.C LIB = $(FOAM_LIBBIN)/liblagrangianFunctionObjects diff --git a/src/postProcessing/functionObjects/lagrangian/cloudInfo/cloudInfo.C b/src/postProcessing/functionObjects/lagrangian/cloudInfo/cloudInfo.C index 369804dc948ec520f39e06211a670082ac64a6a9..86db6abc03891c1b10d6bd92f83d298133ac62cc 100644 --- a/src/postProcessing/functionObjects/lagrangian/cloudInfo/cloudInfo.C +++ b/src/postProcessing/functionObjects/lagrangian/cloudInfo/cloudInfo.C @@ -24,8 +24,8 @@ License \*---------------------------------------------------------------------------*/ #include "cloudInfo.H" -#include "dictionary.H" #include "kinematicCloud.H" +#include "addToRunTimeSelectionTable.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -34,6 +34,13 @@ namespace Foam namespace functionObjects { defineTypeNameAndDebug(cloudInfo, 0); + + addToRunTimeSelectionTable + ( + functionObject, + cloudInfo, + dictionary + ); } } @@ -55,14 +62,11 @@ void Foam::functionObjects::cloudInfo::writeFileHeader(const label i) Foam::functionObjects::cloudInfo::cloudInfo ( const word& name, - const objectRegistry& obr, - const dictionary& dict, - const bool loadFromFiles + const Time& runTime, + const dictionary& dict ) : - functionObjectFiles(obr, name), - name_(name), - obr_(obr) + writeFiles(name, runTime, dict, name) { read(dict); } @@ -76,11 +80,11 @@ Foam::functionObjects::cloudInfo::~cloudInfo() // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -void Foam::functionObjects::cloudInfo::read(const dictionary& dict) +bool Foam::functionObjects::cloudInfo::read(const dictionary& dict) { - functionObjectFiles::resetNames(dict.lookup("clouds")); + writeFiles::resetNames(dict.lookup("clouds")); - Info<< type() << " " << name_ << ": "; + Info<< type() << " " << name() << ": "; if (names().size()) { Info<< "applying to clouds:" << nl; @@ -94,24 +98,20 @@ void Foam::functionObjects::cloudInfo::read(const dictionary& dict) { Info<< "no clouds to be processed" << nl << endl; } -} - - -void Foam::functionObjects::cloudInfo::execute() -{} - -void Foam::functionObjects::cloudInfo::end() -{} + return true; +} -void Foam::functionObjects::cloudInfo::timeSet() -{} +bool Foam::functionObjects::cloudInfo::execute(const bool postProcess) +{ + return true; +} -void Foam::functionObjects::cloudInfo::write() +bool Foam::functionObjects::cloudInfo::write(const bool postProcess) { - functionObjectFiles::write(); + writeFiles::write(); forAll(names(), i) { @@ -133,6 +133,8 @@ void Foam::functionObjects::cloudInfo::write() << massInSystem << endl; } } + + return true; } diff --git a/src/postProcessing/functionObjects/lagrangian/cloudInfo/cloudInfo.H b/src/postProcessing/functionObjects/lagrangian/cloudInfo/cloudInfo.H index 5906215598b4b4fd3c982edbd614525bdf2807bb..dfd5171275f4641518115b1a363a3e0f5d23a567 100644 --- a/src/postProcessing/functionObjects/lagrangian/cloudInfo/cloudInfo.H +++ b/src/postProcessing/functionObjects/lagrangian/cloudInfo/cloudInfo.H @@ -61,7 +61,7 @@ Description SeeAlso Foam::functionObject - Foam::OutputFilterFunctionObject + Foam::functionObjects::writeFiles SourceFiles cloudInfo.C @@ -71,22 +71,12 @@ SourceFiles #ifndef functionObjects_cloudInfo_H #define functionObjects_cloudInfo_H -#include "functionObjectFiles.H" -#include "PtrList.H" -#include "pointFieldFwd.H" -#include "volFields.H" -#include "surfaceFields.H" +#include "writeFiles.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // namespace Foam { - -// Forward declaration of classes -class objectRegistry; -class dictionary; -class mapPolyMesh; - namespace functionObjects { @@ -96,19 +86,10 @@ namespace functionObjects class cloudInfo : - public functionObjectFiles + public writeFiles { protected: - // Protected data - - //- Name of this set of cloudInfo object - word name_; - - //- Reference to the database - const objectRegistry& obr_; - - // Protected Member Functions //- File header information @@ -134,14 +115,12 @@ public: // Constructors - //- Construct for given objectRegistry and dictionary. - // Allow the possibility to load fields from files + //- Construct from Time and dictionary cloudInfo ( const word& name, - const objectRegistry&, - const dictionary&, - const bool loadFromFiles = false + const Time& runTime, + const dictionary& ); @@ -151,34 +130,14 @@ public: // Member Functions - //- Return name of the cloudInfo object - virtual const word& name() const - { - return name_; - } - //- Read the controls - virtual void read(const dictionary&); + virtual bool read(const dictionary&); //- Execute, currently does nothing - virtual void execute(); - - //- Execute at the final time-loop, currently does nothing - virtual void end(); - - //- Called when time was set at the end of the Time::operator++ - virtual void timeSet(); + virtual bool execute(const bool postProcess = false); //- Write - virtual void write(); - - //- Update for changes of mesh - virtual void updateMesh(const mapPolyMesh&) - {} - - //- Update for changes of mesh - virtual void movePoints(const polyMesh&) - {} + virtual bool write(const bool postProcess = false); }; diff --git a/src/postProcessing/functionObjects/lagrangian/cloudInfo/cloudInfoFunctionObject.C b/src/postProcessing/functionObjects/lagrangian/cloudInfo/cloudInfoFunctionObject.C deleted file mode 100644 index 4ac835ec9dbb41f30faf94ce8945e46f6b54ffed..0000000000000000000000000000000000000000 --- a/src/postProcessing/functionObjects/lagrangian/cloudInfo/cloudInfoFunctionObject.C +++ /dev/null @@ -1,42 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2012-2016 OpenFOAM Foundation - \\/ 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 <http://www.gnu.org/licenses/>. - -\*---------------------------------------------------------------------------*/ - -#include "cloudInfoFunctionObject.H" - -// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // - -namespace Foam -{ - defineNamedTemplateTypeNameAndDebug(cloudInfoFunctionObject, 0); - - addToRunTimeSelectionTable - ( - functionObject, - cloudInfoFunctionObject, - dictionary - ); -} - -// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/lagrangian/cloudInfo/cloudInfoFunctionObject.H b/src/postProcessing/functionObjects/lagrangian/cloudInfo/cloudInfoFunctionObject.H deleted file mode 100644 index 6cfd39830e8f0ce80a4f39b659af64ae628295a5..0000000000000000000000000000000000000000 --- a/src/postProcessing/functionObjects/lagrangian/cloudInfo/cloudInfoFunctionObject.H +++ /dev/null @@ -1,54 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2012-2016 OpenFOAM Foundation - \\/ 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 <http://www.gnu.org/licenses/>. - -Typedef - Foam::cloudInfoFunctionObject - -Description - FunctionObject wrapper around cloudInfo to allow them to be created via - the functions entry within controlDict. - -SourceFiles - cloudInfoFunctionObject.C - -\*---------------------------------------------------------------------------*/ - -#ifndef cloudInfoFunctionObject_H -#define cloudInfoFunctionObject_H - -#include "cloudInfo.H" -#include "OutputFilterFunctionObject.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - typedef OutputFilterFunctionObject<functionObjects::cloudInfo> - cloudInfoFunctionObject; -} - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#endif - -// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/utilities/CourantNo/CourantNo.C b/src/postProcessing/functionObjects/utilities/CourantNo/CourantNo.C index a7fc210de3887d50764cff3033a7f20c047495f5..298963e58d68a61d69f7035b9690141902266b5f 100644 --- a/src/postProcessing/functionObjects/utilities/CourantNo/CourantNo.C +++ b/src/postProcessing/functionObjects/utilities/CourantNo/CourantNo.C @@ -27,6 +27,7 @@ License #include "surfaceFields.H" #include "fvcSurfaceIntegrate.H" #include "zeroGradientFvPatchFields.H" +#include "addToRunTimeSelectionTable.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -35,6 +36,13 @@ namespace Foam namespace functionObjects { defineTypeNameAndDebug(CourantNo, 0); + + addToRunTimeSelectionTable + ( + functionObject, + CourantNo, + dictionary + ); } } @@ -63,17 +71,22 @@ Foam::functionObjects::CourantNo::byRho Foam::functionObjects::CourantNo::CourantNo ( const word& name, - const objectRegistry& obr, - const dictionary& dict, - const bool loadFromFiles + const Time& runTime, + const dictionary& dict ) : - name_(name), - obr_(obr), + functionObject(name), + obr_ + ( + runTime.lookupObject<objectRegistry> + ( + dict.lookupOrDefault("region", polyMesh::defaultRegion) + ) + ), phiName_("phi"), rhoName_("rho") { - if (!isA<fvMesh>(obr)) + if (!isA<fvMesh>(obr_)) { FatalErrorInFunction << "objectRegistry is not an fvMesh" << exit(FatalError); @@ -113,14 +126,16 @@ Foam::functionObjects::CourantNo::~CourantNo() // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -void Foam::functionObjects::CourantNo::read(const dictionary& dict) +bool Foam::functionObjects::CourantNo::read(const dictionary& dict) { phiName_ = dict.lookupOrDefault<word>("phiName", "phi"); rhoName_ = dict.lookupOrDefault<word>("rhoName", "rho"); + + return true; } -void Foam::functionObjects::CourantNo::execute() +bool Foam::functionObjects::CourantNo::execute(const bool postProcess) { const fvMesh& mesh = refCast<const fvMesh>(obr_); @@ -139,29 +154,23 @@ void Foam::functionObjects::CourantNo::execute() /mesh.V() ); Co.correctBoundaryConditions(); -} - -void Foam::functionObjects::CourantNo::end() -{ - execute(); + return true; } -void Foam::functionObjects::CourantNo::timeSet() -{} - - -void Foam::functionObjects::CourantNo::write() +bool Foam::functionObjects::CourantNo::write(const bool postProcess) { const volScalarField& CourantNo = obr_.lookupObject<volScalarField>(type()); - Info<< type() << " " << name_ << " output:" << nl + Info<< type() << " " << name() << " output:" << nl << " writing field " << CourantNo.name() << nl << endl; CourantNo.write(); + + return true; } diff --git a/src/postProcessing/functionObjects/utilities/CourantNo/CourantNo.H b/src/postProcessing/functionObjects/utilities/CourantNo/CourantNo.H index ca377f1c88eeb8a048e1943bbe3a70a6fa7a715d..6db5e796e5b57ebe04d82c98123c4ecabc0b6a69 100644 --- a/src/postProcessing/functionObjects/utilities/CourantNo/CourantNo.H +++ b/src/postProcessing/functionObjects/utilities/CourantNo/CourantNo.H @@ -40,19 +40,13 @@ SourceFiles #ifndef functionObjects_CourantNo_H #define functionObjects_CourantNo_H +#include "functionObject.H" #include "volFields.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // namespace Foam { - -// Forward declaration of classes -class objectRegistry; -class dictionary; -class polyMesh; -class mapPolyMesh; - namespace functionObjects { @@ -61,12 +55,11 @@ namespace functionObjects \*---------------------------------------------------------------------------*/ class CourantNo +: + public functionObject { // Private data - //- Name of this set of CourantNo objects - word name_; - //- Reference to the database const objectRegistry& obr_; @@ -100,14 +93,12 @@ public: // Constructors - //- Construct for given objectRegistry and dictionary. - // Allow the possibility to load fields from files + //- Construct from Time and dictionary CourantNo ( const word& name, - const objectRegistry&, - const dictionary&, - const bool loadFromFiles = false + const Time&, + const dictionary& ); @@ -117,34 +108,14 @@ public: // Member Functions - //- Return name of the set of CourantNo - virtual const word& name() const - { - return name_; - } - //- Read the CourantNo data - virtual void read(const dictionary&); + virtual bool read(const dictionary&); //- Execute, currently does nothing - virtual void execute(); - - //- Execute at the final time-loop, currently does nothing - virtual void end(); - - //- Called when time was set at the end of the Time::operator++ - virtual void timeSet(); + virtual bool execute(const bool postProcess = false); //- Calculate the CourantNo and write - virtual void write(); - - //- Update for changes of mesh - virtual void updateMesh(const mapPolyMesh&) - {} - - //- Update for changes of mesh - virtual void movePoints(const polyMesh&) - {} + virtual bool write(const bool postProcess = false); }; diff --git a/src/postProcessing/functionObjects/utilities/CourantNo/CourantNoFunctionObject.C b/src/postProcessing/functionObjects/utilities/CourantNo/CourantNoFunctionObject.C deleted file mode 100644 index af57c73e67596ac9e9eaaf86a4f0416767a69cac..0000000000000000000000000000000000000000 --- a/src/postProcessing/functionObjects/utilities/CourantNo/CourantNoFunctionObject.C +++ /dev/null @@ -1,42 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2012 OpenFOAM Foundation - \\/ 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 <http://www.gnu.org/licenses/>. - -\*---------------------------------------------------------------------------*/ - -#include "CourantNoFunctionObject.H" - -// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // - -namespace Foam -{ - defineNamedTemplateTypeNameAndDebug(CourantNoFunctionObject, 0); - - addToRunTimeSelectionTable - ( - functionObject, - CourantNoFunctionObject, - dictionary - ); -} - -// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/utilities/CourantNo/CourantNoFunctionObject.H b/src/postProcessing/functionObjects/utilities/CourantNo/CourantNoFunctionObject.H deleted file mode 100644 index 6bab35fc09206c5a4af99f89799db175d5a1b4fb..0000000000000000000000000000000000000000 --- a/src/postProcessing/functionObjects/utilities/CourantNo/CourantNoFunctionObject.H +++ /dev/null @@ -1,54 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2012-2016 OpenFOAM Foundation - \\/ 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 <http://www.gnu.org/licenses/>. - -Typedef - Foam::CourantNoFunctionObject - -Description - FunctionObject wrapper around CourantNo to allow it to be created - via the functions entry within controlDict. - -SourceFiles - CourantNoFunctionObject.C - -\*---------------------------------------------------------------------------*/ - -#ifndef CourantNoFunctionObject_H -#define CourantNoFunctionObject_H - -#include "CourantNo.H" -#include "OutputFilterFunctionObject.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - typedef OutputFilterFunctionObject<functionObjects::CourantNo> - CourantNoFunctionObject; -} - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#endif - -// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/utilities/Lambda2/Lambda2.C b/src/postProcessing/functionObjects/utilities/Lambda2/Lambda2.C index e6c13e8bdf0e65beea8bc167853146bf21d00d1e..defbe1841aaebf46ce9c058dd315b841a687474a 100644 --- a/src/postProcessing/functionObjects/utilities/Lambda2/Lambda2.C +++ b/src/postProcessing/functionObjects/utilities/Lambda2/Lambda2.C @@ -25,9 +25,9 @@ License #include "Lambda2.H" #include "volFields.H" -#include "dictionary.H" #include "zeroGradientFvPatchFields.H" #include "fvcGrad.H" +#include "addToRunTimeSelectionTable.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -36,6 +36,13 @@ namespace Foam namespace functionObjects { defineTypeNameAndDebug(Lambda2, 0); + + addToRunTimeSelectionTable + ( + functionObject, + Lambda2, + dictionary + ); } } @@ -45,16 +52,21 @@ namespace functionObjects Foam::functionObjects::Lambda2::Lambda2 ( const word& name, - const objectRegistry& obr, - const dictionary& dict, - const bool loadFromFiles + const Time& runTime, + const dictionary& dict ) : - name_(name), - obr_(obr), + functionObject(name), + obr_ + ( + runTime.lookupObject<objectRegistry> + ( + dict.lookupOrDefault("region", polyMesh::defaultRegion) + ) + ), UName_("U") { - if (!isA<fvMesh>(obr)) + if (!isA<fvMesh>(obr_)) { FatalErrorInFunction << "objectRegistry is not an fvMesh" << exit(FatalError); @@ -93,13 +105,15 @@ Foam::functionObjects::Lambda2::~Lambda2() // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -void Foam::functionObjects::Lambda2::read(const dictionary& dict) +bool Foam::functionObjects::Lambda2::read(const dictionary& dict) { UName_ = dict.lookupOrDefault<word>("UName", "U"); + + return true; } -void Foam::functionObjects::Lambda2::execute() +bool Foam::functionObjects::Lambda2::execute(const bool postProcess) { const fvMesh& mesh = refCast<const fvMesh>(obr_); @@ -121,29 +135,23 @@ void Foam::functionObjects::Lambda2::execute() ); Lambda2 = -eigenValues(SSplusWW)().component(vector::Y); -} - -void Foam::functionObjects::Lambda2::end() -{ - execute(); + return true; } -void Foam::functionObjects::Lambda2::timeSet() -{} - - -void Foam::functionObjects::Lambda2::write() +bool Foam::functionObjects::Lambda2::write(const bool postProcess) { const volScalarField& Lambda2 = obr_.lookupObject<volScalarField>(type()); - Info<< type() << " " << name_ << " output:" << nl + Info<< type() << " " << name() << " output:" << nl << " writing field " << Lambda2.name() << nl << endl; Lambda2.write(); + + return true; } diff --git a/src/postProcessing/functionObjects/utilities/Lambda2/Lambda2.H b/src/postProcessing/functionObjects/utilities/Lambda2/Lambda2.H index 804bb584fbbca855e6c259256439b478612ef36a..76d3b6d73f24a58c768daf356b30b2b5c4e8604e 100644 --- a/src/postProcessing/functionObjects/utilities/Lambda2/Lambda2.H +++ b/src/postProcessing/functionObjects/utilities/Lambda2/Lambda2.H @@ -40,10 +40,8 @@ SourceFiles #ifndef functionObjects_Lambda2_H #define functionObjects_Lambda2_H +#include "functionObject.H" #include "volFieldsFwd.H" -#include "surfaceFieldsFwd.H" -#include "OFstream.H" -#include "Switch.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -52,9 +50,6 @@ namespace Foam // Forward declaration of classes class objectRegistry; -class dictionary; -class polyMesh; -class mapPolyMesh; namespace functionObjects { @@ -64,12 +59,11 @@ namespace functionObjects \*---------------------------------------------------------------------------*/ class Lambda2 +: + public functionObject { // Private data - //- Name of this set of Lambda2 objects - word name_; - //- Reference to the database const objectRegistry& obr_; @@ -94,14 +88,12 @@ public: // Constructors - //- Construct for given objectRegistry and dictionary. - // Allow the possibility to load fields from files + //- Construct from Time and dictionary Lambda2 ( const word& name, - const objectRegistry&, - const dictionary&, - const bool loadFromFiles = false + const Time& runTime, + const dictionary& dict ); @@ -111,34 +103,14 @@ public: // Member Functions - //- Return name of the set of Lambda2 - virtual const word& name() const - { - return name_; - } - //- Read the Lambda2 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(); - - //- Called when time was set at the end of the Time::operator++ - virtual void timeSet(); - - //- Calculate the Lambda2 and write - virtual void write(); + virtual bool read(const dictionary&); - //- Update for changes of mesh - virtual void updateMesh(const mapPolyMesh&) - {} + //- Calculate Lambda2 + virtual bool execute(const bool postProcess = false); - //- Update for changes of mesh - virtual void movePoints(const polyMesh&) - {} + //- Write Lambda2 + virtual bool write(const bool postProcess = false); }; diff --git a/src/postProcessing/functionObjects/utilities/Lambda2/Lambda2FunctionObject.C b/src/postProcessing/functionObjects/utilities/Lambda2/Lambda2FunctionObject.C deleted file mode 100644 index ced087ce9bb9684d9333733f8d95eb72ac6ac9d5..0000000000000000000000000000000000000000 --- a/src/postProcessing/functionObjects/utilities/Lambda2/Lambda2FunctionObject.C +++ /dev/null @@ -1,42 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2012 OpenFOAM Foundation - \\/ 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 <http://www.gnu.org/licenses/>. - -\*---------------------------------------------------------------------------*/ - -#include "Lambda2FunctionObject.H" - -// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // - -namespace Foam -{ - defineNamedTemplateTypeNameAndDebug(Lambda2FunctionObject, 0); - - addToRunTimeSelectionTable - ( - functionObject, - Lambda2FunctionObject, - dictionary - ); -} - -// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/utilities/Lambda2/Lambda2FunctionObject.H b/src/postProcessing/functionObjects/utilities/Lambda2/Lambda2FunctionObject.H deleted file mode 100644 index 63031374cbb46c4096c50853456d43cd4ff5fd37..0000000000000000000000000000000000000000 --- a/src/postProcessing/functionObjects/utilities/Lambda2/Lambda2FunctionObject.H +++ /dev/null @@ -1,54 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2012-2016 OpenFOAM Foundation - \\/ 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 <http://www.gnu.org/licenses/>. - -Typedef - Foam::Lambda2FunctionObject - -Description - FunctionObject wrapper around Lambda2 to allow it to be created - via the functions entry within controlDict. - -SourceFiles - Lambda2FunctionObject.C - -\*---------------------------------------------------------------------------*/ - -#ifndef Lambda2FunctionObject_H -#define Lambda2FunctionObject_H - -#include "Lambda2.H" -#include "OutputFilterFunctionObject.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - typedef OutputFilterFunctionObject<functionObjects::Lambda2> - Lambda2FunctionObject; -} - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#endif - -// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/utilities/Make/files b/src/postProcessing/functionObjects/utilities/Make/files index b9601ff78e58872bab37d6ad8815570e58c12781..90464e991385e8411190c2fb9d6f20317598cc48 100644 --- a/src/postProcessing/functionObjects/utilities/Make/files +++ b/src/postProcessing/functionObjects/utilities/Make/files @@ -1,58 +1,22 @@ codedFunctionObject/codedFunctionObject.C - CourantNo/CourantNo.C -CourantNo/CourantNoFunctionObject.C - Lambda2/Lambda2.C -Lambda2/Lambda2FunctionObject.C - Peclet/Peclet.C -Peclet/PecletFunctionObject.C - Q/Q.C -Q/QFunctionObject.C - blendingFactor/blendingFactor.C -blendingFactor/blendingFactorFunctionObject.C - dsmcFields/dsmcFields.C -dsmcFields/dsmcFieldsFunctionObject.C - residuals/residuals.C -residuals/residualsFunctionObject.C - scalarTransport/scalarTransport.C -scalarTransport/scalarTransportFunctionObject.C - timeActivatedFileUpdate/timeActivatedFileUpdate.C -timeActivatedFileUpdate/timeActivatedFileUpdateFunctionObject.C - turbulenceFields/turbulenceFields.C -turbulenceFields/turbulenceFieldsFunctionObject.C - vorticity/vorticity.C -vorticity/vorticityFunctionObject.C - yPlus/yPlus.C -yPlus/yPlusFunctionObject.C - setTimeStep/setTimeStepFunctionObject.C - systemCall/systemCall.C -systemCall/systemCallFunctionObject.C - abort/abort.C - partialWrite/partialWrite.C -partialWrite/partialWriteFunctionObject.C - removeRegisteredObject/removeRegisteredObject.C -removeRegisteredObject/removeRegisteredObjectFunctionObject.C - writeDictionary/writeDictionary.C -writeDictionary/writeDictionaryFunctionObject.C - writeRegisteredObject/writeRegisteredObject.C -writeRegisteredObject/writeRegisteredObjectFunctionObject.C LIB = $(FOAM_LIBBIN)/libutilityFunctionObjects diff --git a/src/postProcessing/functionObjects/utilities/Peclet/Peclet.C b/src/postProcessing/functionObjects/utilities/Peclet/Peclet.C index 9bc2a62e1530258f86e2f9131026bd20abcb632e..b4560d54ee32fcf693574cab597a369b31a8208b 100644 --- a/src/postProcessing/functionObjects/utilities/Peclet/Peclet.C +++ b/src/postProcessing/functionObjects/utilities/Peclet/Peclet.C @@ -30,6 +30,7 @@ License #include "turbulentTransportModel.H" #include "turbulentFluidThermoModel.H" #include "surfaceInterpolate.H" +#include "addToRunTimeSelectionTable.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -38,6 +39,13 @@ namespace Foam namespace functionObjects { defineTypeNameAndDebug(Peclet, 0); + + addToRunTimeSelectionTable + ( + functionObject, + Peclet, + dictionary + ); } } @@ -47,17 +55,22 @@ namespace functionObjects Foam::functionObjects::Peclet::Peclet ( const word& name, - const objectRegistry& obr, - const dictionary& dict, - const bool loadFromFiles + const Time& runTime, + const dictionary& dict ) : - name_(name), - obr_(obr), + functionObject(name), + obr_ + ( + runTime.lookupObject<objectRegistry> + ( + dict.lookupOrDefault("region", polyMesh::defaultRegion) + ) + ), phiName_("phi"), rhoName_("rho") { - if (!isA<fvMesh>(obr)) + if (!isA<fvMesh>(obr_)) { FatalErrorInFunction << "objectRegistry is not an fvMesh" << exit(FatalError); @@ -96,14 +109,16 @@ Foam::functionObjects::Peclet::~Peclet() // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -void Foam::functionObjects::Peclet::read(const dictionary& dict) +bool Foam::functionObjects::Peclet::read(const dictionary& dict) { phiName_ = dict.lookupOrDefault<word>("phiName", "phi"); rhoName_ = dict.lookupOrDefault<word>("rhoName", "rho"); + + return true; } -void Foam::functionObjects::Peclet::execute() +bool Foam::functionObjects::Peclet::execute(const bool postProcess) { typedef compressible::turbulenceModel cmpTurbModel; typedef incompressible::turbulenceModel icoTurbModel; @@ -183,28 +198,23 @@ void Foam::functionObjects::Peclet::execute() *mesh.surfaceInterpolation::deltaCoeffs() *fvc::interpolate(nuEff) ); -} - -void Foam::functionObjects::Peclet::end() -{ - execute(); + return true; } -void Foam::functionObjects::Peclet::timeSet() -{} - -void Foam::functionObjects::Peclet::write() +bool Foam::functionObjects::Peclet::write(const bool postProcess) { const surfaceScalarField& Peclet = obr_.lookupObject<surfaceScalarField>(type()); - Info<< type() << " " << name_ << " output:" << nl + Info<< type() << " " << name() << " output:" << nl << " writing field " << Peclet.name() << nl << endl; Peclet.write(); + + return true; } diff --git a/src/postProcessing/functionObjects/utilities/Peclet/Peclet.H b/src/postProcessing/functionObjects/utilities/Peclet/Peclet.H index 4b500ec0dc798f311eb829acf92d5b38c628b814..ed829c196f238697eeefba259678971ff8f0a101 100644 --- a/src/postProcessing/functionObjects/utilities/Peclet/Peclet.H +++ b/src/postProcessing/functionObjects/utilities/Peclet/Peclet.H @@ -39,10 +39,8 @@ SourceFiles #ifndef functionObjects_Peclet_H #define functionObjects_Peclet_H +#include "functionObject.H" #include "volFieldsFwd.H" -#include "surfaceFieldsFwd.H" -#include "OFstream.H" -#include "Switch.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -51,9 +49,6 @@ namespace Foam // Forward declaration of classes class objectRegistry; -class dictionary; -class polyMesh; -class mapPolyMesh; namespace functionObjects { @@ -63,12 +58,11 @@ namespace functionObjects \*---------------------------------------------------------------------------*/ class Peclet +: + public functionObject { // Private data - //- Name of this set of Peclet objects - word name_; - //- Reference to the database const objectRegistry& obr_; @@ -101,9 +95,8 @@ public: Peclet ( const word& name, - const objectRegistry&, - const dictionary&, - const bool loadFromFiles = false + const Time& runTime, + const dictionary& dict ); @@ -113,34 +106,14 @@ public: // Member Functions - //- Return name of the set of Peclet - virtual const word& name() const - { - return name_; - } - //- Read the Peclet 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(); - - //- Called when time was set at the end of the Time::operator++ - virtual void timeSet(); - - //- Calculate the Peclet and write - virtual void write(); + virtual bool read(const dictionary&); - //- Update for changes of mesh - virtual void updateMesh(const mapPolyMesh&) - {} + //- Calculate the Peclet number field + virtual bool execute(const bool postProcess = false); - //- Update for changes of mesh - virtual void movePoints(const polyMesh&) - {} + //- Write the Peclet number field + virtual bool write(const bool postProcess = false); }; diff --git a/src/postProcessing/functionObjects/utilities/Peclet/PecletFunctionObject.C b/src/postProcessing/functionObjects/utilities/Peclet/PecletFunctionObject.C deleted file mode 100644 index fdb247703cf93447ef7443649c06aa92626b5c8f..0000000000000000000000000000000000000000 --- a/src/postProcessing/functionObjects/utilities/Peclet/PecletFunctionObject.C +++ /dev/null @@ -1,42 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2012 OpenFOAM Foundation - \\/ 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 <http://www.gnu.org/licenses/>. - -\*---------------------------------------------------------------------------*/ - -#include "PecletFunctionObject.H" - -// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // - -namespace Foam -{ - defineNamedTemplateTypeNameAndDebug(PecletFunctionObject, 0); - - addToRunTimeSelectionTable - ( - functionObject, - PecletFunctionObject, - dictionary - ); -} - -// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/utilities/Peclet/PecletFunctionObject.H b/src/postProcessing/functionObjects/utilities/Peclet/PecletFunctionObject.H deleted file mode 100644 index a740de23d67acbf1477175dd209989647e410fef..0000000000000000000000000000000000000000 --- a/src/postProcessing/functionObjects/utilities/Peclet/PecletFunctionObject.H +++ /dev/null @@ -1,54 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2012-2016 OpenFOAM Foundation - \\/ 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 <http://www.gnu.org/licenses/>. - -Typedef - Foam::PecletFunctionObject - -Description - FunctionObject wrapper around Peclet to allow it to be created - via the functions entry within controlDict. - -SourceFiles - PecletFunctionObject.C - -\*---------------------------------------------------------------------------*/ - -#ifndef PecletFunctionObject_H -#define PecletFunctionObject_H - -#include "Peclet.H" -#include "OutputFilterFunctionObject.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - typedef OutputFilterFunctionObject<functionObjects::Peclet> - PecletFunctionObject; -} - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#endif - -// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/utilities/Q/Q.C b/src/postProcessing/functionObjects/utilities/Q/Q.C index cea5d053346aee9ffe73668b1f08d860121541a4..407ce0ba6a08626c260f91822f09e6002f57a271 100644 --- a/src/postProcessing/functionObjects/utilities/Q/Q.C +++ b/src/postProcessing/functionObjects/utilities/Q/Q.C @@ -25,8 +25,8 @@ License #include "Q.H" #include "volFields.H" -#include "dictionary.H" #include "fvcGrad.H" +#include "addToRunTimeSelectionTable.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -35,6 +35,13 @@ namespace Foam namespace functionObjects { defineTypeNameAndDebug(Q, 0); + + addToRunTimeSelectionTable + ( + functionObject, + Q, + dictionary + ); } } @@ -44,16 +51,21 @@ namespace functionObjects Foam::functionObjects::Q::Q ( const word& name, - const objectRegistry& obr, - const dictionary& dict, - const bool loadFromFiles + const Time& runTime, + const dictionary& dict ) : - name_(name), - obr_(obr), + functionObject(name), + obr_ + ( + runTime.lookupObject<objectRegistry> + ( + dict.lookupOrDefault("region", polyMesh::defaultRegion) + ) + ), UName_("U") { - if (!isA<fvMesh>(obr)) + if (!isA<fvMesh>(obr_)) { FatalErrorInFunction << "objectRegistry is not an fvMesh" << exit(FatalError); @@ -92,13 +104,15 @@ Foam::functionObjects::Q::~Q() // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -void Foam::functionObjects::Q::read(const dictionary& dict) +bool Foam::functionObjects::Q::read(const dictionary& dict) { UName_ = dict.lookupOrDefault<word>("UName", "U"); + + return true; } -void Foam::functionObjects::Q::execute() +bool Foam::functionObjects::Q::execute(const bool postProcess) { const fvMesh& mesh = refCast<const fvMesh>(obr_); @@ -114,29 +128,23 @@ void Foam::functionObjects::Q::execute() ); Q = 0.5*(sqr(tr(gradU)) - tr(((gradU) & (gradU)))); -} - -void Foam::functionObjects::Q::end() -{ - execute(); + return true; } -void Foam::functionObjects::Q::timeSet() -{} - - -void Foam::functionObjects::Q::write() +bool Foam::functionObjects::Q::write(const bool postProcess) { const volScalarField& Q = obr_.lookupObject<volScalarField>(type()); - Info<< type() << " " << name_ << " output:" << nl + Info<< type() << " " << name() << " output:" << nl << " writing field " << Q.name() << nl << endl; Q.write(); + + return true; } diff --git a/src/postProcessing/functionObjects/utilities/Q/Q.H b/src/postProcessing/functionObjects/utilities/Q/Q.H index e8395211c49162cc95e5b7b733c1248c667aa351..52ec9aaadefadafa5068fd3bd63fa87d956e906c 100644 --- a/src/postProcessing/functionObjects/utilities/Q/Q.H +++ b/src/postProcessing/functionObjects/utilities/Q/Q.H @@ -43,10 +43,8 @@ SourceFiles #ifndef functionObjects_Q_H #define functionObjects_Q_H +#include "functionObject.H" #include "volFieldsFwd.H" -#include "surfaceFieldsFwd.H" -#include "OFstream.H" -#include "Switch.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -55,9 +53,6 @@ namespace Foam // Forward declaration of classes class objectRegistry; -class dictionary; -class polyMesh; -class mapPolyMesh; namespace functionObjects { @@ -67,12 +62,11 @@ namespace functionObjects \*---------------------------------------------------------------------------*/ class Q +: + public functionObject { // Private data - //- Name of this set of Q objects - word name_; - //- Reference to the database const objectRegistry& obr_; @@ -97,14 +91,12 @@ public: // Constructors - //- Construct for given objectRegistry and dictionary. - // Allow the possibility to load fields from files + //- Construct from Time and dictionary Q ( const word& name, - const objectRegistry&, - const dictionary&, - const bool loadFromFiles = false + const Time& runTime, + const dictionary& dict ); @@ -114,34 +106,14 @@ public: // Member Functions - //- Return name of the set of Q - virtual const word& name() const - { - return name_; - } - //- Read the Q 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(); - - //- Called when time was set at the end of the Time::operator++ - virtual void timeSet(); - - //- Calculate the Q and write - virtual void write(); + virtual bool read(const dictionary&); - //- Update for changes of mesh - virtual void updateMesh(const mapPolyMesh&) - {} + //- Calculate the Q-field + virtual bool execute(const bool postProcess = false); - //- Update for changes of mesh - virtual void movePoints(const polyMesh&) - {} + //- Write the Q-field + virtual bool write(const bool postProcess = false); }; diff --git a/src/postProcessing/functionObjects/utilities/Q/QFunctionObject.C b/src/postProcessing/functionObjects/utilities/Q/QFunctionObject.C deleted file mode 100644 index 0fa525f0b6020edc244e981eadfbbfbf85f238a3..0000000000000000000000000000000000000000 --- a/src/postProcessing/functionObjects/utilities/Q/QFunctionObject.C +++ /dev/null @@ -1,42 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2012 OpenFOAM Foundation - \\/ 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 <http://www.gnu.org/licenses/>. - -\*---------------------------------------------------------------------------*/ - -#include "QFunctionObject.H" - -// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // - -namespace Foam -{ - defineNamedTemplateTypeNameAndDebug(QFunctionObject, 0); - - addToRunTimeSelectionTable - ( - functionObject, - QFunctionObject, - dictionary - ); -} - -// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/utilities/Q/QFunctionObject.H b/src/postProcessing/functionObjects/utilities/Q/QFunctionObject.H deleted file mode 100644 index 27d72f6aa110b7e09120fdf2ce36ac9148fec2b4..0000000000000000000000000000000000000000 --- a/src/postProcessing/functionObjects/utilities/Q/QFunctionObject.H +++ /dev/null @@ -1,54 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2012-2016 OpenFOAM Foundation - \\/ 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 <http://www.gnu.org/licenses/>. - -Typedef - Foam::QFunctionObject - -Description - FunctionObject wrapper around Q to allow it to be created - via the functions entry within controlDict. - -SourceFiles - QFunctionObject.C - -\*---------------------------------------------------------------------------*/ - -#ifndef QFunctionObject_H -#define QFunctionObject_H - -#include "Q.H" -#include "OutputFilterFunctionObject.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - typedef OutputFilterFunctionObject<functionObjects::Q> - QFunctionObject; -} - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#endif - -// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/utilities/abort/abort.C b/src/postProcessing/functionObjects/utilities/abort/abort.C index 76e71d39a1fd144760473a2fc2ccca329f46889a..f0194414c87be40bef892f4fa449b5345ebed486 100644 --- a/src/postProcessing/functionObjects/utilities/abort/abort.C +++ b/src/postProcessing/functionObjects/utilities/abort/abort.C @@ -29,6 +29,7 @@ License #include "Time.H" #include "OSspecific.H" #include "PstreamReduceOps.H" +#include "addToRunTimeSelectionTable.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -37,6 +38,13 @@ namespace Foam namespace functionObjects { defineTypeNameAndDebug(abort, 0); + + addToRunTimeSelectionTable + ( + functionObject, + abort, + dictionary + ); } } @@ -68,7 +76,7 @@ void Foam::functionObjects::abort::removeFile() const if (hasAbort && Pstream::master()) { - // cleanup ABORT file (on master only) + // Cleanup ABORT file (on master only) rm(abortFile_); } } @@ -79,20 +87,19 @@ void Foam::functionObjects::abort::removeFile() const Foam::functionObjects::abort::abort ( const word& name, - const objectRegistry& obr, - const dictionary& dict, - const bool loadFromFiles + const Time& runTime, + const dictionary& dict ) : - name_(name), - obr_(obr), + functionObject(name), + time_(runTime), abortFile_("$FOAM_CASE/" + name), action_(nextWrite) { abortFile_.expand(); read(dict); - // remove any old files from previous runs + // Remove any old files from previous runs removeFile(); } @@ -105,7 +112,7 @@ Foam::functionObjects::abort::~abort() // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -void Foam::functionObjects::abort::read(const dictionary& dict) +bool Foam::functionObjects::abort::read(const dictionary& dict) { if (dict.found("action")) { @@ -120,10 +127,12 @@ void Foam::functionObjects::abort::read(const dictionary& dict) { abortFile_.expand(); } + + return true; } -void Foam::functionObjects::abort::execute() +bool Foam::functionObjects::abort::execute(const bool postProcess) { bool hasAbort = isFile(abortFile_); reduce(hasAbort, orOp<bool>()); @@ -134,10 +143,10 @@ void Foam::functionObjects::abort::execute() { case noWriteNow : { - if (obr_.time().stopAt(Time::saNoWriteNow)) + if (time_.stopAt(Time::saNoWriteNow)) { Info<< "USER REQUESTED ABORT (timeIndex=" - << obr_.time().timeIndex() + << time_.timeIndex() << "): stop without writing data" << endl; } @@ -146,10 +155,10 @@ void Foam::functionObjects::abort::execute() case writeNow : { - if (obr_.time().stopAt(Time::saWriteNow)) + if (time_.stopAt(Time::saWriteNow)) { Info<< "USER REQUESTED ABORT (timeIndex=" - << obr_.time().timeIndex() + << time_.timeIndex() << "): stop+write data" << endl; } @@ -158,10 +167,10 @@ void Foam::functionObjects::abort::execute() case nextWrite : { - if (obr_.time().stopAt(Time::saNextWrite)) + if (time_.stopAt(Time::saNextWrite)) { Info<< "USER REQUESTED ABORT (timeIndex=" - << obr_.time().timeIndex() + << time_.timeIndex() << "): stop after next data write" << endl; } @@ -169,21 +178,22 @@ void Foam::functionObjects::abort::execute() } } } + + return true; } -void Foam::functionObjects::abort::end() +bool Foam::functionObjects::abort::write(const bool postProcess) { - removeFile(); + return true; } -void Foam::functionObjects::abort::timeSet() -{} - - -void Foam::functionObjects::abort::write() -{} +bool Foam::functionObjects::abort::end() +{ + removeFile(); + return true; +} // ************************************************************************* // diff --git a/src/postProcessing/functionObjects/utilities/abort/abort.H b/src/postProcessing/functionObjects/utilities/abort/abort.H index 05cb4da4c8851da354728eaa9a235ee99f0f6077..e0e5d5aa69b7d43ba496ee75a1702561e481cd27 100644 --- a/src/postProcessing/functionObjects/utilities/abort/abort.H +++ b/src/postProcessing/functionObjects/utilities/abort/abort.H @@ -44,19 +44,13 @@ SourceFiles #ifndef functionObjects_abort_H #define functionObjects_abort_H +#include "functionObject.H" #include "NamedEnum.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // namespace Foam { - -// Forward declaration of classes -class objectRegistry; -class dictionary; -class polyMesh; -class mapPolyMesh; - namespace functionObjects { @@ -65,6 +59,8 @@ namespace functionObjects \*---------------------------------------------------------------------------*/ class abort +: + public functionObject { public: @@ -82,10 +78,8 @@ private: // Private data - //- Name of the abort file unless otherwise specified - word name_; - - const objectRegistry& obr_; + //- Reference to the Time + const Time& time_; //- The fully-qualified name of the abort file fileName abortFile_; @@ -117,13 +111,12 @@ public: // Constructors - //- Construct for given objectRegistry and dictionary. + //- Construct from Time and dictionary abort ( const word& name, - const objectRegistry&, - const dictionary&, - const bool loadFromFilesUnused = false + const Time& runTime, + const dictionary& ); @@ -133,34 +126,17 @@ public: // Member Functions - //- Return name of the abort file - virtual const word& name() const - { - return name_; - } - //- Read the dictionary settings - virtual void read(const dictionary&); + virtual bool read(const dictionary&); //- Execute, check existence of abort file and take action - virtual void execute(); - - //- Execute at the final time-loop, used for cleanup - virtual void end(); - - //- Called when time was set at the end of the Time::operator++ - virtual void timeSet(); + virtual bool execute(const bool postProcess = false); //- Execute, check existence of abort file and take action - virtual void write(); + virtual bool write(const bool postProcess = false); - //- Update for changes of mesh - does nothing - virtual void updateMesh(const mapPolyMesh&) - {} - - //- Update for changes of mesh - does nothing - virtual void movePoints(const polyMesh&) - {} + //- Execute at the final time-loop, used for cleanup + virtual bool end(); }; diff --git a/src/postProcessing/functionObjects/utilities/abort/abortFunctionObject.C b/src/postProcessing/functionObjects/utilities/abort/abortFunctionObject.C deleted file mode 100644 index 0e7cb8fe3552322934fe30d9428c96010f4386b4..0000000000000000000000000000000000000000 --- a/src/postProcessing/functionObjects/utilities/abort/abortFunctionObject.C +++ /dev/null @@ -1,42 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation - \\/ 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 <http://www.gnu.org/licenses/>. - -\*---------------------------------------------------------------------------*/ - -#include "abortFunctionObject.H" - -// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // - -namespace Foam -{ - defineNamedTemplateTypeNameAndDebug(abortFunctionObject, 0); - - addToRunTimeSelectionTable - ( - functionObject, - abortFunctionObject, - dictionary - ); -} - -// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/utilities/abort/abortFunctionObject.H b/src/postProcessing/functionObjects/utilities/abort/abortFunctionObject.H deleted file mode 100644 index cd53ca0851b5fbee18457cf49b355c8aef086506..0000000000000000000000000000000000000000 --- a/src/postProcessing/functionObjects/utilities/abort/abortFunctionObject.H +++ /dev/null @@ -1,54 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation - \\/ 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 <http://www.gnu.org/licenses/>. - -Typedef - Foam::abortFunctionObject - -Description - FunctionObject wrapper around abort to allow it to be created via - the functions entry within controlDict. - -SourceFiles - abortFunctionObject.C - -\*---------------------------------------------------------------------------*/ - -#ifndef abortFunctionObject_H -#define abortFunctionObject_H - -#include "abort.H" -#include "OutputFilterFunctionObject.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - typedef OutputFilterFunctionObject<functionObjects::abort> - abortFunctionObject; -} - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#endif - -// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/utilities/blendingFactor/blendingFactor.C b/src/postProcessing/functionObjects/utilities/blendingFactor/blendingFactor.C index 96c73367d545bb41e5d104ad10aed114bade27d6..e57156c53cc87ab75136ef45d53ba5121266fa8e 100644 --- a/src/postProcessing/functionObjects/utilities/blendingFactor/blendingFactor.C +++ b/src/postProcessing/functionObjects/utilities/blendingFactor/blendingFactor.C @@ -24,7 +24,8 @@ License \*---------------------------------------------------------------------------*/ #include "blendingFactor.H" -#include "dictionary.H" +#include "volFields.H" +#include "addToRunTimeSelectionTable.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -33,6 +34,7 @@ namespace Foam namespace functionObjects { defineTypeNameAndDebug(blendingFactor, 0); + addToRunTimeSelectionTable(functionObject, blendingFactor, dictionary); } } @@ -42,17 +44,22 @@ namespace functionObjects Foam::functionObjects::blendingFactor::blendingFactor ( const word& name, - const objectRegistry& obr, - const dictionary& dict, - const bool loadFromFiles + const Time& runTime, + const dictionary& dict ) : - name_(name), - obr_(obr), + functionObject(name), + obr_ + ( + runTime.lookupObject<objectRegistry> + ( + dict.lookupOrDefault("region", polyMesh::defaultRegion) + ) + ), phiName_("unknown-phiName"), fieldName_("unknown-fieldName") { - if (!isA<fvMesh>(obr)) + if (!isA<fvMesh>(obr_)) { FatalErrorInFunction << "objectRegistry is not an fvMesh" << exit(FatalError); @@ -70,41 +77,38 @@ Foam::functionObjects::blendingFactor::~blendingFactor() // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -void Foam::functionObjects::blendingFactor::read(const dictionary& dict) +bool Foam::functionObjects::blendingFactor::read(const dictionary& dict) { phiName_ = dict.lookupOrDefault<word>("phiName", "phi"); dict.lookup("fieldName") >> fieldName_; + + return true; } -void Foam::functionObjects::blendingFactor::execute() +bool Foam::functionObjects::blendingFactor::execute(const bool postProcess) { calc<scalar>(); calc<vector>(); -} - -void Foam::functionObjects::blendingFactor::end() -{ - execute(); + return true; } -void Foam::functionObjects::blendingFactor::timeSet() -{} - -void Foam::functionObjects::blendingFactor::write() +bool Foam::functionObjects::blendingFactor::write(const bool postProcess) { const word fieldName = "blendingFactor:" + fieldName_; const volScalarField& blendingFactor = obr_.lookupObject<volScalarField>(fieldName); - Info<< type() << " " << name_ << " output:" << nl + Info<< type() << " " << name() << " output:" << nl << " writing field " << blendingFactor.name() << nl << endl; blendingFactor.write(); + + return true; } diff --git a/src/postProcessing/functionObjects/utilities/blendingFactor/blendingFactor.H b/src/postProcessing/functionObjects/utilities/blendingFactor/blendingFactor.H index 938449e3244e1bd4c0e4f0c66236c647f9aff72e..f47fc0806189b91a19069034055f8f6cda3b08f1 100644 --- a/src/postProcessing/functionObjects/utilities/blendingFactor/blendingFactor.H +++ b/src/postProcessing/functionObjects/utilities/blendingFactor/blendingFactor.H @@ -32,7 +32,6 @@ Description the bended convection schemes. The output is a volume field (cells) whose value is calculated via the maximum blending factor for any cell face. - SourceFiles blendingFactor.C @@ -41,10 +40,8 @@ SourceFiles #ifndef functionObjects_blendingFactor_H #define functionObjects_blendingFactor_H +#include "functionObject.H" #include "volFieldsFwd.H" -#include "surfaceFieldsFwd.H" -#include "OFstream.H" -#include "Switch.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -53,9 +50,6 @@ namespace Foam // Forward declaration of classes class objectRegistry; -class dictionary; -class polyMesh; -class mapPolyMesh; namespace functionObjects { @@ -65,13 +59,12 @@ namespace functionObjects \*---------------------------------------------------------------------------*/ class blendingFactor +: + public functionObject { // Private data - //- Name of this set of blendingFactor objects - word name_; - - //- Reference to the database + //- Reference to the objectRegistry const objectRegistry& obr_; //- Name of flux field, default is "phi" @@ -109,14 +102,12 @@ public: // Constructors - //- Construct for given objectRegistry and dictionary. - // Allow the possibility to load fields from files + //- Construct from Time and dictionary blendingFactor ( const word& name, - const objectRegistry&, - const dictionary&, - const bool loadFromFiles = false + const Time& runTime, + const dictionary& dict ); @@ -126,34 +117,14 @@ public: // Member Functions - //- Return name of the set of blendingFactor - virtual const word& name() const - { - return name_; - } - //- Read the blendingFactor 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(); - - //- Called when time was set at the end of the Time::operator++ - virtual void timeSet(); - - //- Calculate the blendingFactor and write - virtual void write(); + virtual bool read(const dictionary&); - //- Update for changes of mesh - virtual void updateMesh(const mapPolyMesh&) - {} + //- Calculate the blending-factor + virtual bool execute(const bool postProcess = false); - //- Update for changes of mesh - virtual void movePoints(const polyMesh&) - {} + //- Write the blending-factor + virtual bool write(const bool postProcess = false); }; diff --git a/src/postProcessing/functionObjects/utilities/blendingFactor/blendingFactorFunctionObject.C b/src/postProcessing/functionObjects/utilities/blendingFactor/blendingFactorFunctionObject.C deleted file mode 100644 index 6f32ea9c6f5d800583c1f4ef9ac9a387980e25bf..0000000000000000000000000000000000000000 --- a/src/postProcessing/functionObjects/utilities/blendingFactor/blendingFactorFunctionObject.C +++ /dev/null @@ -1,42 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2013 OpenFOAM Foundation - \\/ 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 <http://www.gnu.org/licenses/>. - -\*---------------------------------------------------------------------------*/ - -#include "blendingFactorFunctionObject.H" - -// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // - -namespace Foam -{ - defineNamedTemplateTypeNameAndDebug(blendingFactorFunctionObject, 0); - - addToRunTimeSelectionTable - ( - functionObject, - blendingFactorFunctionObject, - dictionary - ); -} - -// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/utilities/blendingFactor/blendingFactorFunctionObject.H b/src/postProcessing/functionObjects/utilities/blendingFactor/blendingFactorFunctionObject.H deleted file mode 100644 index 301d365d1315de7c2d07eff2c90ec48a2ca31034..0000000000000000000000000000000000000000 --- a/src/postProcessing/functionObjects/utilities/blendingFactor/blendingFactorFunctionObject.H +++ /dev/null @@ -1,54 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2013-2016 OpenFOAM Foundation - \\/ 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 <http://www.gnu.org/licenses/>. - -Typedef - Foam::blendingFactorFunctionObject - -Description - FunctionObject wrapper around blendingFactor to allow it to be created - via the functions entry within controlDict. - -SourceFiles - blendingFactorFunctionObject.C - -\*---------------------------------------------------------------------------*/ - -#ifndef blendingFactorFunctionObject_H -#define blendingFactorFunctionObject_H - -#include "blendingFactor.H" -#include "OutputFilterFunctionObject.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - typedef OutputFilterFunctionObject<functionObjects::blendingFactor> - blendingFactorFunctionObject; -} - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#endif - -// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/utilities/codedFunctionObject/codedFunctionObject.C b/src/postProcessing/functionObjects/utilities/codedFunctionObject/codedFunctionObject.C index 2e1c78dd6aa26031f31427f2d098241c9ca705a3..35342d1b39e25ad511ecbd9dec44793839c4e929 100644 --- a/src/postProcessing/functionObjects/utilities/codedFunctionObject/codedFunctionObject.C +++ b/src/postProcessing/functionObjects/utilities/codedFunctionObject/codedFunctionObject.C @@ -64,32 +64,30 @@ void Foam::codedFunctionObject::prepare dynCode.setFilterVariable("codeTimeSet", codeTimeSet_); //dynCode.setFilterVariable("codeWrite", codeWrite_); - // compile filtered C template + // Compile filtered C template dynCode.addCompileFile("functionObjectTemplate.C"); - dynCode.addCompileFile("FilterFunctionObjectTemplate.C"); - // copy filtered H template - dynCode.addCopyFile("FilterFunctionObjectTemplate.H"); + // Copy filtered H template dynCode.addCopyFile("functionObjectTemplate.H"); - // debugging: make BC verbose + // Debugging: make BC verbose // dynCode.setFilterVariable("verbose", "true"); // Info<<"compile " << redirectType_ << " sha1: " // << context.sha1() << endl; - // define Make/options + // Define Make/options dynCode.setMakeOptions - ( - "EXE_INC = -g \\\n" - "-I$(LIB_SRC)/finiteVolume/lnInclude \\\n" - "-I$(LIB_SRC)/meshTools/lnInclude \\\n" - + context.options() - + "\n\nLIB_LIBS = \\\n" - + " -lOpenFOAM \\\n" - + " -lfiniteVolume \\\n" - + " -lmeshTools \\\n" - + context.libs() - ); + ( + "EXE_INC = -g \\\n" + "-I$(LIB_SRC)/finiteVolume/lnInclude \\\n" + "-I$(LIB_SRC)/meshTools/lnInclude \\\n" + + context.options() + + "\n\nLIB_LIBS = \\\n" + + " -lOpenFOAM \\\n" + + " -lfiniteVolume \\\n" + + " -lmeshTools \\\n" + + context.libs() + ); } @@ -123,8 +121,7 @@ Foam::codedFunctionObject::codedFunctionObject ( const word& name, const Time& time, - const dictionary& dict, - bool readNow + const dictionary& dict ) : functionObject(name), @@ -132,10 +129,7 @@ Foam::codedFunctionObject::codedFunctionObject time_(time), dict_(dict) { - if (readNow) - { - read(dict_); - } + read(dict_); updateLibrary(redirectType_); redirectFunctionObject(); @@ -295,12 +289,4 @@ bool Foam::codedFunctionObject::read(const dictionary& dict) } -void Foam::codedFunctionObject::updateMesh(const mapPolyMesh&) -{} - - -void Foam::codedFunctionObject::movePoints(const polyMesh&) -{} - - // ************************************************************************* // diff --git a/src/postProcessing/functionObjects/utilities/codedFunctionObject/codedFunctionObject.H b/src/postProcessing/functionObjects/utilities/codedFunctionObject/codedFunctionObject.H index b5a1ec3637efb8b714fe1860c924af6997caf507..4628283137c9f9617ec1f45299b63417923c4772 100644 --- a/src/postProcessing/functionObjects/utilities/codedFunctionObject/codedFunctionObject.H +++ b/src/postProcessing/functionObjects/utilities/codedFunctionObject/codedFunctionObject.H @@ -66,7 +66,6 @@ Description SeeAlso Foam::functionObject - Foam::OutputFilterFunctionObject Foam::codedBase SourceFiles @@ -151,14 +150,12 @@ public: // Constructors - //- Construct for given objectRegistry and dictionary. - // Allow the possibility to load fields from files + //- Construct from Time and dictionary codedFunctionObject ( const word& name, const Time& time, - const dictionary& dict, - bool readNow=true // allow child-classes to avoid compilation + const dictionary& dict ); @@ -190,12 +187,6 @@ public: //- Read and set the function object if its data have changed virtual bool read(const dictionary&); - - //- Update mesh - virtual void updateMesh(const mapPolyMesh&); - - //- Move points - virtual void movePoints(const polyMesh&); }; diff --git a/src/postProcessing/functionObjects/utilities/dsmcFields/dsmcFields.C b/src/postProcessing/functionObjects/utilities/dsmcFields/dsmcFields.C index 8b519877bf52bfd61fc06c279c0bcf39f1375a0d..894df64a95b7887348561f8f71e967b194784161 100644 --- a/src/postProcessing/functionObjects/utilities/dsmcFields/dsmcFields.C +++ b/src/postProcessing/functionObjects/utilities/dsmcFields/dsmcFields.C @@ -27,8 +27,8 @@ License #include "volFields.H" #include "dictionary.H" #include "dsmcCloud.H" - #include "constants.H" +#include "addToRunTimeSelectionTable.H" using namespace Foam::constant; @@ -39,6 +39,13 @@ namespace Foam namespace functionObjects { defineTypeNameAndDebug(dsmcFields, 0); + + addToRunTimeSelectionTable + ( + functionObject, + dsmcFields, + dictionary + ); } } @@ -48,15 +55,20 @@ namespace functionObjects Foam::functionObjects::dsmcFields::dsmcFields ( const word& name, - const objectRegistry& obr, - const dictionary& dict, - const bool loadFromFiles + const Time& runTime, + const dictionary& dict ) : - name_(name), - obr_(obr) + functionObject(name), + obr_ + ( + runTime.lookupObject<objectRegistry> + ( + dict.lookupOrDefault("region", polyMesh::defaultRegion) + ) + ) { - if (!isA<fvMesh>(obr)) + if (!isA<fvMesh>(obr_)) { FatalErrorInFunction << "objectRegistry is not an fvMesh" << exit(FatalError); @@ -74,23 +86,19 @@ Foam::functionObjects::dsmcFields::~dsmcFields() // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -void Foam::functionObjects::dsmcFields::read(const dictionary& dict) -{} - - -void Foam::functionObjects::dsmcFields::execute() -{} - - -void Foam::functionObjects::dsmcFields::end() -{} +bool Foam::functionObjects::dsmcFields::read(const dictionary& dict) +{ + return true; +} -void Foam::functionObjects::dsmcFields::timeSet() -{} +bool Foam::functionObjects::dsmcFields::execute(const bool postProcess) +{ + return true; +} -void Foam::functionObjects::dsmcFields::write() +bool Foam::functionObjects::dsmcFields::write(const bool postProcess) { word rhoNMeanName = "rhoNMean"; word rhoMMeanName = "rhoMMean"; @@ -254,6 +262,8 @@ void Foam::functionObjects::dsmcFields::write() p.write(); Info<< "dsmcFields written." << nl << endl; + + return true; } else { @@ -261,6 +271,8 @@ void Foam::functionObjects::dsmcFields::write() << ") found in rhoNMean field. " << "Not calculating dsmcFields to avoid division by zero." << endl; + + return false; } } diff --git a/src/postProcessing/functionObjects/utilities/dsmcFields/dsmcFields.H b/src/postProcessing/functionObjects/utilities/dsmcFields/dsmcFields.H index 08c5cb7f0b1887d995cd06402f5bc6197d6a0d4c..9aa5125d44a363479822f7803f5c9d08b22f4a6d 100644 --- a/src/postProcessing/functionObjects/utilities/dsmcFields/dsmcFields.H +++ b/src/postProcessing/functionObjects/utilities/dsmcFields/dsmcFields.H @@ -43,8 +43,7 @@ SourceFiles #ifndef functionObjects_dsmcFields_H #define functionObjects_dsmcFields_H -#include "typeInfo.H" -#include "autoPtr.H" +#include "functionObject.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -53,9 +52,6 @@ namespace Foam // Forward declaration of classes class objectRegistry; -class dictionary; -class polyMesh; -class mapPolyMesh; namespace functionObjects { @@ -65,12 +61,11 @@ namespace functionObjects \*---------------------------------------------------------------------------*/ class dsmcFields +: + public functionObject { // Private data - //- Name of this set of dsmcFields objects - word name_; - const objectRegistry& obr_; @@ -91,14 +86,12 @@ public: // Constructors - //- Construct for given objectRegistry and dictionary. - // Allow the possibility to load fields from files + //- Construct from Time and dictionary dsmcFields ( const word& name, - const objectRegistry&, - const dictionary&, - const bool loadFromFiles = false + const Time& runTime, + const dictionary& dict ); @@ -108,34 +101,14 @@ public: // Member Functions - //- Return name of the set of dsmcFields - virtual const word& name() const - { - return name_; - } - //- Read the dsmcFields 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(); - - //- Called when time was set at the end of the Time::operator++ - virtual void timeSet(); - - //- Calculate the dsmcFields and write - virtual void write(); + virtual bool read(const dictionary&); - //- Update for changes of mesh - virtual void updateMesh(const mapPolyMesh&) - {} + //- Do nothing + virtual bool execute(const bool postProcess = false); - //- Update for changes of mesh - virtual void movePoints(const polyMesh&) - {} + //- Calculate and write the DSMC fields + virtual bool write(const bool postProcess = false); }; diff --git a/src/postProcessing/functionObjects/utilities/dsmcFields/dsmcFieldsFunctionObject.C b/src/postProcessing/functionObjects/utilities/dsmcFields/dsmcFieldsFunctionObject.C deleted file mode 100644 index 657243c4bc74fa67a1210eff5c058ea907fd1ebd..0000000000000000000000000000000000000000 --- a/src/postProcessing/functionObjects/utilities/dsmcFields/dsmcFieldsFunctionObject.C +++ /dev/null @@ -1,42 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation - \\/ 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 <http://www.gnu.org/licenses/>. - -\*---------------------------------------------------------------------------*/ - -#include "dsmcFieldsFunctionObject.H" - -// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // - -namespace Foam -{ - defineNamedTemplateTypeNameAndDebug(dsmcFieldsFunctionObject, 0); - - addToRunTimeSelectionTable - ( - functionObject, - dsmcFieldsFunctionObject, - dictionary - ); -} - -// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/utilities/dsmcFields/dsmcFieldsFunctionObject.H b/src/postProcessing/functionObjects/utilities/dsmcFields/dsmcFieldsFunctionObject.H deleted file mode 100644 index 7a220c4bbab91647cb9d942a0c6e11c70152bf80..0000000000000000000000000000000000000000 --- a/src/postProcessing/functionObjects/utilities/dsmcFields/dsmcFieldsFunctionObject.H +++ /dev/null @@ -1,54 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation - \\/ 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 <http://www.gnu.org/licenses/>. - -Typedef - Foam::dsmcFieldsFunctionObject - -Description - FunctionObject wrapper around dsmcFields to allow it to be created via - the functions entry within controlDict. - -SourceFiles - dsmcFieldsFunctionObject.C - -\*---------------------------------------------------------------------------*/ - -#ifndef dsmcFieldsFunctionObject_H -#define dsmcFieldsFunctionObject_H - -#include "dsmcFields.H" -#include "OutputFilterFunctionObject.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - typedef OutputFilterFunctionObject<functionObjects::dsmcFields> - dsmcFieldsFunctionObject; -} - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#endif - -// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/utilities/partialWrite/partialWrite.C b/src/postProcessing/functionObjects/utilities/partialWrite/partialWrite.C index c9eb349bc8e838903363ea96bd9a22ca6c886645..734d6197cf45885beef37a5d0ceb564b822b0153 100644 --- a/src/postProcessing/functionObjects/utilities/partialWrite/partialWrite.C +++ b/src/postProcessing/functionObjects/utilities/partialWrite/partialWrite.C @@ -24,11 +24,9 @@ License \*---------------------------------------------------------------------------*/ #include "partialWrite.H" -#include "dictionary.H" #include "Time.H" -#include "IOobjectList.H" #include "polyMesh.H" -#include "cloud.H" +#include "addToRunTimeSelectionTable.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -37,6 +35,13 @@ namespace Foam namespace functionObjects { defineTypeNameAndDebug(partialWrite, 0); + + addToRunTimeSelectionTable + ( + functionObject, + partialWrite, + dictionary + ); } } @@ -46,13 +51,18 @@ namespace functionObjects Foam::functionObjects::partialWrite::partialWrite ( const word& name, - const objectRegistry& obr, - const dictionary& dict, - const bool loadFromFiles + const Time& runTime, + const dictionary& dict ) : - name_(name), - obr_(obr) + functionObject(name), + obr_ + ( + runTime.lookupObject<objectRegistry> + ( + dict.lookupOrDefault("region", polyMesh::defaultRegion) + ) + ) { read(dict); } @@ -66,7 +76,7 @@ Foam::functionObjects::partialWrite::~partialWrite() // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -void Foam::functionObjects::partialWrite::read(const dictionary& dict) +bool Foam::functionObjects::partialWrite::read(const dictionary& dict) { dict.lookup("objectNames") >> objectNames_; dict.lookup("writeInterval") >> writeInterval_; @@ -110,18 +120,18 @@ void Foam::functionObjects::partialWrite::read(const dictionary& dict) loadField<symmTensor>(iter.key(), vSymmtf_, sSymmtf_); loadField<tensor>(iter.key(), vtf_, stf_); } -} - -void Foam::functionObjects::partialWrite::execute() -{} + return true; +} -void Foam::functionObjects::partialWrite::end() -{} +bool Foam::functionObjects::partialWrite::execute(const bool postProcess) +{ + return true; +} -void Foam::functionObjects::partialWrite::timeSet() +bool Foam::functionObjects::partialWrite::timeSet() { if (obr_.time().writeTime()) { @@ -168,12 +178,14 @@ void Foam::functionObjects::partialWrite::timeSet() changeWriteOptions<tensor>(vtf_, stf_, IOobject::NO_WRITE); } } + + return true; } -void Foam::functionObjects::partialWrite::write() +bool Foam::functionObjects::partialWrite::write(const bool postProcess) { - // Fields are written in the standard manner + return true; } diff --git a/src/postProcessing/functionObjects/utilities/partialWrite/partialWrite.H b/src/postProcessing/functionObjects/utilities/partialWrite/partialWrite.H index bfd55e89c01268426ca125e0be66d20f1038042f..d312a78bab66eb5ed03ab271999c34ee5b91dac2 100644 --- a/src/postProcessing/functionObjects/utilities/partialWrite/partialWrite.H +++ b/src/postProcessing/functionObjects/utilities/partialWrite/partialWrite.H @@ -54,7 +54,7 @@ Description SeeAlso Foam::functionObject - Foam::OutputFilterFunctionObject + Foam::functionObjects::timeControl SourceFiles partialWrite.C @@ -64,8 +64,8 @@ SourceFiles #ifndef functionObjects_partialWrite_H #define functionObjects_partialWrite_H +#include "functionObject.H" #include "HashSet.H" -#include "runTimeSelectionTables.H" #include "volFields.H" #include "surfaceFields.H" @@ -73,13 +73,6 @@ SourceFiles namespace Foam { - -// Forward declaration of classes -class objectRegistry; -class dictionary; -class polyMesh; -class mapPolyMesh; - namespace functionObjects { @@ -88,14 +81,14 @@ namespace functionObjects \*---------------------------------------------------------------------------*/ class partialWrite +: + public functionObject { protected: - // Private data - - //- Name of this partialWrite functionObject - word name_; + // Protected data + //- Reference to the objectRegistry const objectRegistry& obr_; //- Loaded fields @@ -111,6 +104,7 @@ protected: UPtrList<surfaceSymmTensorField> sSymmtf_; UPtrList<surfaceTensorField> stf_; + // Read from dictionary //- Names of objects to dump always @@ -120,11 +114,12 @@ protected: label writeInterval_; - //- Current dump instance. If reaches writeInterval do a full write. label writeInstance_; +private: + // Private Member Functions //- Disallow default bitwise copy construct @@ -160,14 +155,12 @@ public: // Constructors - //- Construct for given objectRegistry and dictionary. - // Allow the possibility to load fields from files + //- Construct from Time and dictionary partialWrite ( const word& name, - const objectRegistry&, - const dictionary&, - const bool loadFromFiles = false + const Time& runTime, + const dictionary& dict ); @@ -177,34 +170,18 @@ public: // Member Functions - //- Return name of the partialWrite - virtual const word& name() const - { - return name_; - } - //- Read the partialWrite data - virtual void read(const dictionary&); - - //- Execute - virtual void execute(); - - //- Execute at the final time-loop, currently does nothing - virtual void end(); + virtual bool read(const dictionary&); //- Called when time was set at the end of the Time::operator++ - virtual void timeSet(); - - //- Write the partialWrite - virtual void write(); + virtual bool timeSet(); - //- Update for changes of mesh - virtual void updateMesh(const mapPolyMesh&) - {} + //- Execute + virtual bool execute(const bool postProcess = false); - //- Update for changes of mesh - virtual void movePoints(const polyMesh&) - {} + //- Do nothing. + // The fields are registered and written automatically + virtual bool write(const bool postProcess = false); }; diff --git a/src/postProcessing/functionObjects/utilities/partialWrite/partialWriteFunctionObject.C b/src/postProcessing/functionObjects/utilities/partialWrite/partialWriteFunctionObject.C deleted file mode 100644 index 9938388787cf0437b88d1ac1c1781ab23e97ad80..0000000000000000000000000000000000000000 --- a/src/postProcessing/functionObjects/utilities/partialWrite/partialWriteFunctionObject.C +++ /dev/null @@ -1,46 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation - \\/ 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 <http://www.gnu.org/licenses/>. - -\*---------------------------------------------------------------------------*/ - -#include "partialWriteFunctionObject.H" - -// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // - -namespace Foam -{ - defineNamedTemplateTypeNameAndDebug - ( - partialWriteFunctionObject, - 0 - ); - - addToRunTimeSelectionTable - ( - functionObject, - partialWriteFunctionObject, - dictionary - ); -} - -// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/utilities/partialWrite/partialWriteFunctionObject.H b/src/postProcessing/functionObjects/utilities/partialWrite/partialWriteFunctionObject.H index a65a095fe581b0bff33e838b0602579775d02c1a..9938388787cf0437b88d1ac1c1781ab23e97ad80 100644 --- a/src/postProcessing/functionObjects/utilities/partialWrite/partialWriteFunctionObject.H +++ b/src/postProcessing/functionObjects/utilities/partialWrite/partialWriteFunctionObject.H @@ -21,34 +21,26 @@ License You should have received a copy of the GNU General Public License along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. -Typedef - Foam::partialWriteFunctionObject - -Description - FunctionObject wrapper around partialWrite to allow them to be - created via the functions list within controlDict. - -SourceFiles - partialWriteFunctionObject.C - \*---------------------------------------------------------------------------*/ -#ifndef partialWriteFunctionObject_H -#define partialWriteFunctionObject_H +#include "partialWriteFunctionObject.H" -#include "partialWrite.H" -#include "OutputFilterFunctionObject.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // namespace Foam { - typedef OutputFilterFunctionObject<functionObjects::partialWrite> - partialWriteFunctionObject; + defineNamedTemplateTypeNameAndDebug + ( + partialWriteFunctionObject, + 0 + ); + + addToRunTimeSelectionTable + ( + functionObject, + partialWriteFunctionObject, + dictionary + ); } -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#endif - // ************************************************************************* // diff --git a/src/postProcessing/functionObjects/utilities/removeRegisteredObject/removeRegisteredObject.C b/src/postProcessing/functionObjects/utilities/removeRegisteredObject/removeRegisteredObject.C index 4ecd2a4fe076fffab5fda1357b271e415b87a735..acae44aae2258a89b964045933afe221f620fba5 100644 --- a/src/postProcessing/functionObjects/utilities/removeRegisteredObject/removeRegisteredObject.C +++ b/src/postProcessing/functionObjects/utilities/removeRegisteredObject/removeRegisteredObject.C @@ -24,8 +24,9 @@ License \*---------------------------------------------------------------------------*/ #include "removeRegisteredObject.H" -#include "dictionary.H" #include "Time.H" +#include "polyMesh.H" +#include "addToRunTimeSelectionTable.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -34,6 +35,13 @@ namespace Foam namespace functionObjects { defineTypeNameAndDebug(removeRegisteredObject, 0); + + addToRunTimeSelectionTable + ( + functionObject, + removeRegisteredObject, + dictionary + ); } } @@ -43,13 +51,18 @@ namespace functionObjects Foam::functionObjects::removeRegisteredObject::removeRegisteredObject ( const word& name, - const objectRegistry& obr, - const dictionary& dict, - const bool loadFromFiles + const Time& runTime, + const dictionary& dict ) : - name_(name), - obr_(obr), + functionObject(name), + obr_ + ( + runTime.lookupObject<objectRegistry> + ( + dict.lookupOrDefault("region", polyMesh::defaultRegion) + ) + ), objectNames_() { read(dict); @@ -64,13 +77,18 @@ Foam::functionObjects::removeRegisteredObject::~removeRegisteredObject() // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -void Foam::functionObjects::removeRegisteredObject::read(const dictionary& dict) +bool Foam::functionObjects::removeRegisteredObject::read(const dictionary& dict) { dict.lookup("objectNames") >> objectNames_; + + return true; } -void Foam::functionObjects::removeRegisteredObject::execute() +bool Foam::functionObjects::removeRegisteredObject::execute +( + const bool postProcess +) { forAll(objectNames_, i) { @@ -81,7 +99,7 @@ void Foam::functionObjects::removeRegisteredObject::execute() if (obj.ownedByRegistry()) { - Info<< type() << " " << name_ << " output:" << nl + Info<< type() << " " << name() << " output:" << nl << " removing object " << obj.name() << nl << endl; @@ -90,21 +108,18 @@ void Foam::functionObjects::removeRegisteredObject::execute() } } } + + return true; } -void Foam::functionObjects::removeRegisteredObject::end() +bool Foam::functionObjects::removeRegisteredObject::write +( + const bool postProcess +) { - execute(); + return true; } -void Foam::functionObjects::removeRegisteredObject::timeSet() -{} - - -void Foam::functionObjects::removeRegisteredObject::write() -{} - - // ************************************************************************* // diff --git a/src/postProcessing/functionObjects/utilities/removeRegisteredObject/removeRegisteredObject.H b/src/postProcessing/functionObjects/utilities/removeRegisteredObject/removeRegisteredObject.H index e3fbe35193a78317d617e8c376037a96a8e5e728..7120edf8a7df5bd19ed7ec46b3ba2921ea74c64a 100644 --- a/src/postProcessing/functionObjects/utilities/removeRegisteredObject/removeRegisteredObject.H +++ b/src/postProcessing/functionObjects/utilities/removeRegisteredObject/removeRegisteredObject.H @@ -50,7 +50,6 @@ Description SeeAlso Foam::functionObject - Foam::OutputFilterFunctionObject SourceFiles removeRegisteredObject.C @@ -60,8 +59,8 @@ SourceFiles #ifndef functionObjects_removeRegisteredObject_H #define functionObjects_removeRegisteredObject_H +#include "functionObject.H" #include "wordList.H" -#include "runTimeSelectionTables.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -70,9 +69,6 @@ namespace Foam // Forward declaration of classes class objectRegistry; -class dictionary; -class polyMesh; -class mapPolyMesh; namespace functionObjects { @@ -82,24 +78,18 @@ namespace functionObjects \*---------------------------------------------------------------------------*/ class removeRegisteredObject +: + public functionObject { -protected: - // Private data - //- Name of this set of removeRegisteredObject - word name_; - + //- Reference to the objectRegistry const objectRegistry& obr_; - // Read from dictionary - - //- Names of objects to control - wordList objectNames_; + //- Names of objects to control + wordList objectNames_; -private: - // Private member functions //- Disallow default bitwise copy construct @@ -117,14 +107,12 @@ public: // Constructors - //- Construct for given objectRegistry and dictionary. - // Allow the possibility to load fields from files + //- Construct from Time and dictionary removeRegisteredObject ( const word& name, - const objectRegistry&, - const dictionary&, - const bool loadFromFiles = false + const Time& runTime, + const dictionary& dict ); @@ -134,34 +122,14 @@ public: // Member Functions - //- Return name of the removeRegisteredObject - virtual const word& name() const - { - return name_; - } - //- Read the removeRegisteredObject 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(); - - //- Called when time was set at the end of the Time::operator++ - virtual void timeSet(); - - //- Write the removeRegisteredObject - virtual void write(); + virtual bool read(const dictionary&); - //- Update for changes of mesh - virtual void updateMesh(const mapPolyMesh&) - {} + //- Remove the registered objects + virtual bool execute(const bool postProcess = false); - //- Update for changes of mesh - virtual void movePoints(const polyMesh&) - {} + //- Do nothing + virtual bool write(const bool postProcess = false); }; diff --git a/src/postProcessing/functionObjects/utilities/removeRegisteredObject/removeRegisteredObjectFunctionObject.C b/src/postProcessing/functionObjects/utilities/removeRegisteredObject/removeRegisteredObjectFunctionObject.C deleted file mode 100644 index 698b25d7c56cc93c883300af5c5a65e92b116bf9..0000000000000000000000000000000000000000 --- a/src/postProcessing/functionObjects/utilities/removeRegisteredObject/removeRegisteredObjectFunctionObject.C +++ /dev/null @@ -1,46 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2012-2016 OpenFOAM Foundation - \\/ 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 <http://www.gnu.org/licenses/>. - -\*---------------------------------------------------------------------------*/ - -#include "removeRegisteredObjectFunctionObject.H" - -// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // - -namespace Foam -{ - defineNamedTemplateTypeNameAndDebug - ( - removeRegisteredObjectFunctionObject, - 0 - ); - - addToRunTimeSelectionTable - ( - functionObject, - removeRegisteredObjectFunctionObject, - dictionary - ); -} - -// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/utilities/removeRegisteredObject/removeRegisteredObjectFunctionObject.H b/src/postProcessing/functionObjects/utilities/removeRegisteredObject/removeRegisteredObjectFunctionObject.H deleted file mode 100644 index e166d00be7efd69cb15cfe369ba0c7b139a5473e..0000000000000000000000000000000000000000 --- a/src/postProcessing/functionObjects/utilities/removeRegisteredObject/removeRegisteredObjectFunctionObject.H +++ /dev/null @@ -1,54 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2012-2016 OpenFOAM Foundation - \\/ 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 <http://www.gnu.org/licenses/>. - -Typedef - Foam::removeRegisteredObjectFunctionObject - -Description - FunctionObject wrapper around removeRegisteredObject to allow them to be - created via the functions entry within controlDict. - -SourceFiles - removeRegisteredObjectFunctionObject.C - -\*---------------------------------------------------------------------------*/ - -#ifndef removeRegisteredObjectFunctionObject_H -#define removeRegisteredObjectFunctionObject_H - -#include "removeRegisteredObject.H" -#include "OutputFilterFunctionObject.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - typedef OutputFilterFunctionObject<functionObjects::removeRegisteredObject> - removeRegisteredObjectFunctionObject; -} - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#endif - -// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/utilities/residuals/residuals.C b/src/postProcessing/functionObjects/utilities/residuals/residuals.C index b7a8d52b9483b6f9a1daedcc85ada91dda579148..f7d27d58e3513d87ec3c05a3edcd533e26c1ef22 100644 --- a/src/postProcessing/functionObjects/utilities/residuals/residuals.C +++ b/src/postProcessing/functionObjects/utilities/residuals/residuals.C @@ -24,9 +24,7 @@ License \*---------------------------------------------------------------------------*/ #include "residuals.H" -#include "volFields.H" -#include "dictionary.H" -#include "Time.H" +#include "addToRunTimeSelectionTable.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -35,6 +33,13 @@ namespace Foam namespace functionObjects { defineTypeNameAndDebug(residuals, 0); + + addToRunTimeSelectionTable + ( + functionObject, + residuals, + dictionary + ); } } @@ -44,23 +49,21 @@ namespace functionObjects Foam::functionObjects::residuals::residuals ( const word& name, - const objectRegistry& obr, - const dictionary& dict, - const bool loadFromFiles + const Time& runTime, + const dictionary& dict ) : - functionObjectFiles(obr, name, typeName), - name_(name), - obr_(obr), + writeFiles(name, runTime, dict, name), fieldSet_() { - if (!isA<fvMesh>(obr)) + if (!isA<fvMesh>(obr_)) { FatalErrorInFunction << "objectRegistry is not an fvMesh" << exit(FatalError); } read(dict); + resetName(typeName); } @@ -72,9 +75,11 @@ Foam::functionObjects::residuals::~residuals() // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -void Foam::functionObjects::residuals::read(const dictionary& dict) +bool Foam::functionObjects::residuals::read(const dictionary& dict) { dict.lookup("fields") >> fieldSet_; + + return true; } @@ -101,21 +106,16 @@ void Foam::functionObjects::residuals::writeFileHeader(const label i) } -void Foam::functionObjects::residuals::execute() -{} - - -void Foam::functionObjects::residuals::end() -{} - +bool Foam::functionObjects::residuals::execute(const bool postProcess) +{ -void Foam::functionObjects::residuals::timeSet() -{} + return true; +} -void Foam::functionObjects::residuals::write() +bool Foam::functionObjects::residuals::write(const bool postProcess) { - functionObjectFiles::write(); + writeFiles::write(); if (Pstream::master()) { @@ -134,6 +134,8 @@ void Foam::functionObjects::residuals::write() file() << endl; } + + return true; } diff --git a/src/postProcessing/functionObjects/utilities/residuals/residuals.H b/src/postProcessing/functionObjects/utilities/residuals/residuals.H index 2ffa4641a51129ffe29ead0a68f707c6959c1523..7d43de05ee5deab6fe72bb84375bb81358b862b9 100644 --- a/src/postProcessing/functionObjects/utilities/residuals/residuals.H +++ b/src/postProcessing/functionObjects/utilities/residuals/residuals.H @@ -51,7 +51,8 @@ Description SeeAlso Foam::functionObject - Foam::OutputFilterFunctionObject + Foam::functionObjects::writeFiles + Foam::functionObjects::timeControl SourceFiles residuals.C @@ -61,26 +62,12 @@ SourceFiles #ifndef functionObjects_residuals_H #define functionObjects_residuals_H -#include "functionObjectFiles.H" -#include "primitiveFieldsFwd.H" -#include "volFieldsFwd.H" -#include "HashSet.H" -#include "OFstream.H" -#include "Switch.H" -#include "NamedEnum.H" -#include "solverPerformance.H" +#include "writeFiles.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // namespace Foam { - -// Forward declaration of classes -class objectRegistry; -class dictionary; -class polyMesh; -class mapPolyMesh; - namespace functionObjects { @@ -90,23 +77,17 @@ namespace functionObjects class residuals : - public functionObjectFiles + public writeFiles { protected: // Protected data - //- Name of this set of residuals - // Also used as the name of the output directory - word name_; - - const objectRegistry& obr_; - //- Fields to write residuals wordList fieldSet_; - // Private Member Functions + // Protected Member Functions //- Output field header information template<class Type> @@ -115,6 +96,10 @@ protected: //- Output file header information virtual void writeFileHeader(const label i); + //- Calculate the field min/max + template<class Type> + void writeResidual(const word& fieldName); + private: @@ -135,14 +120,12 @@ public: // Constructors - //- Construct for given objectRegistry and dictionary. - // Allow the possibility to load fields from files + //- Construct from Time and dictionary residuals ( const word& name, - const objectRegistry&, - const dictionary&, - const bool loadFromFiles = false + const Time& runTime, + const dictionary& dict ); @@ -152,38 +135,14 @@ public: // Member Functions - //- Return name of the functionObject - virtual const word& name() const - { - return name_; - } - //- Read the controls - virtual void read(const dictionary&); + virtual bool read(const dictionary&); //- Execute, currently does nothing - virtual void execute(); - - //- Execute at the final time-loop, currently does nothing - virtual void end(); - - //- Called when time was set at the end of the Time::operator++ - virtual void timeSet(); - - //- Calculate the field min/max - template<class Type> - void writeResidual(const word& fieldName); + virtual bool execute(const bool postProcess = false); //- Write the residuals - virtual void write(); - - //- Update for changes of mesh - virtual void updateMesh(const mapPolyMesh&) - {} - - //- Update for changes of mesh - virtual void movePoints(const polyMesh&) - {} + virtual bool write(const bool postProcess = false); }; diff --git a/src/postProcessing/functionObjects/utilities/residuals/residualsFunctionObject.C b/src/postProcessing/functionObjects/utilities/residuals/residualsFunctionObject.C deleted file mode 100644 index ffec5c46042fb3d9945d2b47fec636077f0e0d30..0000000000000000000000000000000000000000 --- a/src/postProcessing/functionObjects/utilities/residuals/residualsFunctionObject.C +++ /dev/null @@ -1,42 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2015 OpenFOAM Foundation - \\/ 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 <http://www.gnu.org/licenses/>. - -\*---------------------------------------------------------------------------*/ - -#include "residualsFunctionObject.H" - -// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // - -namespace Foam -{ - defineNamedTemplateTypeNameAndDebug(residualsFunctionObject, 0); - - addToRunTimeSelectionTable - ( - functionObject, - residualsFunctionObject, - dictionary - ); -} - -// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/utilities/residuals/residualsFunctionObject.H b/src/postProcessing/functionObjects/utilities/residuals/residualsFunctionObject.H deleted file mode 100644 index 3d28368f6ef40b50c0e729e47a4b05ebf92957d3..0000000000000000000000000000000000000000 --- a/src/postProcessing/functionObjects/utilities/residuals/residualsFunctionObject.H +++ /dev/null @@ -1,54 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2015-2016 OpenFOAM Foundation - \\/ 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 <http://www.gnu.org/licenses/>. - -Typedef - Foam::residualsFunctionObject - -Description - FunctionObject wrapper around residuals to allow them to be created via - the functions entry within controlDict. - -SourceFiles - residualsFunctionObject.C - -\*---------------------------------------------------------------------------*/ - -#ifndef residualsFunctionObject_H -#define residualsFunctionObject_H - -#include "residuals.H" -#include "OutputFilterFunctionObject.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - typedef OutputFilterFunctionObject<functionObjects::residuals> - residualsFunctionObject; -} - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#endif - -// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/utilities/residuals/residualsTemplates.C b/src/postProcessing/functionObjects/utilities/residuals/residualsTemplates.C index b7647242bca6e1ee31faef35e29d62c0d7ca7f6b..3f5f2b128ef970fc8cfdb9bb73f5a6d73986fa13 100644 --- a/src/postProcessing/functionObjects/utilities/residuals/residualsTemplates.C +++ b/src/postProcessing/functionObjects/utilities/residuals/residualsTemplates.C @@ -25,8 +25,6 @@ License #include "residuals.H" #include "volFields.H" -#include "dictionary.H" -#include "Time.H" #include "ListOps.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/src/postProcessing/functionObjects/utilities/scalarTransport/scalarTransport.C b/src/postProcessing/functionObjects/utilities/scalarTransport/scalarTransport.C index 1c3d02df283533abf3246d3e7ff590b60aabf8c1..c494a5b2ba2256480fbb5663e92469877424a2ab 100644 --- a/src/postProcessing/functionObjects/utilities/scalarTransport/scalarTransport.C +++ b/src/postProcessing/functionObjects/utilities/scalarTransport/scalarTransport.C @@ -36,6 +36,7 @@ License #include "fvmSup.H" #include "turbulentTransportModel.H" #include "turbulentFluidThermoModel.H" +#include "addToRunTimeSelectionTable.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -44,6 +45,13 @@ namespace Foam namespace functionObjects { defineTypeNameAndDebug(scalarTransport, 0); + + addToRunTimeSelectionTable + ( + functionObject, + scalarTransport, + dictionary + ); } } @@ -145,13 +153,21 @@ Foam::tmp<Foam::volScalarField> Foam::functionObjects::scalarTransport::DT Foam::functionObjects::scalarTransport::scalarTransport ( const word& name, - const objectRegistry& obr, - const dictionary& dict, - const bool loadFromFiles + const Time& runTime, + const dictionary& dict ) : - name_(name), - mesh_(refCast<const fvMesh>(obr)), + functionObject(name), + mesh_ + ( + refCast<const fvMesh> + ( + runTime.lookupObject<objectRegistry> + ( + dict.lookupOrDefault("region", polyMesh::defaultRegion) + ) + ) + ), phiName_(dict.lookupOrDefault<word>("phiName", "phi")), UName_(dict.lookupOrDefault<word>("UName", "U")), rhoName_(dict.lookupOrDefault<word>("rhoName", "rho")), @@ -176,12 +192,6 @@ Foam::functionObjects::scalarTransport::scalarTransport boundaryTypes() ) { - if (!isA<fvMesh>(obr)) - { - FatalErrorInFunction - << "objectRegistry is not an fvMesh" << exit(FatalError); - } - read(dict); if (resetOnStartUp_) @@ -199,7 +209,7 @@ Foam::functionObjects::scalarTransport::~scalarTransport() // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -void Foam::functionObjects::scalarTransport::read(const dictionary& dict) +bool Foam::functionObjects::scalarTransport::read(const dictionary& dict) { Info<< type() << ":" << nl; @@ -220,10 +230,12 @@ void Foam::functionObjects::scalarTransport::read(const dictionary& dict) dict.lookup("autoSchemes") >> autoSchemes_; fvOptions_.reset(dict.subDict("fvOptions")); + + return true; } -void Foam::functionObjects::scalarTransport::execute() +bool Foam::functionObjects::scalarTransport::execute(const bool postProcess) { Info<< type() << " output:" << endl; @@ -304,21 +316,15 @@ void Foam::functionObjects::scalarTransport::execute() } Info<< endl; + + return true; } -void Foam::functionObjects::scalarTransport::end() +bool Foam::functionObjects::scalarTransport::write(const bool postProcess) { - execute(); + return true; } -void Foam::functionObjects::scalarTransport::timeSet() -{} - - -void Foam::functionObjects::scalarTransport::write() -{} - - // ************************************************************************* // diff --git a/src/postProcessing/functionObjects/utilities/scalarTransport/scalarTransport.H b/src/postProcessing/functionObjects/utilities/scalarTransport/scalarTransport.H index 29b5fb0e653fdc22cf03812909546d8ea47ce974..2508ce72116a423123ee578f27560af20d20d698 100644 --- a/src/postProcessing/functionObjects/utilities/scalarTransport/scalarTransport.H +++ b/src/postProcessing/functionObjects/utilities/scalarTransport/scalarTransport.H @@ -47,10 +47,9 @@ SourceFiles #ifndef functionObjects_scalarTransport_H #define functionObjects_scalarTransport_H +#include "functionObject.H" #include "volFields.H" #include "surfaceFieldsFwd.H" -#include "pointFieldFwd.H" -#include "fvMatricesFwd.H" #include "fvOptionList.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -60,8 +59,6 @@ namespace Foam // Forward declaration of classes class objectRegistry; -class dictionary; -class mapPolyMesh; namespace functionObjects { @@ -71,12 +68,11 @@ namespace functionObjects \*---------------------------------------------------------------------------*/ class scalarTransport +: + public functionObject { // Private data - //- Name of this set of scalarTransport objects - word name_; - //- Reference to the mesh database const fvMesh& mesh_; @@ -134,14 +130,12 @@ public: // Constructors - //- Construct for given objectRegistry and dictionary. - // Allow the possibility to load fields from files + //- Construct from Time and dictionary scalarTransport ( const word& name, - const objectRegistry&, - const dictionary&, - const bool loadFromFiles = false + const Time& runTime, + const dictionary& dict ); @@ -151,34 +145,15 @@ public: // Member Functions - //- Return name of the set of scalarTransport - virtual const word& name() const - { - return name_; - } - //- Read the scalarTransport 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(); - - //- Called when time was set at the end of the Time::operator++ - virtual void timeSet(); - - //- Calculate the scalarTransport and write - virtual void write(); + virtual bool read(const dictionary&); - //- Update for changes of mesh - virtual void updateMesh(const mapPolyMesh&) - {} + //- Calculate the scalarTransport + virtual bool execute(const bool postProcess = false); - //- Update for changes of mesh - virtual void movePoints(const polyMesh&) - {} + //- Do nothing. + // The volScalarField is registered and written automatically + virtual bool write(const bool postProcess = false); }; diff --git a/src/postProcessing/functionObjects/utilities/scalarTransport/scalarTransportFunctionObject.C b/src/postProcessing/functionObjects/utilities/scalarTransport/scalarTransportFunctionObject.C deleted file mode 100644 index 3f9ba1b3ad410d031a6e811ec28a16e6c6328a35..0000000000000000000000000000000000000000 --- a/src/postProcessing/functionObjects/utilities/scalarTransport/scalarTransportFunctionObject.C +++ /dev/null @@ -1,42 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2012 OpenFOAM Foundation - \\/ 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 <http://www.gnu.org/licenses/>. - -\*---------------------------------------------------------------------------*/ - -#include "scalarTransportFunctionObject.H" - -// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // - -namespace Foam -{ - defineNamedTemplateTypeNameAndDebug(scalarTransportFunctionObject, 0); - - addToRunTimeSelectionTable - ( - functionObject, - scalarTransportFunctionObject, - dictionary - ); -} - -// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/utilities/scalarTransport/scalarTransportFunctionObject.H b/src/postProcessing/functionObjects/utilities/scalarTransport/scalarTransportFunctionObject.H deleted file mode 100644 index cea384054cb89d6e07b2a0c66e2d8c61e2aba3f0..0000000000000000000000000000000000000000 --- a/src/postProcessing/functionObjects/utilities/scalarTransport/scalarTransportFunctionObject.H +++ /dev/null @@ -1,54 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2012-2016 OpenFOAM Foundation - \\/ 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 <http://www.gnu.org/licenses/>. - -Typedef - Foam::scalarTransportFunctionObject - -Description - FunctionObject wrapper around scalarTransport to allow it to be - created via the functions entry within controlDict. - -SourceFiles - scalarTransportFunctionObject.C - -\*---------------------------------------------------------------------------*/ - -#ifndef scalarTransportFunctionObject_H -#define scalarTransportFunctionObject_H - -#include "scalarTransport.H" -#include "OutputFilterFunctionObject.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - typedef OutputFilterFunctionObject<functionObjects::scalarTransport> - scalarTransportFunctionObject; -} - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#endif - -// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/utilities/setTimeStep/setTimeStepFunctionObject.C b/src/postProcessing/functionObjects/utilities/setTimeStep/setTimeStepFunctionObject.C index 760db856d780d3b673cb686cb2fe2af7da847f0b..37f04583284a47b39b3141337964070e8c0f10bc 100644 --- a/src/postProcessing/functionObjects/utilities/setTimeStep/setTimeStepFunctionObject.C +++ b/src/postProcessing/functionObjects/utilities/setTimeStep/setTimeStepFunctionObject.C @@ -75,36 +75,6 @@ Foam::functionObjects::setTimeStepFunctionObject::time() const } -bool Foam::functionObjects::setTimeStepFunctionObject::execute -( - const bool postProcess -) -{ - return true; -} - - -bool Foam::functionObjects::setTimeStepFunctionObject::write -( - const bool postProcess -) -{ - return true; -} - - -bool Foam::functionObjects::setTimeStepFunctionObject::end() -{ - return true; -} - - -bool Foam::functionObjects::setTimeStepFunctionObject::timeSet() -{ - return true; -} - - bool Foam::functionObjects::setTimeStepFunctionObject::adjustTimeStep() { const_cast<Time&>(time()).setDeltaT @@ -143,18 +113,22 @@ bool Foam::functionObjects::setTimeStepFunctionObject::read } -void Foam::functionObjects::setTimeStepFunctionObject::updateMesh +bool Foam::functionObjects::setTimeStepFunctionObject::execute ( - const mapPolyMesh& + const bool postProcess ) -{} +{ + return true; +} -void Foam::functionObjects::setTimeStepFunctionObject::movePoints +bool Foam::functionObjects::setTimeStepFunctionObject::write ( - const polyMesh& + const bool postProcess ) -{} +{ + return true; +} // ************************************************************************* // diff --git a/src/postProcessing/functionObjects/utilities/setTimeStep/setTimeStepFunctionObject.H b/src/postProcessing/functionObjects/utilities/setTimeStep/setTimeStepFunctionObject.H index 6a31dedbc8d6a4e782c01379fc3f0504ff8c4743..62f12c8cc5c30448409a59671dc197b572a6942f 100644 --- a/src/postProcessing/functionObjects/utilities/setTimeStep/setTimeStepFunctionObject.H +++ b/src/postProcessing/functionObjects/utilities/setTimeStep/setTimeStepFunctionObject.H @@ -101,41 +101,24 @@ public: // Member Functions - // Access + //- Return time database + const Time& time() const; - //- Return time database - const Time& time() const; + //- Called at the end of Time::adjustDeltaT() if adjustTime is true + virtual bool adjustTimeStep(); + //- Read and set the function object if its data have changed + virtual bool read(const dictionary&); - // Function object control + //- Called at each ++ or += of the time-loop. + // postProcess overrides the usual executeControl behaviour and + // forces execution (used in post-processing mode) + virtual bool execute(const bool postProcess = false); - //- Called at each ++ or += of the time-loop. - // postProcess overrides the usual executeControl behaviour and - // forces execution (used in post-processing mode) - virtual bool execute(const bool postProcess = false); - - //- Called at each ++ or += of the time-loop. - // postProcess overrides the usual writeControl behaviour and - // forces writing always (used in post-processing mode) - virtual bool write(const bool postProcess = false); - - //- Called when Time::run() determines that the time-loop exits - virtual bool end(); - - //- Called when time was set at the end of the Time::operator++ - virtual bool timeSet(); - - //- Called at the end of Time::adjustDeltaT() if adjustTime is true - virtual bool adjustTimeStep(); - - //- Read and set the function object if its data have changed - virtual bool read(const dictionary&); - - //- Update for changes of mesh - virtual void updateMesh(const mapPolyMesh&); - - //- Update for changes of mesh - virtual void movePoints(const polyMesh&); + //- Called at each ++ or += of the time-loop. + // postProcess overrides the usual writeControl behaviour and + // forces writing always (used in post-processing mode) + virtual bool write(const bool postProcess = false); }; diff --git a/src/postProcessing/functionObjects/utilities/systemCall/systemCall.C b/src/postProcessing/functionObjects/utilities/systemCall/systemCall.C index 1d1796af9af1817adab04b1835969e2e65b0de1e..9d3645ba437a740435ecfca990e5b32f64628ce7 100644 --- a/src/postProcessing/functionObjects/utilities/systemCall/systemCall.C +++ b/src/postProcessing/functionObjects/utilities/systemCall/systemCall.C @@ -26,6 +26,7 @@ License #include "systemCall.H" #include "Time.H" #include "dynamicCode.H" +#include "addToRunTimeSelectionTable.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -34,6 +35,13 @@ namespace Foam namespace functionObjects { defineTypeNameAndDebug(systemCall, 0); + + addToRunTimeSelectionTable + ( + functionObject, + systemCall, + dictionary + ); } } @@ -43,12 +51,11 @@ namespace functionObjects Foam::functionObjects::systemCall::systemCall ( const word& name, - const objectRegistry&, - const dictionary& dict, - const bool + const Time&, + const dictionary& dict ) : - name_(name), + functionObject(name), executeCalls_(), endCalls_(), writeCalls_() @@ -65,7 +72,7 @@ Foam::functionObjects::systemCall::~systemCall() // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -void Foam::functionObjects::systemCall::read(const dictionary& dict) +bool Foam::functionObjects::systemCall::read(const dictionary& dict) { dict.readIfPresent("executeCalls", executeCalls_); dict.readIfPresent("endCalls", endCalls_); @@ -93,37 +100,41 @@ void Foam::functionObjects::systemCall::read(const dictionary& dict) << " $WM_PROJECT_DIR/etc/controlDict" << nl << nl << exit(FatalError); } + + return true; } -void Foam::functionObjects::systemCall::execute() +bool Foam::functionObjects::systemCall::execute(const bool postProcess) { forAll(executeCalls_, callI) { Foam::system(executeCalls_[callI]); } + + return true; } -void Foam::functionObjects::systemCall::end() +bool Foam::functionObjects::systemCall::end() { forAll(endCalls_, callI) { Foam::system(endCalls_[callI]); } -} - -void Foam::functionObjects::systemCall::timeSet() -{} + return true; +} -void Foam::functionObjects::systemCall::write() +bool Foam::functionObjects::systemCall::write(const bool postProcess) { forAll(writeCalls_, callI) { Foam::system(writeCalls_[callI]); } + + return true; } diff --git a/src/postProcessing/functionObjects/utilities/systemCall/systemCall.H b/src/postProcessing/functionObjects/utilities/systemCall/systemCall.H index e12da249701f67d875131b3698630dd869e3992f..a1dd56046be54bcb51ec723cff12a1fcb88a3b2e 100644 --- a/src/postProcessing/functionObjects/utilities/systemCall/systemCall.H +++ b/src/postProcessing/functionObjects/utilities/systemCall/systemCall.H @@ -76,7 +76,7 @@ Note SeeAlso Foam::functionObject - Foam::OutputFilterFunctionObject + Foam::functionObjects::timeControl SourceFiles systemCall.C @@ -86,19 +86,13 @@ SourceFiles #ifndef functionObjects_systemCall_H #define functionObjects_systemCall_H +#include "functionObject.H" #include "stringList.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // namespace Foam { - -// Forward declaration of classes -class objectRegistry; -class dictionary; -class polyMesh; -class mapPolyMesh; - namespace functionObjects { @@ -107,14 +101,13 @@ namespace functionObjects \*---------------------------------------------------------------------------*/ class systemCall +: + public functionObject { protected: // Private data - //- Name of this set of system calls - word name_; - //- List of calls to execute - every step stringList executeCalls_; @@ -144,14 +137,12 @@ public: // Constructors - //- Construct for given objectRegistry and dictionary. - // Allow the possibility to load fields from files + //- Construct from Time and dictionary systemCall ( const word& name, - const objectRegistry& unused, - const dictionary&, - const bool loadFromFilesUnused = false + const Time& runTime, + const dictionary& dict ); @@ -161,34 +152,17 @@ public: // Member Functions - //- Return name of the system call set - virtual const word& name() const - { - return name_; - } - //- Read the system calls - virtual void read(const dictionary&); + virtual bool read(const dictionary&); //- Execute the "executeCalls" at each time-step - virtual void execute(); + virtual bool execute(const bool postProcess = false); //- Execute the "endCalls" at the final time-loop - virtual void end(); - - //- Called when time was set at the end of the Time::operator++ - virtual void timeSet(); + virtual bool end(); //- Write, execute the "writeCalls" - virtual void write(); - - //- Update for changes of mesh - virtual void updateMesh(const mapPolyMesh&) - {} - - //- Update for changes of mesh - virtual void movePoints(const polyMesh&) - {} + virtual bool write(const bool postProcess = false); }; diff --git a/src/postProcessing/functionObjects/utilities/systemCall/systemCallFunctionObject.C b/src/postProcessing/functionObjects/utilities/systemCall/systemCallFunctionObject.C deleted file mode 100644 index 0dfd7b6b06921e5222ee10da5c35a1d49697338c..0000000000000000000000000000000000000000 --- a/src/postProcessing/functionObjects/utilities/systemCall/systemCallFunctionObject.C +++ /dev/null @@ -1,42 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation - \\/ 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 <http://www.gnu.org/licenses/>. - -\*---------------------------------------------------------------------------*/ - -#include "systemCallFunctionObject.H" - -// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // - -namespace Foam -{ - defineNamedTemplateTypeNameAndDebug(systemCallFunctionObject, 0); - - addToRunTimeSelectionTable - ( - functionObject, - systemCallFunctionObject, - dictionary - ); -} - -// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/utilities/systemCall/systemCallFunctionObject.H b/src/postProcessing/functionObjects/utilities/systemCall/systemCallFunctionObject.H deleted file mode 100644 index b0fdf35ea61f685747fb6134550e22a0b1f5002b..0000000000000000000000000000000000000000 --- a/src/postProcessing/functionObjects/utilities/systemCall/systemCallFunctionObject.H +++ /dev/null @@ -1,54 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation - \\/ 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 <http://www.gnu.org/licenses/>. - -Typedef - Foam::systemCallFunctionObject - -Description - FunctionObject wrapper around systemCall to allow them to be created via - the functions entry within controlDict. - -SourceFiles - systemCallFunctionObject.C - -\*---------------------------------------------------------------------------*/ - -#ifndef systemCallFunctionObject_H -#define systemCallFunctionObject_H - -#include "systemCall.H" -#include "OutputFilterFunctionObject.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - typedef OutputFilterFunctionObject<functionObjects::systemCall> - systemCallFunctionObject; -} - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#endif - -// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/utilities/timeActivatedFileUpdate/timeActivatedFileUpdate.C b/src/postProcessing/functionObjects/utilities/timeActivatedFileUpdate/timeActivatedFileUpdate.C index f571185f1e30a43fecc24613d5c5d45ebaa59a16..9b8af9d7bb8a0ee51bfe675cbe58d795234f6103 100644 --- a/src/postProcessing/functionObjects/utilities/timeActivatedFileUpdate/timeActivatedFileUpdate.C +++ b/src/postProcessing/functionObjects/utilities/timeActivatedFileUpdate/timeActivatedFileUpdate.C @@ -24,9 +24,9 @@ License \*---------------------------------------------------------------------------*/ #include "timeActivatedFileUpdate.H" -#include "objectRegistry.H" #include "Time.H" -#include "dictionary.H" +#include "polyMesh.H" +#include "addToRunTimeSelectionTable.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -35,6 +35,13 @@ namespace Foam namespace functionObjects { defineTypeNameAndDebug(timeActivatedFileUpdate, 0); + + addToRunTimeSelectionTable + ( + functionObject, + timeActivatedFileUpdate, + dictionary + ); } } @@ -47,7 +54,7 @@ void Foam::functionObjects::timeActivatedFileUpdate::updateFile() while ( i < timeVsFile_.size()-1 - && timeVsFile_[i+1].first() < obr_.time().value() + && timeVsFile_[i+1].first() < time_.value() ) { i++; @@ -69,13 +76,12 @@ void Foam::functionObjects::timeActivatedFileUpdate::updateFile() Foam::functionObjects::timeActivatedFileUpdate::timeActivatedFileUpdate ( const word& name, - const objectRegistry& obr, - const dictionary& dict, - const bool loadFromFiles + const Time& runTime, + const dictionary& dict ) : - name_(name), - obr_(obr), + functionObject(name), + time_(runTime), fileToUpdate_(dict.lookup("fileToUpdate")), timeVsFile_(), lastIndex_(-1) @@ -92,7 +98,7 @@ Foam::functionObjects::timeActivatedFileUpdate::~timeActivatedFileUpdate() // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -void Foam::functionObjects::timeActivatedFileUpdate::read +bool Foam::functionObjects::timeActivatedFileUpdate::read ( const dictionary& dict ) @@ -120,27 +126,29 @@ void Foam::functionObjects::timeActivatedFileUpdate::read Info<< endl; updateFile(); + + return true; } -void Foam::functionObjects::timeActivatedFileUpdate::execute() +bool Foam::functionObjects::timeActivatedFileUpdate::execute +( + const bool postProcess +) { updateFile(); + + return true; } -void Foam::functionObjects::timeActivatedFileUpdate::end() +bool Foam::functionObjects::timeActivatedFileUpdate::write +( + const bool postProcess +) { - execute(); + return true; } -void Foam::functionObjects::timeActivatedFileUpdate::timeSet() -{} - - -void Foam::functionObjects::timeActivatedFileUpdate::write() -{} - - // ************************************************************************* // diff --git a/src/postProcessing/functionObjects/utilities/timeActivatedFileUpdate/timeActivatedFileUpdate.H b/src/postProcessing/functionObjects/utilities/timeActivatedFileUpdate/timeActivatedFileUpdate.H index 1b2b1d879d57b3ffe957498225d3158af350396f..e72fb38b7da4e988d48a52558cf0b205034d6d87 100644 --- a/src/postProcessing/functionObjects/utilities/timeActivatedFileUpdate/timeActivatedFileUpdate.H +++ b/src/postProcessing/functionObjects/utilities/timeActivatedFileUpdate/timeActivatedFileUpdate.H @@ -59,6 +59,7 @@ SourceFiles #ifndef functionObjects_timeActivatedFileUpdate_H #define functionObjects_timeActivatedFileUpdate_H +#include "functionObject.H" #include "Tuple2.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -67,10 +68,7 @@ namespace Foam { // Forward declaration of classes -class objectRegistry; -class dictionary; -class polyMesh; -class mapPolyMesh; +class Time; namespace functionObjects { @@ -80,14 +78,13 @@ namespace functionObjects \*---------------------------------------------------------------------------*/ class timeActivatedFileUpdate +: + public functionObject { // Private data - //- Name of this set of timeActivatedFileUpdate objects - word name_; - - //- Owner database - const objectRegistry& obr_; + //- Reference to Time + const Time& time_; //- Name of file to update fileName fileToUpdate_; @@ -119,14 +116,12 @@ public: // Constructors - //- Construct for given objectRegistry and dictionary. - // Allow the possibility to load fields from files + //- Construct from Time and dictionary timeActivatedFileUpdate ( const word& name, - const objectRegistry&, - const dictionary&, - const bool loadFromFiles = false + const Time& runTime, + const dictionary& dict ); @@ -136,34 +131,14 @@ public: // Member Functions - //- Return name of the set of timeActivatedFileUpdate - virtual const word& name() const - { - return name_; - } - //- Read the timeActivatedFileUpdate 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(); - - //- Called when time was set at the end of the Time::operator++ - virtual void timeSet(); - - //- Calculate the timeActivatedFileUpdate and write - virtual void write(); + virtual bool read(const dictionary&); - //- Update for changes of mesh - virtual void updateMesh(const mapPolyMesh&) - {} + //- Execute file updates + virtual bool execute(const bool postProcess = false); - //- Update for changes of mesh - virtual void movePoints(const polyMesh&) - {} + //- Do nothing + virtual bool write(const bool postProcess = false); }; diff --git a/src/postProcessing/functionObjects/utilities/timeActivatedFileUpdate/timeActivatedFileUpdateFunctionObject.C b/src/postProcessing/functionObjects/utilities/timeActivatedFileUpdate/timeActivatedFileUpdateFunctionObject.C deleted file mode 100644 index 7b6498065024262f282f5c42b57880c758d5c06b..0000000000000000000000000000000000000000 --- a/src/postProcessing/functionObjects/utilities/timeActivatedFileUpdate/timeActivatedFileUpdateFunctionObject.C +++ /dev/null @@ -1,46 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation - \\/ 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 <http://www.gnu.org/licenses/>. - -\*---------------------------------------------------------------------------*/ - -#include "timeActivatedFileUpdateFunctionObject.H" - -// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // - -namespace Foam -{ - defineNamedTemplateTypeNameAndDebug - ( - timeActivatedFileUpdateFunctionObject, - 0 - ); - - addToRunTimeSelectionTable - ( - functionObject, - timeActivatedFileUpdateFunctionObject, - dictionary - ); -} - -// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/utilities/timeActivatedFileUpdate/timeActivatedFileUpdateFunctionObject.H b/src/postProcessing/functionObjects/utilities/timeActivatedFileUpdate/timeActivatedFileUpdateFunctionObject.H deleted file mode 100644 index af8d9e4cc9888a6e093cab15762c7c8224db2d62..0000000000000000000000000000000000000000 --- a/src/postProcessing/functionObjects/utilities/timeActivatedFileUpdate/timeActivatedFileUpdateFunctionObject.H +++ /dev/null @@ -1,54 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation - \\/ 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 <http://www.gnu.org/licenses/>. - -Typedef - Foam::timeActivatedFileUpdateFunctionObject - -Description - FunctionObject wrapper around timeActivatedFileUpdate to allow it to be - created via the functions list within controlDict. - -SourceFiles - timeActivatedFileUpdateFunctionObject.C - -\*---------------------------------------------------------------------------*/ - -#ifndef timeActivatedFileUpdateFunctionObject_H -#define timeActivatedFileUpdateFunctionObject_H - -#include "timeActivatedFileUpdate.H" -#include "OutputFilterFunctionObject.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - typedef OutputFilterFunctionObject<functionObjects::timeActivatedFileUpdate> - timeActivatedFileUpdateFunctionObject; -} - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#endif - -// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/utilities/turbulenceFields/turbulenceFields.C b/src/postProcessing/functionObjects/utilities/turbulenceFields/turbulenceFields.C index 41a1de210b39738d073ed6d80cf50e915579f7de..5992908a7d5783bd4f37ac3b2a1c6f37666f535d 100644 --- a/src/postProcessing/functionObjects/utilities/turbulenceFields/turbulenceFields.C +++ b/src/postProcessing/functionObjects/utilities/turbulenceFields/turbulenceFields.C @@ -24,9 +24,9 @@ License \*---------------------------------------------------------------------------*/ #include "turbulenceFields.H" -#include "dictionary.H" #include "turbulentTransportModel.H" #include "turbulentFluidThermoModel.H" +#include "addToRunTimeSelectionTable.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -35,6 +35,13 @@ namespace Foam namespace functionObjects { defineTypeNameAndDebug(turbulenceFields, 0); + + addToRunTimeSelectionTable + ( + functionObject, + turbulenceFields, + dictionary + ); } } @@ -116,16 +123,21 @@ bool Foam::functionObjects::turbulenceFields::compressible() Foam::functionObjects::turbulenceFields::turbulenceFields ( const word& name, - const objectRegistry& obr, - const dictionary& dict, - const bool loadFromFiles + const Time& runTime, + const dictionary& dict ) : - name_(name), - obr_(obr), + functionObject(name), + obr_ + ( + runTime.lookupObject<objectRegistry> + ( + dict.lookupOrDefault("region", polyMesh::defaultRegion) + ) + ), fieldSet_() { - if (!isA<fvMesh>(obr)) + if (!isA<fvMesh>(obr_)) { FatalErrorInFunction << "objectRegistry is not an fvMesh" << exit(FatalError); @@ -133,8 +145,8 @@ Foam::functionObjects::turbulenceFields::turbulenceFields if ( - !obr.foundObject<compressible::turbulenceModel>(modelName) - && !obr.foundObject<incompressible::turbulenceModel>(modelName) + !obr_.foundObject<compressible::turbulenceModel>(modelName) + && !obr_.foundObject<incompressible::turbulenceModel>(modelName) ) { FatalErrorInFunction @@ -154,11 +166,11 @@ Foam::functionObjects::turbulenceFields::~turbulenceFields() // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -void Foam::functionObjects::turbulenceFields::read(const dictionary& dict) +bool Foam::functionObjects::turbulenceFields::read(const dictionary& dict) { fieldSet_.insert(wordList(dict.lookup("fields"))); - Info<< type() << " " << name_ << ": "; + Info<< type() << " " << name() << ": "; if (fieldSet_.size()) { Info<< "storing fields:" << nl; @@ -172,10 +184,12 @@ void Foam::functionObjects::turbulenceFields::read(const dictionary& dict) { Info<< "no fields requested to be stored" << nl << endl; } + + return true; } -void Foam::functionObjects::turbulenceFields::execute() +bool Foam::functionObjects::turbulenceFields::execute(const bool postProcess) { bool comp = compressible(); @@ -285,21 +299,15 @@ void Foam::functionObjects::turbulenceFields::execute() } } } + + return true; } -void Foam::functionObjects::turbulenceFields::end() +bool Foam::functionObjects::turbulenceFields::write(const bool postProcess) { - execute(); + return true; } -void Foam::functionObjects::turbulenceFields::timeSet() -{} - - -void Foam::functionObjects::turbulenceFields::write() -{} - - // ************************************************************************* // diff --git a/src/postProcessing/functionObjects/utilities/turbulenceFields/turbulenceFields.H b/src/postProcessing/functionObjects/utilities/turbulenceFields/turbulenceFields.H index f578022b86f68c71075e9d2ff7c85fd59a6b04fb..bd480dfdfbd79a246581af4a4f8f727fd7ca1d78 100644 --- a/src/postProcessing/functionObjects/utilities/turbulenceFields/turbulenceFields.H +++ b/src/postProcessing/functionObjects/utilities/turbulenceFields/turbulenceFields.H @@ -77,7 +77,7 @@ Description SeeAlso Foam::functionObject - Foam::OutputFilterFunctionObject + Foam::functionObjects::timeControl SourceFiles turbulenceFields.C @@ -87,6 +87,7 @@ SourceFiles #ifndef functionObjects_turbulenceFields_H #define functionObjects_turbulenceFields_H +#include "functionObject.H" #include "HashSet.H" #include "NamedEnum.H" #include "volFieldsFwd.H" @@ -98,9 +99,6 @@ namespace Foam // Forward declaration of classes class objectRegistry; -class dictionary; -class polyMesh; -class mapPolyMesh; namespace functionObjects { @@ -110,6 +108,8 @@ namespace functionObjects \*---------------------------------------------------------------------------*/ class turbulenceFields +: + public functionObject { public: @@ -144,9 +144,7 @@ protected: // Protected data - //- Name of this set of turbulenceFields object - word name_; - + //- Reference to the objectRegistry const objectRegistry& obr_; //- Fields to load @@ -186,14 +184,12 @@ public: // Constructors - //- Construct for given objectRegistry and dictionary. - // Allow the possibility to load fields from files + //- Construct from Time and dictionary turbulenceFields ( const word& name, - const objectRegistry&, - const dictionary&, - const bool loadFromFiles = false + const Time& runTime, + const dictionary& dict ); @@ -203,34 +199,15 @@ public: // Member Functions - //- Return name of the turbulenceFields object - virtual const word& name() const - { - return name_; - } - //- Read the controls - virtual void read(const dictionary&); - - //- Execute, currently does nothing - virtual void execute(); - - //- Execute at the final time-loop, currently does nothing - virtual void end(); - - //- Called when time was set at the end of the Time::operator++ - virtual void timeSet(); - - //- Write - virtual void write(); + virtual bool read(const dictionary&); - //- Update for changes of mesh - virtual void updateMesh(const mapPolyMesh&) - {} + //- Calculate turbulence fields + virtual bool execute(const bool postProcess = false); - //- Update for changes of mesh - virtual void movePoints(const polyMesh&) - {} + //- Do nothing. + // The turbulence fields are registered and written automatically + virtual bool write(const bool postProcess = false); }; diff --git a/src/postProcessing/functionObjects/utilities/turbulenceFields/turbulenceFieldsFunctionObject.C b/src/postProcessing/functionObjects/utilities/turbulenceFields/turbulenceFieldsFunctionObject.C deleted file mode 100644 index 4f779363f880ec8c86d211df21b77e7f19dcef3b..0000000000000000000000000000000000000000 --- a/src/postProcessing/functionObjects/utilities/turbulenceFields/turbulenceFieldsFunctionObject.C +++ /dev/null @@ -1,42 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2012-2014 OpenFOAM Foundation - \\/ 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 <http://www.gnu.org/licenses/>. - -\*---------------------------------------------------------------------------*/ - -#include "turbulenceFieldsFunctionObject.H" - -// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // - -namespace Foam -{ - defineNamedTemplateTypeNameAndDebug(turbulenceFieldsFunctionObject, 0); - - addToRunTimeSelectionTable - ( - functionObject, - turbulenceFieldsFunctionObject, - dictionary - ); -} - -// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/utilities/turbulenceFields/turbulenceFieldsFunctionObject.H b/src/postProcessing/functionObjects/utilities/turbulenceFields/turbulenceFieldsFunctionObject.H deleted file mode 100644 index 6d600f7ce72aff37e897a0b58338e379113a2733..0000000000000000000000000000000000000000 --- a/src/postProcessing/functionObjects/utilities/turbulenceFields/turbulenceFieldsFunctionObject.H +++ /dev/null @@ -1,54 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2012-2016 OpenFOAM Foundation - \\/ 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 <http://www.gnu.org/licenses/>. - -Typedef - Foam::turbulenceFieldsFunctionObject - -Description - FunctionObject wrapper around turbulenceFields to allow them to be created - via the functions entry within controlDict. - -SourceFiles - turbulenceFieldsFunctionObject.C - -\*---------------------------------------------------------------------------*/ - -#ifndef turbulenceFieldsFunctionObject_H -#define turbulenceFieldsFunctionObject_H - -#include "turbulenceFields.H" -#include "OutputFilterFunctionObject.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - typedef OutputFilterFunctionObject<functionObjects::turbulenceFields> - turbulenceFieldsFunctionObject; -} - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#endif - -// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/utilities/vorticity/vorticity.C b/src/postProcessing/functionObjects/utilities/vorticity/vorticity.C index 89cb38d2c3076af8a9d132c124fe90439e820369..ac9828f8e1532a2b2360c9cfa711845f89149d57 100644 --- a/src/postProcessing/functionObjects/utilities/vorticity/vorticity.C +++ b/src/postProcessing/functionObjects/utilities/vorticity/vorticity.C @@ -25,8 +25,8 @@ License #include "vorticity.H" #include "volFields.H" -#include "dictionary.H" #include "fvcCurl.H" +#include "addToRunTimeSelectionTable.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -35,6 +35,13 @@ namespace Foam namespace functionObjects { defineTypeNameAndDebug(vorticity, 0); + + addToRunTimeSelectionTable + ( + functionObject, + vorticity, + dictionary + ); } } @@ -44,17 +51,22 @@ namespace functionObjects Foam::functionObjects::vorticity::vorticity ( const word& name, - const objectRegistry& obr, - const dictionary& dict, - const bool loadFromFiles + const Time& runTime, + const dictionary& dict ) : - name_(name), - obr_(obr), + functionObject(name), + obr_ + ( + runTime.lookupObject<objectRegistry> + ( + dict.lookupOrDefault("region", polyMesh::defaultRegion) + ) + ), UName_("U"), outputName_(typeName) { - if (!isA<fvMesh>(obr)) + if (!isA<fvMesh>(obr_)) { FatalErrorInFunction << "objectRegistry is not an fvMesh" << exit(FatalError); @@ -93,17 +105,19 @@ Foam::functionObjects::vorticity::~vorticity() // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -void Foam::functionObjects::vorticity::read(const dictionary& dict) +bool Foam::functionObjects::vorticity::read(const dictionary& dict) { UName_ = dict.lookupOrDefault<word>("UName", "U"); if (UName_ != "U") { outputName_ = typeName + "(" + UName_ + ")"; } + + return true; } -void Foam::functionObjects::vorticity::execute() +bool Foam::functionObjects::vorticity::execute(const bool postProcess) { const volVectorField& U = obr_.lookupObject<volVectorField>(UName_); @@ -113,29 +127,23 @@ void Foam::functionObjects::vorticity::execute() ); vorticity = fvc::curl(U); -} - -void Foam::functionObjects::vorticity::end() -{ - execute(); + return true; } -void Foam::functionObjects::vorticity::timeSet() -{} - - -void Foam::functionObjects::vorticity::write() +bool Foam::functionObjects::vorticity::write(const bool postProcess) { const volVectorField& vorticity = obr_.lookupObject<volVectorField>(outputName_); - Info<< type() << " " << name_ << " output:" << nl + Info<< type() << " " << name() << " output:" << nl << " writing field " << vorticity.name() << nl << endl; vorticity.write(); + + return true; } diff --git a/src/postProcessing/functionObjects/utilities/vorticity/vorticity.H b/src/postProcessing/functionObjects/utilities/vorticity/vorticity.H index e430924a1bf486ebb675612de45b238fbf74bb6a..942926a9483f8eb158b1b032ca0c0c163b7a9eb6 100644 --- a/src/postProcessing/functionObjects/utilities/vorticity/vorticity.H +++ b/src/postProcessing/functionObjects/utilities/vorticity/vorticity.H @@ -38,6 +38,7 @@ SourceFiles #ifndef functionObjects_vorticity_H #define functionObjects_vorticity_H +#include "functionObject.H" #include "volFieldsFwd.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -47,9 +48,6 @@ namespace Foam // Forward declaration of classes class objectRegistry; -class dictionary; -class polyMesh; -class mapPolyMesh; namespace functionObjects { @@ -59,12 +57,11 @@ namespace functionObjects \*---------------------------------------------------------------------------*/ class vorticity +: + public functionObject { // Private data - //- Name of this set of vorticity objects - word name_; - //- Reference to the database const objectRegistry& obr_; @@ -92,14 +89,12 @@ public: // Constructors - //- Construct for given objectRegistry and dictionary. - // Allow the possibility to load fields from files + //- Construct from Time and dictionary vorticity ( const word& name, - const objectRegistry&, - const dictionary&, - const bool loadFromFiles = false + const Time& runTime, + const dictionary& dict ); @@ -109,34 +104,14 @@ public: // Member Functions - //- Return name of the set of vorticity - virtual const word& name() const - { - return name_; - } - //- Read the vorticity data - virtual void read(const dictionary&); + virtual bool read(const dictionary&); //- Execute, currently does nothing - virtual void execute(); - - //- Execute at the final time-loop, currently does nothing - virtual void end(); - - //- Called when time was set at the end of the Time::operator++ - virtual void timeSet(); + virtual bool execute(const bool postProcess = false); //- Calculate the vorticity and write - virtual void write(); - - //- Update for changes of mesh - virtual void updateMesh(const mapPolyMesh&) - {} - - //- Update for changes of mesh - virtual void movePoints(const polyMesh&) - {} + virtual bool write(const bool postProcess = false); }; diff --git a/src/postProcessing/functionObjects/utilities/vorticity/vorticityFunctionObject.C b/src/postProcessing/functionObjects/utilities/vorticity/vorticityFunctionObject.C deleted file mode 100644 index 51b7c2f1e364e30b39133c5226c54eef5f93d116..0000000000000000000000000000000000000000 --- a/src/postProcessing/functionObjects/utilities/vorticity/vorticityFunctionObject.C +++ /dev/null @@ -1,42 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2014 OpenFOAM Foundation - \\/ 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 <http://www.gnu.org/licenses/>. - -\*---------------------------------------------------------------------------*/ - -#include "vorticityFunctionObject.H" - -// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // - -namespace Foam -{ - defineNamedTemplateTypeNameAndDebug(vorticityFunctionObject, 0); - - addToRunTimeSelectionTable - ( - functionObject, - vorticityFunctionObject, - dictionary - ); -} - -// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/utilities/vorticity/vorticityFunctionObject.H b/src/postProcessing/functionObjects/utilities/vorticity/vorticityFunctionObject.H deleted file mode 100644 index aee3f04f8e1bd5dc78e6e7407eeac628f91cb474..0000000000000000000000000000000000000000 --- a/src/postProcessing/functionObjects/utilities/vorticity/vorticityFunctionObject.H +++ /dev/null @@ -1,54 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2014-2016 OpenFOAM Foundation - \\/ 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 <http://www.gnu.org/licenses/>. - -Typedef - Foam::vorticityFunctionObject - -Description - FunctionObject wrapper around vorticity to allow it to be created - via the functions entry within controlDict. - -SourceFiles - vorticityFunctionObject.C - -\*---------------------------------------------------------------------------*/ - -#ifndef vorticityFunctionObject_H -#define vorticityFunctionObject_H - -#include "vorticity.H" -#include "OutputFilterFunctionObject.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - typedef OutputFilterFunctionObject<functionObjects::vorticity> - vorticityFunctionObject; -} - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#endif - -// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/utilities/writeDictionary/writeDictionary.C b/src/postProcessing/functionObjects/utilities/writeDictionary/writeDictionary.C index 7fdc21fba108d0c81acf37ad2aca745238ed431c..38a293efe9ca8dc00286702e1a4826935abcfe5d 100644 --- a/src/postProcessing/functionObjects/utilities/writeDictionary/writeDictionary.C +++ b/src/postProcessing/functionObjects/utilities/writeDictionary/writeDictionary.C @@ -24,9 +24,9 @@ License \*---------------------------------------------------------------------------*/ #include "writeDictionary.H" -#include "dictionary.H" #include "Time.H" -#include "HashSet.H" +#include "polyMesh.H" +#include "addToRunTimeSelectionTable.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -35,6 +35,13 @@ namespace Foam namespace functionObjects { defineTypeNameAndDebug(writeDictionary, 0); + + addToRunTimeSelectionTable + ( + functionObject, + writeDictionary, + dictionary + ); } } @@ -66,7 +73,7 @@ bool Foam::functionObjects::writeDictionary::tryDirectory { if (firstDict) { - Info<< type() << " " << name_ << " output:" << nl << endl; + Info<< type() << " " << name() << " output:" << nl << endl; IOobject::writeDivider(Info); Info<< endl; @@ -92,13 +99,18 @@ bool Foam::functionObjects::writeDictionary::tryDirectory Foam::functionObjects::writeDictionary::writeDictionary ( const word& name, - const objectRegistry& obr, - const dictionary& dict, - const bool loadFromFiles + const Time& runTime, + const dictionary& dict ) : - name_(name), - obr_(obr), + functionObject(name), + obr_ + ( + runTime.lookupObject<objectRegistry> + ( + dict.lookupOrDefault("region", polyMesh::defaultRegion) + ) + ), dictNames_(), digests_() { @@ -115,7 +127,7 @@ Foam::functionObjects::writeDictionary::~writeDictionary() // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -void Foam::functionObjects::writeDictionary::read(const dictionary& dict) +bool Foam::functionObjects::writeDictionary::read(const dictionary& dict) { wordList dictNames(dict.lookup("dictNames")); HashSet<word> uniqueNames(dictNames); @@ -123,7 +135,7 @@ void Foam::functionObjects::writeDictionary::read(const dictionary& dict) digests_.setSize(dictNames_.size(), SHA1Digest()); - Info<< type() << " " << name_ << ": monitoring dictionaries:" << nl; + Info<< type() << " " << name() << ": monitoring dictionaries:" << nl; if (dictNames_.size()) { forAll(dictNames_, i) @@ -136,10 +148,12 @@ void Foam::functionObjects::writeDictionary::read(const dictionary& dict) Info<< " none" << nl; } Info<< endl; + + return true; } -void Foam::functionObjects::writeDictionary::execute() +bool Foam::functionObjects::writeDictionary::execute(const bool postProcess) { bool firstDict = true; forAll(dictNames_, i) @@ -153,7 +167,7 @@ void Foam::functionObjects::writeDictionary::execute() { if (firstDict) { - Info<< type() << " " << name_ << " output:" << nl << endl; + Info<< type() << " " << name() << " output:" << nl << endl; IOobject::writeDivider(Info); Info<< endl; @@ -192,21 +206,15 @@ void Foam::functionObjects::writeDictionary::execute() } } } + + return true; } -void Foam::functionObjects::writeDictionary::end() +bool Foam::functionObjects::writeDictionary::write(const bool postProcess) { - execute(); + return true; } -void Foam::functionObjects::writeDictionary::timeSet() -{} - - -void Foam::functionObjects::writeDictionary::write() -{} - - // ************************************************************************* // diff --git a/src/postProcessing/functionObjects/utilities/writeDictionary/writeDictionary.H b/src/postProcessing/functionObjects/utilities/writeDictionary/writeDictionary.H index 5a3f81f9d8d23de532d978d9ad4a6e635bda6021..6cee9467a25ceeb6fd20ae8da9b89f938ff6a10b 100644 --- a/src/postProcessing/functionObjects/utilities/writeDictionary/writeDictionary.H +++ b/src/postProcessing/functionObjects/utilities/writeDictionary/writeDictionary.H @@ -38,8 +38,8 @@ SourceFiles #ifndef functionObjects_writeDictionary_H #define functionObjects_writeDictionary_H +#include "functionObject.H" #include "wordList.H" -#include "runTimeSelectionTables.H" #include "SHA1Digest.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -49,9 +49,6 @@ namespace Foam // Forward declaration of classes class objectRegistry; -class dictionary; -class polyMesh; -class mapPolyMesh; namespace functionObjects { @@ -61,14 +58,11 @@ namespace functionObjects \*---------------------------------------------------------------------------*/ class writeDictionary +: + public functionObject { -protected: - // Private data - //- Name of this set of writeDictionary - word name_; - //- Reference to the database const objectRegistry& obr_; @@ -109,14 +103,12 @@ public: // Constructors - //- Construct for given objectRegistry and dictionary. - // Allow the possibility to load fields from files + //- Construct from Time and dictionary writeDictionary ( const word& name, - const objectRegistry&, - const dictionary&, - const bool loadFromFiles = false + const Time& runTime, + const dictionary& dict ); @@ -126,34 +118,14 @@ public: // Member Functions - //- Return name of the writeDictionary - virtual const word& name() const - { - return name_; - } - //- Read the writeDictionary data - virtual void read(const dictionary&); + virtual bool read(const dictionary&); //- Execute, currently does nothing - virtual void execute(); - - //- Execute at the final time-loop, currently does nothing - virtual void end(); - - //- Called when time was set at the end of the Time::operator++ - virtual void timeSet(); + virtual bool execute(const bool postProcess = false); //- Write the writeDictionary - virtual void write(); - - //- Update for changes of mesh - virtual void updateMesh(const mapPolyMesh&) - {} - - //- Update for changes of mesh - virtual void movePoints(const polyMesh&) - {} + virtual bool write(const bool postProcess = false); }; diff --git a/src/postProcessing/functionObjects/utilities/writeDictionary/writeDictionaryFunctionObject.C b/src/postProcessing/functionObjects/utilities/writeDictionary/writeDictionaryFunctionObject.C deleted file mode 100644 index f16f5921b1291220b158909e2c31ca2713eb7aae..0000000000000000000000000000000000000000 --- a/src/postProcessing/functionObjects/utilities/writeDictionary/writeDictionaryFunctionObject.C +++ /dev/null @@ -1,42 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2012-2016 OpenFOAM Foundation - \\/ 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 <http://www.gnu.org/licenses/>. - -\*---------------------------------------------------------------------------*/ - -#include "writeDictionaryFunctionObject.H" - -// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // - -namespace Foam -{ - defineNamedTemplateTypeNameAndDebug(writeDictionaryFunctionObject, 0); - - addToRunTimeSelectionTable - ( - functionObject, - writeDictionaryFunctionObject, - dictionary - ); -} - -// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/utilities/writeDictionary/writeDictionaryFunctionObject.H b/src/postProcessing/functionObjects/utilities/writeDictionary/writeDictionaryFunctionObject.H deleted file mode 100644 index f75e01271dbaf445db945c95c20e14e9c9be58bf..0000000000000000000000000000000000000000 --- a/src/postProcessing/functionObjects/utilities/writeDictionary/writeDictionaryFunctionObject.H +++ /dev/null @@ -1,54 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2012-2016 OpenFOAM Foundation - \\/ 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 <http://www.gnu.org/licenses/>. - -Typedef - Foam::writeDictionaryFunctionObject - -Description - FunctionObject wrapper around writeDictionary to allow them to be - created via the functions entry within controlDict. - -SourceFiles - writeDictionaryFunctionObject.C - -\*---------------------------------------------------------------------------*/ - -#ifndef writeDictionaryFunctionObject_H -#define writeDictionaryFunctionObject_H - -#include "writeDictionary.H" -#include "OutputFilterFunctionObject.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - typedef OutputFilterFunctionObject<functionObjects::writeDictionary> - writeDictionaryFunctionObject; -} - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#endif - -// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/utilities/writeRegisteredObject/writeRegisteredObject.C b/src/postProcessing/functionObjects/utilities/writeRegisteredObject/writeRegisteredObject.C index 837ddd35fa66b3303b395f120cc9d706c6ea5ce2..0963320dbcfc1af4a84174c9263aaacdbe79ff7c 100644 --- a/src/postProcessing/functionObjects/utilities/writeRegisteredObject/writeRegisteredObject.C +++ b/src/postProcessing/functionObjects/utilities/writeRegisteredObject/writeRegisteredObject.C @@ -24,8 +24,9 @@ License \*---------------------------------------------------------------------------*/ #include "writeRegisteredObject.H" -#include "dictionary.H" #include "Time.H" +#include "polyMesh.H" +#include "addToRunTimeSelectionTable.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -34,6 +35,13 @@ namespace Foam namespace functionObjects { defineTypeNameAndDebug(writeRegisteredObject, 0); + + addToRunTimeSelectionTable + ( + functionObject, + writeRegisteredObject, + dictionary + ); } } @@ -43,14 +51,19 @@ namespace functionObjects Foam::functionObjects::writeRegisteredObject::writeRegisteredObject ( const word& name, - const objectRegistry& obr, - const dictionary& dict, - const bool loadFromFiles + const Time& runTime, + const dictionary& dict ) : - name_(name), + functionObject(name), + obr_ + ( + runTime.lookupObject<objectRegistry> + ( + dict.lookupOrDefault("region", polyMesh::defaultRegion) + ) + ), exclusiveWriting_(false), - obr_(obr), objectNames_() { read(dict); @@ -65,28 +78,30 @@ Foam::functionObjects::writeRegisteredObject::~writeRegisteredObject() // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -void Foam::functionObjects::writeRegisteredObject::read(const dictionary& dict) +bool Foam::functionObjects::writeRegisteredObject::read(const dictionary& dict) { dict.lookup("objectNames") >> objectNames_; dict.readIfPresent("exclusiveWriting", exclusiveWriting_); -} - - -void Foam::functionObjects::writeRegisteredObject::execute() -{} - -void Foam::functionObjects::writeRegisteredObject::end() -{} + return true; +} -void Foam::functionObjects::writeRegisteredObject::timeSet() -{} +bool Foam::functionObjects::writeRegisteredObject::execute +( + const bool postProcess +) +{ + return true; +} -void Foam::functionObjects::writeRegisteredObject::write() +bool Foam::functionObjects::writeRegisteredObject::write +( + const bool postProcess +) { - Info<< type() << " " << name_ << " output:" << nl; + Info<< type() << " " << name() << " output:" << nl; DynamicList<word> allNames(obr_.toc().size()); forAll(objectNames_, i) @@ -124,6 +139,8 @@ void Foam::functionObjects::writeRegisteredObject::write() obj.write(); } + + return true; } diff --git a/src/postProcessing/functionObjects/utilities/writeRegisteredObject/writeRegisteredObject.H b/src/postProcessing/functionObjects/utilities/writeRegisteredObject/writeRegisteredObject.H index 012b35f670852fdfedaf2cccef3d84946dab4ab3..a9979dfa01d8e9468104168cfd29db5743cea236 100644 --- a/src/postProcessing/functionObjects/utilities/writeRegisteredObject/writeRegisteredObject.H +++ b/src/postProcessing/functionObjects/utilities/writeRegisteredObject/writeRegisteredObject.H @@ -64,7 +64,7 @@ Description SeeAlso Foam::functionObject - Foam::OutputFilterFunctionObject + Foam::functionObjects::timeControl SourceFiles writeRegisteredObject.C @@ -74,8 +74,8 @@ SourceFiles #ifndef functionObjects_writeRegisteredObject_H #define functionObjects_writeRegisteredObject_H +#include "functionObject.H" #include "wordReList.H" -#include "runTimeSelectionTables.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -84,9 +84,6 @@ namespace Foam // Forward declaration of classes class objectRegistry; -class dictionary; -class polyMesh; -class mapPolyMesh; namespace functionObjects { @@ -96,27 +93,23 @@ namespace functionObjects \*---------------------------------------------------------------------------*/ class writeRegisteredObject +: + public functionObject { // Private data - //- Name of this set of writeRegisteredObject - word name_; - - //- Takes over the writing from Db - bool exclusiveWriting_; - //- Refererence to Db const objectRegistry& obr_; - // Read from dictionary + //- Takes over the writing from Db + bool exclusiveWriting_; - //- Names of objects to control - wordReList objectNames_; + //- Names of objects to control + wordReList objectNames_; // Private Member Functions - //- Disallow default bitwise copy construct writeRegisteredObject(const writeRegisteredObject&); @@ -132,14 +125,12 @@ public: // Constructors - //- Construct for given objectRegistry and dictionary. - // Allow the possibility to load fields from files + //- Construct from Time and dictionary writeRegisteredObject ( const word& name, - const objectRegistry&, - const dictionary&, - const bool loadFromFiles = false + const Time& runTime, + const dictionary& dict ); @@ -149,34 +140,14 @@ public: // Member Functions - //- Return name of the writeRegisteredObject - virtual const word& name() const - { - return name_; - } - //- Read the writeRegisteredObject 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(); - - //- Called when time was set at the end of the Time::operator++ - virtual void timeSet(); - - //- Write the writeRegisteredObject - virtual void write(); + virtual bool read(const dictionary&); - //- Update for changes of mesh - virtual void updateMesh(const mapPolyMesh&) - {} + //- Do nothing + virtual bool execute(const bool postProcess = false); - //- Update for changes of mesh - virtual void movePoints(const polyMesh&) - {} + //- Write the registered objects + virtual bool write(const bool postProcess = false); }; diff --git a/src/postProcessing/functionObjects/utilities/writeRegisteredObject/writeRegisteredObjectFunctionObject.C b/src/postProcessing/functionObjects/utilities/writeRegisteredObject/writeRegisteredObjectFunctionObject.C deleted file mode 100644 index 1eebe9cefaf014c9920379a503b139ec3d3fa37e..0000000000000000000000000000000000000000 --- a/src/postProcessing/functionObjects/utilities/writeRegisteredObject/writeRegisteredObjectFunctionObject.C +++ /dev/null @@ -1,46 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation - \\/ 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 <http://www.gnu.org/licenses/>. - -\*---------------------------------------------------------------------------*/ - -#include "writeRegisteredObjectFunctionObject.H" - -// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // - -namespace Foam -{ - defineNamedTemplateTypeNameAndDebug - ( - writeRegisteredObjectFunctionObject, - 0 - ); - - addToRunTimeSelectionTable - ( - functionObject, - writeRegisteredObjectFunctionObject, - dictionary - ); -} - -// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/utilities/writeRegisteredObject/writeRegisteredObjectFunctionObject.H b/src/postProcessing/functionObjects/utilities/writeRegisteredObject/writeRegisteredObjectFunctionObject.H deleted file mode 100644 index dd45776f4e7a8fd81b7c6c87924fff320c5e9ec7..0000000000000000000000000000000000000000 --- a/src/postProcessing/functionObjects/utilities/writeRegisteredObject/writeRegisteredObjectFunctionObject.H +++ /dev/null @@ -1,54 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation - \\/ 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 <http://www.gnu.org/licenses/>. - -Typedef - Foam::writeRegisteredObjectFunctionObject - -Description - FunctionObject wrapper around writeRegisteredObject to allow them to be - created via the functions entry within controlDict. - -SourceFiles - writeRegisteredObjectFunctionObject.C - -\*---------------------------------------------------------------------------*/ - -#ifndef writeRegisteredObjectFunctionObject_H -#define writeRegisteredObjectFunctionObject_H - -#include "writeRegisteredObject.H" -#include "OutputFilterFunctionObject.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - typedef OutputFilterFunctionObject<functionObjects::writeRegisteredObject> - writeRegisteredObjectFunctionObject; -} - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#endif - -// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/utilities/yPlus/yPlus.C b/src/postProcessing/functionObjects/utilities/yPlus/yPlus.C index 4384c47acfe88927cb27cd981dc3b6ac211cc166..0becd46aa24f09c8a920b61a0f538656e7b62c3e 100644 --- a/src/postProcessing/functionObjects/utilities/yPlus/yPlus.C +++ b/src/postProcessing/functionObjects/utilities/yPlus/yPlus.C @@ -27,6 +27,7 @@ License #include "volFields.H" #include "turbulentTransportModel.H" #include "turbulentFluidThermoModel.H" +#include "addToRunTimeSelectionTable.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -35,6 +36,13 @@ namespace Foam namespace functionObjects { defineTypeNameAndDebug(yPlus, 0); + + addToRunTimeSelectionTable + ( + functionObject, + yPlus, + dictionary + ); } } @@ -59,18 +67,14 @@ void Foam::functionObjects::yPlus::writeFileHeader(const label i) Foam::functionObjects::yPlus::yPlus ( const word& name, - const objectRegistry& obr, - const dictionary& dict, - const bool loadFromFiles + const Time& runTime, + const dictionary& dict ) : - functionObjectFiles(obr, name, typeName), - name_(name), - obr_(obr), - log_(true), + writeFiles(name, runTime, dict, name), phiName_("phi") { - if (!isA<fvMesh>(obr)) + if (!isA<fvMesh>(obr_)) { FatalErrorInFunction << "objectRegistry is not an fvMesh" << exit(FatalError); @@ -96,6 +100,8 @@ Foam::functionObjects::yPlus::yPlus ); mesh.objectRegistry::store(yPlusPtr); + + resetName(typeName); } @@ -107,19 +113,21 @@ Foam::functionObjects::yPlus::~yPlus() // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -void Foam::functionObjects::yPlus::read(const dictionary& dict) +bool Foam::functionObjects::yPlus::read(const dictionary& dict) { - log_ = dict.lookupOrDefault<Switch>("log", true); + writeFiles::read(dict); phiName_ = dict.lookupOrDefault<word>("phiName", "phi"); + + return true; } -void Foam::functionObjects::yPlus::execute() +bool Foam::functionObjects::yPlus::execute(const bool postProcess) { typedef compressible::turbulenceModel cmpModel; typedef incompressible::turbulenceModel icoModel; - functionObjectFiles::write(); + writeFiles::write(); const fvMesh& mesh = refCast<const fvMesh>(obr_); @@ -129,7 +137,7 @@ void Foam::functionObjects::yPlus::execute() mesh.lookupObject<volScalarField>(type()) ); - if (log_) Info<< type() << " " << name_ << " output:" << nl; + if (log_) Info<< type() << " " << name() << " output:" << nl; tmp<volSymmTensorField> Reff; if (mesh.foundObject<cmpModel>(turbulenceModel::propertiesName)) @@ -152,22 +160,14 @@ void Foam::functionObjects::yPlus::execute() << "Unable to find turbulence model in the " << "database" << exit(FatalError); } -} - -void Foam::functionObjects::yPlus::end() -{ - execute(); + return true; } -void Foam::functionObjects::yPlus::timeSet() -{} - - -void Foam::functionObjects::yPlus::write() +bool Foam::functionObjects::yPlus::write(const bool postProcess) { - functionObjectFiles::write(); + writeFiles::write(); const volScalarField& yPlus = obr_.lookupObject<volScalarField>(type()); @@ -175,6 +175,8 @@ void Foam::functionObjects::yPlus::write() if (log_) Info<< " writing field " << yPlus.name() << nl << endl; yPlus.write(); + + return true; } diff --git a/src/postProcessing/functionObjects/utilities/yPlus/yPlus.H b/src/postProcessing/functionObjects/utilities/yPlus/yPlus.H index a40e3b3dbc704cf370c31cb532b7e6f26c493b1d..8674fa15640ced0987150f5dd9a5dbd48a31df0d 100644 --- a/src/postProcessing/functionObjects/utilities/yPlus/yPlus.H +++ b/src/postProcessing/functionObjects/utilities/yPlus/yPlus.H @@ -31,6 +31,11 @@ Description Evaluates and outputs turbulence y+ for models. Values written to time directories as field 'yPlus' +SeeAlso + Foam::functionObject + Foam::functionObjects::writeFiles + Foam::functionObjects::timeControl + SourceFiles yPlus.C @@ -39,10 +44,8 @@ SourceFiles #ifndef functionObjects_yPlus_H #define functionObjects_yPlus_H -#include "functionObjectFiles.H" +#include "writeFiles.H" #include "volFieldsFwd.H" -#include "Switch.H" -#include "OFstream.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -51,9 +54,6 @@ namespace Foam // Forward declaration of classes class objectRegistry; -class dictionary; -class polyMesh; -class mapPolyMesh; class fvMesh; namespace functionObjects @@ -65,18 +65,10 @@ namespace functionObjects class yPlus : - public functionObjectFiles + public writeFiles { // Private data - //- Name of this set of yPlus objects - word name_; - - const objectRegistry& obr_; - - //- Switch to send output to Info as well as to file - Switch log_; - //- Name of mass/volume flux field (optional, default = phi) word phiName_; @@ -110,14 +102,12 @@ public: // Constructors - //- Construct for given objectRegistry and dictionary. - // Allow the possibility to load fields from files + //- Construct from Time and dictionary yPlus ( const word& name, - const objectRegistry&, - const dictionary&, - const bool loadFromFiles = false + const Time& runTime, + const dictionary& dict ); @@ -127,34 +117,14 @@ public: // Member Functions - //- Return name of the set of yPlus - virtual const word& name() const - { - return name_; - } - //- Read the yPlus data - virtual void read(const dictionary&); + virtual bool read(const dictionary&); //- Execute, currently does nothing - virtual void execute(); - - //- Execute at the final time-loop, currently does nothing - virtual void end(); - - //- Called when time was set at the end of the Time::operator++ - virtual void timeSet(); + virtual bool execute(const bool postProcess = false); //- Calculate the yPlus and write - virtual void write(); - - //- Update for changes of mesh - virtual void updateMesh(const mapPolyMesh&) - {} - - //- Update for changes of mesh - virtual void movePoints(const polyMesh&) - {} + virtual bool write(const bool postProcess = false); }; diff --git a/src/postProcessing/functionObjects/utilities/yPlus/yPlusFunctionObject.C b/src/postProcessing/functionObjects/utilities/yPlus/yPlusFunctionObject.C deleted file mode 100644 index a8d98b7cf7b76c88eef9a1ad213518b866c5e708..0000000000000000000000000000000000000000 --- a/src/postProcessing/functionObjects/utilities/yPlus/yPlusFunctionObject.C +++ /dev/null @@ -1,42 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2012-2015 OpenFOAM Foundation - \\/ 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 <http://www.gnu.org/licenses/>. - -\*---------------------------------------------------------------------------*/ - -#include "yPlusFunctionObject.H" - -// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // - -namespace Foam -{ - defineNamedTemplateTypeNameAndDebug(yPlusFunctionObject, 0); - - addToRunTimeSelectionTable - ( - functionObject, - yPlusFunctionObject, - dictionary - ); -} - -// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/utilities/yPlus/yPlusFunctionObject.H b/src/postProcessing/functionObjects/utilities/yPlus/yPlusFunctionObject.H deleted file mode 100644 index 7075ea2729dfca5f923e30eb4b7ce243fc5384b9..0000000000000000000000000000000000000000 --- a/src/postProcessing/functionObjects/utilities/yPlus/yPlusFunctionObject.H +++ /dev/null @@ -1,54 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2012-2016 OpenFOAM Foundation - \\/ 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 <http://www.gnu.org/licenses/>. - -Typedef - Foam::yPlusFunctionObject - -Description - FunctionObject wrapper around yPlus to allow it to be created - via the functions entry within controlDict. - -SourceFiles - yPlusFunctionObject.C - -\*---------------------------------------------------------------------------*/ - -#ifndef yPlusFunctionObject_H -#define yPlusFunctionObject_H - -#include "yPlus.H" -#include "OutputFilterFunctionObject.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - typedef OutputFilterFunctionObject<functionObjects::yPlus> - yPlusFunctionObject; -} - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#endif - -// ************************************************************************* // diff --git a/src/sampling/Make/files b/src/sampling/Make/files index 8bbc898ddae90ca8fc7496ea36f99e87981e890c..5aec62bba98d037b749558629be835c5be486dfb 100644 --- a/src/sampling/Make/files +++ b/src/sampling/Make/files @@ -1,7 +1,6 @@ probes/probes.C probes/patchProbes.C probes/probesGrouping.C -probes/probesFunctionObject/probesFunctionObject.C sampledSet/circle/circleSet.C sampledSet/cloud/cloudSet.C @@ -14,7 +13,6 @@ sampledSet/patchSeed/patchSeedSet.C sampledSet/sampledSet/sampledSet.C sampledSet/sampledSets/sampledSets.C sampledSet/sampledSets/sampledSetsGrouping.C -sampledSet/sampledSetsFunctionObject/sampledSetsFunctionObject.C sampledSet/triSurfaceMeshPointSet/triSurfaceMeshPointSet.C sampledSet/uniform/uniformSet.C sampledSet/array/arraySet.C @@ -33,7 +31,6 @@ sampledSurface/sampledCuttingPlane/sampledCuttingPlane.C sampledSurface/sampledSurface/sampledSurface.C sampledSurface/sampledSurfaces/sampledSurfaces.C sampledSurface/sampledSurfaces/sampledSurfacesGrouping.C -sampledSurface/sampledSurfacesFunctionObject/sampledSurfacesFunctionObject.C sampledSurface/sampledTriSurfaceMesh/sampledTriSurfaceMesh.C sampledSurface/thresholdCellFaces/thresholdCellFaces.C sampledSurface/thresholdCellFaces/sampledThresholdCellFaces.C diff --git a/src/sampling/Make/options b/src/sampling/Make/options index 23e6bc81a7e708d69b5fd14d27073827646e14ef..8e006e099c47d8568a7fec736b44b74672557f50 100644 --- a/src/sampling/Make/options +++ b/src/sampling/Make/options @@ -4,6 +4,7 @@ EXE_INC = \ -I$(LIB_SRC)/surfMesh/lnInclude \ -I$(LIB_SRC)/fileFormats/lnInclude \ -I$(LIB_SRC)/triSurface/lnInclude \ + -I$(LIB_SRC)/dynamicMesh/lnInclude \ -I$(LIB_SRC)/conversion/lnInclude \ -I$(LIB_SRC)/lagrangian/basic/lnInclude @@ -14,4 +15,5 @@ LIB_LIBS = \ -lfileFormats \ -ltriSurface \ -llagrangian \ + -ldynamicMesh \ -lconversion diff --git a/src/sampling/meshToMesh/meshToMesh.C b/src/sampling/meshToMesh/meshToMesh.C index 6f2c5c0f596aae42ae40b0240c052bc412806cc2..b49ae2a7b05281f38f53e1643d918b287d247d36 100644 --- a/src/sampling/meshToMesh/meshToMesh.C +++ b/src/sampling/meshToMesh/meshToMesh.C @@ -265,28 +265,34 @@ void Foam::meshToMesh::calculate(const word& methodName) } // set up as a reverse distribute - mapDistribute::distribute + mapDistributeBase::distribute ( Pstream::nonBlocking, List<labelPair>(), tgtRegion_.nCells(), map.constructMap(), + false, map.subMap(), + false, tgtToSrcCellAddr_, ListPlusEqOp<label>(), + flipOp(), labelList() ); // set up as a reverse distribute - mapDistribute::distribute + mapDistributeBase::distribute ( Pstream::nonBlocking, List<labelPair>(), tgtRegion_.nCells(), map.constructMap(), + false, map.subMap(), + false, tgtToSrcCellWght_, ListPlusEqOp<scalar>(), + flipOp(), scalarList() ); diff --git a/src/sampling/probes/patchProbes.C b/src/sampling/probes/patchProbes.C index 0d4acb2de6d6e189618858dc5d4003666d4e839c..b29174b368f8c84856a73b6fe5a270d597c3f3b5 100644 --- a/src/sampling/probes/patchProbes.C +++ b/src/sampling/probes/patchProbes.C @@ -29,12 +29,21 @@ License #include "mappedPatchBase.H" #include "treeBoundBox.H" #include "treeDataFace.H" +#include "addToRunTimeSelectionTable.H" + // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // namespace Foam { defineTypeNameAndDebug(patchProbes, 0); + + addToRunTimeSelectionTable + ( + functionObject, + patchProbes, + dictionary + ); } // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // @@ -181,6 +190,26 @@ void Foam::patchProbes::findElements(const fvMesh& mesh) // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // +Foam::patchProbes::patchProbes +( + const word& name, + const Time& t, + const dictionary& dict +) +: + probes(name, t, dict) +{ + // When constructing probes above it will have called the + // probes::findElements (since the virtual mechanism not yet operating). + // Not easy to workaround (apart from feeding through flag into constructor) + // so clear out any cells found for now. + elementList_.clear(); + faceList_.clear(); + + read(dict); +} + + Foam::patchProbes::patchProbes ( const word& name, @@ -189,7 +218,7 @@ Foam::patchProbes::patchProbes const bool loadFromFiles ) : - probes(name, obr, dict, loadFromFiles) + probes(name, obr, dict) { // When constructing probes above it will have called the // probes::findElements (since the virtual mechanism not yet operating). @@ -208,7 +237,7 @@ Foam::patchProbes::~patchProbes() {} -void Foam::patchProbes::write() +bool Foam::patchProbes::write() { if (this->size() && prepare()) { @@ -224,12 +253,15 @@ void Foam::patchProbes::write() sampleAndWriteSurfaceFields(surfaceSymmTensorFields_); sampleAndWriteSurfaceFields(surfaceTensorFields_); } + + return true; } -void Foam::patchProbes::read(const dictionary& dict) + +bool Foam::patchProbes::read(const dictionary& dict) { dict.lookup("patchName") >> patchName_; - probes::read(dict); + return probes::read(dict); } diff --git a/src/sampling/probes/patchProbes.H b/src/sampling/probes/patchProbes.H index a2758b469cce77a72657c3ba3ee30419bfc97bbe..746ad9921dd1bed00dc6994e463c2f684a1fa545 100644 --- a/src/sampling/probes/patchProbes.H +++ b/src/sampling/probes/patchProbes.H @@ -128,6 +128,14 @@ public: // Constructors + //- Construct from Time and dictionary + patchProbes + ( + const word& name, + const Time& time, + const dictionary& dict + ); + //- Construct for given objectRegistry and dictionary. // Allow the possibility to load fields from files patchProbes @@ -146,15 +154,16 @@ public: //- Public members //- Sample and write - virtual void write(); + virtual bool write(); //- Read - virtual void read(const dictionary&); + virtual bool read(const dictionary&); //- Find elements containing patchProbes virtual void findElements(const fvMesh&); }; + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // } // End namespace Foam diff --git a/src/sampling/probes/probes.C b/src/sampling/probes/probes.C index b802e1cb2a35da3cffb532602c2a3ac6aa7dea82..0b7ed5d8d256f2797c713a3b5e630f2c95b7816f 100644 --- a/src/sampling/probes/probes.C +++ b/src/sampling/probes/probes.C @@ -29,12 +29,20 @@ License #include "Time.H" #include "IOmanip.H" #include "mapPolyMesh.H" +#include "addToRunTimeSelectionTable.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // namespace Foam { defineTypeNameAndDebug(probes, 0); + + addToRunTimeSelectionTable + ( + functionObject, + probes, + dictionary + ); } @@ -187,7 +195,7 @@ Foam::label Foam::probes::prepare() fileName probeDir; - fileName probeSubDir = name_; + fileName probeSubDir = name(); if (mesh_.name() != polyMesh::defaultRegion) { @@ -267,6 +275,34 @@ Foam::label Foam::probes::prepare() // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // +Foam::probes::probes +( + const word& name, + const Time& t, + const dictionary& dict +) +: + functionObject(name), + pointField(0), + mesh_ + ( + refCast<const fvMesh> + ( + t.lookupObject<objectRegistry> + ( + dict.lookupOrDefault("region", polyMesh::defaultRegion) + ) + ) + ), + loadFromFiles_(false), + fieldSelection_(), + fixedLocations_(true), + interpolationScheme_("cell") +{ + read(dict); +} + + Foam::probes::probes ( const word& name, @@ -275,8 +311,8 @@ Foam::probes::probes const bool loadFromFiles ) : + functionObject(name), pointField(0), - name_(name), mesh_(refCast<const fvMesh>(obr)), loadFromFiles_(loadFromFiles), fieldSelection_(), @@ -295,19 +331,39 @@ Foam::probes::~probes() // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -void Foam::probes::execute() -{} +bool Foam::probes::read(const dictionary& dict) +{ + dict.lookup("probeLocations") >> *this; + dict.lookup("fields") >> fieldSelection_; + dict.readIfPresent("fixedLocations", fixedLocations_); + if (dict.readIfPresent("interpolationScheme", interpolationScheme_)) + { + if (!fixedLocations_ && interpolationScheme_ != "cell") + { + WarningInFunction + << "Only cell interpolation can be applied when " + << "not using fixedLocations. InterpolationScheme " + << "entry will be ignored"; + } + } -void Foam::probes::end() -{} + // Initialise cells to sample from supplied locations + findElements(mesh_); + prepare(); -void Foam::probes::timeSet() -{} + return true; +} + + +bool Foam::probes::execute(const bool postProcess) +{ + return true; +} -void Foam::probes::write() +bool Foam::probes::write(const bool postProcess) { if (size() && prepare()) { @@ -323,30 +379,8 @@ void Foam::probes::write() sampleAndWriteSurfaceFields(surfaceSymmTensorFields_); sampleAndWriteSurfaceFields(surfaceTensorFields_); } -} - - -void Foam::probes::read(const dictionary& dict) -{ - dict.lookup("probeLocations") >> *this; - dict.lookup("fields") >> fieldSelection_; - dict.readIfPresent("fixedLocations", fixedLocations_); - if (dict.readIfPresent("interpolationScheme", interpolationScheme_)) - { - if (!fixedLocations_ && interpolationScheme_ != "cell") - { - WarningInFunction - << "Only cell interpolation can be applied when " - << "not using fixedLocations. InterpolationScheme " - << "entry will be ignored"; - } - } - - // Initialise cells to sample from supplied locations - findElements(mesh_); - - prepare(); + return true; } diff --git a/src/sampling/probes/probes.H b/src/sampling/probes/probes.H index c9c988cdf488f767273e33bb8da7b3dc683bb36f..30d427cf73c6f20292784966f20ab4f31a36b4e9 100644 --- a/src/sampling/probes/probes.H +++ b/src/sampling/probes/probes.H @@ -40,6 +40,7 @@ SourceFiles #ifndef probes_H #define probes_H +#include "functionObject.H" #include "HashPtrTable.H" #include "OFstream.H" #include "polyMesh.H" @@ -55,6 +56,7 @@ namespace Foam { // Forward declaration of classes +class Time; class objectRegistry; class dictionary; class fvMesh; @@ -66,6 +68,7 @@ class mapPolyMesh; class probes : + public functionObject, public pointField { protected: @@ -89,10 +92,6 @@ protected: // Private data - //- Name of this set of probes, - // Also used as the name of the probes directory. - word name_; - //- Const reference to fvMesh const fvMesh& mesh_; @@ -200,13 +199,21 @@ public: // Constructors + //- Construct from Time and dictionary + probes + ( + const word& name, + const Time& time, + const dictionary& dict + ); + //- Construct for given objectRegistry and dictionary. // Allow the possibility to load fields from files probes ( const word& name, - const objectRegistry&, - const dictionary&, + const objectRegistry& obr, + const dictionary& dict, const bool loadFromFiles = false ); @@ -217,12 +224,6 @@ public: // Member Functions - //- Return name of the set of probes - virtual const word& name() const - { - return name_; - } - //- Return names of fields to probe virtual const wordReList& fieldNames() const { @@ -247,20 +248,14 @@ public: return elementList_; } - //- Execute, currently does nothing - virtual void execute(); - - //- Execute at the final time-loop, currently does nothing - virtual void end(); + //- Read the probes + virtual bool read(const dictionary&); - //- Called when time was set at the end of the Time::operator++ - virtual void timeSet(); + //- Execute, currently does nothing + virtual bool execute(const bool postProcess = false); //- Sample and write - virtual void write(); - - //- Read the probes - virtual void read(const dictionary&); + virtual bool write(const bool postProcess = false); //- Update for changes of mesh virtual void updateMesh(const mapPolyMesh&); diff --git a/src/sampling/probes/probesFunctionObject/probesFunctionObject.C b/src/sampling/probes/probesFunctionObject/probesFunctionObject.C deleted file mode 100644 index bf4a5df69b6ead7693b75155318f737c7b6bacae..0000000000000000000000000000000000000000 --- a/src/sampling/probes/probesFunctionObject/probesFunctionObject.C +++ /dev/null @@ -1,49 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation - \\/ 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 <http://www.gnu.org/licenses/>. - -\*---------------------------------------------------------------------------*/ - -#include "probesFunctionObject.H" - -// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // - -namespace Foam -{ - defineNamedTemplateTypeNameAndDebug(probesFunctionObject, 0); - defineNamedTemplateTypeNameAndDebug(patchProbesFunctionObject, 0); - - addToRunTimeSelectionTable - ( - functionObject, - probesFunctionObject, - dictionary - ); - addToRunTimeSelectionTable - ( - functionObject, - patchProbesFunctionObject, - dictionary - ); -} - -// ************************************************************************* // diff --git a/src/sampling/probes/probesFunctionObject/probesFunctionObject.H b/src/sampling/probes/probesFunctionObject/probesFunctionObject.H deleted file mode 100644 index 1c9f154c00e545cb278610660e79fa12420940f3..0000000000000000000000000000000000000000 --- a/src/sampling/probes/probesFunctionObject/probesFunctionObject.H +++ /dev/null @@ -1,55 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation - \\/ 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 <http://www.gnu.org/licenses/>. - -Typedef - Foam::probesFunctionObject - -Description - FunctionObject wrapper around probes to allow them to be created via the - functions entry within controlDict. - -SourceFiles - probesFunctionObject.C - -\*---------------------------------------------------------------------------*/ - -#ifndef probesFunctionObject_H -#define probesFunctionObject_H - -#include "probes.H" -#include "patchProbes.H" -#include "OutputFilterFunctionObject.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - typedef OutputFilterFunctionObject<probes> probesFunctionObject; - typedef OutputFilterFunctionObject<patchProbes> patchProbesFunctionObject; -} - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#endif - -// ************************************************************************* // diff --git a/src/sampling/sampledSet/sampledSets/sampledSets.C b/src/sampling/sampledSet/sampledSets/sampledSets.C index 986955e262fa976cf43af137a97f8a25a0eb5e58..f75ebafa195d0078422858e68cc19c0a3aecab7d 100644 --- a/src/sampling/sampledSet/sampledSets/sampledSets.C +++ b/src/sampling/sampledSet/sampledSets/sampledSets.C @@ -31,6 +31,7 @@ License #include "SortableList.H" #include "volPointInterpolation.H" #include "mapPolyMesh.H" +#include "addToRunTimeSelectionTable.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -38,9 +39,16 @@ namespace Foam { defineTypeNameAndDebug(sampledSets, 0); - bool sampledSets::verbose_ = false; + addToRunTimeSelectionTable + ( + functionObject, + sampledSets, + dictionary + ); } +bool Foam::sampledSets::verbose_ = false; + // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // @@ -130,6 +138,48 @@ void Foam::sampledSets::combineSampledSets // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // +Foam::sampledSets::sampledSets +( + const word& name, + const Time& t, + const dictionary& dict +) +: + functionObject(name), + PtrList<sampledSet>(), + mesh_ + ( + refCast<const fvMesh> + ( + t.lookupObject<objectRegistry> + ( + dict.lookupOrDefault("region", polyMesh::defaultRegion) + ) + ) + ), + loadFromFiles_(false), + outputPath_(fileName::null), + searchEngine_(mesh_), + interpolationScheme_(word::null), + writeFormat_(word::null) +{ + if (Pstream::parRun()) + { + outputPath_ = mesh_.time().path()/".."/"postProcessing"/name; + } + else + { + outputPath_ = mesh_.time().path()/"postProcessing"/name; + } + if (mesh_.name() != fvMesh::defaultRegion) + { + outputPath_ = outputPath_/mesh_.name(); + } + + read(dict); +} + + Foam::sampledSets::sampledSets ( const word& name, @@ -138,8 +188,8 @@ Foam::sampledSets::sampledSets const bool loadFromFiles ) : + functionObject(name), PtrList<sampledSet>(), - name_(name), mesh_(refCast<const fvMesh>(obr)), loadFromFiles_(loadFromFiles), outputPath_(fileName::null), @@ -149,11 +199,11 @@ Foam::sampledSets::sampledSets { if (Pstream::parRun()) { - outputPath_ = mesh_.time().path()/".."/"postProcessing"/name_; + outputPath_ = mesh_.time().path()/".."/"postProcessing"/name; } else { - outputPath_ = mesh_.time().path()/"postProcessing"/name_; + outputPath_ = mesh_.time().path()/"postProcessing"/name; } if (mesh_.name() != fvMesh::defaultRegion) { @@ -178,19 +228,13 @@ void Foam::sampledSets::verbose(const bool verbosity) } -void Foam::sampledSets::execute() -{} - - -void Foam::sampledSets::end() -{} - - -void Foam::sampledSets::timeSet() -{} +bool Foam::sampledSets::execute(const bool postProcess) +{ + return true; +} -void Foam::sampledSets::write() +bool Foam::sampledSets::write(const bool postProcess) { if (size()) { @@ -230,10 +274,12 @@ void Foam::sampledSets::write() sampleAndWrite(tensorFields_); } } + + return true; } -void Foam::sampledSets::read(const dictionary& dict) +bool Foam::sampledSets::read(const dictionary& dict) { dict_ = dict; @@ -276,6 +322,8 @@ void Foam::sampledSets::read(const dictionary& dict) } Pout<< ")" << endl; } + + return true; } diff --git a/src/sampling/sampledSet/sampledSets/sampledSets.H b/src/sampling/sampledSet/sampledSets/sampledSets.H index 26e494c28d3b8da0f703c53be3337fc693a7e01e..001d33122009d0838d59e73931c2314c6cbc70d3 100644 --- a/src/sampling/sampledSet/sampledSets/sampledSets.H +++ b/src/sampling/sampledSet/sampledSets/sampledSets.H @@ -36,6 +36,7 @@ SourceFiles #ifndef sampledSets_H #define sampledSets_H +#include "functionObject.H" #include "sampledSet.H" #include "volFieldsFwd.H" #include "meshSearch.H" @@ -49,6 +50,8 @@ SourceFiles namespace Foam { +// Forward declaration of classes +class Time; class objectRegistry; class dictionary; class fvMesh; @@ -59,6 +62,7 @@ class fvMesh; class sampledSets : + public functionObject, public PtrList<sampledSet> { // Private classes @@ -153,10 +157,6 @@ class sampledSets // Private data - //- Name of this set of sets, - // Also used as the name of the sampledSets directory. - word name_; - //- Const reference to fvMesh const fvMesh& mesh_; @@ -256,6 +256,14 @@ public: // Constructors + //- Construct from Time and dictionary + sampledSets + ( + const word& name, + const Time& time, + const dictionary& dict + ); + //- Construct for given objectRegistry and dictionary // allow the possibility to load fields from files sampledSets @@ -273,29 +281,17 @@ public: // Member Functions - //- Return name of the set of probes - virtual const word& name() const - { - return name_; - } - //- Set verbosity level void verbose(const bool verbosity = true); - //- Execute, currently does nothing - virtual void execute(); - - //- Execute at the final time-loop, currently does nothing - virtual void end(); + //- Read the sampledSets + virtual bool read(const dictionary&); - //- Called when time was set at the end of the Time::operator++ - virtual void timeSet(); + //- Execute, currently does nothing + virtual bool execute(const bool postProcess = false); //- Sample and write - virtual void write(); - - //- Read the sampledSets - virtual void read(const dictionary&); + virtual bool write(const bool postProcess = false); //- Correct for mesh changes void correct(); diff --git a/src/sampling/sampledSet/sampledSetsFunctionObject/sampledSetsDict b/src/sampling/sampledSet/sampledSetsFunctionObject/sampledSetsDict deleted file mode 100644 index 3150c179fa2107dea7dbc0224564fff3643a8c6c..0000000000000000000000000000000000000000 --- a/src/sampling/sampledSet/sampledSetsFunctionObject/sampledSetsDict +++ /dev/null @@ -1,34 +0,0 @@ -/*--------------------------------*- C++ -*----------------------------------*\ -| ========= | | -| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | -| \\ / O peration | Version: dev | -| \\ / A nd | Web: www.OpenFOAM.org | -| \\/ M anipulation | | -\*---------------------------------------------------------------------------*/ - -functions -{ - // Example of sampling on a line - lines - { - type sets; - - functionObjectLibs ("libsampling.so"); - - writeControl writeTime; - setFormat gnuplot; - fields (p U); - interpolationScheme cellPoint; - sets - ( - diagonal - { - type midPoint; - - axis x; - start (-0.0206 -0.0254 -0.0005); - end (0.29 0.0254 0.0005); - } - ); - } -} diff --git a/src/sampling/sampledSet/sampledSetsFunctionObject/sampledSetsFunctionObject.C b/src/sampling/sampledSet/sampledSetsFunctionObject/sampledSetsFunctionObject.C deleted file mode 100644 index 2a71813e121fe96843064a4cfa39a8a8d63a0bd9..0000000000000000000000000000000000000000 --- a/src/sampling/sampledSet/sampledSetsFunctionObject/sampledSetsFunctionObject.C +++ /dev/null @@ -1,42 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation - \\/ 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 <http://www.gnu.org/licenses/>. - -\*---------------------------------------------------------------------------*/ - -#include "sampledSetsFunctionObject.H" - -// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // - -namespace Foam -{ - defineNamedTemplateTypeNameAndDebug(sampledSetsFunctionObject, 0); - - addToRunTimeSelectionTable - ( - functionObject, - sampledSetsFunctionObject, - dictionary - ); -} - -// ************************************************************************* // diff --git a/src/sampling/sampledSet/sampledSetsFunctionObject/sampledSetsFunctionObject.H b/src/sampling/sampledSet/sampledSetsFunctionObject/sampledSetsFunctionObject.H deleted file mode 100644 index c7b94c64326f11471dd88496044364276c292bd2..0000000000000000000000000000000000000000 --- a/src/sampling/sampledSet/sampledSetsFunctionObject/sampledSetsFunctionObject.H +++ /dev/null @@ -1,54 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation - \\/ 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 <http://www.gnu.org/licenses/>. - -Typedef - Foam::sampledSetsFunctionObject - -Description - FunctionObject wrapper around sets to allow them to be created via the - functions entry within controlDict. - -SourceFiles - sampledSetsFunctionObject.C - -\*---------------------------------------------------------------------------*/ - -#ifndef sampledSetsFunctionObject_H -#define sampledSetsFunctionObject_H - -#include "sampledSets.H" -#include "OutputFilterFunctionObject.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - typedef OutputFilterFunctionObject<sampledSets> - sampledSetsFunctionObject; -} - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#endif - -// ************************************************************************* // diff --git a/src/sampling/sampledSurface/sampledSurfaces/sampledSurfaces.C b/src/sampling/sampledSurface/sampledSurfaces/sampledSurfaces.C index b894d5ea663bbf5563d405c3bf68f8412eea6c40..4c59f5b7d3f0b76af9de30d061bf2700199bd75f 100644 --- a/src/sampling/sampledSurface/sampledSurfaces/sampledSurfaces.C +++ b/src/sampling/sampledSurface/sampledSurfaces/sampledSurfaces.C @@ -31,12 +31,20 @@ License #include "volPointInterpolation.H" #include "PatchTools.H" #include "mapPolyMesh.H" +#include "addToRunTimeSelectionTable.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // namespace Foam { defineTypeNameAndDebug(sampledSurfaces, 0); + + addToRunTimeSelectionTable + ( + functionObject, + sampledSurfaces, + dictionary + ); } bool Foam::sampledSurfaces::verbose_ = false; @@ -85,6 +93,45 @@ void Foam::sampledSurfaces::writeGeometry() const // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // +Foam::sampledSurfaces::sampledSurfaces +( + const word& name, + const Time& t, + const dictionary& dict +) +: + functionObject(name), + PtrList<sampledSurface>(), + mesh_ + ( + refCast<const fvMesh> + ( + t.lookupObject<objectRegistry> + ( + dict.lookupOrDefault("region", polyMesh::defaultRegion) + ) + ) + ), + loadFromFiles_(false), + outputPath_(fileName::null), + fieldSelection_(), + interpolationScheme_(word::null), + mergeList_(), + formatter_(NULL) +{ + if (Pstream::parRun()) + { + outputPath_ = mesh_.time().path()/".."/"postProcessing"/name; + } + else + { + outputPath_ = mesh_.time().path()/"postProcessing"/name; + } + + read(dict); +} + + Foam::sampledSurfaces::sampledSurfaces ( const word& name, @@ -93,8 +140,8 @@ Foam::sampledSurfaces::sampledSurfaces const bool loadFromFiles ) : + functionObject(name), PtrList<sampledSurface>(), - name_(name), mesh_(refCast<const fvMesh>(obr)), loadFromFiles_(loadFromFiles), outputPath_(fileName::null), @@ -105,11 +152,11 @@ Foam::sampledSurfaces::sampledSurfaces { if (Pstream::parRun()) { - outputPath_ = mesh_.time().path()/".."/"postProcessing"/name_; + outputPath_ = mesh_.time().path()/".."/"postProcessing"/name; } else { - outputPath_ = mesh_.time().path()/"postProcessing"/name_; + outputPath_ = mesh_.time().path()/"postProcessing"/name; } read(dict); @@ -130,19 +177,13 @@ void Foam::sampledSurfaces::verbose(const bool verbosity) } -void Foam::sampledSurfaces::execute() -{} - - -void Foam::sampledSurfaces::end() -{} - - -void Foam::sampledSurfaces::timeSet() -{} +bool Foam::sampledSurfaces::execute(const bool postProcess) +{ + return true; +} -void Foam::sampledSurfaces::write() +bool Foam::sampledSurfaces::write(const bool postProcess) { if (size()) { @@ -184,10 +225,12 @@ void Foam::sampledSurfaces::write() sampleAndWrite<surfaceSymmTensorField>(objects); sampleAndWrite<surfaceTensorField>(objects); } + + return true; } -void Foam::sampledSurfaces::read(const dictionary& dict) +bool Foam::sampledSurfaces::read(const dictionary& dict) { bool surfacesFound = dict.found("surfaces"); @@ -243,6 +286,8 @@ void Foam::sampledSurfaces::read(const dictionary& dict) } Pout<< ")" << endl; } + + return true; } diff --git a/src/sampling/sampledSurface/sampledSurfaces/sampledSurfaces.H b/src/sampling/sampledSurface/sampledSurfaces/sampledSurfaces.H index f2c2430e5a693bb363e699b47637e5a98c3c0f1d..77c55de4e184f089d64e8522c8f91d47cc753f09 100644 --- a/src/sampling/sampledSurface/sampledSurfaces/sampledSurfaces.H +++ b/src/sampling/sampledSurface/sampledSurfaces/sampledSurfaces.H @@ -37,6 +37,7 @@ SourceFiles #ifndef sampledSurfaces_H #define sampledSurfaces_H +#include "functionObject.H" #include "sampledSurface.H" #include "surfaceWriter.H" #include "volFieldsFwd.H" @@ -49,6 +50,8 @@ SourceFiles namespace Foam { +// Forward declaration of classes +class Time; class fvMesh; class dictionary; @@ -58,11 +61,11 @@ class dictionary; class sampledSurfaces : + public functionObject, public PtrList<sampledSurface> { // Private classes - //- Class used for surface merging information class mergeInfo { @@ -92,10 +95,6 @@ class sampledSurfaces // Private data - //- Name of this set of surfaces, - // Also used as the name of the sampledSurfaces directory. - const word name_; - //- Const reference to fvMesh const fvMesh& mesh_; @@ -176,6 +175,14 @@ public: // Constructors + //- Construct from Time and dictionary + sampledSurfaces + ( + const word& name, + const Time& time, + const dictionary& dict + ); + //- Construct for given objectRegistry and dictionary // allow the possibility to load fields from files sampledSurfaces @@ -205,30 +212,17 @@ public: // Return false if no surfaces required an update. virtual bool update(); - - //- Return name of the set of surfaces - virtual const word& name() const - { - return name_; - } - //- Set verbosity level void verbose(const bool verbosity = true); - //- Execute, currently does nothing - virtual void execute(); - - //- Execute at the final time-loop, currently does nothing - virtual void end(); + //- Read the sampledSurfaces dictionary + virtual bool read(const dictionary&); - //- Called when time was set at the end of the Time::operator++ - virtual void timeSet(); + //- Execute, currently does nothing + virtual bool execute(const bool postProcess = false); //- Sample and write - virtual void write(); - - //- Read the sampledSurfaces dictionary - virtual void read(const dictionary&); + virtual bool write(const bool postProcess = false); //- Update for changes of mesh - expires the surfaces virtual void updateMesh(const mapPolyMesh&); diff --git a/src/sampling/sampledSurface/sampledSurfacesFunctionObject/sampledSurfacesFunctionObject.C b/src/sampling/sampledSurface/sampledSurfacesFunctionObject/sampledSurfacesFunctionObject.C deleted file mode 100644 index 79797e88047064d14e3551f22df86d34eaa1620e..0000000000000000000000000000000000000000 --- a/src/sampling/sampledSurface/sampledSurfacesFunctionObject/sampledSurfacesFunctionObject.C +++ /dev/null @@ -1,42 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation - \\/ 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 <http://www.gnu.org/licenses/>. - -\*---------------------------------------------------------------------------*/ - -#include "sampledSurfacesFunctionObject.H" - -// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // - -namespace Foam -{ - defineNamedTemplateTypeNameAndDebug(sampledSurfacesFunctionObject, 0); - - addToRunTimeSelectionTable - ( - functionObject, - sampledSurfacesFunctionObject, - dictionary - ); -} - -// ************************************************************************* // diff --git a/src/sampling/sampledSurface/sampledSurfacesFunctionObject/sampledSurfacesFunctionObject.H b/src/sampling/sampledSurface/sampledSurfacesFunctionObject/sampledSurfacesFunctionObject.H deleted file mode 100644 index f24a74f45394c27fe199a7c844cc70289cafa5d6..0000000000000000000000000000000000000000 --- a/src/sampling/sampledSurface/sampledSurfacesFunctionObject/sampledSurfacesFunctionObject.H +++ /dev/null @@ -1,54 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation - \\/ 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 <http://www.gnu.org/licenses/>. - -Typedef - Foam::sampledSurfacesFunctionObject - -Description - FunctionObject wrapper around surfaces to allow them to be created via the - functions entry within controlDict. - -SourceFiles - sampledSurfacesFunctionObject.C - -\*---------------------------------------------------------------------------*/ - -#ifndef sampledSurfacesFunctionObject_H -#define sampledSurfacesFunctionObject_H - -#include "sampledSurfaces.H" -#include "OutputFilterFunctionObject.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - typedef OutputFilterFunctionObject<sampledSurfaces> - sampledSurfacesFunctionObject; -} - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#endif - -// ************************************************************************* // diff --git a/src/thermophysicalModels/reactionThermo/functionObjects/moleFractions/moleFractions.C b/src/thermophysicalModels/reactionThermo/functionObjects/moleFractions/moleFractions.C index fb7837cdd477fa1389be3af5388eb0c086d4ceba..83b88380f766284b68205a3e78c30d15baf2f9de 100644 --- a/src/thermophysicalModels/reactionThermo/functionObjects/moleFractions/moleFractions.C +++ b/src/thermophysicalModels/reactionThermo/functionObjects/moleFractions/moleFractions.C @@ -51,21 +51,13 @@ template<class ThermoType> Foam::moleFractions<ThermoType>::moleFractions ( const word& name, - const objectRegistry& obr, - const dictionary& dict, - const bool loadFromFiles + const Time& t, + const dictionary& dict ) : - functionObjectFiles(obr, name), - name_(name), - mesh_(refCast<const fvMesh>(obr)) + writeFiles(name, t, dict, typeName), + mesh_(refCast<const fvMesh>(obr_)) { - if (!isA<fvMesh>(obr)) - { - FatalErrorInFunction - << "objectRegistry is not an fvMesh" << exit(FatalError); - } - if (mesh_.foundObject<ThermoType>(basicThermo::dictName)) { const ThermoType& thermo = @@ -118,33 +110,28 @@ Foam::moleFractions<ThermoType>::~moleFractions() // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // template<class ThermoType> -void Foam::moleFractions<ThermoType>::read +bool Foam::moleFractions<ThermoType>::read ( const dictionary& dict ) -{} +{ + return true; +} template<class ThermoType> -void Foam::moleFractions<ThermoType>::execute() +bool Foam::moleFractions<ThermoType>::execute(const bool postProcess) { calculateMoleFractions(); + return true; } template<class ThermoType> -void Foam::moleFractions<ThermoType>::end() -{} - - -template<class ThermoType> -void Foam::moleFractions<ThermoType>::timeSet() -{} - - -template<class ThermoType> -void Foam::moleFractions<ThermoType>::write() -{} +bool Foam::moleFractions<ThermoType>::write(const bool postProcess) +{ + return true; +} // ************************************************************************* // diff --git a/src/thermophysicalModels/reactionThermo/functionObjects/moleFractions/moleFractions.H b/src/thermophysicalModels/reactionThermo/functionObjects/moleFractions/moleFractions.H index 05c7fa416a59a9f06cb72b1517f726bea36c15f4..c35771832f7f7b5cdbdf4151b815e34c920df291 100644 --- a/src/thermophysicalModels/reactionThermo/functionObjects/moleFractions/moleFractions.H +++ b/src/thermophysicalModels/reactionThermo/functionObjects/moleFractions/moleFractions.H @@ -50,7 +50,6 @@ Description SeeAlso Foam::functionObject - Foam::OutputFilterFunctionObject SourceFiles moleFractions.C @@ -60,7 +59,7 @@ SourceFiles #ifndef moleFractions_H #define moleFractions_H -#include "functionObjectFiles.H" +#include "writeFiles.H" #include "volFields.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -75,13 +74,10 @@ namespace Foam template<class ThermoType> class moleFractions : - public functionObjectFiles + public functionObjects::writeFiles { // Private data - //- Name of moleFractions functionObject - word name_; - //- Reference to the mesh const fvMesh& mesh_; @@ -109,14 +105,12 @@ public: // Constructors - //- Construct for given objectRegistry and dictionary. - // Allow the possibility to load fields from files + //- Construct from Time and dictionary moleFractions ( const word& name, - const objectRegistry&, - const dictionary&, - const bool loadFromFiles = false + const Time& t, + const dictionary& dict ); @@ -126,34 +120,14 @@ public: // Member Functions - //- Return name of the moleFractions functionObject - virtual const word& name() const - { - return name_; - } - //- Read the moleFractions 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(); - - //- Called when time was set at the end of the Time::operator++ - virtual void timeSet(); - - //- Calculate the moleFractions and write - virtual void write(); + virtual bool read(const dictionary&); - //- Update for changes of mesh - virtual void updateMesh(const mapPolyMesh&) - {} + //- Calculate the mole-fraction fields + virtual bool execute(const bool postProcess = false); - //- Update for changes of mesh - virtual void movePoints(const polyMesh&) - {} + //- The mole-fraction fields auto-write + virtual bool write(const bool postProcess = false); }; diff --git a/src/thermophysicalModels/reactionThermo/functionObjects/moleFractions/moleFractionsFunctionObjects.C b/src/thermophysicalModels/reactionThermo/functionObjects/moleFractions/moleFractionsFunctionObjects.C index 09c5a1d8cceade58d1519d6c787bf0f7e59f3c28..d5f06f47afe6fb3b5be079955ece2bb3c8d615bc 100644 --- a/src/thermophysicalModels/reactionThermo/functionObjects/moleFractions/moleFractionsFunctionObjects.C +++ b/src/thermophysicalModels/reactionThermo/functionObjects/moleFractions/moleFractionsFunctionObjects.C @@ -24,18 +24,12 @@ License \*---------------------------------------------------------------------------*/ #include "moleFractionsFunctionObjects.H" +#include "addToRunTimeSelectionTable.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // namespace Foam { - defineTemplateTypeNameAndDebugWithName - ( - moleFractions<psiReactionThermo>, - "psiReactionThermoMoleFractions", - 0 - ); - defineTemplateTypeNameAndDebugWithName ( psiReactionThermoMoleFractionsFunctionObject, @@ -50,13 +44,6 @@ namespace Foam dictionary ); - defineTemplateTypeNameAndDebugWithName - ( - moleFractions<rhoReactionThermo>, - "rhoReactionThermoMoleFractions", - 0 - ); - defineTemplateTypeNameAndDebugWithName ( rhoReactionThermoMoleFractionsFunctionObject, diff --git a/src/thermophysicalModels/reactionThermo/functionObjects/moleFractions/moleFractionsFunctionObjects.H b/src/thermophysicalModels/reactionThermo/functionObjects/moleFractions/moleFractionsFunctionObjects.H index 21092bba3b4b0540f1382a52f4ad5f18ddd85a87..ffb210aac3d6b936fe34da53db265aed5b7b091c 100644 --- a/src/thermophysicalModels/reactionThermo/functionObjects/moleFractions/moleFractionsFunctionObjects.H +++ b/src/thermophysicalModels/reactionThermo/functionObjects/moleFractions/moleFractionsFunctionObjects.H @@ -25,8 +25,8 @@ Typedef Foam::moleFractionsFunctionObject Description - FunctionObject wrapper around moleFractions to allow - it to be created via the functions entry within controlDict. + Instantiate the moleFractions functionObject for + psiReactionThermo and rhoReactionThermo SourceFiles moleFractionsFunctionObjects.C @@ -36,7 +36,6 @@ SourceFiles #ifndef moleFractionsFunctionObjects_H #define moleFractionsFunctionObjects_H -#include "OutputFilterFunctionObject.H" #include "moleFractions.H" #include "psiReactionThermo.H" #include "rhoReactionThermo.H" @@ -45,11 +44,10 @@ SourceFiles namespace Foam { - typedef OutputFilterFunctionObject<moleFractions<psiReactionThermo>> + typedef moleFractions<psiReactionThermo> psiReactionThermoMoleFractionsFunctionObject; - - typedef OutputFilterFunctionObject<moleFractions<rhoReactionThermo>> + typedef moleFractions<rhoReactionThermo> rhoReactionThermoMoleFractionsFunctionObject; } diff --git a/tutorials/basic/potentialFoam/cylinder/system/controlDict b/tutorials/basic/potentialFoam/cylinder/system/controlDict index 8bfa888ba1d36cf4a2a821ded821f7394f1bf0f2..a303ac75f60ca38939aa90dd0ddaa69598e4f530 100644 --- a/tutorials/basic/potentialFoam/cylinder/system/controlDict +++ b/tutorials/basic/potentialFoam/cylinder/system/controlDict @@ -17,19 +17,19 @@ FoamFile application potentialFoam; -startFrom startTime; +startFrom latestTime; startTime 0; -stopAt endTime; +stopAt nextWrite; endTime 1; deltaT 1; -writeControl timeStep; +writeControl timeStep; -writeInterval 1; +writeInterval 1; purgeWrite 0; @@ -51,7 +51,11 @@ functions { // Load the library containing the 'coded' functionObject functionObjectLibs ("libutilityFunctionObjects.so"); + type coded; + + writeControl timeStep; + // Name of on-the-fly generated functionObject redirectType error; code diff --git a/tutorials/combustion/engineFoam/kivaTest/system/controlDict b/tutorials/combustion/engineFoam/kivaTest/system/controlDict index d417c373768d40e104ae60fab131d3a912b1746b..644dd62afed28584e5ee34941006716021a89731 100644 --- a/tutorials/combustion/engineFoam/kivaTest/system/controlDict +++ b/tutorials/combustion/engineFoam/kivaTest/system/controlDict @@ -60,6 +60,10 @@ functions redirectType setDeltaT; code + #{ + #}; + + codeExecute #{ const Time& runTime = mesh().time(); if (runTime.timeToUserTime(runTime.value()) >= -15.0) diff --git a/tutorials/heatTransfer/chtMultiRegionFoam/multiRegionHeater/Allrun b/tutorials/heatTransfer/chtMultiRegionFoam/multiRegionHeater/Allrun index 602f7159e246c7a5884657fe1cb5338285a73cfc..18867ec91feb2b9d0be4afc69fbf6ea4a71e78d0 100755 --- a/tutorials/heatTransfer/chtMultiRegionFoam/multiRegionHeater/Allrun +++ b/tutorials/heatTransfer/chtMultiRegionFoam/multiRegionHeater/Allrun @@ -18,7 +18,7 @@ done for i in bottomWater topAir heater leftSolid rightSolid do - runApplication -s $i changeDictionary -region $i + runApplication -s $i changeDictionary -region $i done diff --git a/tutorials/incompressible/simpleFoam/motorBike/system/wallBoundedStreamLines b/tutorials/incompressible/simpleFoam/motorBike/system/wallBoundedStreamLines index a6dccc670550204a97f71a7a7e023d3dc01759d2..4d13d7d4025dc499c0eeff6269d0ccf3bd9bae8a 100644 --- a/tutorials/incompressible/simpleFoam/motorBike/system/wallBoundedStreamLines +++ b/tutorials/incompressible/simpleFoam/motorBike/system/wallBoundedStreamLines @@ -17,6 +17,9 @@ near // Output every writeControl writeTime; + // Calculate every + executeControl writeTime; + // Fields to be sampled. Per field original name and mapped field to // create. // Note: fields only get updated when writing!