Permalink
Browse files

simpleFoam: Added experimental "-postProcess" option

    Executes application functionObjects to post-process existing results.

    If the "dict" argument is specified the functionObjectList is constructed
    from that dictionary otherwise the functionObjectList is constructed from
    the "functions" sub-dictionary of "system/controlDict"

    Multiple time-steps may be processed and the standard utility time
    controls are provided.

This functionality is equivalent to execFlowFunctionObjects but in a
more efficient and general manner and will be included in all the
OpenFOAM solvers if it proves effective and maintainable.

The command-line options available with the "-postProcess" option may be
obtained by

simpleFoam -help -postProcess

Usage: simpleFoam [OPTIONS]
options:
  -case <dir>       specify alternate case directory, default is the cwd
  -constant         include the 'constant/' dir in the times list
  -dict <file>      read control dictionary from specified location
  -latestTime       select the latest time
  -newTimes         select the new times
  -noFunctionObjects
                    do not execute functionObjects
  -noZero           exclude the '0/' dir from the times list, has precedence
                    over the -withZero option
  -parallel         run in parallel
  -postProcess      Execute functionObjects only
  -region <name>    specify alternative mesh region
  -roots <(dir1 .. dirN)>
                    slave root directories for distributed running
  -time <ranges>    comma-separated time ranges - eg, ':10,20,40:70,1000:'
  -srcDoc           display source code in browser
  -doc              display application documentation in browser
  -help             print the usage

Henry G. Weller
CFD Direct Ltd.
  • Loading branch information...
Henry Weller
Henry Weller committed May 8, 2016
1 parent c1a89ad commit 30e2f912e54a54a370509685197509e846ef3a9a
@@ -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
@@ -41,12 +41,12 @@ Description

