CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Meshing & Mesh Conversion

[blockMesh] blockMesh edit file with custom variables not working

Register Blogs Community New Posts Updated Threads Search

Like Tree1Likes
  • 1 Post By AtoHM

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   September 25, 2023, 14:56
Exclamation blockMesh edit file with custom variables not working
  #1
New Member
 
Debarchan Das
Join Date: Sep 2023
Posts: 3
Rep Power: 3
debda018 is on a distinguished road
Hello,
I am working on the openFOAM lid cavity tutorial.This is my blockMesh file where I have edited and placed my variables to construct the mesh. But smehow i run into an error which I have posted below. IS there anyone who can help me regarding this on where I am going wrong. I am also new in learning openFOAM. Anyone who has solved similar issue??

*--------------------------------*- C++ -*----------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Version: 10
\\/ M anipulation |
\*---------------------------------------------------------------------------*/
FoamFile
{
format ascii;
class dictionary;
object blockMeshDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

convertToMeters 0.1;

xmin 0;
xmax 1;
ymin 0;
ymax 1;
zmin 0;
zmax 0.1;

vertices(
($xmin $ymin $zmin) //0
($xmax $ymin $zmin) //1
($xmax $ymax $zmin) //2
($xmin $ymax $zmin) //3
($xmin $ymin $zmax) //4
($xmax $ymin $zmax) //5
($xmax $ymax $zmax) //6
($xmin $ymax $zmax) //7
);

deltax 0.05; //spacing along x direction
deltay 0.05; //spaceing along y diretcion
deltaz 0.05; //spacing along z direction

lx #calc "$xmax - $xmin"; //length along x-axix
ly #calc "$ymax - $ymin"; //length along y-axis
lz #calc "$zmax - $zmin"; //length along z-axis

xcells #calc "(round($lx / $deltax))"; //no of cells in x direction
ycells #calc "(round($ly / $deltay))"; //no of cells in y direction
zcells #calc "(round($lz / $deltaz))"; //no of cells in z direction

blocks
(
hex (0 1 2 3 4 5 6 7) ($xcells $ycells $zcells)
simpleGrading(
//x direction
(0.2 0.25 8)
(0.6 0.50 1)
(0.2 0.25 0.125)
)
(
//y direction
(0.2 0.25 8)
(0.6 0.50 1)
(0.2 0.25 0.125)
)
(
//z direction
1
)
);

boundary
(
movingWall
{
type wall;
faces
(
(3 7 6 2)
);
}
fixedWalls
{
type wall;
faces
(
(0 4 7 3)
(2 6 5 1)
(1 5 4 0)
);
}
frontAndBack
{
type empty;
faces
(
(0 3 2 1)
(4 5 6 7)
);
}
);


// ************************************************** *********************** //
************************************************** ************************************************** *

The error messege I get after running blockMesh command is here as follows:

*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Version: 10
\\/ M anipulation |
\*---------------------------------------------------------------------------*/
Build : 10-e450dce21ea5
Exec : blockMesh
Date : Sep 25 2023
Time : 17:35:26
Host : "ml"
PID : 31731
I/O : uncollated
Case : /home/ml/OpenFOAM/ml-10/run/cavity/cavity
nProcs : 1
sigFpe : Enabling floating point exception trapping (FOAM_SIGFPE).
fileModificationChecking : Monitoring run-time modified files using timeStampMaster (fileModificationSkew 10)
allowSystemOperations : Allowing user-supplied system call operations

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
Create time

Reading "blockMeshDict"

Creating block mesh from
"system/blockMeshDict"
Using #calcEntry at line 40 in file "/home/ml/OpenFOAM/ml-10/run/cavity/cavity/system/blockMeshDict"
Using #codeStream with "/home/ml/OpenFOAM/ml-10/run/cavity/cavity/dynamicCode/platforms/linux64GccDPInt32Opt/lib/libcodeStream_55901ee8754faa7266ca8fc7a65319beb51c d312.so"
codeStream : dictionary:"/home/ml/OpenFOAM/ml-10/run/cavity/cavity/system/blockMeshDict" master-only-reading:1
Using #calcEntry at line 41 in file "/home/ml/OpenFOAM/ml-10/run/cavity/cavity/system/blockMeshDict"
codeStream : dictionary:"/home/ml/OpenFOAM/ml-10/run/cavity/cavity/system/blockMeshDict" master-only-reading:1
Using #calcEntry at line 42 in file "/home/ml/OpenFOAM/ml-10/run/cavity/cavity/system/blockMeshDict"
Using #codeStream with "/home/ml/OpenFOAM/ml-10/run/cavity/cavity/dynamicCode/platforms/linux64GccDPInt32Opt/lib/libcodeStream_45420be29fe5b8345c57c4b92e41092313d1 37b2.so"
codeStream : dictionary:"/home/ml/OpenFOAM/ml-10/run/cavity/cavity/system/blockMeshDict" master-only-reading:1
Using #calcEntry at line 44 in file "/home/ml/OpenFOAM/ml-10/run/cavity/cavity/system/blockMeshDict"
Using #codeStream with "/home/ml/OpenFOAM/ml-10/run/cavity/cavity/dynamicCode/platforms/linux64GccDPInt32Opt/lib/libcodeStream_0d6337e7391cbfcb6fc07e564888683c9301 a5e9.so"
Invoking "wmake -s libso /home/ml/OpenFOAM/ml-10/run/cavity/cavity/dynamicCode/_0d6337e7391cbfcb6fc07e564888683c9301a5e9"
wmake libso /home/ml/OpenFOAM/ml-10/run/cavity/cavity/dynamicCode/_0d6337e7391cbfcb6fc07e564888683c9301a5e9
Ctoo: codeStreamTemplate.C
/home/ml/OpenFOAM/ml-10/run/cavity/cavity/system/blockMeshDict: In function ‘void Foam::codeStream_0d6337e7391cbfcb6fc07e564888683c9 301a5e9(Foam::Ostream&, const Foam::dictionary&)’:
/home/ml/OpenFOAM/ml-10/run/cavity/cavity/system/blockMeshDict:1:15: error: ‘$lx’ was not declared in this scope
/*--------------------------------*- C++ -*----------------------------------*\
^~~
/home/ml/OpenFOAM/ml-10/run/cavity/cavity/system/blockMeshDict:1:21: error: ‘$deltax’ was not declared in this scope
/*--------------------------------*- C++ -*----------------------------------*\
^~~~~~~
/home/ml/OpenFOAM/ml-10/run/cavity/cavity/system/blockMeshDict:1:21: note: suggested alternative: ‘labelMax’
/*--------------------------------*- C++ -*----------------------------------*\
^~~~~~~
labelMax
/opt/openfoam10/wmake/rules/General/transform:25: recipe for target 'Make/linux64GccDPInt32Opt/codeStreamTemplate.o' failed
make: *** [Make/linux64GccDPInt32Opt/codeStreamTemplate.o] Error 1


--> FOAM FATAL IO ERROR:
Failed wmake "dynamicCode/_0d6337e7391cbfcb6fc07e564888683c9301a5e9/platforms/linux64GccDPInt32Opt/lib/libcodeStream_0d6337e7391cbfcb6fc07e564888683c9301 a5e9.so"


file: /home/ml/OpenFOAM/ml-10/run/cavity/cavity/system/blockMeshDict from line 16 to line 23.

From function static void (* Foam::functionEntries::codeStream::getFunction(con st Foam::dictionary&, const Foam::dictionary&))(Foam::Ostream&, const Foam::dictionary&)
in file db/dictionary/functionEntries/codeStream/codeStream.C at line 175.

FOAM exiting
debda018 is offline   Reply With Quote

Old   September 26, 2023, 09:22
Default
  #2
Senior Member
 
M
Join Date: Dec 2017
Posts: 703
Rep Power: 13
AtoHM is on a distinguished road
a toughy, the error is quite misleading. I pushed some things around to get clearer error messages.

1) you have some syntax errors. "vertices" is not found, because there is no whitespace between the keyword and the "("
2) your grading definition in the block is weird, I switched it to something easier and now it works ... you can work from there.
3) edges () was missing, not sure if this was critical or not.

The below runs withouit errors for me.
Code:
/*--------------------------------*- C++ -*----------------------------------*\
  =========                 |
  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
   \\    /   O peration     | Website:  https://openfoam.org
    \\  /    A nd           | Version:  9
     \\/     M anipulation  |
\*---------------------------------------------------------------------------*/
FoamFile
{
    format      ascii;
    class       dictionary;
    object      blockMeshDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

convertToMeters 0.1;

xmin 0;
xmax 1;
ymin 0;
ymax 1;
zmin 0;
zmax 0.1;

deltax 0.05; //spacing along x direction
deltay 0.05; //spaceing along y diretcion
deltaz 0.05; //spacing along z direction

lx #calc "$xmax - $xmin"; //length along x-axix
ly #calc "$ymax - $ymin"; //length along y-axis
lz #calc "$zmax - $zmin"; //length along z-axis

xcells #calc "(round($lx / $deltax))"; //no of cells in x direction
ycells #calc "(round($ly / $deltay))"; //no of cells in y direction
zcells #calc "(round($lz / $deltaz))"; //no of cells in z direction

vertices (
($xmin $ymin $zmin) //0
($xmax $ymin $zmin) //1
($xmax $ymax $zmin) //2
($xmin $ymax $zmin) //3
($xmin $ymin $zmax) //4
($xmax $ymin $zmax) //5
($xmax $ymax $zmax) //6
($xmin $ymax $zmax) //7
);

blocks (
    hex (0 1 2 3 4 5 6 7) ($xcells $ycells $zcells) simpleGrading (1 1 1)
);

edges
(
);

boundary
(
movingWall
{
type wall;
faces
(
(3 7 6 2)
);
}
fixedWalls
{
type wall;
faces
(
(0 4 7 3)
(2 6 5 1)
(1 5 4 0)
);
}
frontAndBack
{
type empty;
faces
(
(0 3 2 1)
(4 5 6 7)
);
}
);

// ************************************************************************* //
Yann likes this.
AtoHM is offline   Reply With Quote

Old   September 26, 2023, 10:11
Thumbs up Issue solved!
  #3
New Member
 
Debarchan Das
Join Date: Sep 2023
Posts: 3
Rep Power: 3
debda018 is on a distinguished road
Hello AtoHM ,

Thank you so much for you reply. I pasted the code and ran it, polymesh got created. The spcaing tip and the edges were really a good points which I had missed.

I wanted to ask if there are any ways of actually putting gradient in the x and y direction and in that case how does the code works. In that case how will the simpleGradient will look like. Any examples or leads you can send me would be really helpful.
debda018 is offline   Reply With Quote

Old   September 26, 2023, 10:45
Default
  #4
Senior Member
 
M
Join Date: Dec 2017
Posts: 703
Rep Power: 13
AtoHM is on a distinguished road
You are welcome.
There are examples here http://www.wolfdynamics.com/wiki/mes..._blockmesh.pdf that look suspiciously like what you did above. You probably have a missing or exceeding brackets, maybe these?

Code:
simpleGrading (
(  // <-- missing?

...



 ... 

(  // <-- too much?
//z direction
Try to add your code back in and carefully look for the syntax. You can also try to run the whole example from there first to see if it works properly.
AtoHM is offline   Reply With Quote

Old   September 26, 2023, 11:10
Default
  #5
New Member
 
Debarchan Das
Join Date: Sep 2023
Posts: 3
Rep Power: 3
debda018 is on a distinguished road
Thanks for the blockMesh tutorial link. Looking for some similar material. it's a huge help.
debda018 is offline   Reply With Quote

Reply

Tags
#blockmeshdict


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
what is swap4foam ?? AB08 OpenFOAM 28 February 2, 2016 02:22
[swak4Foam] Problem installing swak_2.x for OpenFoam-2.4.0 towanda OpenFOAM Community Contributions 6 September 5, 2015 22:03
[swak4Foam] Error bulding swak4Foam sfigato OpenFOAM Community Contributions 18 August 22, 2013 13:41
"parabolicVelocity" in OpenFoam 2.1.0 ? sawyer86 OpenFOAM Running, Solving & CFD 21 February 7, 2012 12:44
DxFoam reader update hjasak OpenFOAM Post-Processing 69 April 24, 2008 02:24


All times are GMT -4. The time now is 02:37.