# How I learned to mesh a pipe using blockMesh

All I knew was the mesh generation for cavity case described in the user guide. But a small additional info for generating a curved edge was sufficient to understand how to make a pipe mesh.

I came across a tutorial of wolfdynamics.com describing the whole process in a lucid manner. The following is the blockMeshDict used to generate the above mesh ðŸ™‚

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

scale   0.025;

vertices
(
//block 0
(-0.25 0.25 0)
(-0.707106 0.707106 0)
(0.707106 0.707106 0)
(0.25 0.25 0)
(-0.25 0.25 20)
(-0.707106 0.707106 20)
(0.707106 0.707106 20)
(0.25 0.25 20)
//block 1
(0.25 -0.25 0)
(0.707106 -0.707106 0)
(0.25 -0.25 20)
(0.707106 -0.707106 20)
//block 3
(-0.25 -0.25 0)
(-0.707106 -0.707106 0)
(-0.25 -0.25 20)
(-0.707106 -0.707106 20)
);
xcells 20;
ycells 40;
zcells 60;

xcells1 20;
ycells1 20;
zcells1 60;

stretch 0.25;

blocks
(
/*block 0 */ hex (0 3 2 1 4 7 6 5 ) ($xcells$ycells $zcells) simpleGrading (1$stretch 1)
/*block 1 */ hex (3 8 9 2 7 10 11 6) ($xcells$ycells $zcells) simpleGrading (1$stretch 1)
/*block 2 */ hex (8 12 13 9 10 14 15 11) ($xcells$ycells $zcells) simpleGrading (1$stretch 1)
/*block 3 */ hex (12 0 1 13 14 4 5 15) ($xcells$ycells $zcells) simpleGrading (1$stretch 1)
/*block 4 */ hex (0 12 8 3 4 14 10 7) ($xcells1$ycells1 $zcells1) simpleGrading (1 1 1) ); edges ( arc 1 2 (0 1 0) arc 5 6 (0 1 20) arc 2 9 (1 0 0) arc 6 11(1 0 20) arc 9 13 (0 -1 0) arc 11 15 (0 -1 20) arc 1 13 (-1 0 0) arc 5 15 (-1 0 20) ); boundary ( inlet { type patch; faces ( (0 1 2 3) (2 3 8 9) (8 9 13 12) (13 12 0 1) (0 3 8 12) ); } pipe { type wall; faces ( (1 5 6 2) (2 6 11 9) (9 11 15 13) (15 13 5 1) ); } outlet { type patch; faces ( (4 5 6 7) (6 7 10 11) (15 11 10 14) (15 14 4 5) (4 7 10 14) ); } ); mergePatchPairs ( ); // ************************************************************************* // I thank wolfdynamics.com for the detailed tutorial provided for the benefit of learners ðŸ™‚ ðŸ™‚ scale 0.005; vertices ( //block 0 //front shell coordinates cap bottom plane (-0.25 0.25 0) //0 (-0.707106 0.707106 0) //1 (0.707106 0.707106 0) //2 (0.25 0.25 0) //3 //front shell coordinates neck - cap plane (-0.25 0.25 2) //4 above 0 (-0.707106 0.707106 2) //5 above 1 (0.707106 0.707106 2) //6 above 2 (0.25 0.25 2) //7 above 3 //right&back shell common coordinates cap bottom plane (0.25 -0.25 0) //8 (0.707106 -0.707106 0) //9 //right&back shell common coordinates neck-cap plane (0.25 -0.25 2) //10 above 8 (0.707106 -0.707106 2) //11 above 9 //back&left shell common coordinates cap bottom plane (-0.25 -0.25 0) //12 (-0.707106 -0.707106 0) //13 //back & left shell common coordinates neck-cap plane (-0.25 -0.25 2) //14 above 12 (-0.707106 -0.707106 2)//15 above 13 //front shell coordinates body-neck plane (-1.0 1.0 7) //16 above 4 (-2.828424 2.828424 7) //17 above 5 (2.828424 2.828424 7) //18 above 6 (1.0 1.0 7) //19 above 7 //right&back shell common coordinates body-neck plane (1.0 -1.0 7) //20 above 10 (2.828424 -2.828424 7) //21 above 11 //back & left shell common coordinates body-neck plane (-1.0 -1.0 7) //22 above 14 (-2.828424 -2.828424 7) //23 above 15 //-------------------BODY - TOP plane--------------------------- //front shell coordinates body-top plane (-1.0 1.0 20) //24 above 16 (-2.828424 2.828424 20) //25 above 17 (2.828424 2.828424 20) //26 above 18 (1.0 1.0 20) //27 above 19 //right&back shell common coordinates body-top plane (1.0 -1.0 20) //28 above 20 (2.828424 -2.828424 20) //29 above 21 //back & left shell common coordinates body-top plane (-1.0 -1.0 20) //30 above 22 (-2.828424 -2.828424 20) //31 above 23 ); xcells 1;//20; ycells 1;//40; zcells 1;//60; xcells1 1;//20; ycells1 1;//20; zcells1 1;//60; stretch 1;//0.25; blocks ( //---------------------------- CAP ------------------------------------------ //cap front block 0 hex (0 3 2 1 4 7 6 5 ) ($xcells $ycells$zcells) simpleGrading (1 $stretch 1) //cap right block 1 hex (3 8 9 2 7 10 11 6) ($xcells $ycells$zcells) simpleGrading (1 $stretch 1) //cap back block 2 hex (8 12 13 9 10 14 15 11) ($xcells $ycells$zcells) simpleGrading (1 $stretch 1) //cap left block 3 hex (12 0 1 13 14 4 5 15) ($xcells $ycells$zcells) simpleGrading (1 $stretch 1) //cap center block 4 hex (0 12 8 3 4 14 10 7) ($xcells1 $ycells1$zcells1) simpleGrading (1 1 1)

