View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0003532 | OpenFOAM | Bug | public | 2020-08-11 20:00 | 2020-08-13 10:39 |
Reporter | Tiberias_ | Assigned To | henry | ||
Priority | normal | Severity | minor | Reproducibility | always |
Status | closed | Resolution | no change required | ||
Platform | GNU/Linux | OS | Ubuntu | OS Version | 20.04 |
Summary | 0003532: blockMesh with variable calculations in blockMeshDict gives error variable not declared | ||||
Description | Since version 8 blockMesh gives "error: ‘$lx’ was not declared in this scope". xmin -0.2; xmax 0.6; ymin -0.6; ymax 1.2; zmin -0.6; zmax 0.6; dx 0.02; dy 0.015; dz 0.012; lx #calc "$xmax - $xmin"; ly #calc "$ymax - $ymin"; lz #calc "$zmax - $zmin"; xcells #calc "abs($lx/$dx)"; ycells #calc "abs($ly/$dy)"; zcells #calc "abs($lz/$dz)"; The dynamic Code creation for lx, ly and lz works, but at the codeStreamTemplate.C for the calculation of xcells there is no value replacement for "$lx". // * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * // extern "C" { void codeStream_bf33cc3ca44f835968d77095496687b716b9d78f ( Ostream& os, const dictionary& dict ) { //{{{ begin code #line 1 "/home/user/Schreibtisch/meshtest8/system/blockMeshDict" os << (abs($lx/2.0000000e-02)); //}}} end code } } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // | ||||
Steps To Reproduce | Try to execute blockMesh with the attached files. | ||||
Tags | No tags attached. | ||||
|
|
|
The problem is a conflict between the use of '/' for scoped variable lookup, file names, environment variables etc and '/' as the division operator as both are now valid within #calc. The easiest solution is to add put spaces around the '/' xcells #calc "abs($lx / $dx)"; ycells #calc "abs($ly / $dy)"; zcells #calc "abs($lz / $dz)"; |
|
The other option is to use '()' to specify more precisely the scope of the variable lookup: xcells #calc "abs(($lx)/$dx)"; ycells #calc "abs(($ly)/$dy)"; zcells #calc "abs(($lz)/$dz)"; |
|
Your suggested solutions working pretty well for me. Thanks for clarification! |
Date Modified | Username | Field | Change |
---|---|---|---|
2020-08-11 20:00 | Tiberias_ | New Issue | |
2020-08-11 20:00 | Tiberias_ | File Added: meshtest8.zip | |
2020-08-12 15:31 | henry | Note Added: 0011453 | |
2020-08-12 15:38 | henry | Note Added: 0011454 | |
2020-08-12 18:39 | henry | Severity | major => minor |
2020-08-13 01:09 | Tiberias_ | Note Added: 0011455 | |
2020-08-13 09:13 | henry | Assigned To | => henry |
2020-08-13 09:13 | henry | Status | new => closed |
2020-08-13 09:13 | henry | Resolution | open => no change required |
2020-08-13 09:13 | henry | Fixed in Version | => 8 |