etc/caseDicts/functionTemplates: dedicated location for template (coded) functions
This commit is contained in:
60
etc/caseDicts/functionTemplates/cachedField
Normal file
60
etc/caseDicts/functionTemplates/cachedField
Normal file
@ -0,0 +1,60 @@
|
||||
/*--------------------------------*- C++ -*----------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Version: dev
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Description
|
||||
Caches and writes a volVectorField of grad(p)
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
libs ("libutilityFunctionObjects.so");
|
||||
type coded;
|
||||
|
||||
executeControl writeTime;
|
||||
writeControl writeTime;
|
||||
|
||||
codeInclude
|
||||
#{
|
||||
// Header files for classes and functions, e.g. for fvc::grad
|
||||
#include "fvcGrad.H"
|
||||
#};
|
||||
|
||||
// Header file paths for Make/options, e.g. for momentum transport models
|
||||
// Example:
|
||||
// -I$(LIB_SRC)/MomentumTransportModels/incompressible/lnInclude
|
||||
codeOptions
|
||||
#{
|
||||
#};
|
||||
|
||||
// Linked libraries for Make/options, e.g. for momentum transport models
|
||||
// Not usually required since libraries are already linked to the solver
|
||||
// Example:
|
||||
// -lincompressibleMomentumTransportModels
|
||||
codeLibs
|
||||
#{
|
||||
#};
|
||||
|
||||
codeFields
|
||||
#{
|
||||
// Read fields when executing function objects with "foamPostProcess"
|
||||
fields.append("p");
|
||||
#};
|
||||
|
||||
codeExecute
|
||||
#{
|
||||
// Lookup existing field from objectRegistry, e.g. pressure p
|
||||
const volScalarField& p = mesh().lookupObject<volScalarField>("p");
|
||||
|
||||
// Calculate and store field, e.g. grad(p)
|
||||
store("gradP", fvc::grad(p));
|
||||
#};
|
||||
|
||||
codeWrite
|
||||
#{
|
||||
return writeObject("gradP");
|
||||
#};
|
||||
|
||||
// ************************************************************************* //
|
||||
57
etc/caseDicts/functionTemplates/field
Normal file
57
etc/caseDicts/functionTemplates/field
Normal file
@ -0,0 +1,57 @@
|
||||
/*--------------------------------*- C++ -*----------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Version: dev
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Description
|
||||
Writes a volVectorField of grad(p)
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
libs ("libutilityFunctionObjects.so");
|
||||
type coded;
|
||||
|
||||
writeControl writeTime;
|
||||
|
||||
codeInclude
|
||||
#{
|
||||
// Header files for classes and functions, e.g. for fvc::grad
|
||||
#include "fvc.H"
|
||||
#};
|
||||
|
||||
// Header file paths for Make/options, e.g. for momentum transport models
|
||||
// Example:
|
||||
// -I$(LIB_SRC)/MomentumTransportModels/incompressible/lnInclude
|
||||
codeOptions
|
||||
#{
|
||||
#};
|
||||
|
||||
// Linked libraries for Make/options, e.g. for momentum transport models
|
||||
// Not usually required since libraries are already linked to the solver
|
||||
// Example:
|
||||
// -lincompressibleMomentumTransportModels
|
||||
codeLibs
|
||||
#{
|
||||
#};
|
||||
|
||||
codeFields
|
||||
#{
|
||||
// Read fields when executing function objects with "foamPostProcess"
|
||||
fields.append("p");
|
||||
#};
|
||||
|
||||
codeWrite
|
||||
#{
|
||||
// Lookup existing field from objectRegistry, e.g. pressure p
|
||||
const volScalarField& p = mesh().lookupObject<volScalarField>("p");
|
||||
|
||||
// Calculate a new field, e.g. grad(p)
|
||||
volVectorField gradP("gradP", fvc::grad(p));
|
||||
|
||||
// Write the field
|
||||
gradP.write();
|
||||
#};
|
||||
|
||||
// ************************************************************************* //
|
||||
83
etc/caseDicts/functionTemplates/logFile
Normal file
83
etc/caseDicts/functionTemplates/logFile
Normal file
@ -0,0 +1,83 @@
|
||||
/*--------------------------------*- C++ -*----------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Version: dev
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Description
|
||||
Prints data to a log file
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
libs ("libutilityFunctionObjects.so");
|
||||
type coded;
|
||||
|
||||
// Write at the end of every time step but not time zero
|
||||
executeAtStart no;
|
||||
writeControl timeStep;
|
||||
writeInterval 1;
|
||||
|
||||
// Parameters, which can be read from other files using macro expansions, e.g.
|
||||
// magU ${${FOAM_CASE}/0/U!Uinlet};
|
||||
rho 1.2;
|
||||
|
||||
codeInclude
|
||||
#{
|
||||
// Header files for classes and functions
|
||||
#include "OFstream.H"
|
||||
#include "OSspecific.H"
|
||||
#include "fvc.H"
|
||||
#};
|
||||
|
||||
// Header file paths for Make/options, e.g. for momentum transport models
|
||||
// Example:
|
||||
// -I$(LIB_SRC)/MomentumTransportModels/incompressible/lnInclude
|
||||
codeOptions
|
||||
#{
|
||||
#};
|
||||
|
||||
// Linked libraries for Make/options, e.g. for momentum transport models
|
||||
// Not usually required since libraries are already linked to the solver
|
||||
// Example:
|
||||
// -lincompressibleMomentumTransportModels
|
||||
codeLibs
|
||||
#{
|
||||
#};
|
||||
|
||||
codeData
|
||||
#{
|
||||
autoPtr<OFstream> file;
|
||||
autoPtr<scalar> rho;
|
||||
#};
|
||||
|
||||
codeRead
|
||||
#{
|
||||
fileName dir
|
||||
(
|
||||
mesh().time().globalPath()/
|
||||
"postProcessing"/
|
||||
mesh().time().name()/
|
||||
name()
|
||||
);
|
||||
|
||||
mkDir(dir);
|
||||
file = new OFstream(dir/"data");
|
||||
|
||||
// Print a short file header
|
||||
file()<< "#time" << tab << "KE" << endl;
|
||||
|
||||
rho = new scalar($rho);
|
||||
#};
|
||||
|
||||
codeWrite
|
||||
#{
|
||||
const volVectorField& U = mesh().lookupObject<volVectorField>("U");
|
||||
|
||||
scalar KE = 0.5*rho*fvc::domainIntegrate(magSqr(U)).value();
|
||||
|
||||
// Print time-value data in two columns
|
||||
file()<< mesh().time().userTimeValue() << tab << KE << endl;
|
||||
#};
|
||||
|
||||
// ************************************************************************* //
|
||||
66
etc/caseDicts/functionTemplates/printAtEnd
Normal file
66
etc/caseDicts/functionTemplates/printAtEnd
Normal file
@ -0,0 +1,66 @@
|
||||
/*--------------------------------*- C++ -*----------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Version: dev
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Description
|
||||
Prints to standard output at the end of the simulation
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
libs ("libutilityFunctionObjects.so");
|
||||
type coded;
|
||||
|
||||
// Parameters, which can be read from other files using macro expansions, e.g.
|
||||
// magU ${${FOAM_CASE}/0/U!Uinlet};
|
||||
diameter 2;
|
||||
|
||||
codeInclude
|
||||
#{
|
||||
// Header files for classes and functions
|
||||
#include "constants.H"
|
||||
using namespace Foam::constant::mathematical;
|
||||
#};
|
||||
|
||||
// Header file paths for Make/options, e.g. for momentum transport models
|
||||
// Example:
|
||||
// -I$(LIB_SRC)/MomentumTransportModels/incompressible/lnInclude
|
||||
codeOptions
|
||||
#{
|
||||
#};
|
||||
|
||||
// Linked libraries for Make/options, e.g. for momentum transport models
|
||||
// Not usually required since libraries are already linked to the solver
|
||||
// Example:
|
||||
// -lincompressibleMomentumTransportModels
|
||||
codeLibs
|
||||
#{
|
||||
#};
|
||||
|
||||
codeData
|
||||
#{
|
||||
// Member data, must be null constructed, e.g. using autoPtr<...>
|
||||
autoPtr<scalar> radius;
|
||||
#};
|
||||
|
||||
codeRead
|
||||
#{
|
||||
// Initialisation of data using "new" operator
|
||||
// Note: divisions "/" require surrounding spaces with macro-expanded ($)
|
||||
// variables, since "/" is the scoping operator, see magU above
|
||||
radius = new scalar($diameter / 2.0);
|
||||
#};
|
||||
|
||||
codeEnd
|
||||
#{
|
||||
// Print to standard output
|
||||
const fvPatch& patch = mesh().boundary()[0];
|
||||
|
||||
Info<< "Some area = " << pi*sqr(radius) << nl
|
||||
<< "Area of patch '" << patch.name() << "' = " << gSum(patch.magSf())
|
||||
<< nl << endl;
|
||||
#};
|
||||
|
||||
// ************************************************************************* //
|
||||
69
etc/caseDicts/functionTemplates/printAtStart
Normal file
69
etc/caseDicts/functionTemplates/printAtStart
Normal file
@ -0,0 +1,69 @@
|
||||
/*--------------------------------*- C++ -*----------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Version: dev
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Description
|
||||
Prints to standard output before the time loop
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
libs ("libutilityFunctionObjects.so");
|
||||
type coded;
|
||||
|
||||
// executeAtStart is on (by default) so calls the execute function once, with:
|
||||
executeControl none;
|
||||
|
||||
// Parameters, which can be read from other files using macro expansions, e.g.
|
||||
// magU ${${FOAM_CASE}/0/U!Uinlet};
|
||||
diameter 2;
|
||||
|
||||
codeInclude
|
||||
#{
|
||||
// Header files for classes and functions
|
||||
#include "constants.H"
|
||||
using namespace Foam::constant::mathematical;
|
||||
#};
|
||||
|
||||
// Header file paths for Make/options, e.g. for momentum transport models
|
||||
// Example:
|
||||
// -I$(LIB_SRC)/MomentumTransportModels/incompressible/lnInclude
|
||||
codeOptions
|
||||
#{
|
||||
#};
|
||||
|
||||
// Linked libraries for Make/options, e.g. for momentum transport models
|
||||
// Not usually required since libraries are already linked to the solver
|
||||
// Example:
|
||||
// -lincompressibleMomentumTransportModels
|
||||
codeLibs
|
||||
#{
|
||||
#};
|
||||
|
||||
codeData
|
||||
#{
|
||||
// Member data, must be null constructed, e.g. using autoPtr<...>
|
||||
autoPtr<scalar> radius;
|
||||
#};
|
||||
|
||||
codeRead
|
||||
#{
|
||||
// Initialisation of data using "new" operator
|
||||
// Note: divisions "/" require surrounding spaces with macro-expanded ($)
|
||||
// variables, since "/" is the scoping operator, see magU above
|
||||
radius = new scalar($diameter / 2.0);
|
||||
#};
|
||||
|
||||
codeExecute
|
||||
#{
|
||||
// Print to standard output
|
||||
const fvPatch& patch = mesh().boundary()[0];
|
||||
|
||||
Info<< nl << "Some area = " << pi*sqr(radius) << nl
|
||||
<< "Area of patch '" << patch.name() << "' = " << gSum(patch.magSf())
|
||||
<< nl << endl;
|
||||
#};
|
||||
|
||||
// ************************************************************************* //
|
||||
Reference in New Issue
Block a user