Find answers, ask questions, and connect with our <br>community around the world.

Home Forums OpenFOAM Forum Lesson 7 – Cylinder

  • Lesson 7 – Cylinder

    Posted by Raphael on August 1, 2023 at 10:08 am

    Hi, Dear:

    In Lesson 7’s homework we were asked to create the mesh inside and outside the cylinder.

    This must be done by running the “snappyHexMeshDict” file once with the locationInMesh (X Y Z) command twice, both to indicate the inside and outside of the cylinder? According to the example:


    // Mesh selection
    // ~~~~~~~~~~~~~~

    // After refinement patches get added for all refinementSurfaces and
    // all cells intersecting the surfaces get put into these patches. The
    // section reachable from the locationInMesh is kept.
    // NOTE: This point should never be on a face, always inside a cell, even
    // after refinement.

    locationInMesh (0.3001 0.3001 0.0001); //outside

    locationInMesh (0.0000 0.0000 0.0001); //inside

    // Whether any faceZones (as specified in the refinementSurfaces)

    Should we use the “snappyHexMesh” command twice in a row? For example, the first time change the file “snappyHexMeshDict” in the command locationInMesh (X Y Z) to indicate the interior and then apply the “snappyHexMesh” And after that, change the file “snappyHexMeshDict” in the command locationInMesh (X Y Z) to indicate the outside and then apply the “snappyHexMesh” again?

    I entered the locationInMesh command twice in the file and ran it. But now the BackgroundMesh no longer appears in the paraview, even when I delete and recreate the foam.foam with the blockMesh, when I open the foam.foam it opens only the cylinder again.

    Could you guide me please?

    Barış Bicer replied 8 months ago 2 Members · 7 Replies
  • 7 Replies
  • Barış Bicer

    August 4, 2023 at 7:24 am

    Hi Raphael,

    First, you can create one mesh with one running of snappyHexMesh setup. Therefore, you should have 2 cases where you should create one mesh for internal and one mesh for external.

    Dont forget that one set up always should be for one case. Because when you use any command of openfoam then utility reads your setup file (for example it is snappyHexMeshDict here) line by line and proceed it if all lines are correctly arranged.

    For your info.

  • Raphael

    August 4, 2023 at 8:06 am

    Hi Barış,

    Thanks for the feedback, please see the question I have:

    I understand that I have to have 2 cases, one for the inner loop and one for the outer loop. But it is not clear how to accomplish this in practice. Let’s go:

    1 – Should I create two snappyHexMeshDict files where each one indicates the respective ‘location’ command, that is, for external and another for internal? If so, we’ll need to rename the second snappyHexMeshDict file, and I don’t think it makes sense;

    2 – Or in the same snappyHexMeshDict file I must first indicate an internal location, use the snappyHexMeshDict command, and then how would I create a result with a different name to use a second snappyHexMesh command from the same snappyHexMeshDict file pointing to external location?

    I imagine the solution must be much simpler, could you guide me?

  • Barış Bicer

    August 4, 2023 at 8:57 am

    Hi Again,

    Please create one case lets for internal and named as case 01_internal_case. you should have all folders and subfiles under this case (such as 0, constant and sysyem forlders). Create your internal mesh. After you finish internal mesh case then copy this case using this command cp -r 01_internal_case 02_external_case then go to inside of new case snappyHexMeshDict file and arrange location line as external and run your case.

    I hope that it helps you!

  • Raphael

    August 8, 2023 at 9:45 am


    I ask for your help.

    I did as you instructed,

    In the first phase:
    -creation of the external case
    -got all folders and subfiles in this case (like 0, constant and sysyem forlders)
    -Creation of the external mesh.
    -Run cp -r 3/polyMesh/ constant/
    And we obtained the outer mesh as shown in the figure.

    Then in the second phase:
    -copied the case and renamed it to internalcase
    -In snappyHexMeshDict we set the location to locationInMesh (0.1001 0.1001 0.1001);
    -Run the command snappyHexMesh | tee log.snappy

    But we got an error as follows:

    | ========= | |
    | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
    | \\ / O peration | Version: 2306 |
    | \\ / A nd | Website: |
    | \\/ M anipulation | |
    Build : _fbf00d6bf2-20230626 OPENFOAM=2306 version=v2306
    Arch : “LSB;label=32;scalar=64”
    Exec : snappyHexMesh
    Date : Aug 08 2023
    Time : 06:24:01
    Host : raphael-XPS-8950
    PID : 21135
    I/O : uncollated
    Case : /home/raphael/OpenFOAM/raphael-v2306/run/Lesson_07_internalGeo
    nProcs : 1
    trapFpe: Floating point exception trapping enabled (FOAM_SIGFPE).
    fileModificationChecking : Monitoring run-time modified files using timeStampMaster (fileModificationSkew 5, maxFileModificationPolls 20)
    allowSystemOperations : Allowing user-supplied system call operations

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

    Create mesh for time = 0

    Read mesh in = 0.06 s

    Overall mesh bounding box : (-5 -4 0) (15 4 8)
    Relative tolerance : 1e-06
    Absolute matching distance : 2.29783e-05

    Reading refinement surfaces.
    Read refinement surfaces in = 0.03 s

    Reading refinement shells.
    Refinement level 4 for all cells inside refinementBox
    Read refinement shells in = 0 s

    Setting refinement level of surface to be consistent with shells.
    For geometry cylinder_geometry.stl detected 0 uncached triangles out of 36366
    Checked shell refinement in = 0.06 s

    Reading features.
    Read edgeMesh cylinder_geometry.eMesh
    points : 126
    edges : 126
    boundingBox : (-0.249814 -0.249814 0) (0.25 0.25 6)

    Refinement level according to distance to “cylinder_geometry.eMesh” (126 points, 126 edges).
    level 6 for all cells within 0 metre.
    Read features in = 0 s

    Determining initial surface intersections

    Edge intersection testing:
    Number of edges : 1466978
    Number of edges to retest : 0
    Number of intersected edges : 0
    Edge intersection testing:
    Number of edges : 1466978
    Number of edges to retest : 1466978
    Number of intersected edges : 10294
    Calculated surface intersections in = 1.21 s

    Initial mesh : cells:478560 faces:1466978 points:510229
    Cells per refinement level:
    0 892
    1 2080
    2 7464
    3 16064
    4 387087
    5 56485
    6 8488
    Setting refinement level of surface to be consistent with curvature.
    Checked curvature refinement in = 0 s

    Adding patches for surface regions

    Patch Type Region
    —– —- ——

    5 wall cylinder_geometry_outlet
    6 wall cylinder_geometry_suplat
    7 wall cylinder_geometry_inlet

    Added patches in = 0.02 s

    Edge intersection testing:
    Number of edges : 1466978
    Number of edges to retest : 10556
    Number of intersected edges : 10556
    Decomposition method none [1]

    Refinement phase


    –> FOAM FATAL ERROR: (openfoam-2306)
    Point (0.1001 0.1001 0.1001) is not inside the mesh or on a face or edge.
    Bounding box of the mesh:(-5 -4 0) (15 4 8)

    From static Foam::labelList Foam::refinementParameters::findCells(bool, const Foam::polyMesh&, const pointField&)
    in file snappyHexMeshDriver/refinementParameters/refinementParameters.C at line 249.

    FOAM exiting

  • Barış Bicer

    August 11, 2023 at 12:52 pm

    For second case before run the snappyHexMEsh you have to delete polyMEsh file since it belongs to first case. It tries to rewrite but doesnt work with only snappyHexMEsh command. Please delete mesh folder and re-run snappyHexMEsh

  • Raphael

    August 16, 2023 at 8:41 am

    I assume when you wrote “delete polyMesh file” you are referring to deleting the polyMesh folder, right?

    Based on that understanding, I did the following:
    1 -> ~/OpenFOAM/raphael-v2306/run/Lesson_07_internalGeo/constant$ rm -r “polyMesh”
    Was this right? Did you refer to the polyMesh folder in the constant folder?
    Or did you refer to each polyMesh folder in 1, 2 and 3 folders?
    I don’t think I understood the mechanism until now. But with your help I will do it.
    2 -> It was necessary to use the “blockMesh” command again,
    3 -> Finally I used the command “snappyHexMesh | tee log.snappy”

    Then I applied the paraview foam.foam

    And I got the internal mesh but without the external mesh and without the external cavity that I got in the first case.

    Was it supposed to be like this?

    Please see the following

  • Barış Bicer

    August 18, 2023 at 8:38 am

    Hi again,

    please copy internal mesh case. and delete these folders: 1, 2 and 3 which are created after snappy process. and also delete the polyMesh under constant folder. then start with blockMesh and then change locationInMesh as outside of cylinder and run snappyHexMesh. after snappy the polyMesh under /3 folder is your final mesh copy it into constant folder.

    DONT FORGET that the polyMesh folder under /3 folder is the final mesh of snappy. after conclusion of snappy process you have to copy it into constant folder to keep final mesh under constant folder.

    For your info.

Log in to reply.

error: Content is protected !!