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.
42 lines
1.2 KiB
C++
42 lines
1.2 KiB
C++
/*--------------------------------*- C++ -*----------------------------------*\
|
|
========= |
|
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
|
\\ / O peration | Website: https://openfoam.org
|
|
\\ / A nd | Version: dev
|
|
\\/ M anipulation |
|
|
\*---------------------------------------------------------------------------*/
|
|
FoamFile
|
|
{
|
|
format ascii;
|
|
class dictionary;
|
|
object simpleBlockMeshDict;
|
|
}
|
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
|
|
|
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
|
|
#calcInclude "boundBox.H"
|
|
vertices #calc "boundBox($<vector>min, $<vector>max).points()";
|
|
|
|
blocks
|
|
(
|
|
hex #calc "identityMap(8)" $nCells simpleGrading (1 1 1)
|
|
);
|
|
|
|
defaultPatch
|
|
{
|
|
type patch;
|
|
}
|
|
|
|
boundary
|
|
();
|
|
|
|
// ************************************************************************* //
|