mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: use exprString expansions for #eval
- follows the principle of least surprise if the expansion behaviour for #eval and expressions (eg, exprFixedValue) are the same. This is possible now that we harness the regular stringOps::expand() within exprString::expand()
This commit is contained in:
@ -47,10 +47,10 @@ eval6b #eval " pi() * 2 * ${{ ${unknown:-0} * ${{ 15 * 3 }} }} + 5";
|
||||
eval6c #eval " pi() * 2 * ${{ -${unknown:-0} * ${{ 15 * 3 }} }} + 5";
|
||||
|
||||
// Even this work
|
||||
eval7a #eval " pi() * 1 * ${factor${{2*5}}:-100}";
|
||||
eval7a #eval " pi() * 1 * ${factor${{2*5}}:-100}";
|
||||
|
||||
// Even this work
|
||||
eval7b #eval " pi() * 1 * ${factorXYZ${{2*5}}:-100}";
|
||||
eval7b #eval " pi() * 1 * ${factorXYZ${{2*5}}:-100}";
|
||||
|
||||
index 10;
|
||||
|
||||
@ -58,7 +58,40 @@ eval8a #eval " pi() * 2 * ${{ ${factor$index} + ${factor10} }}";
|
||||
|
||||
eval8b #eval " pi() * 2 * $factor * ${{ 100 }}";
|
||||
|
||||
eval10a #eval "vector(1,2,3) * 5";
|
||||
eval10a #eval "vector(1,2,3) * 5";
|
||||
|
||||
|
||||
// Slightly stranger ideas:
|
||||
|
||||
axis1 (1 0 0);
|
||||
axis2 (0 1 0);
|
||||
axis3 (0 0 1);
|
||||
index 100;
|
||||
|
||||
location #eval #{
|
||||
400 *
|
||||
|
||||
// Numerator: use the index to get relevant suffix [1,2,3]
|
||||
// to form the lookup of axis1,axis2,...
|
||||
// Treat the lookup as a vector within the expression evaluation
|
||||
|
||||
$[(vector) axis${{
|
||||
($index % 3) + 1 /* Evaluates: 1,2,3 from index */ }}
|
||||
]
|
||||
|
||||
// Denominator: divide by index with zero-division protection
|
||||
/ ${{max(1, $index)}}
|
||||
|
||||
// Same thing, but using expressions-syntax for variable lookup
|
||||
/ ${{max(1, $[index])}}
|
||||
#};
|
||||
|
||||
|
||||
// This is still a rather clunky syntax
|
||||
length #eval{ cbrt(mag($[(vector) location])) };
|
||||
|
||||
|
||||
// Remove evidence of some variables
|
||||
#remove ("axis[0-9]*" index)
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
Reference in New Issue
Block a user