View Issue Details

IDProjectCategoryView StatusLast Update
0003532OpenFOAMBugpublic2020-08-13 10:39
ReporterTiberias_ Assigned Tohenry  
PrioritynormalSeverityminorReproducibilityalways
Status closedResolutionno change required 
PlatformGNU/LinuxOSUbuntuOS Version20.04
Summary0003532: blockMesh with variable calculations in blockMeshDict gives error variable not declared
DescriptionSince 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 ReproduceTry to execute blockMesh with the attached files.
TagsNo tags attached.

Activities

Tiberias_

2020-08-11 20:00

reporter  

meshtest8.zip (6,629 bytes)

henry

2020-08-12 15:31

manager   ~0011453

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)";

henry

2020-08-12 15:38

manager   ~0011454

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)";

Tiberias_

2020-08-13 01:09

reporter   ~0011455

Your suggested solutions working pretty well for me.

Thanks for clarification!

Issue History

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