ENH: remove restricted precision for calc/eval (#2635)

- in earlier versions: used 'fixed' notation
  to force floating point numbers to be printed with at least
  some decimal digits. However, in the meantime we are more
  flexible with handling float/int input so remove this constraint.

- use ITstream::toString, which makes the string expansion of ${var}
  and the expression expansion of $[var] consistent.
This commit is contained in:
Mark Olesen
2023-02-21 13:14:25 +01:00
parent 74d65ed018
commit d006339c9a
5 changed files with 85 additions and 50 deletions

View File

@ -0,0 +1,39 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2306 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object dictionary;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Test evaluation with small values
dp #eval{ sqrt(3./2.) *1e-3};
a #eval{ 2/sqrt(2.)*$dp };
A_square #eval{ $a*$a };
A_inlet #eval{ $A_square-2*degToRad(180)*$dp*$dp*0.25 };
Q $A_inlet;
Qerror #eval{$A_inlet};
e #eval{0.2526944494428081};
Uin #eval{ $Q/($A_square*$e) };
// Bypass
alt_dp #eval{ sqrt(3./2.) *1e-3};
alt_a #eval{ 2/sqrt(2.)*$[alt_dp] };
alt_A_square #eval{ $[alt_a]*$[alt_a] };
alt_A_inlet #eval{ $[alt_A_square]-2*degToRad(180)*$[alt_dp]*$[alt_dp]*0.25 };
alt_Q $alt_A_inlet;
alt_Qerror #eval{ $[alt_A_inlet] };
alt_e #eval{0.2526944494428081};
alt_Uin #eval{ $[alt_Q]/($[alt_A_square]*$[alt_e]) };
// ************************************************************************* //