diff --git a/applications/utilities/postProcessing/patch/patchAverage/Make/files b/applications/utilities/postProcessing/patch/patchAverage/Make/files deleted file mode 100644 index 4d17c39ce18e1e5ece570eec09677fac001bdee3..0000000000000000000000000000000000000000 --- a/applications/utilities/postProcessing/patch/patchAverage/Make/files +++ /dev/null @@ -1,3 +0,0 @@ -patchAverage.C - -EXE = $(FOAM_APPBIN)/patchAverage diff --git a/applications/utilities/postProcessing/patch/patchAverage/Make/options b/applications/utilities/postProcessing/patch/patchAverage/Make/options deleted file mode 100644 index 318e1be8f4db9fb03aa149e620e74d560ddd241d..0000000000000000000000000000000000000000 --- a/applications/utilities/postProcessing/patch/patchAverage/Make/options +++ /dev/null @@ -1,8 +0,0 @@ -EXE_INC = \ - -I$(LIB_SRC)/finiteVolume/lnInclude \ - -I$(LIB_SRC)/meshTools/lnInclude - -EXE_LIBS = \ - -lgenericPatchFields \ - -lfiniteVolume \ - -lmeshTools diff --git a/applications/utilities/postProcessing/patch/patchAverage/patchAverage.C b/applications/utilities/postProcessing/patch/patchAverage/patchAverage.C deleted file mode 100644 index 0d79e42b8acf271d0ffa92ead9bccbaed1962f1f..0000000000000000000000000000000000000000 --- a/applications/utilities/postProcessing/patch/patchAverage/patchAverage.C +++ /dev/null @@ -1,147 +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 - patchAverage - -Description - Calculates the average of the specified field over the specified patch. - -\*---------------------------------------------------------------------------*/ - -#include "fvCFD.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -template<class FieldType> -void printAverage -( - const fvMesh& mesh, - const IOobject& fieldHeader, - const scalar area, - const label patchi, - bool& done -) -{ - if (!done && fieldHeader.headerClassName() == FieldType::typeName) - { - Info<< " Reading " << fieldHeader.headerClassName() << " " - << fieldHeader.name() << endl; - - FieldType field(fieldHeader, mesh); - - typename FieldType::value_type sumField = - Zero; - - if (area > 0) - { - sumField = gSum - ( - mesh.magSf().boundaryField()[patchi] - * field.boundaryField()[patchi] - ) / area; - } - - Info<< " Average of " << fieldHeader.headerClassName() - << " over patch " - << mesh.boundary()[patchi].name() - << '[' << patchi << ']' << " = " - << sumField << endl; - - done = true; - } -} - - - -int main(int argc, char *argv[]) -{ - timeSelector::addOptions(); - #include "addRegionOption.H" - argList::validArgs.append("fieldName"); - argList::validArgs.append("patchName"); - #include "setRootCase.H" - #include "createTime.H" - instantList timeDirs = timeSelector::select0(runTime, args); - #include "createNamedMesh.H" - - const word fieldName = args[1]; - const word patchName = args[2]; - - forAll(timeDirs, timeI) - { - runTime.setTime(timeDirs[timeI], timeI); - Info<< "Time = " << runTime.timeName() << endl; - - IOobject io - ( - fieldName, - runTime.timeName(), - mesh, - IOobject::MUST_READ - ); - - // Check field exists - if (io.headerOk()) - { - mesh.readUpdate(); - - const label patchi = mesh.boundaryMesh().findPatchID(patchName); - if (patchi < 0) - { - FatalError - << "Unable to find patch " << patchName << nl - << exit(FatalError); - } - scalar area = gSum(mesh.magSf().boundaryField()[patchi]); - - bool done = false; - printAverage<volScalarField>(mesh, io, area, patchi, done); - printAverage<volVectorField>(mesh, io, area, patchi, done); - printAverage<volSphericalTensorField>(mesh, io, area, patchi, done); - printAverage<volSymmTensorField>(mesh, io, area, patchi, done); - printAverage<volTensorField>(mesh, io, area, patchi, done); - - if (!done) - { - FatalError - << "Only possible to average volFields." - << " Field " << fieldName << " is of type " - << io.headerClassName() - << nl << exit(FatalError); - } - } - else - { - Info<< " No field " << fieldName << endl; - } - - Info<< endl; - } - - Info<< "End\n" << endl; - - return 0; -} - -// ************************************************************************* // diff --git a/applications/utilities/postProcessing/patch/patchIntegrate/Make/files b/applications/utilities/postProcessing/patch/patchIntegrate/Make/files deleted file mode 100644 index 6595b6a7ff5b88cdef38457c7d0feb1ffcf8ff9d..0000000000000000000000000000000000000000 --- a/applications/utilities/postProcessing/patch/patchIntegrate/Make/files +++ /dev/null @@ -1,3 +0,0 @@ -patchIntegrate.C - -EXE = $(FOAM_APPBIN)/patchIntegrate diff --git a/applications/utilities/postProcessing/patch/patchIntegrate/Make/options b/applications/utilities/postProcessing/patch/patchIntegrate/Make/options deleted file mode 100644 index 318e1be8f4db9fb03aa149e620e74d560ddd241d..0000000000000000000000000000000000000000 --- a/applications/utilities/postProcessing/patch/patchIntegrate/Make/options +++ /dev/null @@ -1,8 +0,0 @@ -EXE_INC = \ - -I$(LIB_SRC)/finiteVolume/lnInclude \ - -I$(LIB_SRC)/meshTools/lnInclude - -EXE_LIBS = \ - -lgenericPatchFields \ - -lfiniteVolume \ - -lmeshTools diff --git a/applications/utilities/postProcessing/patch/patchIntegrate/patchIntegrate.C b/applications/utilities/postProcessing/patch/patchIntegrate/patchIntegrate.C deleted file mode 100644 index 61cecad44156bc596f1a25619de044f0d09364e4..0000000000000000000000000000000000000000 --- a/applications/utilities/postProcessing/patch/patchIntegrate/patchIntegrate.C +++ /dev/null @@ -1,255 +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 - patchIntegrate - -Description - Calculates the integral of the specified field over the specified patch. - -\*---------------------------------------------------------------------------*/ - -#include "fvCFD.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -template<class FieldType> -void printIntegrate -( - const fvMesh& mesh, - const IOobject& fieldHeader, - const label patchi, - bool& done -) -{ - if (!done && fieldHeader.headerClassName() == FieldType::typeName) - { - Info<< " Reading " << fieldHeader.headerClassName() << " " - << fieldHeader.name() << endl; - - FieldType field(fieldHeader, mesh); - - Info<< " Integral of " << fieldHeader.name() - << " over vector area of patch " - << mesh.boundary()[patchi].name() << '[' << patchi << ']' << " = " - << gSum - ( - mesh.Sf().boundaryField()[patchi] - *field.boundaryField()[patchi] - ) - << nl; - - Info<< " Integral of " << fieldHeader.name() - << " over area magnitude of patch " - << mesh.boundary()[patchi].name() << '[' << patchi << ']' << " = " - << gSum - ( - mesh.magSf().boundaryField()[patchi] - *field.boundaryField()[patchi] - ) - << nl; - - done = true; - } -} - - -template<class FieldType> -void printSum -( - const fvMesh& mesh, - const IOobject& fieldHeader, - const label patchi, - bool& done -) -{ - if (!done && fieldHeader.headerClassName() == FieldType::typeName) - { - Info<< " Reading " << FieldType::typeName << " " - << fieldHeader.name() << endl; - - FieldType field(fieldHeader, mesh); - typename FieldType::value_type sumField = gSum - ( - field.boundaryField()[patchi] - ); - - Info<< " Integral of " << fieldHeader.name() << " over patch " - << mesh.boundary()[patchi].name() << '[' << patchi << ']' << " = " - << sumField << nl; - - done = true; - } -} - - - -int main(int argc, char *argv[]) -{ - timeSelector::addOptions(); - #include "addRegionOption.H" - argList::validArgs.append("fieldName"); - argList::validArgs.append("patchName"); - #include "setRootCase.H" - #include "createTime.H" - instantList timeDirs = timeSelector::select0(runTime, args); - #include "createNamedMesh.H" - - const word fieldName = args[1]; - const word patchName = args[2]; - - forAll(timeDirs, timeI) - { - runTime.setTime(timeDirs[timeI], timeI); - Info<< "Time = " << runTime.timeName() << endl; - - IOobject fieldHeader - ( - fieldName, - runTime.timeName(), - mesh, - IOobject::MUST_READ - ); - - // Check field exists - if (fieldHeader.headerOk()) - { - mesh.readUpdate(); - - const label patchi = mesh.boundaryMesh().findPatchID(patchName); - if (patchi < 0) - { - FatalError - << "Unable to find patch " << patchName << nl - << exit(FatalError); - } - - // Give patch area - Info<< " Area vector of patch " - << patchName << '[' << patchi << ']' << " = " - << gSum(mesh.Sf().boundaryField()[patchi]) << endl; - Info<< " Area magnitude of patch " - << patchName << '[' << patchi << ']' << " = " - << gSum(mesh.magSf().boundaryField()[patchi]) << endl; - - // Read field and calc integral - bool done = false; - printIntegrate<volScalarField> - ( - mesh, - fieldHeader, - patchi, - done - ); - printIntegrate<volVectorField> - ( - mesh, - fieldHeader, - patchi, - done - ); - - //- No tensor integrations - //printIntegrate<volSphericalTensorField> - //( - // mesh, - // fieldHeader, - // patchi, - // done - //); - //printIntegrate<volSymmTensorField> - //( - // mesh, - // fieldHeader, - // patchi, - // done - //); - //printIntegrate<volTensorField> - //( - // mesh, - // fieldHeader, - // patchi, - // done - //); - - printSum<surfaceScalarField> - ( - mesh, - fieldHeader, - patchi, - done - ); - printSum<surfaceVectorField> - ( - mesh, - fieldHeader, - patchi, - done - ); - printSum<volSphericalTensorField> - ( - mesh, - fieldHeader, - patchi, - done - ); - printSum<volSymmTensorField> - ( - mesh, - fieldHeader, - patchi, - done - ); - printSum<volTensorField> - ( - mesh, - fieldHeader, - patchi, - done - ); - - if (!done) - { - FatalError - << "Only possible to integrate " - << "volFields and surfaceFields." - << " Field " << fieldName << " is of type " - << fieldHeader.headerClassName() - << nl << exit(FatalError); - } - } - else - { - Info<< " No field " << fieldName << endl; - } - - Info<< endl; - } - - Info<< "End\n" << endl; - - return 0; -} - - -// ************************************************************************* // diff --git a/applications/utilities/postProcessing/postProcess/postProcess.C b/applications/utilities/postProcessing/postProcess/postProcess.C index 335006d17cc6f91100fcbdc756de88afcf14ff32..3b3878d4ba423628540a1e8a75bbbae9f616d5aa 100644 --- a/applications/utilities/postProcessing/postProcess/postProcess.C +++ b/applications/utilities/postProcessing/postProcess/postProcess.C @@ -128,6 +128,9 @@ int main(int argc, char *argv[]) #include "addRegionOption.H" #include "addFunctionObjectOptions.H" + // Set functionObject post-processing mode + functionObject::postProcess = true; + #include "setRootCase.H" if (args.optionFound("list")) diff --git a/bin/patchAverage b/bin/patchAverage new file mode 100755 index 0000000000000000000000000000000000000000..bd15b518c65bdf40a3657f560820a8f16e298ba7 --- /dev/null +++ b/bin/patchAverage @@ -0,0 +1,37 @@ +#!/bin/sh +#------------------------------------------------------------------------------ +# ========= | +# \\ / 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/>. +# +# Script +# patchAverage +# +# Description +# Script to suggest using the new "postProcess" utility. +# +#------------------------------------------------------------------------------ +Script=${0##*/} + +echo $Script "has been superceded by the postProcess utility:" +echo "postProcess -func '"$Script"(name=inlet,p)'" + +#------------------------------------------------------------------------------ diff --git a/bin/patchIntegrate b/bin/patchIntegrate new file mode 100755 index 0000000000000000000000000000000000000000..72c6021441fab43aff29fbdb5b73cf77ed7ef584 --- /dev/null +++ b/bin/patchIntegrate @@ -0,0 +1,37 @@ +#!/bin/sh +#------------------------------------------------------------------------------ +# ========= | +# \\ / 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/>. +# +# Script +# patchIntegrate +# +# Description +# Script to suggest using the new "postProcess" utility. +# +#------------------------------------------------------------------------------ +Script=${0##*/} + +echo $Script "has been superceded by the postProcess utility:" +echo "postProcess -func '"$Script"(name=inlet,p)'" + +#------------------------------------------------------------------------------ diff --git a/etc/caseDicts/postProcessing/surfaceRegion/patchAverage b/etc/caseDicts/postProcessing/surfaceRegion/patchAverage index 8f042fa96ca120f023df310de955ab1a90ac0302..2a1bda2fc980565707e72530faf60e4cb2ccfac8 100644 --- a/etc/caseDicts/postProcessing/surfaceRegion/patchAverage +++ b/etc/caseDicts/postProcessing/surfaceRegion/patchAverage @@ -17,8 +17,6 @@ patchAverage operation average; #includeEtc "caseDicts/postProcessing/surfaceRegion/patch.cfg" - - log true; } diff --git a/etc/caseDicts/postProcessing/surfaceRegion/patchIntegrate b/etc/caseDicts/postProcessing/surfaceRegion/patchIntegrate index 1c86de23283a99bdf654da6796ada65806a73b0e..41b24735310292dc5b036e92078dbee87b543472 100644 --- a/etc/caseDicts/postProcessing/surfaceRegion/patchIntegrate +++ b/etc/caseDicts/postProcessing/surfaceRegion/patchIntegrate @@ -17,8 +17,6 @@ patchIntegrate operation areaIntegrate; #includeEtc "caseDicts/postProcessing/surfaceRegion/patch.cfg" - - log true; } diff --git a/src/OpenFOAM/db/functionObjects/functionObject/functionObject.C b/src/OpenFOAM/db/functionObjects/functionObject/functionObject.C index 965cafff506a36e66ff184bb6d68de8d62f5dd74..c0cd27a9738e4f714a4285c3422553cf23e78751 100644 --- a/src/OpenFOAM/db/functionObjects/functionObject/functionObject.C +++ b/src/OpenFOAM/db/functionObjects/functionObject/functionObject.C @@ -36,12 +36,15 @@ namespace Foam defineRunTimeSelectionTable(functionObject, dictionary); } +bool Foam::functionObject::postProcess(false); + // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // Foam::functionObject::functionObject(const word& name) : - name_(name) + name_(name), + log(postProcess) {} @@ -120,6 +123,17 @@ const Foam::word& Foam::functionObject::name() const } +bool Foam::functionObject::read(const dictionary& dict) +{ + if (!postProcess) + { + log = dict.lookupOrDefault<Switch>("log", true); + } + + return true; +} + + bool Foam::functionObject::end() { return execute() && write(); diff --git a/src/OpenFOAM/db/functionObjects/functionObject/functionObject.H b/src/OpenFOAM/db/functionObjects/functionObject/functionObject.H index 7958dc37d22c7022664bfa65b563d9374aa6992d..74457227aa2b2c5adbe42684351993ecaf31f55c 100644 --- a/src/OpenFOAM/db/functionObjects/functionObject/functionObject.H +++ b/src/OpenFOAM/db/functionObjects/functionObject/functionObject.H @@ -112,6 +112,7 @@ SourceFiles #include "typeInfo.H" #include "autoPtr.H" +#include "Switch.H" #include "runTimeSelectionTables.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -152,6 +153,12 @@ public: static int debug; + //- Global post-processing mode switch + static bool postProcess; + + //- Switch write log to Info + Switch log; + // Declare run-time constructor selection tables @@ -199,7 +206,7 @@ public: const word& name() const; //- Read and set the function object if its data have changed - virtual bool read(const dictionary&) = 0; + virtual bool read(const dictionary&); //- Called at each ++ or += of the time-loop. // postProcess overrides the usual executeControl behaviour and diff --git a/src/OpenFOAM/db/functionObjects/functionObjectList/postProcess.H b/src/OpenFOAM/db/functionObjects/functionObjectList/postProcess.H index d264ebf49147bb9ab8e346ab6a1a4ee1b92aac5b..09a3b0d9534d30c5fea9e220d186a2faf94b8ed4 100644 --- a/src/OpenFOAM/db/functionObjects/functionObjectList/postProcess.H +++ b/src/OpenFOAM/db/functionObjects/functionObjectList/postProcess.H @@ -73,6 +73,9 @@ if (argList::postProcess(argc, argv)) #include "addRegionOption.H" #include "addFunctionObjectOptions.H" + // Set functionObject post-processing mode + functionObject::postProcess = true; + #include "setRootCase.H" if (args.optionFound("list")) diff --git a/src/OpenFOAM/db/functionObjects/regionFunctionObject/regionFunctionObject.C b/src/OpenFOAM/db/functionObjects/regionFunctionObject/regionFunctionObject.C index d4cef191672051763c16242999632c39774c183b..c010855bceeec0f333865b52270c0c7f7a76c995 100644 --- a/src/OpenFOAM/db/functionObjects/regionFunctionObject/regionFunctionObject.C +++ b/src/OpenFOAM/db/functionObjects/regionFunctionObject/regionFunctionObject.C @@ -105,8 +105,7 @@ Foam::functionObjects::regionFunctionObject::regionFunctionObject ( dict.lookupOrDefault("region", polyMesh::defaultRegion) ) - ), - log(true) + ) {} @@ -119,8 +118,7 @@ Foam::functionObjects::regionFunctionObject::regionFunctionObject : functionObject(name), time_(obr.time()), - obr_(obr), - log(true) + obr_(obr) {} @@ -134,9 +132,7 @@ Foam::functionObjects::regionFunctionObject::~regionFunctionObject() bool Foam::functionObjects::regionFunctionObject::read(const dictionary& dict) { - log = dict.lookupOrDefault<Switch>("log", true); - - return true; + return functionObject::read(dict); } diff --git a/src/OpenFOAM/db/functionObjects/regionFunctionObject/regionFunctionObject.H b/src/OpenFOAM/db/functionObjects/regionFunctionObject/regionFunctionObject.H index dcdb7b7f4457e3cdf2a23051a550d74bad9ef121..928ad04abdc9728e40070bc07dfd343ded86465e 100644 --- a/src/OpenFOAM/db/functionObjects/regionFunctionObject/regionFunctionObject.H +++ b/src/OpenFOAM/db/functionObjects/regionFunctionObject/regionFunctionObject.H @@ -40,7 +40,6 @@ SourceFiles #define functionObjects_regionFunctionObject_H #include "functionObject.H" -#include "Switch.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -115,9 +114,6 @@ public: //- Runtime type information TypeName("regionFunctionObject"); - //- Switch write log to Info - Switch log; - // Constructors