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/)
-   -   [snappyHexMesh] SnappyHexMesh with Empty patches in blockMesh (https://www.cfd-online.com/Forums/openfoam-meshing/242706-snappyhexmesh-empty-patches-blockmesh.html)

Magistrane May 6, 2022 07:21

SnappyHexMesh with Empty patches in blockMesh
 
Hello Foamers,

I really hope someone will see this soon, cause I am stuck here :/

So, I am working on a project using oversets. I used the wolfdynamics tutorials as basis to build my simulation. In those, the meshes containing the structures uses snappyHexMesh without problems. Their front and back are defined in the blockMesh as symmetryPlane.
In the overall mesh (backgroud), front and back patches were defined as "empty". and the overset is working well.

My problem is, I need to use snappyHexMesh to localy improve my 2D mesh but with empty patches in blockmesh, there is a point the calcul stop sending a warning :

Code:

Correcting 2-D mesh motion--> FOAM Warning :
    From void Foam::twoDPointCorrector::calcAddressing() const
    in file twoDPointCorrector/twoDPointCorrector.C at line 163
    The number of points in the mesh is not equal to twice the number of edges normal to the plane - this may be OK only for wedge geometries.
    Please check the geometry or adjust the orthogonality tolerance.

Number of normal edges: 1066710 number of points: 1269000

The snappy never ends.

I solved the problem by defining front and back as symmetryPlane but... doing that, the overset stopped working: in my simulation my moving meshes controled by the overset seems completly independant of the background mesh...

I indentified 4 potential solutions upto now but don't know how to apply them or which one would be the best :

- Include my mesh refinement in the blockmeshdict. I don't like this solution because it strongly limits my possibilities.

- Find a way to use snappyHexMesh with empty front and back patches. I already tried to reorder the points before using snappy, but it did not change a thing.

- Find another kind of patch that will not interfer with my overset. But as a symmetryPlane isn't working, I guess that none of them will.

- Putting the symmetryPlane to mesh and removing it with a createPatch -overwrite to empty, but until now, this solution never succeed for some magical reasons, openfoam is refusing to swap back to empty patches...

Do any of you have an idea how to solve this ? I would be really grateful.

Feel free to ask for informations if you thing something is lacking in the thread, I really need to sort the things out !

Have a amazing day !

Magi

Yann May 6, 2022 08:20

Hi Magi,
  1. Do not use empty patch in your blockMeshDict
  2. After running snappyHexMesh, run extrudeMesh
  3. Finally, use changeDictionary to update your front and back patches to empty

Snappy uses octree structure to split the mesh when refining and AFAIK it cannot deal with 2D meshes. This means the resulting mesh will have several cells in the 3rd direction, which is obviously something your want to avoid for a 2D case.

This is why you need to use extrudeMesh to extrude a one layer thickness mesh out of one of the front or back patch. This will give you a clean 2D mesh with only one cell layer in the 3rd direction.

changeDictionary can be used to update boundary conditions or patches types, it is great to update boundary types after meshing.

I did not check but you should be able to find tutorials using extrudeMesh and changeDictionary.

I hope this helps,
Yann

Magistrane May 9, 2022 05:42

Thank you for your reactivity Yann. The solution seems to work. i changed my boundaries using changeDictionary function :

Quote:

boundary
{
front
{
type empty;
}
back
{
type empty;
}
}
I have some instabilities in my calculation now, but i think it is more about my mesh.

Merci !

saeed jamshidi January 22, 2024 11:56

Quote:

Originally Posted by Yann (Post 827558)
Hi Magi,
  1. Do not use empty patch in your blockMeshDict
  2. After running snappyHexMesh, run extrudeMesh
  3. Finally, use changeDictionary to update your front and back patches to empty

Snappy uses octree structure to split the mesh when refining and AFAIK it cannot deal with 2D meshes. This means the resulting mesh will have several cells in the 3rd direction, which is obviously something your want to avoid for a 2D case.

This is why you need to use extrudeMesh to extrude a one layer thickness mesh out of one of the front or back patch. This will give you a clean 2D mesh with only one cell layer in the 3rd direction.

changeDictionary can be used to update boundary conditions or patches types, it is great to update boundary types after meshing.

I did not check but you should be able to find tutorials using extrudeMesh and changeDictionary.

I hope this helps,
Yann

Hi Yann,

I tried to do the mentioned steps, except for running extrudeMesh!
However, I can't see any changes in the boundary patches!!
Code:

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

dictionaryReplacement
{
    boundary
    {
        front
        {
            type            empty;
        }
               
                back
        {
            type            empty;
        }
    }
}


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

Code:

/*--------------------------------*- C++ -*----------------------------------*\
| =========                |                                                |
| \\      /  F ield        | OpenFOAM: The Open Source CFD Toolbox          |
|  \\    /  O peration    | Version:  2112                                  |
|  \\  /    A nd          | Website:  www.openfoam.com                      |
|    \\/    M anipulation  |                                                |
\*---------------------------------------------------------------------------*/
FoamFile
{
    version    2.0;
    format      ascii;
    arch        "LSB;label=32;scalar=64";
    class      polyBoundaryMesh;
    location    "constant/polyMesh";
    object      boundary;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

7
(
    inlet
    {
        type            patch;
        nFaces          80;
        startFace      266920;
    }
    outlet
    {
        type            patch;
        nFaces          80;
        startFace      267000;
    }
    top
    {
        type            patch;
        nFaces          140;
        startFace      267080;
    }
    bottom
    {
        type            patch;
        nFaces          140;
        startFace      267220;
    }
    front
    {
        type            patch;
        nFaces          23189;
        startFace      267360;
    }
    back
    {
        type            patch;
        nFaces          23189;
        startFace      290549;
    }
    naca
    {
        type            wall;
        inGroups        2(nacaGroup wall);
        nFaces          7232;
        startFace      313738;
    }
)

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


Yann January 22, 2024 12:03

Hello Saeed,

What output do you get when running changeDictionary?

If you're using v2112 the syntax should be:

Code:

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


boundary
{
        front
        {
                type            empty;
        }
       
        back
        {
                type            empty;
        }
}


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

Regards,
Yann

saeed jamshidi January 22, 2024 12:13

yeahhh, it worked.

Thanks Yann:cool:

saeed jamshidi January 22, 2024 12:25

1 Attachment(s)
Ohhh, changeDictionary works properly, but an error occures in decomposition step!!

Code:

Create mesh for time = 0

Read dictionary changeDictionaryDict with replacements for dictionaries 1(boundary)
Reading polyMesh/boundary file to extract patch names
Loaded dictionary boundary with entries 7(inlet outlet top bottom front back naca)
Extracted patch groups:
    group nacaGroup with patches 1(naca)
    group wall with patches 1(naca)
Replacing entries in dictionary boundary
Special handling of boundary as polyMesh/boundary file.
Merging entries from 2(front back)
fieldDict:
{
    inlet
    {
        type            patch;
        nFaces          80;
        startFace      266920;
    }
    outlet
    {
        type            patch;
        nFaces          80;
        startFace      267000;
    }
    top
    {
        type            patch;
        nFaces          140;
        startFace      267080;
    }
    bottom
    {
        type            patch;
        nFaces          140;
        startFace      267220;
    }
    front
    {
        type            empty;
        nFaces          23189;
        startFace      267360;
    }
    back
    {
        type            empty;
        nFaces          23189;
        startFace      290549;
    }
    naca
    {
        type            wall;
        inGroups        2 ( nacaGroup wall );
        nFaces          7232;
        startFace      313738;
    }
}

Writing modified boundary

End

  - Decomposition
/*---------------------------------------------------------------------------*\
| =========                |                                                |
| \\      /  F ield        | OpenFOAM: The Open Source CFD Toolbox          |
|  \\    /  O peration    | Version:  2112                                  |
|  \\  /    A nd          | Website:  www.openfoam.com                      |
|    \\/    M anipulation  |                                                |
\*---------------------------------------------------------------------------*/
Build  : _6e1fca0e-20220610 OPENFOAM=2112 patch=220610 version=2112
Arch  : "LSB;label=32;scalar=64"
Exec  : decomposePar
Date  : Jan 22 2024
Time  : 20:52:31
Host  : DESKTOP-TK3D7CI
PID    : 22616
I/O    : uncollated
Case  : /mnt/e/OpenFoam/Run/naca2412
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



Decomposing mesh

Create mesh

Calculating distribution of cells
Decomposition method simple [6] (region region0)

Finished decomposition in 0.03 s

Calculating original mesh data

Distributing cells to processors

Distributing faces to processors

Distributing points to processors

Constructing processor meshes
Reading hexRef8 data : cellLevel
Reading hexRef8 data : pointLevel
Reading hexRef8 data : level0Edge

Processor 0
    Number of cells = 8373
    Number of faces shared with processor 1 = 316
    Number of faces shared with processor 3 = 496
    Number of processor patches = 2
    Number of processor faces = 812
    Number of boundary faces = 6387

Processor 1
    Number of cells = 21279
    Number of faces shared with processor 0 = 316
    Number of faces shared with processor 2 = 823
    Number of faces shared with processor 4 = 717
    Number of processor patches = 3
    Number of processor faces = 1856
    Number of boundary faces = 5268

Processor 2
    Number of cells = 18482
    Number of faces shared with processor 1 = 823
    Number of faces shared with processor 5 = 432
    Number of processor patches = 2
    Number of processor faces = 1255
    Number of boundary faces = 15362

Processor 3
    Number of cells = 23717
    Number of faces shared with processor 0 = 496
    Number of faces shared with processor 4 = 618
    Number of processor patches = 2
    Number of processor faces = 1114
    Number of boundary faces = 9761

Processor 4
    Number of cells = 10810
    Number of faces shared with processor 1 = 717
    Number of faces shared with processor 3 = 618
    Number of faces shared with processor 5 = 210
    Number of processor patches = 3
    Number of processor faces = 1545
    Number of boundary faces = 3007

Processor 5
    Number of cells = 13607
    Number of faces shared with processor 2 = 432
    Number of faces shared with processor 4 = 210
    Number of processor patches = 2
    Number of processor faces = 642
    Number of boundary faces = 14265

Number of processor faces = 3612
Max number of cells = 23717 (47.8186% above average 16044.7)
Max number of processor patches = 3 (28.5714% above average 2.33333)
Max number of faces between processors = 1856 (54.1528% above average 1204)

Time = 0


--> FOAM FATAL IO ERROR: (openfoam-2112 patch=220610)
inconsistent patch and patchField types for
    patch type empty and patchField type zeroGradient

file: 0/cellLevel.boundaryField.front at line 96315.

    From static Foam::tmp<Foam::fvPatchField<Type> > Foam::fvPatchField<Type>::New(const Foam::fvPatch&, const Foam::DimensionedField<Type, Foam::volMesh>&, const Foam::dictionary&) [with Type = double]
    in file /usr/src/packages/BUILD/src/finiteVolume/lnInclude/fvPatchFieldNew.C at line 141.

FOAM exiting

Is there an issue with my running steps?!
  1. cp -r 0.orig 0
  2. blockMesh
  3. surfaceFeatureExtract
  4. mpirun snappyHexMesh -overwrite
  5. changeDictionary
  6. decomposePar

The error refers to this part in cellLevel:
Attachment 98243

Yann January 23, 2024 03:40

Hello Saeed,

changeDictionary modified your patch type to empty in the mesh (specifically in the constant/polyMesh/boundary file) but it didn't update these patches in the 0 directory since you didn't specify it.

cellLevel is a variable written by snappy while meshing, so it has the same patch type as the ones defined during meshing.

decomposePar complains because the front and back patches are now type empty in the boundary file, but the boundary conditions defined for those patches in 0 directory are incompatible (it should be empty too)

To solve this issue you should also update the files in 0 directory:

Code:

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


boundary
{
        front
        {
                type            empty;
        }
       
        back
        {
                type            empty;
        }
}

cellLevel
{
        front
        {
                type            empty;
        }
       
        back
        {
                type            empty;
        }
}

// Same thing for all variables which need to be updated in 0 directory


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

On a side note: I guess it's a typo but you shouldn't have mpirun in front of snappyHexMesh -overwrite in your workflow since you're meshing in serial.

saeed jamshidi January 23, 2024 05:07

1 Attachment(s)
Hello Yann, thank you for the reply.

I adopted the following changeDictionary for my case, however, it gave me additional repetitive patches for front and back!!

Code:

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


boundary
{
        front
        {
                type            empty;
        }
       
        back
        {
                type            empty;
        }
}

cellLevel
{
        front
        {
                type            empty;
        }
       
        back
        {
                type            empty;
        }
}

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

Attachment 98247

Yann January 23, 2024 05:11

My bad, this should be the proper syntax for the changeDictionaryDict file:

Code:

cellLevel
{
    boundaryField
    {
        front
        {
            type            empty;
        }
        back
        {
            type            empty;
        }
    }
}


saeed jamshidi January 23, 2024 05:14

Ohhh yeahh, I think I need some rest to recharge my batteries:)

Thanks again.


All times are GMT -4. The time now is 07:50.