// List of vectors example
listU ((1.1 2.1 1.1) (2.1 3.2 4.1) (4.3 5.3 0));
magU1 #calc "mag($<List<vector>>listU[1])";
// Field of vectors and scalars example
magUs #calc "mag($<Field<vector>>listU)";
magSqrU1 #calc "sqr($<Field<scalar>>magUs[1])";
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})";