ENH: support token conversion of scalar to label (#1696)
- this specifically arises in the case we have used the `#eval` syntax to generate a value. However, since the expressions produce scalar/vector/tensor etc, the tokenized value will *not* be introduced into the dictionary as a label, even if it appears to be an integer value. Eg, eval "2*5", eval "sqrt(100)" both yield `scalar(100)`, which will not be suitable for any consumer expecting a label value. With the `#calc` version, this problem is glossed over since it uses a string buffer for the output (which can suppress the decimal) and re-parses the string into tokens, which causes a label to be recognized. - Since we obviously already support implicit handling of ints as floats (when reading), now also allow conversion of float representations of integral values. Uses the ad hoc value of 1e-4 for deciding if the value deviates too far from being integral. - As a side-effect, can now also support scientific notation when specifying integers. Eg, (10 100 1e+3) for cell counts.
Showing
- src/OpenFOAM/primitives/ints/int32/int32IO.C 30 additions, 1 deletionsrc/OpenFOAM/primitives/ints/int32/int32IO.C
- src/OpenFOAM/primitives/ints/int64/int64IO.C 30 additions, 1 deletionsrc/OpenFOAM/primitives/ints/int64/int64IO.C
- src/OpenFOAM/primitives/ints/uint32/uint32IO.C 30 additions, 1 deletionsrc/OpenFOAM/primitives/ints/uint32/uint32IO.C
- src/OpenFOAM/primitives/ints/uint64/uint64IO.C 30 additions, 1 deletionsrc/OpenFOAM/primitives/ints/uint64/uint64IO.C
Please register or sign in to comment