From 09262f527361e39a4cb184ac184934dc9fc54922 Mon Sep 17 00:00:00 2001 From: Henry Weller <http://cfd.direct> Date: Sun, 1 May 2016 14:48:30 +0100 Subject: [PATCH] src/postProcessing/functionObjects: Moving the functionObjects into the "functionObjects" namespace --- .../IO/partialWrite/partialWrite.C | 54 ++++++++---- .../IO/partialWrite/partialWrite.H | 16 +++- .../partialWrite/partialWriteFunctionObject.H | 4 +- .../IO/partialWrite/partialWriteTemplates.C | 4 +- .../removeRegisteredObject.C | 45 ++++++---- .../removeRegisteredObject.H | 14 ++++ .../removeRegisteredObjectFunctionObject.H | 4 +- .../IO/writeDictionary/writeDictionary.C | 48 +++++++---- .../IO/writeDictionary/writeDictionary.H | 14 ++++ .../writeDictionaryFunctionObject.H | 4 +- .../writeRegisteredObject.C | 49 +++++++---- .../writeRegisteredObject.H | 14 ++++ .../writeRegisteredObjectFunctionObject.H | 4 +- .../cloud/cloudInfo/cloudInfo.C | 35 ++++++-- .../cloud/cloudInfo/cloudInfo.H | 14 ++++ .../cloud/cloudInfo/cloudInfoFunctionObject.H | 4 +- .../field/histogram/histogram.C | 5 +- .../forces/forceCoeffs/forceCoeffs.C | 55 ++++++++---- .../forces/forceCoeffs/forceCoeffs.H | 15 +++- .../forceCoeffs/forceCoeffsFunctionObject.H | 5 +- .../functionObjects/forces/forces/forces.C | 84 ++++++++++++------- .../functionObjects/forces/forces/forces.H | 13 +++ .../forces/forces/forcesFunctionObject.H | 5 +- src/rigidBodyMeshMotion/rigidBodyMeshMotion.C | 4 +- ...gidBodyDisplacementPointPatchVectorField.C | 4 +- .../sixDoFRigidBodyMotionSolver.C | 4 +- 26 files changed, 375 insertions(+), 146 deletions(-) diff --git a/src/postProcessing/functionObjects/IO/partialWrite/partialWrite.C b/src/postProcessing/functionObjects/IO/partialWrite/partialWrite.C index a681b856930..c04f6eca2d2 100644 --- a/src/postProcessing/functionObjects/IO/partialWrite/partialWrite.C +++ b/src/postProcessing/functionObjects/IO/partialWrite/partialWrite.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2014-2015 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2014-2016 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -33,14 +33,17 @@ License // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // namespace Foam +{ +namespace functionObjects { defineTypeNameAndDebug(partialWrite, 0); } +} // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // -Foam::partialWrite::partialWrite +Foam::functionObjects::partialWrite::partialWrite ( const word& name, const objectRegistry& obr, @@ -55,15 +58,38 @@ Foam::partialWrite::partialWrite } +Foam::autoPtr<Foam::functionObjects::partialWrite> +Foam::functionObjects::partialWrite::New +( + const word& name, + const objectRegistry& obr, + const dictionary& dict, + const bool loadFromFiles +) +{ + if (isA<fvMesh>(obr)) + { + return autoPtr<partialWrite> + ( + new partialWrite(name, obr, dict, loadFromFiles) + ); + } + else + { + return autoPtr<partialWrite>(); + } +} + + // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // -Foam::partialWrite::~partialWrite() +Foam::functionObjects::partialWrite::~partialWrite() {} // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -void Foam::partialWrite::read(const dictionary& dict) +void Foam::functionObjects::partialWrite::read(const dictionary& dict) { dict.lookup("objectNames") >> objectNames_; dict.lookup("writeInterval") >> writeInterval_; @@ -72,6 +98,7 @@ void Foam::partialWrite::read(const dictionary& dict) Info<< type() << " " << name() << ":" << nl << " dumping every " << writeInterval_ << " th outputTime : " << nl << endl ; + forAllConstIter(HashSet<word>, objectNames_, iter) { Info<< ' ' << iter.key(); @@ -109,19 +136,15 @@ void Foam::partialWrite::read(const dictionary& dict) } -void Foam::partialWrite::execute() -{ -} +void Foam::functionObjects::partialWrite::execute() +{} -void Foam::partialWrite::end() -{ - //Pout<< "end at time " << obr_.time().timeName() << endl; - // Do nothing - only valid on write -} +void Foam::functionObjects::partialWrite::end() +{} -void Foam::partialWrite::timeSet() +void Foam::functionObjects::partialWrite::timeSet() { if (obr_.time().outputTime()) { @@ -171,10 +194,9 @@ void Foam::partialWrite::timeSet() } -void Foam::partialWrite::write() +void Foam::functionObjects::partialWrite::write() { - // Do nothing. The fields get written through the - // standard dump + // Fields are written in the standard manner } diff --git a/src/postProcessing/functionObjects/IO/partialWrite/partialWrite.H b/src/postProcessing/functionObjects/IO/partialWrite/partialWrite.H index 59f101619f2..a49aabc1293 100644 --- a/src/postProcessing/functionObjects/IO/partialWrite/partialWrite.H +++ b/src/postProcessing/functionObjects/IO/partialWrite/partialWrite.H @@ -81,6 +81,9 @@ class dictionary; class polyMesh; class mapPolyMesh; +namespace functionObjects +{ + /*---------------------------------------------------------------------------*\ Class partialWrite Declaration \*---------------------------------------------------------------------------*/ @@ -91,7 +94,7 @@ protected: // Private data - //- Name of this set of partialWrite + //- Name of this partialWrite functionObject word name_; const objectRegistry& obr_; @@ -168,6 +171,16 @@ public: const bool loadFromFiles = false ); + //- Construct on free-store and return pointer if successful + // otherwise return a null-pointer + static autoPtr<partialWrite> New + ( + const word& name, + const objectRegistry&, + const dictionary&, + const bool loadFromFiles = false + ); + //- Destructor virtual ~partialWrite(); @@ -208,6 +221,7 @@ public: // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // +} // End namespace functionObjects } // End namespace Foam // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/src/postProcessing/functionObjects/IO/partialWrite/partialWriteFunctionObject.H b/src/postProcessing/functionObjects/IO/partialWrite/partialWriteFunctionObject.H index a84b02aa115..a65a095fe58 100644 --- a/src/postProcessing/functionObjects/IO/partialWrite/partialWriteFunctionObject.H +++ b/src/postProcessing/functionObjects/IO/partialWrite/partialWriteFunctionObject.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -43,7 +43,7 @@ SourceFiles namespace Foam { - typedef OutputFilterFunctionObject<partialWrite> + typedef OutputFilterFunctionObject<functionObjects::partialWrite> partialWriteFunctionObject; } diff --git a/src/postProcessing/functionObjects/IO/partialWrite/partialWriteTemplates.C b/src/postProcessing/functionObjects/IO/partialWrite/partialWriteTemplates.C index ea6683fffe4..0cd06903c9e 100644 --- a/src/postProcessing/functionObjects/IO/partialWrite/partialWriteTemplates.C +++ b/src/postProcessing/functionObjects/IO/partialWrite/partialWriteTemplates.C @@ -31,7 +31,7 @@ License // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // template<class Type> -void Foam::partialWrite::loadField +void Foam::functionObjects::partialWrite::loadField ( const word& fieldName, UPtrList<GeometricField<Type, fvPatchField, volMesh>>& vflds, @@ -83,7 +83,7 @@ void Foam::partialWrite::loadField template<class Type> -void Foam::partialWrite::changeWriteOptions +void Foam::functionObjects::partialWrite::changeWriteOptions ( UPtrList<GeometricField<Type, fvPatchField, volMesh>>& vflds, UPtrList<GeometricField<Type, fvsPatchField, surfaceMesh>>& sflds, diff --git a/src/postProcessing/functionObjects/IO/removeRegisteredObject/removeRegisteredObject.C b/src/postProcessing/functionObjects/IO/removeRegisteredObject/removeRegisteredObject.C index 28bb18292eb..ea296544c3f 100644 --- a/src/postProcessing/functionObjects/IO/removeRegisteredObject/removeRegisteredObject.C +++ b/src/postProcessing/functionObjects/IO/removeRegisteredObject/removeRegisteredObject.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2013-2014 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2013-2016 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -31,13 +31,16 @@ License namespace Foam { -defineTypeNameAndDebug(removeRegisteredObject, 0); +namespace functionObjects +{ + defineTypeNameAndDebug(removeRegisteredObject, 0); +} } // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // -Foam::removeRegisteredObject::removeRegisteredObject +Foam::functionObjects::removeRegisteredObject::removeRegisteredObject ( const word& name, const objectRegistry& obr, @@ -53,21 +56,37 @@ Foam::removeRegisteredObject::removeRegisteredObject } +Foam::autoPtr<Foam::functionObjects::removeRegisteredObject> +Foam::functionObjects::removeRegisteredObject::New +( + const word& name, + const objectRegistry& obr, + const dictionary& dict, + const bool loadFromFiles +) +{ + return autoPtr<removeRegisteredObject> + ( + new removeRegisteredObject(name, obr, dict, loadFromFiles) + ); +} + + // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // -Foam::removeRegisteredObject::~removeRegisteredObject() +Foam::functionObjects::removeRegisteredObject::~removeRegisteredObject() {} // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -void Foam::removeRegisteredObject::read(const dictionary& dict) +void Foam::functionObjects::removeRegisteredObject::read(const dictionary& dict) { dict.lookup("objectNames") >> objectNames_; } -void Foam::removeRegisteredObject::execute() +void Foam::functionObjects::removeRegisteredObject::execute() { forAll(objectNames_, i) { @@ -90,22 +109,18 @@ void Foam::removeRegisteredObject::execute() } -void Foam::removeRegisteredObject::end() +void Foam::functionObjects::removeRegisteredObject::end() { execute(); } -void Foam::removeRegisteredObject::timeSet() -{ - // Do nothing - only valid on execute -} +void Foam::functionObjects::removeRegisteredObject::timeSet() +{} -void Foam::removeRegisteredObject::write() -{ - // Do nothing - only valid on execute -} +void Foam::functionObjects::removeRegisteredObject::write() +{} // ************************************************************************* // diff --git a/src/postProcessing/functionObjects/IO/removeRegisteredObject/removeRegisteredObject.H b/src/postProcessing/functionObjects/IO/removeRegisteredObject/removeRegisteredObject.H index 8a9b2774f9c..860a2e98635 100644 --- a/src/postProcessing/functionObjects/IO/removeRegisteredObject/removeRegisteredObject.H +++ b/src/postProcessing/functionObjects/IO/removeRegisteredObject/removeRegisteredObject.H @@ -75,6 +75,9 @@ class dictionary; class polyMesh; class mapPolyMesh; +namespace functionObjects +{ + /*---------------------------------------------------------------------------*\ Class removeRegisteredObject Declaration \*---------------------------------------------------------------------------*/ @@ -125,6 +128,16 @@ public: const bool loadFromFiles = false ); + //- Construct on free-store and return pointer if successful + // otherwise return a null-pointer + static autoPtr<removeRegisteredObject> New + ( + const word& name, + const objectRegistry&, + const dictionary&, + const bool loadFromFiles = false + ); + //- Destructor virtual ~removeRegisteredObject(); @@ -165,6 +178,7 @@ public: // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // +} // End namespace functionObjects } // End namespace Foam // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/src/postProcessing/functionObjects/IO/removeRegisteredObject/removeRegisteredObjectFunctionObject.H b/src/postProcessing/functionObjects/IO/removeRegisteredObject/removeRegisteredObjectFunctionObject.H index 9bc0e1be51b..e166d00be7e 100644 --- a/src/postProcessing/functionObjects/IO/removeRegisteredObject/removeRegisteredObjectFunctionObject.H +++ b/src/postProcessing/functionObjects/IO/removeRegisteredObject/removeRegisteredObjectFunctionObject.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2012 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2012-2016 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -43,7 +43,7 @@ SourceFiles namespace Foam { - typedef OutputFilterFunctionObject<removeRegisteredObject> + typedef OutputFilterFunctionObject<functionObjects::removeRegisteredObject> removeRegisteredObjectFunctionObject; } diff --git a/src/postProcessing/functionObjects/IO/writeDictionary/writeDictionary.C b/src/postProcessing/functionObjects/IO/writeDictionary/writeDictionary.C index 0e6ec44ce8c..7acd2abefbc 100644 --- a/src/postProcessing/functionObjects/IO/writeDictionary/writeDictionary.C +++ b/src/postProcessing/functionObjects/IO/writeDictionary/writeDictionary.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2013-2014 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2013-2016 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -32,13 +32,16 @@ License namespace Foam { -defineTypeNameAndDebug(writeDictionary, 0); +namespace functionObjects +{ + defineTypeNameAndDebug(writeDictionary, 0); +} } // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // -bool Foam::writeDictionary::tryDirectory +bool Foam::functionObjects::writeDictionary::tryDirectory ( const label dictI, const word& location, @@ -86,7 +89,7 @@ bool Foam::writeDictionary::tryDirectory // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // -Foam::writeDictionary::writeDictionary +Foam::functionObjects::writeDictionary::writeDictionary ( const word& name, const objectRegistry& obr, @@ -100,20 +103,35 @@ Foam::writeDictionary::writeDictionary digests_() { read(dict); - execute(); } +Foam::autoPtr<Foam::functionObjects::writeDictionary> +Foam::functionObjects::writeDictionary::New +( + const word& name, + const objectRegistry& obr, + const dictionary& dict, + const bool loadFromFiles +) +{ + return autoPtr<writeDictionary> + ( + new writeDictionary(name, obr, dict, loadFromFiles) + ); +} + + // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // -Foam::writeDictionary::~writeDictionary() +Foam::functionObjects::writeDictionary::~writeDictionary() {} // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -void Foam::writeDictionary::read(const dictionary& dict) +void Foam::functionObjects::writeDictionary::read(const dictionary& dict) { wordList dictNames(dict.lookup("dictNames")); HashSet<word> uniqueNames(dictNames); @@ -137,7 +155,7 @@ void Foam::writeDictionary::read(const dictionary& dict) } -void Foam::writeDictionary::execute() +void Foam::functionObjects::writeDictionary::execute() { bool firstDict = true; forAll(dictNames_, i) @@ -193,22 +211,18 @@ void Foam::writeDictionary::execute() } -void Foam::writeDictionary::end() +void Foam::functionObjects::writeDictionary::end() { execute(); } -void Foam::writeDictionary::timeSet() -{ - // do nothing -} +void Foam::functionObjects::writeDictionary::timeSet() +{} -void Foam::writeDictionary::write() -{ - // do nothing -} +void Foam::functionObjects::writeDictionary::write() +{} // ************************************************************************* // diff --git a/src/postProcessing/functionObjects/IO/writeDictionary/writeDictionary.H b/src/postProcessing/functionObjects/IO/writeDictionary/writeDictionary.H index 9282daec354..19d42766efc 100644 --- a/src/postProcessing/functionObjects/IO/writeDictionary/writeDictionary.H +++ b/src/postProcessing/functionObjects/IO/writeDictionary/writeDictionary.H @@ -54,6 +54,9 @@ class dictionary; class polyMesh; class mapPolyMesh; +namespace functionObjects +{ + /*---------------------------------------------------------------------------*\ Class writeDictionary Declaration \*---------------------------------------------------------------------------*/ @@ -117,6 +120,16 @@ public: const bool loadFromFiles = false ); + //- Construct on free-store and return pointer if successful + // otherwise return a null-pointer + static autoPtr<writeDictionary> New + ( + const word& name, + const objectRegistry&, + const dictionary&, + const bool loadFromFiles = false + ); + //- Destructor virtual ~writeDictionary(); @@ -157,6 +170,7 @@ public: // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // +} // End namespace functionObjects } // End namespace Foam // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/src/postProcessing/functionObjects/IO/writeDictionary/writeDictionaryFunctionObject.H b/src/postProcessing/functionObjects/IO/writeDictionary/writeDictionaryFunctionObject.H index 2f53fd5d2e9..f75e01271db 100644 --- a/src/postProcessing/functionObjects/IO/writeDictionary/writeDictionaryFunctionObject.H +++ b/src/postProcessing/functionObjects/IO/writeDictionary/writeDictionaryFunctionObject.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2012 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2012-2016 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -43,7 +43,7 @@ SourceFiles namespace Foam { - typedef OutputFilterFunctionObject<writeDictionary> + typedef OutputFilterFunctionObject<functionObjects::writeDictionary> writeDictionaryFunctionObject; } diff --git a/src/postProcessing/functionObjects/IO/writeRegisteredObject/writeRegisteredObject.C b/src/postProcessing/functionObjects/IO/writeRegisteredObject/writeRegisteredObject.C index 35513a0b8b4..ad68d6b9aea 100644 --- a/src/postProcessing/functionObjects/IO/writeRegisteredObject/writeRegisteredObject.C +++ b/src/postProcessing/functionObjects/IO/writeRegisteredObject/writeRegisteredObject.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -31,13 +31,16 @@ License namespace Foam { -defineTypeNameAndDebug(writeRegisteredObject, 0); +namespace functionObjects +{ + defineTypeNameAndDebug(writeRegisteredObject, 0); +} } // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // -Foam::writeRegisteredObject::writeRegisteredObject +Foam::functionObjects::writeRegisteredObject::writeRegisteredObject ( const word& name, const objectRegistry& obr, @@ -54,40 +57,50 @@ Foam::writeRegisteredObject::writeRegisteredObject } +Foam::autoPtr<Foam::functionObjects::writeRegisteredObject> +Foam::functionObjects::writeRegisteredObject::New +( + const word& name, + const objectRegistry& obr, + const dictionary& dict, + const bool loadFromFiles +) +{ + return autoPtr<writeRegisteredObject> + ( + new writeRegisteredObject(name, obr, dict, loadFromFiles) + ); +} + + // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // -Foam::writeRegisteredObject::~writeRegisteredObject() +Foam::functionObjects::writeRegisteredObject::~writeRegisteredObject() {} // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -void Foam::writeRegisteredObject::read(const dictionary& dict) +void Foam::functionObjects::writeRegisteredObject::read(const dictionary& dict) { dict.lookup("objectNames") >> objectNames_; dict.readIfPresent("exclusiveWriting", exclusiveWriting_); } -void Foam::writeRegisteredObject::execute() -{ - // Do nothing - only valid on write -} +void Foam::functionObjects::writeRegisteredObject::execute() +{} -void Foam::writeRegisteredObject::end() -{ - // Do nothing - only valid on write -} +void Foam::functionObjects::writeRegisteredObject::end() +{} -void Foam::writeRegisteredObject::timeSet() -{ - // Do nothing - only valid on write -} +void Foam::functionObjects::writeRegisteredObject::timeSet() +{} -void Foam::writeRegisteredObject::write() +void Foam::functionObjects::writeRegisteredObject::write() { Info<< type() << " " << name_ << " output:" << nl; diff --git a/src/postProcessing/functionObjects/IO/writeRegisteredObject/writeRegisteredObject.H b/src/postProcessing/functionObjects/IO/writeRegisteredObject/writeRegisteredObject.H index a4fd4dec630..37bb625c4e8 100644 --- a/src/postProcessing/functionObjects/IO/writeRegisteredObject/writeRegisteredObject.H +++ b/src/postProcessing/functionObjects/IO/writeRegisteredObject/writeRegisteredObject.H @@ -89,6 +89,9 @@ class dictionary; class polyMesh; class mapPolyMesh; +namespace functionObjects +{ + /*---------------------------------------------------------------------------*\ Class writeRegisteredObject Declaration \*---------------------------------------------------------------------------*/ @@ -140,6 +143,16 @@ public: const bool loadFromFiles = false ); + //- Construct on free-store and return pointer if successful + // otherwise return a null-pointer + static autoPtr<writeRegisteredObject> New + ( + const word& name, + const objectRegistry&, + const dictionary&, + const bool loadFromFiles = false + ); + //- Destructor virtual ~writeRegisteredObject(); @@ -180,6 +193,7 @@ public: // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // +} // End namespace functionObjects } // End namespace Foam // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/src/postProcessing/functionObjects/IO/writeRegisteredObject/writeRegisteredObjectFunctionObject.H b/src/postProcessing/functionObjects/IO/writeRegisteredObject/writeRegisteredObjectFunctionObject.H index a7e47134f78..dd45776f4e7 100644 --- a/src/postProcessing/functionObjects/IO/writeRegisteredObject/writeRegisteredObjectFunctionObject.H +++ b/src/postProcessing/functionObjects/IO/writeRegisteredObject/writeRegisteredObjectFunctionObject.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -43,7 +43,7 @@ SourceFiles namespace Foam { - typedef OutputFilterFunctionObject<writeRegisteredObject> + typedef OutputFilterFunctionObject<functionObjects::writeRegisteredObject> writeRegisteredObjectFunctionObject; } diff --git a/src/postProcessing/functionObjects/cloud/cloudInfo/cloudInfo.C b/src/postProcessing/functionObjects/cloud/cloudInfo/cloudInfo.C index 902c79d0cfe..f17f3668455 100644 --- a/src/postProcessing/functionObjects/cloud/cloudInfo/cloudInfo.C +++ b/src/postProcessing/functionObjects/cloud/cloudInfo/cloudInfo.C @@ -30,14 +30,17 @@ License // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // namespace Foam +{ +namespace functionObjects { defineTypeNameAndDebug(cloudInfo, 0); } +} // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * // -void Foam::cloudInfo::writeFileHeader(const label i) +void Foam::functionObjects::cloudInfo::writeFileHeader(const label i) { writeHeader(file(), "Cloud information"); writeCommented(file(), "Time"); @@ -49,7 +52,7 @@ void Foam::cloudInfo::writeFileHeader(const label i) // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // -Foam::cloudInfo::cloudInfo +Foam::functionObjects::cloudInfo::cloudInfo ( const word& name, const objectRegistry& obr, @@ -66,15 +69,31 @@ Foam::cloudInfo::cloudInfo } +Foam::autoPtr<Foam::functionObjects::cloudInfo> +Foam::functionObjects::cloudInfo::New +( + const word& name, + const objectRegistry& obr, + const dictionary& dict, + const bool loadFromFiles +) +{ + return autoPtr<cloudInfo> + ( + new cloudInfo(name, obr, dict, loadFromFiles) + ); +} + + // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // -Foam::cloudInfo::~cloudInfo() +Foam::functionObjects::cloudInfo::~cloudInfo() {} // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -void Foam::cloudInfo::read(const dictionary& dict) +void Foam::functionObjects::cloudInfo::read(const dictionary& dict) { if (active_) { @@ -98,19 +117,19 @@ void Foam::cloudInfo::read(const dictionary& dict) } -void Foam::cloudInfo::execute() +void Foam::functionObjects::cloudInfo::execute() {} -void Foam::cloudInfo::end() +void Foam::functionObjects::cloudInfo::end() {} -void Foam::cloudInfo::timeSet() +void Foam::functionObjects::cloudInfo::timeSet() {} -void Foam::cloudInfo::write() +void Foam::functionObjects::cloudInfo::write() { if (active_) { diff --git a/src/postProcessing/functionObjects/cloud/cloudInfo/cloudInfo.H b/src/postProcessing/functionObjects/cloud/cloudInfo/cloudInfo.H index 281ef26b824..3af05b7d104 100644 --- a/src/postProcessing/functionObjects/cloud/cloudInfo/cloudInfo.H +++ b/src/postProcessing/functionObjects/cloud/cloudInfo/cloudInfo.H @@ -88,6 +88,9 @@ class objectRegistry; class dictionary; class mapPolyMesh; +namespace functionObjects +{ + /*---------------------------------------------------------------------------*\ Class cloudInfo Declaration \*---------------------------------------------------------------------------*/ @@ -145,6 +148,16 @@ public: const bool loadFromFiles = false ); + //- Construct on free-store and return pointer if successful + // otherwise return a null-pointer + static autoPtr<cloudInfo> New + ( + const word& name, + const objectRegistry&, + const dictionary&, + const bool loadFromFiles = false + ); + //- Destructor virtual ~cloudInfo(); @@ -185,6 +198,7 @@ public: // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // +} // End namespace functionObjects } // End namespace Foam // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/src/postProcessing/functionObjects/cloud/cloudInfo/cloudInfoFunctionObject.H b/src/postProcessing/functionObjects/cloud/cloudInfo/cloudInfoFunctionObject.H index 3d85754fceb..6cfd39830e8 100644 --- a/src/postProcessing/functionObjects/cloud/cloudInfo/cloudInfoFunctionObject.H +++ b/src/postProcessing/functionObjects/cloud/cloudInfo/cloudInfoFunctionObject.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2012 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2012-2016 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -43,7 +43,7 @@ SourceFiles namespace Foam { - typedef OutputFilterFunctionObject<cloudInfo> + typedef OutputFilterFunctionObject<functionObjects::cloudInfo> cloudInfoFunctionObject; } diff --git a/src/postProcessing/functionObjects/field/histogram/histogram.C b/src/postProcessing/functionObjects/field/histogram/histogram.C index 79391d628e4..38c0f59c151 100644 --- a/src/postProcessing/functionObjects/field/histogram/histogram.C +++ b/src/postProcessing/functionObjects/field/histogram/histogram.C @@ -104,7 +104,10 @@ Foam::functionObjects::histogram::New { if (isA<fvMesh>(obr)) { - return autoPtr<histogram>(new histogram(name, obr, dict)); + return autoPtr<histogram> + ( + new histogram(name, obr, dict, loadFromFiles) + ); } else { diff --git a/src/postProcessing/functionObjects/forces/forceCoeffs/forceCoeffs.C b/src/postProcessing/functionObjects/forces/forceCoeffs/forceCoeffs.C index a6e6dd108f6..f54bc9bf2b1 100644 --- a/src/postProcessing/functionObjects/forces/forceCoeffs/forceCoeffs.C +++ b/src/postProcessing/functionObjects/forces/forceCoeffs/forceCoeffs.C @@ -26,20 +26,24 @@ License #include "forceCoeffs.H" #include "dictionary.H" #include "Time.H" +#include "fvMesh.H" #include "Pstream.H" #include "IOmanip.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // namespace Foam +{ +namespace functionObjects { defineTypeNameAndDebug(forceCoeffs, 0); } +} // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * // -void Foam::forceCoeffs::writeFileHeader(const label i) +void Foam::functionObjects::forceCoeffs::writeFileHeader(const label i) { if (i == 0) { @@ -119,7 +123,7 @@ void Foam::forceCoeffs::writeFileHeader(const label i) // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // -Foam::forceCoeffs::forceCoeffs +Foam::functionObjects::forceCoeffs::forceCoeffs ( const word& name, const objectRegistry& obr, @@ -141,15 +145,38 @@ Foam::forceCoeffs::forceCoeffs } +Foam::autoPtr<Foam::functionObjects::forceCoeffs> +Foam::functionObjects::forceCoeffs::New +( + const word& name, + const objectRegistry& obr, + const dictionary& dict, + const bool loadFromFiles +) +{ + if (isA<fvMesh>(obr)) + { + return autoPtr<forceCoeffs> + ( + new forceCoeffs(name, obr, dict, loadFromFiles) + ); + } + else + { + return autoPtr<forceCoeffs>(); + } +} + + // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // -Foam::forceCoeffs::~forceCoeffs() +Foam::functionObjects::forceCoeffs::~forceCoeffs() {} // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -void Foam::forceCoeffs::read(const dictionary& dict) +void Foam::functionObjects::forceCoeffs::read(const dictionary& dict) { if (active_) { @@ -170,25 +197,19 @@ void Foam::forceCoeffs::read(const dictionary& dict) } -void Foam::forceCoeffs::execute() -{ - // Do nothing - only valid on write -} +void Foam::functionObjects::forceCoeffs::execute() +{} -void Foam::forceCoeffs::end() -{ - // Do nothing - only valid on write -} +void Foam::functionObjects::forceCoeffs::end() +{} -void Foam::forceCoeffs::timeSet() -{ - // Do nothing - only valid on write -} +void Foam::functionObjects::forceCoeffs::timeSet() +{} -void Foam::forceCoeffs::write() +void Foam::functionObjects::forceCoeffs::write() { forces::calcForcesMoment(); diff --git a/src/postProcessing/functionObjects/forces/forceCoeffs/forceCoeffs.H b/src/postProcessing/functionObjects/forces/forceCoeffs/forceCoeffs.H index e291065f33e..c0618311359 100644 --- a/src/postProcessing/functionObjects/forces/forceCoeffs/forceCoeffs.H +++ b/src/postProcessing/functionObjects/forces/forceCoeffs/forceCoeffs.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -99,6 +99,8 @@ SourceFiles namespace Foam { +namespace functionObjects +{ /*---------------------------------------------------------------------------*\ Class forceCoeffs Declaration @@ -170,6 +172,16 @@ public: const bool loadFromFiles = false ); + //- Construct on free-store and return pointer if successful + // otherwise return a null-pointer + static autoPtr<forceCoeffs> New + ( + const word& name, + const objectRegistry&, + const dictionary&, + const bool loadFromFiles = false + ); + //- Destructor virtual ~forceCoeffs(); @@ -196,6 +208,7 @@ public: // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // +} // End namespace functionObjects } // End namespace Foam // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/src/postProcessing/functionObjects/forces/forceCoeffs/forceCoeffsFunctionObject.H b/src/postProcessing/functionObjects/forces/forceCoeffs/forceCoeffsFunctionObject.H index f47469fff90..7be6eb561af 100644 --- a/src/postProcessing/functionObjects/forces/forceCoeffs/forceCoeffsFunctionObject.H +++ b/src/postProcessing/functionObjects/forces/forceCoeffs/forceCoeffsFunctionObject.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -43,7 +43,8 @@ SourceFiles namespace Foam { - typedef OutputFilterFunctionObject<forceCoeffs> forceCoeffsFunctionObject; + typedef OutputFilterFunctionObject<functionObjects::forceCoeffs> + forceCoeffsFunctionObject; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/src/postProcessing/functionObjects/forces/forces/forces.C b/src/postProcessing/functionObjects/forces/forces/forces.C index 743dd1a27ed..4775d1caa0c 100644 --- a/src/postProcessing/functionObjects/forces/forces/forces.C +++ b/src/postProcessing/functionObjects/forces/forces/forces.C @@ -36,14 +36,20 @@ License // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // namespace Foam +{ +namespace functionObjects { defineTypeNameAndDebug(forces, 0); } +} // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * // -Foam::wordList Foam::forces::createFileNames(const dictionary& dict) const +Foam::wordList Foam::functionObjects::forces::createFileNames +( + const dictionary& dict +) const { DynamicList<word> names(1); @@ -65,7 +71,7 @@ Foam::wordList Foam::forces::createFileNames(const dictionary& dict) const } -void Foam::forces::writeFileHeader(const label i) +void Foam::functionObjects::forces::writeFileHeader(const label i) { if (i == 0) { @@ -153,7 +159,7 @@ void Foam::forces::writeFileHeader(const label i) } -void Foam::forces::initialise() +void Foam::functionObjects::forces::initialise() { if (initialised_ || !active_) { @@ -202,7 +208,8 @@ void Foam::forces::initialise() } -Foam::tmp<Foam::volSymmTensorField> Foam::forces::devRhoReff() const +Foam::tmp<Foam::volSymmTensorField> +Foam::functionObjects::forces::devRhoReff() const { typedef compressible::turbulenceModel cmpTurbModel; typedef incompressible::turbulenceModel icoTurbModel; @@ -264,7 +271,7 @@ Foam::tmp<Foam::volSymmTensorField> Foam::forces::devRhoReff() const } -Foam::tmp<Foam::volScalarField> Foam::forces::mu() const +Foam::tmp<Foam::volScalarField> Foam::functionObjects::forces::mu() const { if (obr_.foundObject<fluidThermo>(basicThermo::dictName)) { @@ -303,7 +310,7 @@ Foam::tmp<Foam::volScalarField> Foam::forces::mu() const } -Foam::tmp<Foam::volScalarField> Foam::forces::rho() const +Foam::tmp<Foam::volScalarField> Foam::functionObjects::forces::rho() const { if (rhoName_ == "rhoInf") { @@ -331,7 +338,7 @@ Foam::tmp<Foam::volScalarField> Foam::forces::rho() const } -Foam::scalar Foam::forces::rho(const volScalarField& p) const +Foam::scalar Foam::functionObjects::forces::rho(const volScalarField& p) const { if (p.dimensions() == dimPressure) { @@ -351,7 +358,7 @@ Foam::scalar Foam::forces::rho(const volScalarField& p) const } -void Foam::forces::applyBins +void Foam::functionObjects::forces::applyBins ( const vectorField& Md, const vectorField& fN, @@ -388,7 +395,7 @@ void Foam::forces::applyBins } -void Foam::forces::writeForces() +void Foam::functionObjects::forces::writeForces() { if (log_) Info << type() << " " << name_ << " output:" << nl @@ -434,7 +441,7 @@ void Foam::forces::writeForces() } -void Foam::forces::writeBins() +void Foam::functionObjects::forces::writeBins() { if (nBin_ == 1) { @@ -515,7 +522,7 @@ void Foam::forces::writeBins() // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // -Foam::forces::forces +Foam::functionObjects::forces::forces ( const word& name, const objectRegistry& obr, @@ -570,7 +577,30 @@ Foam::forces::forces } -Foam::forces::forces +Foam::autoPtr<Foam::functionObjects::forces> +Foam::functionObjects::forces::New +( + const word& name, + const objectRegistry& obr, + const dictionary& dict, + const bool loadFromFiles +) +{ + if (isA<fvMesh>(obr)) + { + return autoPtr<forces> + ( + new forces(name, obr, dict, loadFromFiles) + ); + } + else + { + return autoPtr<forces>(); + } +} + + +Foam::functionObjects::forces::forces ( const word& name, const objectRegistry& obr, @@ -619,13 +649,13 @@ Foam::forces::forces // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // -Foam::forces::~forces() +Foam::functionObjects::forces::~forces() {} // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -void Foam::forces::read(const dictionary& dict) +void Foam::functionObjects::forces::read(const dictionary& dict) { if (active_) { @@ -758,25 +788,19 @@ void Foam::forces::read(const dictionary& dict) } -void Foam::forces::execute() -{ - // Do nothing - only valid on write -} +void Foam::functionObjects::forces::execute() +{} -void Foam::forces::end() -{ - // Do nothing - only valid on write -} +void Foam::functionObjects::forces::end() +{} -void Foam::forces::timeSet() -{ - // Do nothing - only valid on write -} +void Foam::functionObjects::forces::timeSet() +{} -void Foam::forces::write() +void Foam::functionObjects::forces::write() { calcForcesMoment(); @@ -798,7 +822,7 @@ void Foam::forces::write() } -void Foam::forces::calcForcesMoment() +void Foam::functionObjects::forces::calcForcesMoment() { initialise(); @@ -943,13 +967,13 @@ void Foam::forces::calcForcesMoment() } -Foam::vector Foam::forces::forceEff() const +Foam::vector Foam::functionObjects::forces::forceEff() const { return sum(force_[0]) + sum(force_[1]) + sum(force_[2]); } -Foam::vector Foam::forces::momentEff() const +Foam::vector Foam::functionObjects::forces::momentEff() const { return sum(moment_[0]) + sum(moment_[1]) + sum(moment_[2]); } diff --git a/src/postProcessing/functionObjects/forces/forces/forces.H b/src/postProcessing/functionObjects/forces/forces/forces.H index 97706425269..1c5c2befbbe 100644 --- a/src/postProcessing/functionObjects/forces/forces/forces.H +++ b/src/postProcessing/functionObjects/forces/forces/forces.H @@ -135,6 +135,9 @@ class dictionary; class polyMesh; class mapPolyMesh; +namespace functionObjects +{ + /*---------------------------------------------------------------------------*\ Class forces Declaration \*---------------------------------------------------------------------------*/ @@ -293,6 +296,15 @@ public: const bool readFields = true ); + //- Construct on free-store and return pointer if successful + // otherwise return a null-pointer + static autoPtr<forces> New + ( + const word& name, + const objectRegistry&, + const dictionary&, + const bool loadFromFiles = false + ); //- Construct from components forces @@ -357,6 +369,7 @@ public: // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // +} // End namespace functionObjects } // End namespace Foam // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/src/postProcessing/functionObjects/forces/forces/forcesFunctionObject.H b/src/postProcessing/functionObjects/forces/forces/forcesFunctionObject.H index 0b38a7e50b0..518815cc718 100644 --- a/src/postProcessing/functionObjects/forces/forces/forcesFunctionObject.H +++ b/src/postProcessing/functionObjects/forces/forces/forcesFunctionObject.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -43,7 +43,8 @@ SourceFiles namespace Foam { - typedef OutputFilterFunctionObject<forces> forcesFunctionObject; + typedef OutputFilterFunctionObject<functionObjects::forces> + forcesFunctionObject; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/src/rigidBodyMeshMotion/rigidBodyMeshMotion.C b/src/rigidBodyMeshMotion/rigidBodyMeshMotion.C index 54197202975..fcff9df278e 100644 --- a/src/rigidBodyMeshMotion/rigidBodyMeshMotion.C +++ b/src/rigidBodyMeshMotion/rigidBodyMeshMotion.C @@ -250,13 +250,13 @@ void Foam::rigidBodyMeshMotion::solve() const label bodyID = bodyMeshes_[bi].bodyID_; dictionary forcesDict; - forcesDict.add("type", forces::typeName); + forcesDict.add("type", functionObjects::forces::typeName); forcesDict.add("patches", bodyMeshes_[bi].patches_); forcesDict.add("rhoInf", rhoInf_); forcesDict.add("rhoName", rhoName_); forcesDict.add("CofR", vector::zero); - forces f("forces", db(), forcesDict); + functionObjects::forces f("forces", db(), forcesDict); f.calcForcesMoment(); fx[bodyID] = spatialVector(f.momentEff(), f.forceEff()); diff --git a/src/sixDoFRigidBodyMotion/pointPatchFields/derived/sixDoFRigidBodyDisplacement/sixDoFRigidBodyDisplacementPointPatchVectorField.C b/src/sixDoFRigidBodyMotion/pointPatchFields/derived/sixDoFRigidBodyDisplacement/sixDoFRigidBodyDisplacementPointPatchVectorField.C index 353397bc2a8..b2ef71dc8f3 100644 --- a/src/sixDoFRigidBodyMotion/pointPatchFields/derived/sixDoFRigidBodyDisplacement/sixDoFRigidBodyDisplacementPointPatchVectorField.C +++ b/src/sixDoFRigidBodyMotion/pointPatchFields/derived/sixDoFRigidBodyDisplacement/sixDoFRigidBodyDisplacementPointPatchVectorField.C @@ -210,13 +210,13 @@ void sixDoFRigidBodyDisplacementPointPatchVectorField::updateCoeffs() dictionary forcesDict; - forcesDict.add("type", forces::typeName); + forcesDict.add("type", functionObjects::forces::typeName); forcesDict.add("patches", wordList(1, ptPatch.name())); forcesDict.add("rhoInf", rhoInf_); forcesDict.add("rhoName", rhoName_); forcesDict.add("CofR", motion_.centreOfRotation()); - forces f("forces", db(), forcesDict); + functionObjects::forces f("forces", db(), forcesDict); f.calcForcesMoment(); diff --git a/src/sixDoFRigidBodyMotion/sixDoFRigidBodyMotionSolver/sixDoFRigidBodyMotionSolver.C b/src/sixDoFRigidBodyMotion/sixDoFRigidBodyMotionSolver/sixDoFRigidBodyMotionSolver.C index f25d1bba490..9aaf0785636 100644 --- a/src/sixDoFRigidBodyMotion/sixDoFRigidBodyMotionSolver/sixDoFRigidBodyMotionSolver.C +++ b/src/sixDoFRigidBodyMotion/sixDoFRigidBodyMotionSolver/sixDoFRigidBodyMotionSolver.C @@ -216,13 +216,13 @@ void Foam::sixDoFRigidBodyMotionSolver::solve() { dictionary forcesDict; - forcesDict.add("type", forces::typeName); + forcesDict.add("type", functionObjects::forces::typeName); forcesDict.add("patches", patches_); forcesDict.add("rhoInf", rhoInf_); forcesDict.add("rhoName", rhoName_); forcesDict.add("CofR", motion_.centreOfRotation()); - forces f("forces", db(), forcesDict); + functionObjects::forces f("forces", db(), forcesDict); f.calcForcesMoment(); -- GitLab