This can be used identically to a standard Function1. In addition, it
also permits specification of the dimensions. This allows the dimensions
to be checked. It also permits unit conversions. For example:
<name>
{
type table;
// Dimensions
xDimensions [CAD]; // Optional. Argument dimensions/units.
// Here, this specifies coordinates are in
// crank angle degrees (available if using
// engine time).
dimensions [mm]; // Optional. Value dimensions/units.
// Here, values are in mm.
// Tablulated data
values
(
(0 0)
(60 12) // <-- i.e., 12 mm at 60 degrees
(180 20)
(240 8)
(360 0)
);
outOfBounds repeat;
}
This replaces TimeFunction1, as it allows per-function control over
whether the function is considered to be one of real-time or user-time.
Description
Generates the weight for step-wise interpolation and integration
The step transitions are at the end of each interval.
The value returned by the Table::value function returns the value set for the
start of each interval within that interval and transitions abruptly to the next
interval value at the start of the next interval.
The he*Thermo classes have been renamed to match their corresponding
basic thermo classes. E.g., rhoThermo now corresponds to RhoThermo,
rather than heRhoThermo.
This simplifies the IOerror constructors and allows for the location to
be conveniently cached for errors that can't be triggered until after
the IO operation.
at Function1s of time.
Underlying this new functionObject is a generalisation of the handling of the
maximum time-step in the modular solvers to allow complex user-specification of
the maximum time-step used in a simulation, not just the time-dependency
provided by fluidMaxDeltaT but functions of anything in the simulation by
creating a specialised functionObject in which the maxDeltaT function is
defined.
The chemical and combustion time-scale functionObjects adjustTimeStepToChemistry
and adjustTimeStepToCombustion have been updated and simplified using the above
mechanism.
which calls the fvModel::write function which defaults to doing nothing but can
be overridden in derived fvModels to write useful state information at the end
of the write-times.
If the code string is delimited by '#{...#}' multiple lines and multiple code
statements can be used to generate the entry using 'os << ...;'. This is
equivalent to #codeStream but with a more compact syntax, e.g.
maxAngle 30;
nAngles 7;
Us #calc
const vector U($<vector>testCalc2!U);
const int nAngles = $nAngles;
const scalar angleStep = ($<scalar>maxAngle)/(nAngles - 1);
List<vector> Us(nAngles);
for(int i=0; i<nAngles; i++)
{
const scalar angle = degToRad(i*angleStep);
Us[i] = transform(Ry(angle), U);
}
os << Us;
Note the 'os << Us;' statement which writes the data to the dictionary entry in
the same manner as #codeStream, this provides flexibility on how the data is
created and written.
This allows #FOAM_CASE for example to be used in #calc variable lookup, e.g. in
test/dictionary/testCalc:
// assuming the testCalc2 file is local
magU #calc "mag($<vector>testCalc2!U)";
// finding the testCalc2 file using $FOAM_CASE
k #calc "1.5*magSqr(0.05*$<vector>{${FOAM_CASE}/testCalc2!U})";
Also provide fields and curFields functions which return the list of registered
fields not including the geometryFields and current registered fields not
including the geometryFields or old-time fields to simplify mapping code for
NCC, mesh-to-mesh mapping and load-balancing.
Class
Foam::functionEntries::calcEntry
Description
Compiles and executes code string expressions,
returning the result to the dictionary
Usage
\verbatim
a 1.1;
b 3.2;
c #calc "$a*$b";
\endverbatim
Special care is required for calc entries that include a division since
"/" is also used as the scoping operator to identify keywords in
sub-dictionaries. For example, "$a/b" expects a keyword "b" within a
sub-dictionary named "a". A division can be correctly executed by using a
space between a variables and "/", e.g.
\verbatim
c #calc "$a / $b";
\endverbatim
or bracketing the variable, e.g.
\verbatim
c #calc "($a)/$b";
\endverbatim
The code string can be delimited either by '"..."' in which newlines must be
escaped or '#{...#}' which directly supports multi-line strings and is more
convenient when evaluating string expressions by avoiding the need to
escape the quotes, e.g.
\verbatim
c #calc #{ $a*sqrt($b) #};
\endverbatim
\verbatim
s "field";
fieldName #calc #{ $<string>s + "Name" #};
\endverbatim
Additional include files for the #calc code compilation can be specified
using the #calcInclude entry, e.g. if functions from transform.H are used
\verbatim
angleOfAttack 5; // degs
angle #calc "-degToRad($angleOfAttack)";
#calcInclude "transform.H"
liftDir #calc "transform(Ry($angle), vector(0, 0, 1))";
dragDir #calc "transform(Ry($angle), vector(1, 0, 0))";
\endverbatim
Note:
Internally this is just a wrapper around codeStream functionality - the
#calc string is used to construct a dictionary for codeStream.
See also
Foam::functionEntries::calcIncludeEntry
Description
Specify an include file for #calc, expects a single string to follow.
For example if functions from transform.H are used in the #calc expression
\verbatim
angleOfAttack 5; // degs
angle #calc "-degToRad($angleOfAttack)";
#calcInclude "transform.H"
liftDir #calc "transform(Ry($angle), vector(0, 0, 1))";
dragDir #calc "transform(Ry($angle), vector(1, 0, 0))";
\endverbatim
The usual expansion of environment variables and other constructs
(eg, the \c ~OpenFOAM/ expansion) is retained.
See also:
Class
Foam::functionEntries::calcEntry
Description
Uses dynamic compilation to provide calculating functionality
for entering dictionary entries.
E.g.
\verbatim
a 1.0;
b 3;
c #calc "$a*$b";
\endverbatim
Note the explicit trailing 0 ('1.0') to force a to be read (and written)
as a floating point number.
Special care is required for calc entries that include a division since
"/" is also used as the scoping operator to identify keywords in
sub-dictionaries. For example, "$a/b" expects a keyword "b" within a
sub-dictionary named "a". A division can be correctly executed by using a
space between a variables and "/", e.g.
\verbatim
c #calc "$a / $b";
\endverbatim
or "()" scoping around the variable, e.g.
\verbatim
c #calc "($a)/$b";
\endverbatim
Additional include files for the #calc code compilation can be specified
using the #calcInclude entry, e.g. if functions from transform.H are used
\verbatim
angleOfAttack 5; // degs
angle #calc "-degToRad($angleOfAttack)";
#calcInclude "transform.H"
liftDir #calc "transform(Ry($angle), vector(0, 0, 1))";
dragDir #calc "transform(Ry($angle), vector(1, 0, 0))";
\endverbatim
Note:
Internally this is just a wrapper around codeStream functionality - the
#calc string is used to construct a dictionary for codeStream.
Dictionary entries constructed with #calc and #codeStream can now
conveniently access and use typed variables. This means calculations
involving vectors and tensors and list and field types are now possible.
To access a variable and construct it as a given type within a #calc
or #codeStream entry, put the type immediately after the $ symbol inside
angled brackets <>. So, $<vector>var or $<vector>{var} substitutes a
variable named var as a vector.
Examples:
- Reflect a point in a plane defined by a normal
p (1 2 3);
n (1 1 0);
pStar #calc "$<vector>p - (2*sqr($<vector>n)/magSqr($<vector>n)&$<vector>p)";
- Rotate a list of points around an axis by a given angle
points ((3 0 0) (2 1 1) (1 2 2) (0 3 3));
rotation
{
axis (0 1 1);
angle 45;
}
#codeStream
{
codeInclude
#{
#include "pointField.H"
#include "transform.H"
#};
code
#{
const pointField points($<List<point>>points);
const vector axis = $<vector>!rotation/axis;
const scalar angle = degToRad($!rotation/angle);
os << "pointsRotated" << nl << (Ra(axis, angle) & points)() << ";";
#};
};
- Compute the centre and trianglation of a polygon
polygon ((0 0 0) (1 0 0) (2 1 0) (0 2 0) (-1 1 0));
#codeStream
{
codeInclude
#{
#include "polygonTriangulate.H"
#};
code
#{
const List<point> polygon($<List<point>>polygon);
writeEntry(os, "polygonCentre", face::centre(polygon));
polygonTriangulate triEngine;
triEngine.triangulate(polygon);
os << "polygonTris" << ' ' << triEngine.triPoints() << ";";
#};
};
- Generate a single block blockMeshDict for use with snappyHexMesh with no redundant information
min (-2.5 -1.2 -3.0); // Minimum coordinates of the block
max (2.5 1.2 3.0); // Maximum coordinates of the block
nCellsByL 33.3333; // Number of cells per unit length
// Calculate the number of cells in each block direction
nCells #calc "Vector<label>($nCellsByL*($<vector>max - $<vector>min) + vector::one/2)";
// Generate the vertices using a boundBox
vertices #codeStream
{
codeInclude
#{
#include "boundBox.H"
#};
code
#{
os << boundBox($<vector>min, $<vector>max).points();
#};
};
blocks
(
hex (0 1 2 3 4 5 6 7) $nCells simpleGrading (1 1 1)
);
defaultPatch
{
type patch;
}
boundary
();
Specific names have been given for expand functions. Unused functions
have been removed, and functions only used locally have been removed
from the namespace. Documentation has been corrected. Default and
alternative value handling has been removed from code template
expansion.
This allows primitive and other types either directly or indirectly
constructable from Istream to be constructed from a string using pTraits and
IStringStream, e.g.
const vector v(read<vector>("(1 2 3)"));
Variadic constructors have been added to dictionary to facilitate
convenient construction in code, including within a #codeStream entry.
The constructors take an even number of arguments, alternating between
the key and the corresponding value. The values may, themselves, be
dictionaries constructed in the same way. This means that the code
directly maps to the resulting nested dictionary structure.
For example, the following code stream entry:
#codeStream
{
code
#{
writeEntry
(
os,
"dict",
dictionary
(
"s", 1,
"wl", wordList({"apples", "oranges"}),
"subDict", dictionary
(
"v", vector(2, 3, 4),
"t", tensor(5, 6, 7, 8, 9, 10, 11, 12, 13),
"ll", labelList(10, -1)
)
)
);
#};
}
Expands to the following:
dict
{
s 1;
wl 2 ( apples oranges );
subDict
{
v ( 2 3 4 );
t ( 5 6 7 8 9 10 11 12 13 );
ll 10 { -1 };
}
}
setFormat no longer defaults to the value of graphFormat optionally set in
controlDict and must be set in the functionObject dictionary.
boundaryFoam, financialFoam and pdfPlot still require a graphFormat entry in
controlDict but this is now read directly rather than by Time.
With
executeControl runTimes;
executeTimes (0.1 0.2 0.3);
the functionObject will be executed at 0.1s, 0.2s and 0.3s only.
With
writeControl runTimes;
writeTimes (0.1 0.2 0.3);
the functionObject will write at 0.1s, 0.2s and 0.3s only.
for cases started or restarted from some arbitrary time without a corresponding
<time>/uniform/time dictionary to set the beginTime to the logical start of the
simulation. Setting beginTime to 0 for example ensures that write times,
functionObject evaluations and writes etc. occur at intervals starting from 0
rather than the arbitrary startTime.
If the libs entry is not provided and the name of the library containing the
functionObject, fvModel or fvConstraint corresponds to the type specified the
corresponding library is automatically loaded, e.g. to apply the
VoFTurbulenceDamping fvModel to an incompressibleVoF simulation the following
will load the libVoFTurbulenceDamping.so library automatically and instantiate
the fvModel:
turbulenceDamping
{
type VoFTurbulenceDamping;
delta 1e-4;
}