BUG: Updated execFlowFunctionObjects to prevent result overwrite - mantis #562

This commit is contained in:
andy
2013-03-12 17:03:57 +00:00
parent 53df4289df
commit 3599609cd7
3 changed files with 80 additions and 35 deletions

View File

@ -1,5 +1,4 @@
EXE_INC = \ EXE_INC = \
-I$(LIB_SRC)/postProcessing/postCalc \
-I$(LIB_SRC)/transportModels \ -I$(LIB_SRC)/transportModels \
-I$(LIB_SRC)/turbulenceModels \ -I$(LIB_SRC)/turbulenceModels \
-I$(LIB_SRC)/turbulenceModels/LES/LESdeltas/lnInclude \ -I$(LIB_SRC)/turbulenceModels/LES/LESdeltas/lnInclude \
@ -7,7 +6,6 @@ EXE_INC = \
-I$(LIB_SRC)/finiteVolume/lnInclude -I$(LIB_SRC)/finiteVolume/lnInclude
EXE_LIBS = \ EXE_LIBS = \
$(FOAM_LIBBIN)/postCalc.o \
-lincompressibleTransportModels \ -lincompressibleTransportModels \
-lincompressibleRASModels \ -lincompressibleRASModels \
-lincompressibleLESModels \ -lincompressibleLESModels \

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2012 OpenFOAM Foundation \\ / A nd | Copyright (C) 2012-2013 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -21,7 +21,7 @@ License
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Global Application
execFlowFunctionObjects execFlowFunctionObjects
Description Description
@ -35,7 +35,8 @@ Description
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#include "calc.H" #include "argList.H"
#include "timeSelector.H"
#include "volFields.H" #include "volFields.H"
#include "surfaceFields.H" #include "surfaceFields.H"
@ -51,12 +52,18 @@ Description
#include "compressible/RAS/RASModel/RASModel.H" #include "compressible/RAS/RASModel/RASModel.H"
#include "compressible/LES/LESModel/LESModel.H" #include "compressible/LES/LESModel/LESModel.H"
using namespace Foam;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam void execFunctionObjects
(
const argList& args,
const Time& runTime,
autoPtr<functionObjectList>& folPtr
)
{ {
void execFlowFunctionObjects(const argList& args, const Time& runTime) if (folPtr.empty())
{ {
if (args.optionFound("dict")) if (args.optionFound("dict"))
{ {
@ -70,23 +77,27 @@ namespace Foam
) )
); );
functionObjectList fol(runTime, dict); folPtr.reset(new functionObjectList(runTime, dict));
fol.start();
fol.execute(true); // override outputControl - force writing
} }
else else
{ {
functionObjectList fol(runTime); folPtr.reset(new functionObjectList(runTime));
fol.start();
fol.execute(true); // override outputControl - force writing
} }
folPtr->start();
} }
folPtr->execute(true);
} }
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // void calc
(
void Foam::calc(const argList& args, const Time& runTime, const fvMesh& mesh) const argList& args,
const Time& runTime,
const fvMesh& mesh,
autoPtr<functionObjectList>& folPtr
)
{ {
if (args.optionFound("noFlow")) if (args.optionFound("noFlow"))
{ {
@ -148,7 +159,7 @@ void Foam::calc(const argList& args, const Time& runTime, const fvMesh& mesh)
PtrList<pointTensorField> ptFlds; PtrList<pointTensorField> ptFlds;
ReadFields(pMesh, objects, ptFlds); ReadFields(pMesh, objects, ptFlds);
execFlowFunctionObjects(args, runTime); execFunctionObjects(args, runTime, folPtr);
} }
else else
{ {
@ -191,7 +202,7 @@ void Foam::calc(const argList& args, const Time& runTime, const fvMesh& mesh)
mesh mesh
); );
if (phi.dimensions() == dimensionSet(0, 3, -1, 0, 0)) if (phi.dimensions() == dimVolume/dimTime)
{ {
IOobject RASPropertiesHeader IOobject RASPropertiesHeader
( (
@ -228,7 +239,8 @@ void Foam::calc(const argList& args, const Time& runTime, const fvMesh& mesh)
laminarTransport laminarTransport
) )
); );
execFlowFunctionObjects(args, runTime);
execFunctionObjects(args, runTime, folPtr);
} }
else if (LESPropertiesHeader.headerOk()) else if (LESPropertiesHeader.headerOk())
{ {
@ -241,7 +253,7 @@ void Foam::calc(const argList& args, const Time& runTime, const fvMesh& mesh)
incompressible::LESModel::New(U, phi, laminarTransport) incompressible::LESModel::New(U, phi, laminarTransport)
); );
execFlowFunctionObjects(args, runTime); execFunctionObjects(args, runTime, folPtr);
} }
else else
{ {
@ -257,12 +269,10 @@ void Foam::calc(const argList& args, const Time& runTime, const fvMesh& mesh)
) )
); );
dimensionedScalar nu(transportProperties.lookup("nu")); execFunctionObjects(args, runTime, folPtr);
execFlowFunctionObjects(args, runTime);
} }
} }
else if (phi.dimensions() == dimensionSet(1, 0, -1, 0, 0)) else if (phi.dimensions() == dimMass/dimTime)
{ {
autoPtr<fluidThermo> thermo(fluidThermo::New(mesh)); autoPtr<fluidThermo> thermo(fluidThermo::New(mesh));
@ -312,7 +322,7 @@ void Foam::calc(const argList& args, const Time& runTime, const fvMesh& mesh)
) )
); );
execFlowFunctionObjects(args, runTime); execFunctionObjects(args, runTime, folPtr);
} }
else if (LESPropertiesHeader.headerOk()) else if (LESPropertiesHeader.headerOk())
{ {
@ -323,7 +333,7 @@ void Foam::calc(const argList& args, const Time& runTime, const fvMesh& mesh)
compressible::LESModel::New(rho, U, phi, thermo()) compressible::LESModel::New(rho, U, phi, thermo())
); );
execFlowFunctionObjects(args, runTime); execFunctionObjects(args, runTime, folPtr);
} }
else else
{ {
@ -339,9 +349,7 @@ void Foam::calc(const argList& args, const Time& runTime, const fvMesh& mesh)
) )
); );
dimensionedScalar mu(transportProperties.lookup("mu")); execFunctionObjects(args, runTime, folPtr);
execFlowFunctionObjects(args, runTime);
} }
} }
else else
@ -354,4 +362,48 @@ void Foam::calc(const argList& args, const Time& runTime, const fvMesh& mesh)
} }
int main(int argc, char *argv[])
{
Foam::timeSelector::addOptions();
#include "addRegionOption.H"
Foam::argList::addBoolOption
(
"noFlow",
"suppress creating flow models"
);
#include "addDictOption.H"
#include "setRootCase.H"
#include "createTime.H"
Foam::instantList timeDirs = Foam::timeSelector::select0(runTime, args);
#include "createNamedMesh.H"
autoPtr<functionObjectList> folPtr;
forAll(timeDirs, timeI)
{
runTime.setTime(timeDirs[timeI], timeI);
Info<< "Time = " << runTime.timeName() << endl;
mesh.readUpdate();
FatalIOError.throwExceptions();
try
{
calc(args, runTime, mesh, folPtr);
}
catch (IOerror& err)
{
Warning<< err << endl;
}
Info<< endl;
}
return 0;
}
// ************************************************************************* // // ************************************************************************* //

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -63,11 +63,6 @@ int main(int argc, char *argv[])
"noWrite", "noWrite",
"suppress writing results" "suppress writing results"
); );
Foam::argList::addBoolOption
(
"noFlow",
"suppress creating flow models (execFlowFunctionObjects only)"
);
#include "addDictOption.H" #include "addDictOption.H"
#include "setRootCase.H" #include "setRootCase.H"