From 88f4b6ca8d8eff6073ba910c70503d872fb871c5 Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Fri, 9 Feb 2018 19:24:31 +0100 Subject: [PATCH] ENH: optionally limit systemCall function-object to master only (closes #729) --- .../utilities/systemCall/systemCall.C | 80 ++++++++++------- .../utilities/systemCall/systemCall.H | 34 +++++--- tutorials/IO/systemCall/0.orig/U | 52 +++++++++++ .../IO/systemCall/0.orig/include/fixedInlet | 15 ++++ .../0.orig/include/frontBackUpperPatches | 19 ++++ .../0.orig/include/initialConditions | 14 +++ tutorials/IO/systemCall/0.orig/k | 53 ++++++++++++ tutorials/IO/systemCall/0.orig/nut | 64 ++++++++++++++ tutorials/IO/systemCall/0.orig/omega | 52 +++++++++++ tutorials/IO/systemCall/0.orig/p | 51 +++++++++++ tutorials/IO/systemCall/Allrun | 13 +++ .../systemCall/constant/transportProperties | 21 +++++ .../systemCall/constant/turbulenceProperties | 28 ++++++ tutorials/IO/systemCall/system/blockMeshDict | 86 +++++++++++++++++++ tutorials/IO/systemCall/system/controlDict | 53 ++++++++++++ .../IO/systemCall/system/decomposeParDict | 26 ++++++ tutorials/IO/systemCall/system/fvSchemes | 58 +++++++++++++ tutorials/IO/systemCall/system/fvSolution | 86 +++++++++++++++++++ tutorials/IO/systemCall/system/systemCall | 29 +++++++ 19 files changed, 790 insertions(+), 44 deletions(-) create mode 100644 tutorials/IO/systemCall/0.orig/U create mode 100644 tutorials/IO/systemCall/0.orig/include/fixedInlet create mode 100644 tutorials/IO/systemCall/0.orig/include/frontBackUpperPatches create mode 100644 tutorials/IO/systemCall/0.orig/include/initialConditions create mode 100644 tutorials/IO/systemCall/0.orig/k create mode 100644 tutorials/IO/systemCall/0.orig/nut create mode 100644 tutorials/IO/systemCall/0.orig/omega create mode 100644 tutorials/IO/systemCall/0.orig/p create mode 100755 tutorials/IO/systemCall/Allrun create mode 100644 tutorials/IO/systemCall/constant/transportProperties create mode 100644 tutorials/IO/systemCall/constant/turbulenceProperties create mode 100644 tutorials/IO/systemCall/system/blockMeshDict create mode 100644 tutorials/IO/systemCall/system/controlDict create mode 100644 tutorials/IO/systemCall/system/decomposeParDict create mode 100644 tutorials/IO/systemCall/system/fvSchemes create mode 100644 tutorials/IO/systemCall/system/fvSolution create mode 100644 tutorials/IO/systemCall/system/systemCall diff --git a/src/functionObjects/utilities/systemCall/systemCall.C b/src/functionObjects/utilities/systemCall/systemCall.C index 2076b3d3a4..d16f571a8e 100644 --- a/src/functionObjects/utilities/systemCall/systemCall.C +++ b/src/functionObjects/utilities/systemCall/systemCall.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -46,6 +46,36 @@ namespace functionObjects } +// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * // + +Foam::label Foam::functionObjects::systemCall::dispatch(const stringList& calls) +{ + if (calls.empty()) + { + return 0; + } + + label nCalls = 0; + + if (!masterOnly_ || Pstream::master()) + { + for (const string& call : calls) + { + Foam::system(call); // Handles empty command as a successful no-op. + ++nCalls; + } + } + + // MPI barrier + if (masterOnly_) + { + Pstream::scatter(nCalls); + } + + return nCalls; +} + + // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // Foam::functionObjects::systemCall::systemCall @@ -58,27 +88,27 @@ Foam::functionObjects::systemCall::systemCall functionObject(name), executeCalls_(), endCalls_(), - writeCalls_() + writeCalls_(), + masterOnly_(false) { read(dict); } -// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // - -Foam::functionObjects::systemCall::~systemCall() -{} - - // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // bool Foam::functionObjects::systemCall::read(const dictionary& dict) { functionObject::read(dict); + executeCalls_.clear(); + writeCalls_.clear(); + endCalls_.clear(); + dict.readIfPresent("executeCalls", executeCalls_); - dict.readIfPresent("endCalls", endCalls_); dict.readIfPresent("writeCalls", writeCalls_); + dict.readIfPresent("endCalls", endCalls_); + masterOnly_ = dict.lookupOrDefault("master", false); if (executeCalls_.empty() && endCalls_.empty() && writeCalls_.empty()) { @@ -89,8 +119,8 @@ bool Foam::functionObjects::systemCall::read(const dictionary& dict) else if (!dynamicCode::allowSystemOperations) { FatalErrorInFunction - << "Executing user-supplied system calls is not enabled by " - << "default because of " << nl + << "Executing user-supplied system calls may not be enabled by " + << "default due to potential " << nl << "security issues. If you trust the case you can enable this " << "facility by " << nl << "adding to the InfoSwitches setting in the system controlDict:" @@ -109,33 +139,21 @@ bool Foam::functionObjects::systemCall::read(const dictionary& dict) bool Foam::functionObjects::systemCall::execute() { - forAll(executeCalls_, calli) - { - Foam::system(executeCalls_[calli]); - } - - return true; -} - - -bool Foam::functionObjects::systemCall::end() -{ - forAll(endCalls_, calli) - { - Foam::system(endCalls_[calli]); - } - + dispatch(executeCalls_); return true; } bool Foam::functionObjects::systemCall::write() { - forAll(writeCalls_, calli) - { - Foam::system(writeCalls_[calli]); - } + dispatch(writeCalls_); + return true; +} + +bool Foam::functionObjects::systemCall::end() +{ + dispatch(endCalls_); return true; } diff --git a/src/functionObjects/utilities/systemCall/systemCall.H b/src/functionObjects/utilities/systemCall/systemCall.H index a83848f211..17f2c72f66 100644 --- a/src/functionObjects/utilities/systemCall/systemCall.H +++ b/src/functionObjects/utilities/systemCall/systemCall.H @@ -28,7 +28,7 @@ Group grpUtilitiesFunctionObjects Description - Executes system calls, entered in the form of a string lists. + Executes system calls, entered in the form of string lists. Calls can be made at the following points in the calculation: - every time step @@ -36,7 +36,7 @@ Description - end of the calculation Usage - Example of function object specification: + Example of the function object specification: \verbatim systemCall1 { @@ -49,11 +49,11 @@ Usage ); writeCalls ( - "echo \*\*\* writing data \*\*\*" + "echo === writing data ===" ); endCalls ( - "echo \*\*\* writing .bashrc \*\*\*" + "echo === echoing .bashrc ===" "cat ~/.bashrc" "echo \*\*\* done \*\*\*" ); @@ -67,6 +67,7 @@ Usage executeCalls | list of calls on execute | yes | writeCalls | list of calls on write | yes | endCalls | list of calls on end | yes | + master | execute on master only | no | false \endtable Note @@ -75,6 +76,9 @@ Note \c allowSystemOperations must be set to '1'; otherwise, system calls will not be allowed. + Additionally, since the system commands are normally sent via the shell, + special shell character may require backslash escaping. + See also Foam::functionObject Foam::functionObjects::timeControl @@ -118,16 +122,20 @@ protected: //- List of calls to execute - write steps stringList writeCalls_; + //- Perform system calls on the master only + bool masterOnly_; -private: - // Private member functions + // Protected Member Functions + + //- Dispatch specified calls + label dispatch(const stringList& calls); //- Disallow default bitwise copy construct - systemCall(const systemCall&); + systemCall(const systemCall&) = delete; //- Disallow default bitwise assignment - void operator=(const systemCall&); + void operator=(const systemCall&) = delete; public: @@ -148,22 +156,22 @@ public: //- Destructor - virtual ~systemCall(); + virtual ~systemCall() = default; // Member Functions //- Read the system calls - virtual bool read(const dictionary&); + virtual bool read(const dictionary& dict); //- Execute the "executeCalls" at each time-step virtual bool execute(); - //- Execute the "endCalls" at the final time-loop - virtual bool end(); - //- Write, execute the "writeCalls" virtual bool write(); + + //- Execute the "endCalls" at the final time-loop + virtual bool end(); }; diff --git a/tutorials/IO/systemCall/0.orig/U b/tutorials/IO/systemCall/0.orig/U new file mode 100644 index 0000000000..ff1bc9a5b0 --- /dev/null +++ b/tutorials/IO/systemCall/0.orig/U @@ -0,0 +1,52 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: plus | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class volVectorField; + location "0"; + object U; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#include "include/initialConditions" + +dimensions [0 1 -1 0 0 0 0]; + +internalField uniform $flowVelocity; + +boundaryField +{ + #includeEtc "caseDicts/setConstraintTypes" + + #include "include/fixedInlet" + + outlet + { + type inletOutlet; + inletValue uniform (0 0 0); + value $internalField; + } + + lowerWall + { + type fixedValue; + value $internalField; + } + + motorBikeGroup + { + type noSlip; + } + + #include "include/frontBackUpperPatches" +} + + +// ************************************************************************* // diff --git a/tutorials/IO/systemCall/0.orig/include/fixedInlet b/tutorials/IO/systemCall/0.orig/include/fixedInlet new file mode 100644 index 0000000000..d69bf4f580 --- /dev/null +++ b/tutorials/IO/systemCall/0.orig/include/fixedInlet @@ -0,0 +1,15 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: plus | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ + +inlet +{ + type fixedValue; + value $internalField; +} + +// ************************************************************************* // diff --git a/tutorials/IO/systemCall/0.orig/include/frontBackUpperPatches b/tutorials/IO/systemCall/0.orig/include/frontBackUpperPatches new file mode 100644 index 0000000000..15a394abc2 --- /dev/null +++ b/tutorials/IO/systemCall/0.orig/include/frontBackUpperPatches @@ -0,0 +1,19 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: plus | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ + +upperWall +{ + type slip; +} + +frontAndBack +{ + type slip; +} + +// ************************************************************************* // diff --git a/tutorials/IO/systemCall/0.orig/include/initialConditions b/tutorials/IO/systemCall/0.orig/include/initialConditions new file mode 100644 index 0000000000..32bc1d1ff4 --- /dev/null +++ b/tutorials/IO/systemCall/0.orig/include/initialConditions @@ -0,0 +1,14 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: plus | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ + +flowVelocity (20 0 0); +pressure 0; +turbulentKE 0.24; +turbulentOmega 1.78; + +// ************************************************************************* // diff --git a/tutorials/IO/systemCall/0.orig/k b/tutorials/IO/systemCall/0.orig/k new file mode 100644 index 0000000000..0f4ece8bfe --- /dev/null +++ b/tutorials/IO/systemCall/0.orig/k @@ -0,0 +1,53 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: plus | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class volScalarField; + object k; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#include "include/initialConditions" + +dimensions [0 2 -2 0 0 0 0]; + +internalField uniform $turbulentKE; + +boundaryField +{ + #includeEtc "caseDicts/setConstraintTypes" + + //- Define inlet conditions + #include "include/fixedInlet" + + outlet + { + type inletOutlet; + inletValue $internalField; + value $internalField; + } + + lowerWall + { + type kqRWallFunction; + value $internalField; + } + + motorBikeGroup + { + type kqRWallFunction; + value $internalField; + } + + #include "include/frontBackUpperPatches" +} + + +// ************************************************************************* // diff --git a/tutorials/IO/systemCall/0.orig/nut b/tutorials/IO/systemCall/0.orig/nut new file mode 100644 index 0000000000..cff1c42399 --- /dev/null +++ b/tutorials/IO/systemCall/0.orig/nut @@ -0,0 +1,64 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: plus | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class volScalarField; + location "0"; + object nut; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [0 2 -1 0 0 0 0]; + +internalField uniform 0; + +boundaryField +{ + #includeEtc "caseDicts/setConstraintTypes" + + frontAndBack + { + type calculated; + value uniform 0; + } + + inlet + { + type calculated; + value uniform 0; + } + + outlet + { + type calculated; + value uniform 0; + } + + lowerWall + { + type nutkWallFunction; + value uniform 0; + } + + upperWall + { + type calculated; + value uniform 0; + } + + motorBikeGroup + { + type nutkWallFunction; + value uniform 0; + } +} + + +// ************************************************************************* // diff --git a/tutorials/IO/systemCall/0.orig/omega b/tutorials/IO/systemCall/0.orig/omega new file mode 100644 index 0000000000..3381e6db75 --- /dev/null +++ b/tutorials/IO/systemCall/0.orig/omega @@ -0,0 +1,52 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: plus | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class volScalarField; + object omega; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#include "include/initialConditions" + +dimensions [0 0 -1 0 0 0 0]; + +internalField uniform $turbulentOmega; + +boundaryField +{ + #includeEtc "caseDicts/setConstraintTypes" + + #include "include/fixedInlet" + + outlet + { + type inletOutlet; + inletValue $internalField; + value $internalField; + } + + lowerWall + { + type omegaWallFunction; + value $internalField; + } + + motorBikeGroup + { + type omegaWallFunction; + value $internalField; + } + + #include "include/frontBackUpperPatches" +} + + +// ************************************************************************* // diff --git a/tutorials/IO/systemCall/0.orig/p b/tutorials/IO/systemCall/0.orig/p new file mode 100644 index 0000000000..dee14af37e --- /dev/null +++ b/tutorials/IO/systemCall/0.orig/p @@ -0,0 +1,51 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: plus | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class volScalarField; + object p; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#include "include/initialConditions" + +dimensions [0 2 -2 0 0 0 0]; + +internalField uniform $pressure; + +boundaryField +{ + #includeEtc "caseDicts/setConstraintTypes" + + inlet + { + type zeroGradient; + } + + outlet + { + type fixedValue; + value $internalField; + } + + lowerWall + { + type zeroGradient; + } + + motorBikeGroup + { + type zeroGradient; + } + + #include "include/frontBackUpperPatches" +} + +// ************************************************************************* // diff --git a/tutorials/IO/systemCall/Allrun b/tutorials/IO/systemCall/Allrun new file mode 100755 index 0000000000..a42d43db7b --- /dev/null +++ b/tutorials/IO/systemCall/Allrun @@ -0,0 +1,13 @@ +#!/bin/sh +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions + +runApplication blockMesh +runApplication decomposePar + +#- For parallel running: set the initial fields +restore0Dir -processor + +runParallel $(getApplication) + +#------------------------------------------------------------------------------ diff --git a/tutorials/IO/systemCall/constant/transportProperties b/tutorials/IO/systemCall/constant/transportProperties new file mode 100644 index 0000000000..c4e6700e33 --- /dev/null +++ b/tutorials/IO/systemCall/constant/transportProperties @@ -0,0 +1,21 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: plus | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object transportProperties; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +transportModel Newtonian; + +nu 1.5e-05; + +// ************************************************************************* // diff --git a/tutorials/IO/systemCall/constant/turbulenceProperties b/tutorials/IO/systemCall/constant/turbulenceProperties new file mode 100644 index 0000000000..3ac433a9e9 --- /dev/null +++ b/tutorials/IO/systemCall/constant/turbulenceProperties @@ -0,0 +1,28 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: plus | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object turbulenceProperties; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +simulationType RAS; + +RAS +{ + RASModel kOmegaSST; + + turbulence on; + + printCoeffs on; +} + +// ************************************************************************* // diff --git a/tutorials/IO/systemCall/system/blockMeshDict b/tutorials/IO/systemCall/system/blockMeshDict new file mode 100644 index 0000000000..c9ab3e0342 --- /dev/null +++ b/tutorials/IO/systemCall/system/blockMeshDict @@ -0,0 +1,86 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: plus | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object blockMeshDict; +} + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +scale 1; + +vertices +( + (-5 -4 0) + (15 -4 0) + (15 4 0) + (-5 4 0) + (-5 -4 8) + (15 -4 8) + (15 4 8) + (-5 4 8) +); + +blocks +( + hex (0 1 2 3 4 5 6 7) (20 8 8) simpleGrading (1 1 1) +); + +edges +( +); + +boundary +( + frontAndBack + { + type patch; + faces + ( + (3 7 6 2) + (1 5 4 0) + ); + } + inlet + { + type patch; + faces + ( + (0 4 7 3) + ); + } + outlet + { + type patch; + faces + ( + (2 6 5 1) + ); + } + lowerWall + { + type wall; + faces + ( + (0 3 2 1) + ); + } + upperWall + { + type patch; + faces + ( + (4 5 6 7) + ); + } +); + +// ************************************************************************* // diff --git a/tutorials/IO/systemCall/system/controlDict b/tutorials/IO/systemCall/system/controlDict new file mode 100644 index 0000000000..759c337df8 --- /dev/null +++ b/tutorials/IO/systemCall/system/controlDict @@ -0,0 +1,53 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: plus | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object controlDict; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +application simpleFoam; + +startFrom latestTime; + +startTime 0; + +stopAt endTime; + +endTime 4; + +deltaT 1; + +writeControl timeStep; + +writeInterval 100; + +purgeWrite 0; + +writeFormat binary; + +writePrecision 6; + +writeCompression off; + +timeFormat general; + +timePrecision 6; + +runTimeModifiable true; + +functions +{ + #include "systemCall" +} + + +// ************************************************************************* // diff --git a/tutorials/IO/systemCall/system/decomposeParDict b/tutorials/IO/systemCall/system/decomposeParDict new file mode 100644 index 0000000000..ea3efe0610 --- /dev/null +++ b/tutorials/IO/systemCall/system/decomposeParDict @@ -0,0 +1,26 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: plus | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object decomposeParDict; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +numberOfSubdomains 6; + +method hierarchical; + +coeffs +{ + n (3 2 1); +} + +// ************************************************************************* // diff --git a/tutorials/IO/systemCall/system/fvSchemes b/tutorials/IO/systemCall/system/fvSchemes new file mode 100644 index 0000000000..12fdd994df --- /dev/null +++ b/tutorials/IO/systemCall/system/fvSchemes @@ -0,0 +1,58 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: plus | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object fvSchemes; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +ddtSchemes +{ + default steadyState; +} + +gradSchemes +{ + default Gauss linear; + grad(U) cellLimited Gauss linear 1; +} + +divSchemes +{ + default none; + div(phi,U) bounded Gauss linearUpwindV grad(U); + div(phi,k) bounded Gauss upwind; + div(phi,omega) bounded Gauss upwind; + div((nuEff*dev2(T(grad(U))))) Gauss linear; +} + +laplacianSchemes +{ + default Gauss linear corrected; +} + +interpolationSchemes +{ + default linear; +} + +snGradSchemes +{ + default corrected; +} + +wallDist +{ + method meshWave; +} + + +// ************************************************************************* // diff --git a/tutorials/IO/systemCall/system/fvSolution b/tutorials/IO/systemCall/system/fvSolution new file mode 100644 index 0000000000..20bbd0fc4e --- /dev/null +++ b/tutorials/IO/systemCall/system/fvSolution @@ -0,0 +1,86 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: plus | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object fvSolution; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +solvers +{ + p + { + solver GAMG; + smoother GaussSeidel; + tolerance 1e-7; + relTol 0.01; + } + + Phi + { + $p; + } + + U + { + solver smoothSolver; + smoother GaussSeidel; + tolerance 1e-8; + relTol 0.1; + nSweeps 1; + } + + k + { + solver smoothSolver; + smoother GaussSeidel; + tolerance 1e-8; + relTol 0.1; + nSweeps 1; + } + + omega + { + solver smoothSolver; + smoother GaussSeidel; + tolerance 1e-8; + relTol 0.1; + nSweeps 1; + } +} + +SIMPLE +{ + nNonOrthogonalCorrectors 0; + consistent yes; +} + +potentialFlow +{ + nNonOrthogonalCorrectors 10; +} + +relaxationFactors +{ + equations + { + U 0.9; + k 0.7; + omega 0.7; + } +} + +cache +{ + grad(U); +} + +// ************************************************************************* // diff --git a/tutorials/IO/systemCall/system/systemCall b/tutorials/IO/systemCall/system/systemCall new file mode 100644 index 0000000000..f8d4debf5c --- /dev/null +++ b/tutorials/IO/systemCall/system/systemCall @@ -0,0 +1,29 @@ +// -*- C++ -*- +// An example of using systemCall +system +{ + type systemCall; + libs ("libutilityFunctionObjects.so"); + + // Execute on the master process only + master true; + + executeCalls + ( + "echo execute: shell $$" + ); + + writeCalls + ( + "echo \*\*\* writing data \*\*\*" + ); + + endCalls + ( + "echo \*\*\* end of run \*\*\*" + "grep application system/controlDict" + "echo \*\*\* done \*\*\*" + ); +} + +// ************************************************************************* //