//---------------------------- NECK ------------------------------------------

//neck front block 5
hex (4 7 6 5 16 19 18 17) ($xcells$ycells $zcells) simpleGrading (1$stretch 1)

//neck right block 6
hex (7 10 11 6 19 20 21 18) ($xcells$ycells $zcells) simpleGrading (1$stretch 1)

//neck back block 7
hex (10 14 15 11 20 22 23 21) ($xcells$ycells $zcells) simpleGrading (1$stretch 1)

//neck left block 8
hex (14 4 5 15 22 16 17 23) ($xcells$ycells $zcells) simpleGrading (1$stretch 1)

//neck center block 9
hex (4 14 10 7 16 22 20 19) ($xcells1$ycells1 $zcells1) simpleGrading (1 1 1) //---------------------------- BODY ------------------------------------------ //body front block 5 hex (16 19 18 17 24 27 26 25) ($xcells $ycells$zcells) simpleGrading (1 $stretch 1) //body right block 6 hex (19 20 21 18 27 28 29 26) ($xcells $ycells$zcells) simpleGrading (1 $stretch 1) //body back block 7 hex (20 22 23 21 28 30 31 29) ($xcells $ycells$zcells) simpleGrading (1 $stretch 1) //body left block 8 hex (22 16 17 23 30 24 25 31) ($xcells $ycells$zcells) simpleGrading (1 $stretch 1) //body center block 9 hex (16 22 20 19 24 30 28 27) ($xcells1 $ycells1$zcells1) simpleGrading (1 1 1)
);


edges
(
arc 1 2 (0 1 0)
arc 5 6 (0 1 2)
arc 2 9 (1 0 0)
arc 6 11(1 0 2)
arc 9 13 (0 -1 0)
arc 11 15 (0 -1 2)
arc 1 13 (-1 0 0)
arc 5 15 (-1 0 2)
//body-neck plane
arc 17 18(0 4 7)
arc 18 21(4 0 7)
arc 21 23 (0 -4 7)
arc 17 23(-4 0 7)
//body plane
arc 25 26(0 4 20)
arc 26 29(4 0 20)
arc 29 31 (0 -4 20)
arc 25 31(-4 0 20)
);

boundary
(
inletOutlet
{
type patch;
faces
(
(0 1 2 3)
(2 3 8 9)
(8 9 13 12)
(13 12 0 1)
(0 3 8 12)
);
}
pipe
{
type wall;
faces
(
(1 5 6 2)
(2 6 11 9)
(9 11 15 13)
(15 13 5 1)

(5 17 18 6)
(6 18 21 11)
(11 21 23 15)
(15 23 17 5)

(17 25 26 18)
(18 26 29 21)
(21 29 31 23)
(23 31 25 17)

//bottom plane
(24 25 26 27)
(27 26 29 28)
(28 29 31 30)
(30 31 25 24)
(24 27 28 30)
);
}
);
mergePatchPairs
(
);