2018-07-16 16:58 BST

View Issue Details Jump to Notes ]
IDProjectCategoryView StatusLast Update
0002889OpenFOAM[All Projects] Bugpublic2018-03-26 16:04
ReporterSamMallinson 
Assigned Tohenry 
PrioritynormalSeverityminorReproducibilityalways
StatusresolvedResolutionfixed 
PlatformUnixOSDebianOS Versionbuster
Product Version5.x 
Target VersionFixed in Versiondev 
Summary0002889: #calc converts all variables to float
Description#calc is a great way to perform simple calcs on the fly, and thus avoid hand calculation errors

However, I have noticed a strange behaviour when I use variables that have small values.

For example, if I have some parameters defined in a file:

// material properties
nu 1.0e-8;
// data for gradient calculation
U0 1.0;
dUdx #calc "$U0 / $nu";

which is then #include-d in a dict, then I get a floating point exception.

Looking into the dynamicCode generated:

dynamicCode/_895f27c8e0b93b41af125bc39eee9041e7fd19d5/codeStreamTemplate.C:

os << (1.000000 / 0.000000);

i.e. the doubles have been printed in some kind of %f format and reduced to zero.
Steps To Reproduce#include a file, with some parameters which are calculated, inside a dict

run an application which accesses this dict

I've attached a very simple example to demonstrate this
Additional InformationObvious workaround - change units (or non-dimensionalize) to eliminate this possibility
Tags#calc, codeStream
Attached Files

-Relationships
+Relationships

-Notes

~0009445

henry (reporter)

Resolved by commit 80cf711937dfae84e6afc11adb5de1e4f3003cae
+Notes

-Issue History
Date Modified Username Field Change
2018-03-26 01:28 SamMallinson New Issue
2018-03-26 01:28 SamMallinson File Added: hashcalcexample.tar
2018-03-26 01:28 SamMallinson Tag Attached: codeStream
2018-03-26 01:28 SamMallinson Tag Attached: #calc
2018-03-26 16:04 henry Assigned To => henry
2018-03-26 16:04 henry Status new => resolved
2018-03-26 16:04 henry Resolution open => fixed
2018-03-26 16:04 henry Fixed in Version => dev
2018-03-26 16:04 henry Note Added: 0009445
+Issue History