CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Meshing & Mesh Conversion (https://www.cfd-online.com/Forums/openfoam-meshing/)
-   -   [blockMesh] 3-D Mesh in a cylinder (https://www.cfd-online.com/Forums/openfoam-meshing/104486-3-d-mesh-cylinder.html)

MartinB September 17, 2012 11:57

Hi Prashant,

the old syntax is:
Code:

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

convertToMeters 1;

vertices       
(
    (0 0 0)
    (0.11 0 0)
    (1.2 0 0)
    (0 1.2 0)
    (0 0.11 0)
    (0 0 0.8)
    (0.11 0 0.8)
    (1.2 0 0.8)
    (0 1.2 0.8)
    (0 0.11 0.8)
    (0.11 0 4.4)
    (1.2 0 4.4)
    (0 1.2 4.4)
    (0 0.11 4.4) 
);

blocks         
(
    hex (0 1 4 0 5 6 9 5) (10 10 4) simpleGrading (1 1 1)
    hex (4 1 2 3 9 6 7 8) (10 10 4) simpleGrading (1 1 1)
    hex (9 6 7 8 13 10 11 12) (10 10 9) simpleGrading (1 1 1)
);

edges         
(
    arc 1 4 (0.078 0.078 0)
    arc 2 3 (0.848 0.848 0)
    arc 6 9 (0.078 0.078 0.8)
    arc 7 8 (0.848 0.848 0.8)
    arc 10 13 (0.078 0.078 4.4)
    arc 11 12 (0.848 0.848 4.4)
);

// Syntax for OF-1.7.1
patches
(
    wall top_innerc
    (
        (6 10 13 9)
    )
    symmetryPlane side1
    (
        (1 2 7 6) 
        (0 1 6 5)             
        (6 7 11 10)
    )
    symmetryPlane side2
    (
            (9 8 3 4) 
            (5 9 4 0) 
            (13 12 8 9)
    )
    wall top
    (
        (10 11 12 13)
    )
    wall bottom
    (
        (2 1 4 3)
        (1 0 4 1)
    )
    wall lateral
    (
            (7 2 3 8)
            (11 7 8 12)
            (5 6 9 5)
    )
);

/* new syntax for OF-2.0 and higher
boundary
(

    top_innerc
    {
        type wall;
        faces
        ( 
            (6 10 13 9)
        );
    }

    side1
    {
        type symmetryPlane;
        faces
        ( 
            (1 2 7 6) 
            (0 1 6 5)             
            (6 7 11 10)
        );
    }

    side2
    {
        type symmetryPlane;
        faces
        (
            (9 8 3 4) 
            (5 9 4 0) 
            (13 12 8 9)
        );
    }

    top
    {
        type wall;
        faces
        (
            (10 11 12 13)
        );
    }
   
    bottom
    {
        type wall;
        faces
        (
            (2 1 4 3)
            (1 0 4 1)
        );
    } 

    lateral
    {
        type wall;
        faces
        (
            (7 2 3 8)
            (11 7 8 12)
            (5 6 9 5)
        );
    }
     
);
*/
mergePatchPairs
(
);

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

I've not tested the blockMeshDict file...

Martin

Prash September 17, 2012 12:12

Thanks Martin :)

This works !!







Quote:

Originally Posted by MartinB (Post 382187)
Hi Prashant,

the old syntax is:
Code:

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

convertToMeters 1;

vertices       
(
    (0 0 0)
    (0.11 0 0)
    (1.2 0 0)
    (0 1.2 0)
    (0 0.11 0)
    (0 0 0.8)
    (0.11 0 0.8)
    (1.2 0 0.8)
    (0 1.2 0.8)
    (0 0.11 0.8)
    (0.11 0 4.4)
    (1.2 0 4.4)
    (0 1.2 4.4)
    (0 0.11 4.4) 
);

blocks         
(
    hex (0 1 4 0 5 6 9 5) (10 10 4) simpleGrading (1 1 1)
    hex (4 1 2 3 9 6 7 8) (10 10 4) simpleGrading (1 1 1)
    hex (9 6 7 8 13 10 11 12) (10 10 9) simpleGrading (1 1 1)
);

edges         
(
    arc 1 4 (0.078 0.078 0)
    arc 2 3 (0.848 0.848 0)
    arc 6 9 (0.078 0.078 0.8)
    arc 7 8 (0.848 0.848 0.8)
    arc 10 13 (0.078 0.078 4.4)
    arc 11 12 (0.848 0.848 4.4)
);

// Syntax for OF-1.7.1
patches
(
    wall top_innerc
    (
        (6 10 13 9)
    )
    symmetryPlane side1
    (
        (1 2 7 6) 
        (0 1 6 5)             
        (6 7 11 10)
    )
    symmetryPlane side2
    (
            (9 8 3 4) 
            (5 9 4 0) 
            (13 12 8 9)
    )
    wall top
    (
        (10 11 12 13)
    )
    wall bottom
    (
        (2 1 4 3)
        (1 0 4 1)
    )
    wall lateral
    (
            (7 2 3 8)
            (11 7 8 12)
            (5 6 9 5)
    )
);

/* new syntax for OF-2.0 and higher
boundary
(

    top_innerc
    {
        type wall;
        faces
        ( 
            (6 10 13 9)
        );
    }

    side1
    {
        type symmetryPlane;
        faces
        ( 
            (1 2 7 6) 
            (0 1 6 5)             
            (6 7 11 10)
        );
    }

    side2
    {
        type symmetryPlane;
        faces
        (
            (9 8 3 4) 
            (5 9 4 0) 
            (13 12 8 9)
        );
    }

    top
    {
        type wall;
        faces
        (
            (10 11 12 13)
        );
    }
   
    bottom
    {
        type wall;
        faces
        (
            (2 1 4 3)
            (1 0 4 1)
        );
    } 

    lateral
    {
        type wall;
        faces
        (
            (7 2 3 8)
            (11 7 8 12)
            (5 6 9 5)
        );
    }
     
);
*/
mergePatchPairs
(
);

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

I've not tested the blockMeshDict file...

Martin


cesarjets May 19, 2014 20:31

blockMesh cylinder
 
Quote:

Originally Posted by MartinB (Post 371149)
Hi Nikunj,

your blockMeshDict is fine. The problems come from the other settings. Attached you can find a version that runs for a bit longer, although it still crashes at some point of time.

You should play around with mesh resolution, eventually fvSchemes, max time step and maxCo, nOuterCorrectors etc.

Good luck

Martin

Martin, how the arcs are calculated to draw this cylinder? I know it could be a silly question, I'll appreciate any help. thanks

MartinB May 20, 2014 03:24

Hi,

this can be done with sine and cosine. See the pyCylinder.py script in the pipe_2.tar.gz archive attached to this post:
http://www.cfd-online.com/Forums/ope...tml#post285979

Martin

cesarjets May 20, 2014 19:09

Martin,

right, thanks much for your reply. this code calculates the arcs? that is what I could get from it. If I wanted to change the length of this cylinder how I could do it? Additionally, how I could add another cylinder inside this one? I mean a concentric one?. I have been trying to check the you talked about with someone else but it doesn't work when I try to visualize it in paraview. That one could also work for me.

Thanks much, I'll appreciate any help on this. kind of new with circular geometries in openFOAM.

cesarjets May 23, 2014 19:49

Martin,

Sorry if I bother you so much, just as stated in my previous reply, how this code calculates the arcs? I have not been able to get what the angles are for sine and cosine? or what's the equation to calculate them?
I believe it is some trigonometry equation?

Thanks much, I'll appreciate any help on this. :)

cesarjets May 23, 2014 20:16

Hi Nikunj,

I have been trying to check your cylinder in paraview but it has some erros, so, I have not been able to visualize it.

I need draw something similar, concentric cylinders, wondering if you could help me out with your blockMesh file?. It could be a good starting point to me. I even have another example I got in this forum. I could attach it and would like to know if you can tell me how I could add another cylinder inside it?

Thanks much, any help on this will be appreciated.

cesarjets May 24, 2014 18:01

1 Attachment(s)
Quote:

Originally Posted by MartinB (Post 492999)
Hi,

this can be done with sine and cosine. See the pyCylinder.py script in the pipe_2.tar.gz archive attached to this post:
http://www.cfd-online.com/Forums/ope...tml#post285979

Martin

Martin, sorry again if I other you so much, I attached an image of the geometry I need to get. Not sure how I could get it taking your pipe case as a starting point. the radius of the smaller cylinder would be 0.065 m and the bigger one 0.13m

Thanks for your help

MartinB May 25, 2014 10:01

Hi,

you should look up:
If you need the mesh only once, you can make your blockMeshDict directly.

If you need it for a complex study of geometric parameters, you should use Python (which I prefer) or M4 (for which plenty of examples exists in this forum) or whatever programming language you prefer.

Beside of that, it is easy to create your mesh with ParaView and snappyHexMesh as well, if you do not need perfect mesh quality.

Good luck

Martin

cesarjets June 10, 2014 11:45

3D mesh cylinder
 
Quote:

Originally Posted by MartinB (Post 494020)
Hi,

you should look up:
If you need the mesh only once, you can make your blockMeshDict directly.

If you need it for a complex study of geometric parameters, you should use Python (which I prefer) or M4 (for which plenty of examples exists in this forum) or whatever programming language you prefer.

Beside of that, it is easy to create your mesh with ParaView and snappyHexMesh as well, if you do not need perfect mesh quality.

Good luck

Martin

Martin,

All right thanks much,

I already draw this cylinder and saved it as a STL file. I've been thinking about meshing it with snappyHexMesh. However, I'm not sure if snappyHexMesh would work as this geometry has an inlet/outlet and not sure if I would have to use something like blender to generate independent files for inlets/outlets?

Thanks for your help,

Rhoddwen December 15, 2014 09:28

Hy, I have a simmilar problem.....................I think
 
:D

I am trying to simulate the flow between two concentric cylinders. The inner one rotating (R = 25), the outer one fixed (R=30). Moreover, the inner cylinder should be connected at the upper wall which rotates with-it. My problem is that I have tried everything but I cannot build my geometry....I am not using anything else but open foam.I was wondering if enyone can help me figure this out.The dimensions of inner and outer cylinders have no relevance..the geometry shape is important.

So..my case is a multiphase case, I use interFoam solver.

My geometry is build-ed as axi-simmetric wedge. I don't know if it is correct, cause I cannot manage to obtain the ''in-between of cylinders'' flow domain. It builds every time the block relying the inner cylinder to the axis (the cone - see also attached piks).
I tried everything:
- defining all blocks and set "empty" boundaries on the 'hex' that normally does not belong to the flow domain; but than open foam build it anyway, and fills it with air;
- not defing the 'cone' relying my flow domain to the axis; but then 'blockMesh' and 'check mesh' failed...as wedge is not recognized, even if I used a small angle;

I am sending you all the data...the log, the mesh file, set fields, alpha.org...

Please answer me these questions..if you know.. :
1. How do I build a geometry consisting within 2 concentric cylinders in openF.

2. How do I change the coordinate system from Cartesian to Cylindrical;

3. How do I set a precise volume of "water" within my flow domain - the gap between 2 concentric cylinders.

I hope that anyone can help me...
Thank you.
---------------------------------------------------------------------------------------------------------------------------
LOG FILE
---------------------------------------------------------------------------------------------------------------------------
BLOCK MESH LOG
-----------------------------------------------------------------------------------------

Creating block mesh from
"/home/FOAM_RUN/DC/interFoam/laminar/pocheGR/constant/polyMesh/blockMeshDict"
Creating curved edges
Creating topology blocks
Creating topology patches

Creating block mesh topology

Check topology

Basic statistics
Number of internal faces : 5
Number of boundary faces : 20
Number of defined boundary faces : 20
Number of undefined boundary faces : 0
Checking patch -> block consistency

Creating block offsets
Creating merge list .

Creating polyMesh from blockMesh
Creating patches
Creating cells
Creating points with scale 1
Block 0 cell size :
i : 0.0333333 .. 0.0333333
j : 0.416667 .. 0.416667
k : 0 .. 0

Block 1 cell size :
i : 0.0166667 .. 0.0166667
j : 0.416667 .. 0.416667
k : 0 .. 0

Block 2 cell size :
i : 0.0333333 .. 0.0333333
j : 0.0333333 .. 0.0333333
k : 2.49896 .. 2.49896

Block 3 cell size :
i : 0.0166667 .. 0.0166667
j : 0.0333333 .. 0.0333333
k : 2.49896 .. 2.49896

Block 4 cell size :
i : 0.0333333 .. 0.0333333
j : 0.0666667 .. 0.0666667
k : 2.69888 .. 2.69888


Writing polyMesh
----------------
Mesh Information
----------------
boundingBox: (0 0 -1.54935) (3 30.9613 1.54935)
nPoints: 36481
nCells: 18000
nFaces: 72180
nInternalFaces: 35700
----------------
Patches
----------------
patch 0 (start: 35700 size: 120) name: leftWall
patch 1 (start: 35820 size: 120) name: rightWall
patch 2 (start: 35940 size: 120) name: sides
patch 3 (start: 36060 size: 0) name: axis
patch 4 (start: 36060 size: 60) name: atmosphere
patch 5 (start: 36120 size: 60) name: upperWall
patch 6 (start: 36180 size: 18000) name: back
patch 7 (start: 54180 size: 18000) name: front

End

-----------------------------------------------------------------------------------------
CHECK MESH LOG
-----------------------------------------------------------------------------------------


Create polyMesh for time = 0

Time = 0

Mesh stats
points: 36481
internal points: 0
faces: 72180
internal faces: 35700
cells: 18000
faces per cell: 5.99333
boundary patches: 8
point zones: 0
face zones: 0
cell zones: 0

Overall number of cells of each type:
hexahedra: 17880
prisms: 120
wedges: 0
pyramids: 0
tet wedges: 0
tetrahedra: 0
polyhedra: 0

Checking topology...
Boundary definition OK.
***Total number of faces on empty patches is not divisible by the number of cells in the mesh. Hence this mesh is not 1D or 2D.
Cell to face addressing OK.
Point usage OK.
Upper triangular ordering OK.
Face vertices OK.
Number of regions: 1 (OK).

Checking patch topology for multiply connected surfaces...
Patch Faces Points Surface topology
leftWall 120 242 ok (non-closed singly connected)
rightWall 120 244 ok (non-closed singly connected)
sides 120 242 ok (non-closed singly connected)
axis 0 0 ok (empty)
atmosphere 60 122 ok (non-closed singly connected)
upperWall 60 122 ok (non-closed singly connected)
back 18000 18301 ok (non-closed singly connected)
front 18000 18301 ok (non-closed singly connected)

Checking geometry...
Overall domain bounding box (0 0 -1.54935) (3 30.9613 1.54935)
Mesh (non-empty, non-wedge) directions (1 1 0)
Mesh (non-empty) directions (0 1 1)
Wedge back with angle 2.86479 degrees
Wedge front with angle 2.86479 degrees
All edges aligned with or perpendicular to non-empty directions.
Boundary openness (1.66689e-17 -5.15476e-15 5.04149e-15) OK.
Max cell openness = 1.65719e-16 OK.
Max aspect ratio = 24.7607 OK.
Minimum face area = 0.000555555. Maximum face area = 1.03127. Face area magnitudes OK.
Min volume = 0.000144435. Max volume = 0.0343755. Total volume = 132.329. Cell volumes OK.
Mesh non-orthogonality Max: 0 average: 0
Non-orthogonality check OK.
Face pyramids OK.
Max skewness = 0.330003 OK.
Coupled point location match (average 0) OK.

Mesh OK.

End

-----------------------------------------------------------------------------------------
SET FIELDS LOG
-----------------------------------------------------------------------------------------

Create time

Create mesh for time = 0

Reading setFieldsDict

Setting field default values
Setting internal values of volScalarField alpha.water

Setting field region values
Adding cells with centre within cylinder, with p1 = (0.2 25 -1), p2 = (0.2 26 1) and radius = 26
Setting internal values of volScalarField alpha.water

End

-------------------------------------------------------------------------------------------------------------------------
MESH FILE
----------------------------------------------------------------------------------------------------------------------
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object blockMeshDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

convertToMeters 1;
//puncte aranjate pe verticala//
vertices
(
(0 0 0)//p0//
(2 0 0)//p1//
(3 0 0)//p2//
(0 24.96875650987 -1.24947923177)//p3//
(2 24.96875650987 -1.24947923177)//p4//
(3 24.96875650987 -1.24947923177)//p5//
(3 26.96625703066 -1.34943757031)//p6//
(2 26.96625703066 -1.34943757031)//p7//
(0 26.96625703066 -1.34943757031)//p8//
(0 30.96125807224 -1.54935424739)//p9//
(2 30.96125807224 -1.54935424739)//p10//
(0 24.96875650987 1.24947923177)//p11//
(2 24.96875650987 1.24947923177)//p12//
(3 24.96875650987 1.24947923177)//p13//
(3 26.96625703066 1.34943757031)//p14//
(2 26.96625703066 1.34943757031)//p15//
(0 26.96625703066 1.34943757031)//p16//
(0 30.96125807224 1.54935424739)//p17//
(2 30.96125807224 1.54935424739)//p18//
);

blocks
(
hex (0 1 4 3 0 1 12 11) (60 60 1) simpleGrading (1 1 1)
hex (1 2 5 4 1 2 13 12) (60 60 1) simpleGrading (1 1 1)
hex (3 4 7 8 11 12 15 16) (60 60 1) simpleGrading (1 1 1)
hex (4 5 6 7 12 13 14 15) (60 60 1) simpleGrading (1 1 1)
hex (8 7 10 9 16 15 18 17) (60 60 1) simpleGrading (1 1 1)
);

edges
(
);

boundary
(
leftWall
{
type walls;
faces
(
(3 8 16 11)
(8 9 17 16)
);
}
rightWall
{
type wall;
faces
(
(5 6 14 13)
(7 10 18 15)
);
}
sides
{
type empty;
faces
(
(0 3 11 0)
(2 5 13 2)
);
}
axis
{
type empty;
faces
(
(0 1 1 0)
(1 2 2 1)
);
}
atmosphere
{
type wall;//patch;
faces
(
(9 10 18 17)
);
}
upperWall
{
type wall;
faces
(
(7 6 14 15) // (10 9 17 18)//
);
}
back
{
type wedge;
faces
(
(0 1 4 3)
(1 2 5 4)
(3 4 7 8)
(4 5 6 7)
(8 7 10 9)
);
}
front
{
type wedge;
faces
(
(0 1 12 11)
(1 2 13 12)
(11 12 15 16)
(12 13 14 15)
(16 15 18 17)
);
}
);

mergePatchPairs
(
);

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

--------------------------------------------------------------------------------------------------------------------------
BOUNDARY CONDITIONS FILE
-------------------------------------------------------------------------------------------------------------------------
FoamFile
{
version 2.0;
format ascii;
class polyBoundaryMesh;
location "constant/polyMesh";
object boundary;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

8
(
leftWall
{
type walls;
nFaces 120;
startFace 35700;
faces ( ( 3 8 16 11 ) ( 8 9 17 16 ) );
}
rightWall
{
type wall;
inGroups 1(wall);
nFaces 120;
startFace 35820;
}
sides
{
type empty;
inGroups 1(empty);
nFaces 120;
startFace 35940;
}
axis
{
type empty;
inGroups 1(empty);
nFaces 0;
startFace 36060;
}
atmosphere
{
type wall;
inGroups 1(wall);
nFaces 60;
startFace 36060;
}
upperWall
{
type wall;
inGroups 1(wall);
nFaces 60;
startFace 36120;
}
back
{
type wedge;
inGroups 1(wedge);
nFaces 18000;
startFace 36180;
}
front
{
type wedge;
inGroups 1(wedge);
nFaces 18000;
startFace 54180;
}
)
-----------------------------------------------------------------------------------------------------------------------
SET FIELDS FILE
------------------------------------------------------------------------------------------------------------------------
FoamFile
{
version 2.0;
format ascii;
class dictionary;
location "system";
object setFieldsDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

defaultFieldValues
(
volScalarFieldValue alpha.water 0
);

regions
(
cylinderToCell //boxToCell //box (3 0 -1.34947923177) (3 26.96625703066 1.34943757031);
{
p1 (0.2 25 -1); //Min
p2 (0.2 26 1); //Max
radius 26;
// radius 26;

fieldValues
(
volScalarFieldValue alpha.water 1
);
}
);

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

-----------------------------------------------------------------------------------------------------------------------
ALPHA WATER FILE

FoamFile
{
version 2.0;
format ascii;
class volScalarField;
object alpha.water;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

dimensions [0 0 0 0 0 0 0];

internalField uniform 0;

boundaryField
{
leftWall
{
type zeroGradient;
}

rightWall
{
type zeroGradient;
}

axis
{
type empty;
}

upperWall
{
type zeroGradient;
}

front
{
type wedge;
}

back
{
type wedge;
}

atmosphere
{
type zeroGradient;//type inletOutlet;
//inletValue uniform 0;
//value uniform 0;
}

defaultFaces
{
type empty;
}
}

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

adrieno March 22, 2016 08:56

1 Attachment(s)
Hi all,

I'm trying ro mesh a quater of cylinder (with symmetriplan faces).
I want to mesh it properly, with three blocks as showed on the photo I posted.
In fact I allways have to face with a fatal error telling me something like :
"... does not have neighbour cell face : ..."

So I tried directly your mesh which must work, but I get again the same message :

" face 1 in patch 4 does not have neighbour cell face: 4(1 0 4 1) "

What is this fatal error exactly ? what can I do ? My version of OpenFoam is 2.2.2, does it changes anything ? I'm completely stuck...

qutadah.r July 9, 2023 13:22

Im trying to make this work for openfoam 12, but im receiving erros, any suggestions?


thanks!


All times are GMT -4. The time now is 13:59.