int main(int argc, char *argv[])
{
#include "postProcess.H"

#include "setRootCase.H"
#include "createTime.H"
#include "createMesh.H"

simpleControl simple(mesh);

#include "createControls.H"
#include "createFields.H"
#include "createFvOptions.H"
#include "initContinuityErrs.H"
@@ -0,0 +1 @@
simpleControl simple(mesh);
@@ -41,3 +41,5 @@ autoPtr<incompressible::turbulenceModel> turbulence
(
incompressible::turbulenceModel::New(U, phi, laminarTransport)
);

#include "createMRF.H"
@@ -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
@@ -42,14 +42,14 @@ Description

int main(int argc, char *argv[])
{
#define CREATE_FIELDS_2 createPorousZones.H
#include "postProcess.H"

#include "setRootCase.H"
#include "createTime.H"
#include "createMesh.H"

simpleControl simple(mesh);

#include "createControls.H"
#include "createFields.H"
#include "createMRF.H"
#include "createPorousZones.H"
#include "createFvOptions.H"
#include "initContinuityErrs.H"
@@ -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
@@ -39,14 +39,13 @@ Description

int main(int argc, char *argv[])
{
#include "postProcess.H"

#include "setRootCase.H"
#include "createTime.H"
#include "createMesh.H"

simpleControl simple(mesh);

#include "createControls.H"
#include "createFields.H"
#include "createMRF.H"
#include "createFvOptions.H"
#include "initContinuityErrs.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
@@ -26,6 +26,7 @@ License
#include "functionObjectList.H"
#include "Time.H"
#include "mapPolyMesh.H"
#include "argList.H"

// * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * //

@@ -92,6 +93,42 @@ Foam::functionObjectList::functionObjectList
{}


Foam::autoPtr<Foam::functionObjectList> Foam::functionObjectList::New
(
const argList& args,
const Time& runTime,
dictionary& functionObjectsDict
)
{
autoPtr<functionObjectList> functionObjectsPtr;

if (args.optionFound("dict"))
{
functionObjectsDict = IOdictionary
(
IOobject
(
args["dict"],
runTime,
IOobject::MUST_READ_IF_MODIFIED
)
);

functionObjectsPtr.reset
(
new functionObjectList(runTime, functionObjectsDict)
);
}
else
{
functionObjectsPtr.reset(new functionObjectList(runTime));
}
functionObjectsPtr->start();

return functionObjectsPtr;
}


// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //

Foam::functionObjectList::~functionObjectList()
@@ -50,6 +50,7 @@ namespace Foam
{

class mapPolyMesh;
class argList;

/*---------------------------------------------------------------------------*\
Class functionObjectList Declaration
@@ -107,7 +108,6 @@ public:
const bool execution=true
);


//- Construct from Time, a dictionary with "functions" entry
// and the execution setting.
// \param[in] t - the other Time instance to construct from
@@ -123,6 +123,19 @@ public:
const bool execution=true
);

//- Construct and return a functionObjectList for an application.
//
// If the "dict" argument is specified the functionObjectList is
// constructed from that dictionary which is returned as
// functionObjectsDict otherwise the functionObjectList is constructed
// from the "functions" sub-dictionary of "system/controlDict"
static autoPtr<functionObjectList> New
(
const argList& args,
const Time& runTime,
dictionary& functionObjectsDict
);


//- Destructor
virtual ~functionObjectList();
@@ -0,0 +1,138 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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/>.
Global
postProcess
Description
Execute application functionObjects to post-process existing results.
If the "dict" argument is specified the functionObjectList is constructed
from that dictionary otherwise the functionObjectList is constructed from
the "functions" sub-dictionary of "system/controlDict"
Multiple time-steps may be processed and the standard utility time
controls are provided.
\*---------------------------------------------------------------------------*/

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

#ifndef CREATE_MESH
#define CREATE_MESH createMesh.H
#endif

#ifndef CREATE_FIELDS_1
#define CREATE_FIELDS_1 createFields.H
#endif

#ifndef CREATE_CONTROLS
#define CREATE_CONTROLS createControls.H
#endif

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

#define INCLUDE_FILE(X) INCLUDE_FILE2(X)
#define INCLUDE_FILE2(X) #X

Foam::argList::addBoolOption
(
argList::postProcessOptionName,
"Execute functionObjects only"
);

if (argList::postProcess(argc, argv))
{
Foam::timeSelector::addOptions();
#include "addRegionOption.H"
#include "addDictOption.H"

#include "setRootCase.H"
#include "createTime.H"
Foam::instantList timeDirs = Foam::timeSelector::select0(runTime, args);
#include INCLUDE_FILE(CREATE_MESH)
#include INCLUDE_FILE(CREATE_CONTROLS)

// Externally stored dictionary for functionObjectList
// if not constructed from runTime
dictionary functionObjectsDict;

// Construct functionObjectList
autoPtr<functionObjectList> functionObjectsPtr
(
functionObjectList::New(args, runTime, functionObjectsDict)
);

forAll(timeDirs, timeI)
{
runTime.setTime(timeDirs[timeI], timeI);

Info<< "Time = " << runTime.timeName() << endl;

if (mesh.readUpdate() != polyMesh::UNCHANGED)
{
// Update functionObjects if mesh changes
functionObjectsPtr =
functionObjectList::New(args, runTime, functionObjectsDict);
}

#include INCLUDE_FILE(CREATE_FIELDS_1)

#ifdef CREATE_FIELDS_2
#include INCLUDE_FILE(CREATE_FIELDS_2)
#endif

#ifdef CREATE_FIELDS_3
#include INCLUDE_FILE(CREATE_FIELDS_3)
#endif

FatalIOError.throwExceptions();

try
{
functionObjectsPtr->execute(true);
}
catch (IOerror& err)
{
Warning<< err << endl;
}

Info<< endl;
}

Info<< "End\n" << endl;

return 0;
}


// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

#undef INCLUDE_FILE
#undef INCLUDE_FILE2

#undef CREATE_MESH
#undef CREATE_FIELDS_1
#undef CREATE_CONTROLS

// ************************************************************************* //
Oops, something went wrong.

0 comments on commit 30e2f91

Please sign in to comment.