diff --git a/applications/utilities/postProcessing/foamPostProcess/Make/files b/applications/utilities/postProcessing/foamPostProcess/Make/files new file mode 100644 index 0000000000..c6eb49d19c --- /dev/null +++ b/applications/utilities/postProcessing/foamPostProcess/Make/files @@ -0,0 +1,3 @@ +foamPostProcess.C + +EXE = $(FOAM_APPBIN)/foamPostProcess diff --git a/applications/utilities/postProcessing/foamPostProcess/Make/options b/applications/utilities/postProcessing/foamPostProcess/Make/options new file mode 100644 index 0000000000..fa15f12452 --- /dev/null +++ b/applications/utilities/postProcessing/foamPostProcess/Make/options @@ -0,0 +1,5 @@ +EXE_INC = \ + -I$(LIB_SRC)/finiteVolume/lnInclude + +EXE_LIBS = \ + -lfiniteVolume diff --git a/applications/utilities/postProcessing/postProcess/postProcess.C b/applications/utilities/postProcessing/foamPostProcess/foamPostProcess.C similarity index 60% rename from applications/utilities/postProcessing/postProcess/postProcess.C rename to applications/utilities/postProcessing/foamPostProcess/foamPostProcess.C index 24127e7e32..8729f14e4c 100644 --- a/applications/utilities/postProcessing/postProcess/postProcess.C +++ b/applications/utilities/postProcessing/foamPostProcess/foamPostProcess.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2016-2022 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2022 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -22,17 +22,75 @@ License along with OpenFOAM. If not, see . Application - postProcess + foamPostProcess Description Execute the set of functionObjects specified in the selected dictionary (which defaults to system/controlDict) or on the command-line for the selected set of times on the selected set of fields. + The functionObjects are either executed directly or for the solver + optionally specified as a command-line argument. + +Usage + \b foamPostProcess [OPTION] + - \par -dict + Read control dictionary from specified location + + - \par -solver + Solver name + + - \par -libs '(\"lib1.so\" ... \"libN.so\")' + Specify the additional libraries loaded + + -\par -region + Specify the region + + - \par -func + Specify the name of the functionObject to execute, e.g. Q + + - \par -funcs + Specify the names of the functionObjects to execute, e.g. '(Q div(U))' + + - \par -field + Specify the name of the field to be processed, e.g. U + + - \par -fields + Specify a list of fields to be processed, + e.g. '(U T p)' - regular expressions not currently supported + + - \par -time + comma-separated time ranges - eg, ':10,20,40:70,1000:' + + - \par -latestTime + Select the latest time + + - \par -list + List the available configured functionObjects + + Example usage: + - Print the list of available configured functionObjects: + \verbatim + foamPostProcess -list + \endverbatim + + - Execute the functionObjects specified in the controlDict of the + fluid region for all the available times: + \verbatim + foamPostProcess -region fluid + \endverbatim + + - Execute the functionObjects specified in the controlDict + for the 'fluid' solver in the 'cooling' region for the latest time only: + \verbatim + foamPostProcess -solver fluid -region cooling -latestTime + \endverbatim + \*---------------------------------------------------------------------------*/ #include "argList.H" #include "timeSelector.H" +#include "solver.H" #include "ReadFields.H" #include "volFields.H" #include "surfaceFields.H" @@ -135,9 +193,18 @@ void executeFunctionObjects } +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + int main(int argc, char *argv[]) { - Foam::timeSelector::addOptions(); + argList::addOption + ( + "solver", + "name", + "Solver name" + ); + + timeSelector::addOptions(); #include "addRegionOption.H" #include "addFunctionObjectOptions.H" @@ -156,18 +223,57 @@ int main(int argc, char *argv[]) } #include "createTime.H" - Foam::instantList timeDirs = Foam::timeSelector::select0(runTime, args); - #include "createNamedMesh.H" - // Initialise the set of selected fields from the command-line options - HashSet requiredFields; - if (args.optionFound("fields")) + instantList timeDirs = timeSelector::select0(runTime, args); + + word regionName = fvMesh::defaultRegion; + + if (args.optionReadIfPresent("region", regionName)) { - args.optionLookup("fields")() >> requiredFields; + Info + << "Create mesh " << regionName << " for time = " + << runTime.timeName() << nl << endl; } - if (args.optionFound("field")) + else { - requiredFields.insert(args.optionLookup("field")()); + Info + << "Create mesh for time = " + << runTime.timeName() << nl << endl; + } + + fvMesh mesh + ( + IOobject + ( + regionName, + runTime.timeName(), + runTime, + IOobject::MUST_READ + ) + ); + + // Either the solver name is specified... + word solverName; + + // ...or the fields are specified on the command-line + // or later inferred from the function arguments + HashSet requiredFields; + + if (args.optionReadIfPresent("solver", solverName)) + { + libs.open("lib" + solverName + ".so"); + } + else + { + // Initialise the set of selected fields from the command-line options + if (args.optionFound("fields")) + { + args.optionLookup("fields")() >> requiredFields; + } + if (args.optionFound("field")) + { + requiredFields.insert(args.optionLookup("field")()); + } } // Externally stored dictionary for functionObjectList @@ -206,15 +312,30 @@ int main(int argc, char *argv[]) try { - executeFunctionObjects - ( - args, - runTime, - mesh, - requiredFields, - functionsPtr(), - timei == timeDirs.size()-1 - ); + if (solverName != word::null) + { + // Optionally instantiate the selected solver + autoPtr solverPtr; + + solverPtr = solver::New(solverName, mesh); + + functionsPtr->execute(); + + // Clear the objects owned by the mesh + mesh.objectRegistry::clear(); + } + else + { + executeFunctionObjects + ( + args, + runTime, + mesh, + requiredFields, + functionsPtr(), + timei == timeDirs.size()-1 + ); + } } catch (IOerror& err) { diff --git a/applications/utilities/postProcessing/postProcess/Make/files b/applications/utilities/postProcessing/postProcess/Make/files deleted file mode 100644 index 712053a449..0000000000 --- a/applications/utilities/postProcessing/postProcess/Make/files +++ /dev/null @@ -1,3 +0,0 @@ -postProcess.C - -EXE = $(FOAM_APPBIN)/postProcess diff --git a/applications/utilities/postProcessing/postProcess/Make/options b/applications/utilities/postProcessing/postProcess/Make/options deleted file mode 100644 index 15b42222a2..0000000000 --- a/applications/utilities/postProcessing/postProcess/Make/options +++ /dev/null @@ -1,23 +0,0 @@ -EXE_INC = \ - -I$(LIB_SRC)/physicalProperties/lnInclude \ - -I$(LIB_SRC)/thermophysicalModels/basic/lnInclude \ - -I$(LIB_SRC)/MomentumTransportModels/momentumTransportModels/lnInclude \ - -I$(LIB_SRC)/MomentumTransportModels/incompressible/lnInclude \ - -I$(LIB_SRC)/MomentumTransportModels/compressible/lnInclude \ - -I$(LIB_SRC)/finiteVolume/lnInclude \ - -I$(LIB_SRC)/fvModels/lnInclude \ - -I$(LIB_SRC)/meshTools/lnInclude \ - -I$(LIB_SRC)/sampling/lnInclude - -EXE_LIBS = \ - -lmomentumTransportModels \ - -lincompressibleMomentumTransportModels \ - -lcompressibleMomentumTransportModels \ - -lphysicalProperties \ - -lfluidThermophysicalModels \ - -lspecie \ - -lfiniteVolume \ - -lfvModels \ - -lgenericPatchFields \ - -lmeshTools \ - -lsampling diff --git a/bin/postProcess b/bin/postProcess new file mode 100755 index 0000000000..899eb4f636 --- /dev/null +++ b/bin/postProcess @@ -0,0 +1,43 @@ +#!/bin/sh +#------------------------------------------------------------------------------ +# ========= | +# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox +# \\ / O peration | Website: https://openfoam.org +# \\ / A nd | Copyright (C) 2022 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 . +# +# Script +# postProcess +# +# Description +# Script to inform the user that postProcess has been superseded +# and replaced by the more general foamPostProcess utility. +# +#------------------------------------------------------------------------------ + +cat <