Commit Graph

8 Commits

Author SHA1 Message Date
fbc36b8d21 test/dictionary/testCalcNewton: Added a #codeStream graph writing example 2023-07-18 17:31:29 +01:00
cc9991e9a3 test/dictionary/testCalcNewton: Example of #calc with #{...#} to find the root of a function
using Newton-Raphson iteration.
2023-07-18 15:26:46 +01:00
bebe584842 test/dictionary/testCalc: Added example of a HashTable entry and access in #calc
namedU          (U0 (1.1 2.1 1.1) U1 (2.1 3.2 4.1) U2 (4.3 5.3 0));
magU2           #calc "mag($<HashTable<vector>>namedU[\"U2\"])";
2023-07-17 20:59:51 +01:00
1f6ceeb3d6 test/dictionary/testCalc: Added examples of lists and fields
// 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])";
2023-07-17 20:30:22 +01:00
441b60c70d functionEntries::calcEntry: Extended the functionality of multi-statement/multi-line #calc
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.
2023-07-06 23:11:36 +01:00
8d1f918c31 stringOps::inplaceExpandCodeString: Added environment variable path expansion to #calc
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})";
2023-07-04 21:51:22 +01:00
9fbb298204 test/dictionary: Added more dictionary tests and examples
All dictionaries are expanded using foamDictionary -expand
2023-07-04 13:44:37 +01:00
835ef31a1d foamDictionary: Moved the dictionary tests/examples to applications/test/dictionary 2023-07-03 13:38:37 +01:00