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] Creating an axisymmetric piston cylinder in blockMeshDict (https://www.cfd-online.com/Forums/openfoam-meshing/205599-creating-axisymmetric-piston-cylinder-blockmeshdict.html)

foadsf August 21, 2018 19:05

Creating an axisymmetric piston cylinder in blockMeshDict
 
I'm trying to follow this tutorial to create an axisymmetric cylinder and piston in blockMeshDict and this is my blockMeshDict file:

Code:


/*--------------------------------*- C++ -*----------------------------------*\
| =========                |                                                |
| \\      /  F ield        | OpenFOAM: The Open Source CFD Toolbox          |
|  \\    /  O peration    | Version:  5                                    |
|  \\  /    A nd          | Web:      www.OpenFOAM.org                      |
|    \\/    M anipulation  |                                                |
\*---------------------------------------------------------------------------*/
FoamFile
{
    version    2.0;
    format      ascii;

    root            "";
    case            "";
    instance        "";
    local          "";

    class      dictionary;
    object      blockMeshDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

convertToMeters 0.001;

wa 5.0; // wedge angle must be 5 degrees
cr 10.0; // cylinder radius
pr 8.0; //piston radius
cl 50.0; // length of cylinder
px 20.0; // position of piston
pl 10.0; // length of piston
px2 #calc "$px+$pl"; // end of the piston
ms 50; //meshsize



vertices
(
    (0                      0                        0)    //00
    (#calc "$pr*cos($wa/2)" #calc "$pr*sin($wa/2)"    0)    //01
    (#calc "$pr*cos($wa/2)" #calc "-$pr*sin($wa/2)"  0)    //02
    (#calc "$pr*cos($wa/2)" #calc "-$pr*sin($wa/2)"  $px)  //03
    (#calc "$pr*cos($wa/2)" #calc "$pr*sin($wa/2)"    $px)  //04
    (0                      0                        $px)  //05
    (#calc "$cr*cos($wa/2)" #calc "$cr*sin($wa/2)"    $px)  //06
    (#calc "$cr*cos($wa/2)" #calc "$cr*sin($wa/2)"    0)    //07
    (#calc "$cr*cos($wa/2)" #calc "-$cr*sin($wa/2)"  0)    //08
    (#calc "$cr*cos($wa/2)" #calc "-$cr*sin($wa/2)"  $px)  //09
    (#calc "$cr*cos($wa/2)" #calc "-$cr*sin($wa/2)"  $px2) //10
    (#calc "$cr*cos($wa/2)" #calc "$cr*sin($wa/2)"    $px2) //11
    (#calc "$pr*cos($wa/2)" #calc "$pr*sin($wa/2)"    $px2) //12
    (#calc "$pr*cos($wa/2)" #calc "-$pr*sin($wa/2)"  $px2) //13
    (#calc "$pr*cos($wa/2)" #calc "-$pr*sin($wa/2)"  $cl)  //14
    (#calc "$pr*cos($wa/2)" #calc "$pr*sin($wa/2)"    $cl)  //15
    (#calc "$cr*cos($wa/2)" #calc "$cr*sin($wa/2)"    $cl)  //16
    (#calc "$cr*cos($wa/2)" #calc "-$cr*sin($wa/2)"  $cl)  //17
    (0                      0                        $cl)  //18
    (0                      0                        $px2) //19
);

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

edges
(
);

boundary
(
    inlet
    {
        type patch;
        faces
        (
            (0 1 2 0)
            (1 7 8 2)
        );
    }
    outlet
    {
        type patch;
        faces
        (
            (18 15 14 18)
            (15 16 17 14)
        );
    }
    walls
    {
        type wall;
        faces
        (
            (7  8  9  6)
            (6  9  10 11)
            (11 10 17 16)
        );
    }
    wedges
    {
        type wedge;
        faces
        (
            (0  1  4  5)
            (1  7  6  4)
            (4  6  11 12)
            (12 11 16 15)
            (19 12 15 18)
            (0  5  3  2)
            (2  3  9  8)
            (3  13 10 9)
            (13 14 17 10)
            (19 18 14 13)
        );
    }
    axis
    {
          type empty;
          faces 
          (
              (0  5  5  0)
              (19 18 18 19)
          );
    }
);

mergePatchPairs
(
);

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

or here in this GitHub Gist.

However when I try to compile the mesh I get the infamous error message:

Quote:

--> FOAM FATAL ERROR:
face 1 in patch 1 does not have neighbour cell face: 4(15 16 17 14)

From function Foam::labelList Foam:: polyMesh::facePatchFaceCells(const faceList&, const labelListList&, const faceListList&, Foam::label) const
in file meshes/polyMesh/polyMeshFromShapeMesh.C at line 118.

FOAM aborting

#0 Foam::error:: printStack(Foam::Ostream&) at ??:?
#1 Foam::error::abort() at ??:?
#2 Foam:: polyMesh::facePatchFaceCells(Foam::List<Foam::face > const&, Foam::List<Foam::List<int> > const&, Foam::List<Foam::List<Foam::face> > const&, int) const at ??:?
#3 Foam:: polyMesh::setTopology(Foam::List<Foam::cellShape> const&, Foam::List<Foam::List<Foam::face> > const&, Foam::List<Foam::word> const&, Foam::List<int>&, Foam::List<int>&, int&, int&, Foam::List<Foam::cell>&) at ??:?
#4 Foam:: polyMesh:: polyMesh(Foam::IOobject const&, Foam::Xfer<Foam::Field<Foam::Vector<double> > > const&, Foam::List<Foam::cellShape> const&, Foam::List<Foam::List<Foam::face> > const&, Foam::List<Foam::word> const&, Foam::PtrList<Foam::dictionary> const&, Foam::word const&, Foam::word const&, bool) at ??:?
#5 Foam::blockMesh::createTopology(Foam::IOdictionary const&, Foam::word const&) at ??:?
#6 Foam::blockMesh::blockMesh(Foam::IOdictionary const&, Foam::word const&) at ??:?
#7 ? at ??:?
#8 __libc_start_main in "/lib/x86_64-linux-gnu/libc.so.6"
#9 ? at ??:?
Aborted (core dumped)
I tried many different posts here in cfd-online or other forums, but none helped resolve the issue. I was wondering if you could:
  1. could help me find the issue in my blockMeshDict
  2. give me any examples of an axisymmetric system modeled directly in BlockMeshDict.

simrego August 22, 2018 04:58

Hi!


Your patch definition is bad.


--> FOAM FATAL ERROR:
face 1 in patch 1 does not have neighbour cell face: 4(15 16 17 14)


So in patch 1 (outlet), the face 1 (15 16 17 14) is not valid.



But there are also some weird stuff going on. If you create a hex, how can you have 10 vertices for a hex???

Check your block and patch definitions!


Maybe this can help you a bit:
https://cfd.direct/openfoam/user-guide/v6-blockmesh/

foadsf August 22, 2018 05:57

1 Attachment(s)
I changed the blocks section to:

Code:


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

and Now I get the error:

Quote:


--> FOAM FATAL ERROR:
wedge wedges plane aligns with a coordinate plane.
The wedge plane should make a small angle (~2.5deg) with the coordinate plan e
and the the pair of wedge planes should be symmetric about the coordinate pl ane.
Normal of wedge plane is (0.598471 1.11022e-017 -1.92593e-035) , implied coo rdinate plane direction is (1 0 -0)

From function virtual void Foam::wedgePolyPatch::calcGeometry(Foam::PstreamB uffers&)
in file meshes/polyMesh/polyPatches/constraint/wedge/wedgePolyPatch.C at lin e 110.

FOAM exiting



Also here you may see an image illustrating the points:
Attachment 65200

simrego August 22, 2018 06:37

Sorry now i'm a bit lost. I do not really understand this error message, but there is some problem with the wedge patch.
Maybe try to split the wedge patch into 2 patches: wedgeFront and wedgeBack. I'm not sure if they can be in the same patch.
If still not working, you can try with patchtype patch for the wegdes just to generate the mesh and at least you will see if your geometry is correct. (but it won't solve the problem since you will need a wedge type.)

foadsf August 22, 2018 07:01

I will try splitting patches.

Have you seen any working examples of using blockMeshDict to create an axisymmetric model?

simrego August 22, 2018 07:58

Yes I've also tried it a long time ago and it is working perfectly.
You can find tutorial blockMesh files containing wedge like:
find $FOAM_TUTORIALS -name blockMeshDict | xargs grep -l -i wedge
an example:
incompressible/pimplyDyMFoam/movingCone

foadsf August 22, 2018 19:11

I divided the wedges boundary as suggested:

Code:

    wedgeBack
    {
        type wedge;
        faces
        (
            (0  1  4  5)
            (1  7  6  4)
            (4  6  11 12)
            (12 11 16 15)
            (19 12 15 18)
        );
    }

    wedgeFront
    {
        type wedge;
        faces
        (
            (0  5  3  2)
            (2  3  9  8)
            (3  13 10 9)
            (13 14 17 10)
            (19 18 14 13)
        );
    }

surprisingly there are no errors with the outlet face (15 16 17 14) anymore. however I get a bunch of warnings:

Code:

Creating block mesh topology
--> FOAM Warning :
    From function Foam::polyMesh::polyMesh(const Foam::IOobject&, const Foam::Xfer<Foam::Field<Foam::Vector<double> > >&, const cellShapeList&, const faceListList&, const wordList&, const Foam::PtrList<Foam::dictionary>&, const Foam::word&, const Foam::word&, bool)
    in file meshes/polyMesh/polyMeshFromShapeMesh.C at line 871
    Found 3 undefined faces in mesh; adding to default patch.
--> FOAM Warning :
    From function virtual void Foam::wedgePolyPatch::calcGeometry(Foam::PstreamBuffers&)
    in file meshes/polyMesh/polyPatches/constraint/wedge/wedgePolyPatch.C at line 70
    Wedge patch 'wedgeFront' is not planar.
At local face at (-3.20457 2.39389 10) the normal (0.598472 0.801143 0) differs from the average normal (0.598471 0.801144 1.11022e-18) by 2.72438e-12
Either correct the patch or split it into planar parts
--> FOAM Warning :
    From function virtual void Foam::wedgePolyPatch::calcGeometry(Foam::PstreamBuffers&)
    in file meshes/polyMesh/polyPatches/constraint/wedge/wedgePolyPatch.C at line 70
    Wedge patch 'wedgeFront' is not planar.
At local face at (-7.2103 5.38625 10) the normal (0.59847 0.801145 1.38778e-18) differs from the average normal (0.598471 0.801144 1.11022e-18) by 1.21084e-12
Either correct the patch or split it into planar parts
--> FOAM Warning :
    From function virtual void Foam::wedgePolyPatch::calcGeometry(Foam::PstreamBuffers&)
    in file meshes/polyMesh/polyPatches/constraint/wedge/wedgePolyPatch.C at line 70
    Wedge patch 'wedgeFront' is not planar.
At local face at (-7.2103 5.38625 25) the normal (0.59847 0.801145 2.77556e-18) differs from the average normal (0.598471 0.801144 1.11022e-18) by 1.21084e-12
Either correct the patch or split it into planar parts
--> FOAM Warning :
    From function virtual void Foam::wedgePolyPatch::calcGeometry(Foam::PstreamBuffers&)
    in file meshes/polyMesh/polyPatches/constraint/wedge/wedgePolyPatch.C at line 70
    Wedge patch 'wedgeFront' is not planar.
At local face at (-7.2103 5.38625 40) the normal (0.59847 0.801145 1.38778e-18) differs from the average normal (0.598471 0.801144 1.11022e-18) by 1.21084e-12
Either correct the patch or split it into planar parts
--> FOAM Warning :
    From function virtual void Foam::wedgePolyPatch::calcGeometry(Foam::PstreamBuffers&)
    in file meshes/polyMesh/polyPatches/constraint/wedge/wedgePolyPatch.C at line 70
    Wedge patch 'wedgeFront' is not planar.
At local face at (-3.20457 2.39389 40) the normal (0.598472 0.801143 0) differs from the average normal (0.598471 0.801144 1.11022e-18) by 2.72438e-12
Either correct the patch or split it into planar parts
--> FOAM Warning :
    From function virtual void Foam::wedgePolyPatch::calcGeometry(Foam::PstreamBuffers&)
    in file meshes/polyMesh/polyPatches/constraint/wedge/wedgePolyPatch.C at line 70
    Wedge patch 'wedgeFront' is not planar.
At local face at (-3.20457 -2.39389 10) the normal (0.598472 -0.801143 0) differs from the average normal (0.598471 -0.801144 -1.11022e-18) by 2.72438e-12
Either correct the patch or split it into planar parts
--> FOAM Warning :
    From function virtual void Foam::wedgePolyPatch::calcGeometry(Foam::PstreamBuffers&)
    in file meshes/polyMesh/polyPatches/constraint/wedge/wedgePolyPatch.C at line 70
    Wedge patch 'wedgeFront' is not planar.
At local face at (-7.2103 -5.38625 10) the normal (0.59847 -0.801145 -1.38778e-18) differs from the average normal (0.598471 -0.801144 -1.11022e-18) by 1.21084e-12
Either correct the patch or split it into planar parts
--> FOAM Warning :
    From function virtual void Foam::wedgePolyPatch::calcGeometry(Foam::PstreamBuffers&)
    in file meshes/polyMesh/polyPatches/constraint/wedge/wedgePolyPatch.C at line 70
    Wedge patch 'wedgeFront' is not planar.
At local face at (-7.2103 -5.38625 25) the normal (0.59847 -0.801145 -2.77556e-18) differs from the average normal (0.598471 -0.801144 -1.11022e-18) by 1.21084e-12
Either correct the patch or split it into planar parts
--> FOAM Warning :
    From function virtual void Foam::wedgePolyPatch::calcGeometry(Foam::PstreamBuffers&)
    in file meshes/polyMesh/polyPatches/constraint/wedge/wedgePolyPatch.C at line 70
    Wedge patch 'wedgeFront' is not planar.
At local face at (-7.2103 -5.38625 40) the normal (0.59847 -0.801145 -1.38778e-18) differs from the average normal (0.598471 -0.801144 -1.11022e-18) by 1.21084e-12
Either correct the patch or split it into planar parts
--> FOAM Warning :
    From function virtual void Foam::wedgePolyPatch::calcGeometry(Foam::PstreamBuffers&)
    in file meshes/polyMesh/polyPatches/constraint/wedge/wedgePolyPatch.C at line 70
    Wedge patch 'wedgeFront' is not planar.
At local face at (-3.20457 -2.39389 40) the normal (0.598472 -0.801143 0) differs from the average normal (0.598471 -0.801144 -1.11022e-18) by 2.72438e-12
Either correct the patch or split it into planar parts

and an error:

Code:

--> FOAM FATAL ERROR:
wedge wedgeFront centre plane does not align with a coordinate plane by 0.360319

    From function virtual void Foam::wedgePolyPatch::calcGeometry(Foam::PstreamBuffers&)
    in file meshes/polyMesh/polyPatches/constraint/wedge/wedgePolyPatch.C at line 98.

FOAM exiting

I also posted this error here in StachOverflow.

foadsf August 23, 2018 07:21

with the help of StackOverflow I managed to get most of I want:

Code:

//following this: https://openfoamwiki.net/index.php/Main_ContribExamples/AxiSymmetric
//  /cygdrive/c/Users/sojoodif/surfdrive/sync/MyPhD/simulation/OpenFOAM/20180131_2

/*--------------------------------*- C++ -*----------------------------------*\
| =========                |                                                |
| \\      /  F ield        | OpenFOAM: The Open Source CFD Toolbox          |
|  \\    /  O peration    | Version:  5                                    |
|  \\  /    A nd          | Web:      www.OpenFOAM.org                      |
|    \\/    M anipulation  |                                                |
\*---------------------------------------------------------------------------*/
FoamFile
{
    version    2.0;
    format      ascii;

    root            "";
    case            "";
    instance        "";
    local          "";

    class      dictionary;
    object      blockMeshDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

convertToMeters 0.001;

wa 5.0*constant::mathematical::pi/180; // wedge angle must be smaller than 5 degrees
cr 10.0; // cylinder radius
pr 8.0; //piston radius
cl 50.0; // length of cylinder
px 20.0; // position of piston
pl 10.0; // length of piston
px2 #calc "$px+$pl"; // end of the piston
ms 50; //meshsize



vertices
(
    (0                      0                        0)    //00
    (#calc "$pr*cos($wa/2)" #calc "$pr*sin($wa/2)"    0)    //01
    (#calc "$pr*cos($wa/2)" #calc "-$pr*sin($wa/2)"  0)    //02
    (#calc "$pr*cos($wa/2)" #calc "-$pr*sin($wa/2)"  $px)  //03
    (#calc "$pr*cos($wa/2)" #calc "$pr*sin($wa/2)"    $px)  //04
    (0                      0                        $px)  //05
    (#calc "$cr*cos($wa/2)" #calc "$cr*sin($wa/2)"    $px)  //06
    (#calc "$cr*cos($wa/2)" #calc "$cr*sin($wa/2)"    0)    //07
    (#calc "$cr*cos($wa/2)" #calc "-$cr*sin($wa/2)"  0)    //08
    (#calc "$cr*cos($wa/2)" #calc "-$cr*sin($wa/2)"  $px)  //09
    (#calc "$cr*cos($wa/2)" #calc "-$cr*sin($wa/2)"  $px2) //10
    (#calc "$cr*cos($wa/2)" #calc "$cr*sin($wa/2)"    $px2) //11
    (#calc "$pr*cos($wa/2)" #calc "$pr*sin($wa/2)"    $px2) //12
    (#calc "$pr*cos($wa/2)" #calc "-$pr*sin($wa/2)"  $px2) //13
    (#calc "$pr*cos($wa/2)" #calc "-$pr*sin($wa/2)"  $cl)  //14
    (#calc "$pr*cos($wa/2)" #calc "$pr*sin($wa/2)"    $cl)  //15
    (#calc "$cr*cos($wa/2)" #calc "$cr*sin($wa/2)"    $cl)  //16
    (#calc "$cr*cos($wa/2)" #calc "-$cr*sin($wa/2)"  $cl)  //17
    (0                      0                        $cl)  //18
    (0                      0                        $px2) //19
);


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


edges
(
);

boundary
(
    inlet
    {
        type patch;
        faces
        (
            (0 2 1 0)
            (1 2 8 7)
        );
    }
    outlet
    {
        type patch;
        faces
        (
            (18 15 14 18)
            (15 16 17 14)
        );
    }
    walls
    {
        type wall;
        faces
        (
            (7  8  9  6)
            (6  9  10 11)
            (11 10 17 16)
            (5  4  3  5)
            (12 13 3  4)
            (19 13 12 19)
        );
    }
    wedgeFront
    {
        type wedge;
        faces
        (
            (0  1  4  5)
            (1  7  6  4)
            (4  6  11 12)
            (12 11 16 15)
            (19 12 15 18)
        );
    }

    wedgeBack
    {
        type wedge;
        faces
        (
            (0  2  3  5)
            (2  8  9  3)
            (3  9  10 13)
            (13 10 17 14)
            (19 13 14 18)
        );
    }

    axis
    {
          type empty;
          faces 
          (
              (0  5  5  0)
              (19 18 18 19)
          );
    }
);

mergePatchPairs
(
);

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

however now I'm not able to divide hex blocks 2 ,3 and 4 in x direction

foadsf August 23, 2018 07:55

I was able to generate what I need. please read the comments of this post

simrego August 23, 2018 08:54

If you do what i suggested earlier, you could be done a long time ago...
( Use patch instead of wedge for troubleshooting and then just swap back to wedge.. )


In openFoam warnings tell you a LOT! So if you have an error, first read it!
That long warning what you posted only tell you that you missed 3 boundary patches from the definition so they are in the defaultFaces patch, and the others tell you that your wedge patches are not planar...
For the first time these errors looks weird, but they help you a lot! (in this case exactly tells you what was your mistake)



If you have 2 neighboring blocks, the spacing on the same face must be identical and you will have no error...
You really have to read that cfd.direct link what I sent you because all of your mistakes could be avoided if you know the basics of blockMesh


All times are GMT -4. The time now is 16:08.