mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: improve expression string expansions
- reuse more of stringOps expansions to reduce code and improve the
syntax flexiblity.
We can now embed "pre-calculated" values into an expression.
For example,
angle 35;
valueExpr "vector(${{cos(degToRad($angle))}}, 2, 3)";
and the ${{..}} will be evaluated with the regular string evaluation
and used to build the entire expression for boundary condition
evaluation.
Could also use for fairly wild indirect referencing:
axis1 (1 0 0);
axis2 (0 1 0);
axis3 (0 0 1);
index 100;
expr "$[(vector) axis${{ ($index % 3) +1 }}] / ${{max(1,$index)}}";
This commit is contained in:
@ -115,7 +115,25 @@ public:
|
||||
~exprString() = default;
|
||||
|
||||
|
||||
// Member Functions
|
||||
// Static Member Functions
|
||||
|
||||
//- Inplace expansion with dictionary variables,
|
||||
//- and strip C/C++ comments from the input
|
||||
static void inplaceExpand
|
||||
(
|
||||
std::string& str,
|
||||
const dictionary& dict,
|
||||
const bool stripComments = true
|
||||
);
|
||||
|
||||
//- Get and expand expression with dictionary entries,
|
||||
//- optionally strip C/C++ comments from the input
|
||||
static exprString getExpression
|
||||
(
|
||||
const word& name,
|
||||
const dictionary& dict,
|
||||
const bool stripComments = false
|
||||
);
|
||||
|
||||
//- Copy convert string to exprString.
|
||||
// No expansions, know what you are doing.
|
||||
@ -125,6 +143,9 @@ public:
|
||||
// No expansions, know what you are doing.
|
||||
inline static exprString toExpr(std::string&& str);
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Inplace expansion with dictionary variables,
|
||||
//- and strip C/C++ comments from the input
|
||||
exprString& expand
|
||||
|
||||
Reference in New Issue
Block a user