diff --git a/bin/foamNewFunctionObject b/bin/foamNewFunctionObject index a6de93f70d..a2f5d2bf20 100755 --- a/bin/foamNewFunctionObject +++ b/bin/foamNewFunctionObject @@ -42,8 +42,6 @@ Usage: $Script [-h | -help] (dir) - .H - .C - - FunctionObject.H - - FunctionObject.C - IO.H - Make (dir) - files diff --git a/etc/codeTemplates/functionObject/FUNCTIONOBJECT.C b/etc/codeTemplates/functionObject/FUNCTIONOBJECT.C index 4cdaf575bc..ad866cfbee 100644 --- a/etc/codeTemplates/functionObject/FUNCTIONOBJECT.C +++ b/etc/codeTemplates/functionObject/FUNCTIONOBJECT.C @@ -24,28 +24,39 @@ License \*---------------------------------------------------------------------------*/ #include "FUNCTIONOBJECT.H" -#include "dictionary.H" +#include "Time.H" +#include "fvMesh.H" +#include "addToRunTimeSelectionTable.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // namespace Foam +{ +namespace functionObjects { defineTypeNameAndDebug(FUNCTIONOBJECT, 0); + addToRunTimeSelectionTable(functionObject, FUNCTIONOBJECT, dictionary); +} } // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // -Foam::FUNCTIONOBJECT::FUNCTIONOBJECT +Foam::functionObjects::FUNCTIONOBJECT::FUNCTIONOBJECT ( 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 + ( + dict.lookupOrDefault("region", polyMesh::defaultRegion) + ) + ), wordData_(dict.lookupOrDefault("wordData", "defaultWord")), scalarData_(readScalar(dict.lookup("scalarData"))), labelData_(readLabel(dict.lookup("labelData"))) @@ -56,34 +67,44 @@ Foam::FUNCTIONOBJECT::FUNCTIONOBJECT // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // -Foam::FUNCTIONOBJECT::~FUNCTIONOBJECT() +Foam::functionObjects::FUNCTIONOBJECT::~FUNCTIONOBJECT() {} // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -void Foam::FUNCTIONOBJECT::read(const dictionary& dict) +bool Foam::functionObjects::FUNCTIONOBJECT::read(const dictionary& dict) { dict.readIfPresent("wordData", wordData_); dict.lookup("scalarData") >> scalarData_; dict.lookup("labelData") >> labelData_; + + return true; } -void Foam::FUNCTIONOBJECT::execute() -{} +bool Foam::functionObjects::FUNCTIONOBJECT::execute(const bool postProcess) +{ + return true; +} -void Foam::FUNCTIONOBJECT::end() -{} +bool Foam::functionObjects::FUNCTIONOBJECT::end() +{ + return true; +} -void Foam::FUNCTIONOBJECT::timeSet() -{} +bool Foam::functionObjects::FUNCTIONOBJECT::timeSet() +{ + return true; +} -void Foam::FUNCTIONOBJECT::write() -{} +bool Foam::functionObjects::FUNCTIONOBJECT::write(const bool postProcess) +{ + return true; +} // ************************************************************************* // diff --git a/etc/codeTemplates/functionObject/FUNCTIONOBJECT.H b/etc/codeTemplates/functionObject/FUNCTIONOBJECT.H index ad45ba61b4..6dbf37d3fb 100644 --- a/etc/codeTemplates/functionObject/FUNCTIONOBJECT.H +++ b/etc/codeTemplates/functionObject/FUNCTIONOBJECT.H @@ -22,7 +22,7 @@ License along with OpenFOAM. If not, see . Class - Foam::FUNCTIONOBJECT + Foam::functionObjects::FUNCTIONOBJECT Group @@ -59,7 +59,7 @@ SourceFiles #ifndef FUNCTIONOBJECT_H #define FUNCTIONOBJECT_H -#include "runTimeSelectionTables.H" +#include "functionObject.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -68,22 +68,21 @@ namespace Foam // Forward declaration of classes class objectRegistry; -class dictionary; -class polyMesh; -class mapPolyMesh; + +namespace functionObjects +{ /*---------------------------------------------------------------------------*\ Class FUNCTIONOBJECT Declaration \*---------------------------------------------------------------------------*/ class FUNCTIONOBJECT +: + public functionObject { // Private data - //- Name of this set of FUNCTIONOBJECT - word name_; - - //- Refererence to Db + //- Refererence to the objectRegistry const objectRegistry& obr_; // Read from dictionary @@ -116,14 +115,12 @@ public: // Constructors - //- Construct for given objectRegistry and dictionary. - // Allow the possibility to load fields from files + //- Construct from Time and dictionary FUNCTIONOBJECT ( const word& name, - const objectRegistry&, - const dictionary&, - const bool loadFromFiles = false + const Time& runTime, + const dictionary& dict ); @@ -133,39 +130,26 @@ public: // Member Functions - //- Return name of the FUNCTIONOBJECT - const word& name() const - { - return name_; - } - //- Read the FUNCTIONOBJECT data - virtual void read(const dictionary&); + virtual bool read(const dictionary&); //- Execute, currently does nothing - virtual void execute(); + virtual bool execute(const bool postProcess = false); //- Execute at the final time-loop, currently does nothing - virtual void end(); + virtual bool end(); //- Called when time was set at the end of the Time::operator++ - virtual void timeSet(); + virtual bool timeSet(); //- Write the FUNCTIONOBJECT - 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); }; // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // +} // End namespace functionObjects } // End namespace Foam // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/etc/codeTemplates/functionObject/FUNCTIONOBJECTFunctionObject.C b/etc/codeTemplates/functionObject/FUNCTIONOBJECTFunctionObject.C deleted file mode 100644 index b10ecc5098..0000000000 --- a/etc/codeTemplates/functionObject/FUNCTIONOBJECTFunctionObject.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 . - -\*---------------------------------------------------------------------------*/ - -#include "FUNCTIONOBJECTFunctionObject.H" - -// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // - -namespace Foam -{ - defineNamedTemplateTypeNameAndDebug - ( - FUNCTIONOBJECTFunctionObject, - 0 - ); - - addToRunTimeSelectionTable - ( - functionObject, - FUNCTIONOBJECTFunctionObject, - dictionary - ); -} - -// ************************************************************************* // diff --git a/etc/codeTemplates/functionObject/Make/files b/etc/codeTemplates/functionObject/Make/files index 73b9956031..fb04c4e1df 100644 --- a/etc/codeTemplates/functionObject/Make/files +++ b/etc/codeTemplates/functionObject/Make/files @@ -1,4 +1,3 @@ FUNCTIONOBJECT.C -FUNCTIONOBJECTFunctionObject.C LIB = $(FOAM_USER_LIBBIN)/libFUNCTIONOBJECTFunctionObject