# [blockMesh] Mesing a polar cylinder in x-direction

 Register Blogs Members List Search Today's Posts Mark Forums Read

 April 4, 2024, 14:39 Mesing a polar cylinder in x-direction #1 Member   Marķa Rosales Join Date: Mar 2023 Location: Spain Posts: 35 Rep Power: 3 Good day community, Please, can you give me a hand in the block definition. I want to elaborate a cylindrical geometry, radial directions in y & z, and length along x-axis. The grid that I want is polar so I wanted to reproduce 4 times a quarter of cylinder but I got stucked in the block definition: Code: ```scale 1; cx 0.0; cy 0.0; cz 80.0; height 3; r 45; h #calc "\$height+\$cx"; vz #calc "\$cz+\$r"; nvz #calc "\$cz-\$r"; vy #calc "\$cy+\$r"; nvy #calc "\$cy-\$r"; c1 #calc "\$cz + (\$r*cos(45.0))"; // cosine in first quadrant s1 #calc "\$cy + (\$r*sin(45.0))"; // sine c2 #calc "\$cz + (\$r*cos(135.0))"; // cosine in first quadrant s2 #calc "\$cy + (\$r*sin(135.0))"; // sine c3 #calc "\$cz + (\$r*cos(225.0))"; // cosine in first quadrant s3 #calc "\$cy + (\$r*sin(225.0))"; // sine c4 #calc "\$cz + (\$r*cos(315.0))"; // cosine in first quadrant s4 #calc "\$cy + (\$r*sin(315.0))"; // sine vertices ( (\$cx \$cy \$nvz) //0 (\$h \$cy \$nvz) //1 (\$h \$vy \$cz) //2 (\$cx \$vy \$cz) //3 (\$cx \$nvy \$cz) //4 (\$h \$nvy \$cz) //5 (\$h \$cy \$vz) //6 (\$cz \$cy \$vz) //7 (\$cx \$cy \$cz) //8 (\$h \$cy \$cz) //9 ); blocks ( hex (8 4 0 8 9 5 1 9) (1 15 15) simpleGrading (1 1 1) hex (8 0 3 8 9 1 2 9) (1 15 15) simpleGrading (1 1 1) hex (8 3 7 8 9 2 6 9) (1 15 15) simpleGrading (1 1 1) hex (8 7 4 8 9 6 5 9) (1 15 15) simpleGrading (1 1 1) ); edges ( arc 0 1 (\$cx \$s1 \$c1) arc 1 2 (\$cx \$s2 \$c2) arc 2 3 (\$cx \$s3 \$c3) arc 3 0 (\$cx \$s4 \$c4) arc 4 5 (\$h \$s1 \$c1) arc 5 6 (\$h \$s2 \$c2) arc 6 7 (\$h \$s3 \$c3) arc 7 4 (\$h \$s4 \$c4) );``` The error in terminal is: Code: ```Creating block edges No non-planar block faces defined Creating topology blocks --> FOAM Warning : From Foam::vector Foam::cellModel::centre(const labelList&, const Foam::UList >&) const in file meshes/meshShapes/cellModel/cellModel.C at line 63 zero or negative pyramid volume: -12487.5 for face 1 --> FOAM Warning : From Foam::vector Foam::cellModel::centre(const labelList&, const Foam::UList >&) const in file meshes/meshShapes/cellModel/cellModel.C at line 63 zero or negative pyramid volume: -6243.75 for face 3 --> FOAM Warning : From Foam::vector Foam::cellModel::centre(const labelList&, const Foam::UList >&) const in file meshes/meshShapes/cellModel/cellModel.C at line 63 zero or negative pyramid volume: -2868.75 for face 4 --> FOAM Warning : From Foam::vector Foam::cellModel::centre(const labelList&, const Foam::UList >&) const in file meshes/meshShapes/cellModel/cellModel.C at line 63 zero or negative pyramid volume: -2868.75 for face 5 --> FOAM FATAL IO ERROR: (openfoam-2306) Block hex (8 3 7 8 9 2 6 9) (1 15 15) grading (1(1) 1(1) 1(1)) has inward-pointing faces 4(3 7 6 2) 4(8 9 6 7) 4(8 8 7 3) 4(9 2 6 9) file: system/blockMeshDict.blocks at line 68. From void Foam::blockDescriptor::check(const Foam::Istream&) in file blockDescriptor/blockDescriptor.C at line 147. FOAM exiting``` Any comments are welcome

 April 5, 2024, 06:46 #2 New Member   Matthias Renaud Join Date: Jan 2023 Posts: 2 Rep Power: 0 Hola Maria, I see a few errors in your blockMeshDict file. First I assume the cos and sin function to take angle in rad as inputs, you could also used sqrt(2) just as I did. Second your vertex 7 in not defined correctly, it should be (\$cx \$cy \$vz) you wrote \$cz instead. And last all your edges are wrong, there should be no arc between vertices 0 and 1, 6 and 7, 4 and 5, 2 and 3. Below is my version of the blockMeshDict (it works): Code: ```scale 1; cx 0.0; cy 0.0; cz 80.0; height 3; r 45; h #calc "\$height+\$cx"; vz #calc "\$cz+\$r"; nvz #calc "\$cz-\$r"; vy #calc "\$cy+\$r"; nvy #calc "\$cy-\$r"; c1 #calc "\$cz + (\$r / sqrt(2.0))"; // cosine in first quadrant s1 #calc "\$cy + (\$r / sqrt(2.0))"; // sine c2 #calc "\$cz - (\$r / sqrt(2.0))"; // cosine in first quadrant s2 #calc "\$cy + (\$r / sqrt(2.0))"; // sine c3 #calc "\$cz - (\$r / sqrt(2.0))"; // cosine in first quadrant s3 #calc "\$cy - (\$r / sqrt(2.0))"; // sine c4 #calc "\$cz + (\$r / sqrt(2.0))"; // cosine in first quadrant s4 #calc "\$cy - (\$r / sqrt(2.0))"; // sine vertices ( (\$cx \$cy \$nvz) //0 (\$h \$cy \$nvz) //1 (\$h \$vy \$cz) //2 (\$cx \$vy \$cz) //3 (\$cx \$nvy \$cz) //4 (\$h \$nvy \$cz) //5 (\$h \$cy \$vz) //6 (\$cx \$cy \$vz) //7 (\$cx \$cy \$cz) //8 (\$h \$cy \$cz) //9 ); blocks ( hex (8 4 0 8 9 5 1 9) (15 15 15) simpleGrading (1 1 1) hex (8 0 3 8 9 1 2 9) (15 15 15) simpleGrading (1 1 1) hex (8 3 7 8 9 2 6 9) (15 15 15) simpleGrading (1 1 1) hex (8 7 4 8 9 6 5 9) (15 15 15) simpleGrading (1 1 1) ); edges ( arc 7 3 (\$cx \$s1 \$c1) arc 6 2 (\$h \$s1 \$c1) arc 3 0 (\$cx \$s2 \$c2) arc 2 1 (\$h \$s2 \$c2) arc 0 4 (\$cx \$s3 \$c3) arc 1 5 (\$h \$s3 \$c3) arc 4 7 (\$cx \$s4 \$c4) arc 5 6 (\$h \$s4 \$c4) );``` Have a nice day, Matthias

 April 5, 2024, 10:38 #3 Member   Marķa Rosales Join Date: Mar 2023 Location: Spain Posts: 35 Rep Power: 3 MUCHAS GRACIAS Matthias, The cylinder worked with your solution! Here I share how the blockMesh would look like: Code: ``` scale 1; cx 0.0; cy 0.0; cz 80.0; height 3; r 45; h #calc "\$height+\$cx"; vz #calc "\$cz+\$r"; nvz #calc "\$cz-\$r"; vy #calc "\$cy+\$r"; nvy #calc "\$cy-\$r"; c1 #calc "\$cz + (\$r / sqrt(2.0))"; // cosine in first quadrant s1 #calc "\$cy + (\$r / sqrt(2.0))"; // sine c2 #calc "\$cz - (\$r / sqrt(2.0))"; // cosine in first quadrant s2 #calc "\$cy + (\$r / sqrt(2.0))"; // sine c3 #calc "\$cz - (\$r / sqrt(2.0))"; // cosine in first quadrant s3 #calc "\$cy - (\$r / sqrt(2.0))"; // sine c4 #calc "\$cz + (\$r / sqrt(2.0))"; // cosine in first quadrant s4 #calc "\$cy - (\$r / sqrt(2.0))"; // sine vertices ( (\$cx \$cy \$nvz) //0 (\$h \$cy \$nvz) //1 (\$h \$vy \$cz) //2 (\$cx \$vy \$cz) //3 (\$cx \$nvy \$cz) //4 (\$h \$nvy \$cz) //5 (\$h \$cy \$vz) //6 (\$cx \$cy \$vz) //7 (\$cx \$cy \$cz) //8 (\$h \$cy \$cz) //9 ); blocks ( hex (8 4 0 8 9 5 1 9) (15 15 1) simpleGrading (1 1 1) hex (8 0 3 8 9 1 2 9) (15 15 1) simpleGrading (1 1 1) hex (8 3 7 8 9 2 6 9) (15 15 1) simpleGrading (1 1 1) hex (8 7 4 8 9 6 5 9) (15 15 1) simpleGrading (1 1 1) ); edges ( arc 7 3 (\$cx \$s1 \$c1) arc 6 2 (\$h \$s1 \$c1) arc 3 0 (\$cx \$s2 \$c2) arc 2 1 (\$h \$s2 \$c2) arc 0 4 (\$cx \$s3 \$c3) arc 1 5 (\$h \$s3 \$c3) arc 4 7 (\$cx \$s4 \$c4) arc 5 6 (\$h \$s4 \$c4) ); boundary ( upwind { type patch; faces ( (8 0 4 8) (8 3 0 8) (8 7 3 8) (8 4 7 8) ); } sides { type patch; faces ( (0 4 5 1) (7 6 2 3) (5 6 7 4) (3 2 1 0) ); } leeward { type patch; faces ( (9 6 5 9) (9 5 1 9) (9 1 2 9) (9 2 6 9) ); } ); mergePatchPairs ( );```

 Tags blockmesh, blockmesh cylinder, mesh