CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Meshing & Mesh Conversion

[snappyHexMesh] SnappyHexMesh with Empty patches in blockMesh

Register Blogs Community New Posts Updated Threads Search

Like Tree6Likes
  • 2 Post By Yann
  • 1 Post By Magistrane
  • 1 Post By Yann
  • 1 Post By Yann
  • 1 Post By Yann

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   May 6, 2022, 08:21
Default SnappyHexMesh with Empty patches in blockMesh
  #1
Member
 
Ilan
Join Date: Dec 2018
Posts: 52
Rep Power: 8
Magistrane is on a distinguished road
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
Magistrane is offline   Reply With Quote

Old   May 6, 2022, 09:20
Default
  #2
Senior Member
 
Yann
Join Date: Apr 2012
Location: France
Posts: 1,238
Rep Power: 29
Yann will become famous soon enoughYann will become famous soon enough
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 and saeed jamshidi like this.
Yann is offline   Reply With Quote

Old   May 9, 2022, 06:42
Default
  #3
Member
 
Ilan
Join Date: Dec 2018
Posts: 52
Rep Power: 8
Magistrane is on a distinguished road
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 !
Yann likes this.
Magistrane is offline   Reply With Quote

Old   January 22, 2024, 12:56
Default
  #4
Senior Member
 
Saeed Jamshidi
Join Date: Aug 2019
Posts: 214
Rep Power: 8
saeed jamshidi is on a distinguished road
Quote:
Originally Posted by Yann View Post
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;
    }
)

// ************************************************************************* //
saeed jamshidi is offline   Reply With Quote

Old   January 22, 2024, 13:03
Default
  #5
Senior Member
 
Yann
Join Date: Apr 2012
Location: France
Posts: 1,238
Rep Power: 29
Yann will become famous soon enoughYann will become famous soon enough
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 likes this.
Yann is offline   Reply With Quote

Old   January 22, 2024, 13:13
Default
  #6
Senior Member
 
Saeed Jamshidi
Join Date: Aug 2019
Posts: 214
Rep Power: 8
saeed jamshidi is on a distinguished road
yeahhh, it worked.

Thanks Yann
saeed jamshidi is offline   Reply With Quote

Old   January 22, 2024, 13:25
Default
  #7
Senior Member
 
Saeed Jamshidi
Join Date: Aug 2019
Posts: 214
Rep Power: 8
saeed jamshidi is on a distinguished road
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:
Screenshot (271).jpg

Last edited by saeed jamshidi; January 22, 2024 at 16:04.
saeed jamshidi is offline   Reply With Quote

Old   January 23, 2024, 04:40
Default
  #8
Senior Member
 
Yann
Join Date: Apr 2012
Location: France
Posts: 1,238
Rep Power: 29
Yann will become famous soon enoughYann will become famous soon enough
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 likes this.
Yann is offline   Reply With Quote

Old   January 23, 2024, 06:07
Default
  #9
Senior Member
 
Saeed Jamshidi
Join Date: Aug 2019
Posts: 214
Rep Power: 8
saeed jamshidi is on a distinguished road
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;
	}
}

// ************************************************************************* //
Screenshot (275).jpg
saeed jamshidi is offline   Reply With Quote

Old   January 23, 2024, 06:11
Default
  #10
Senior Member
 
Yann
Join Date: Apr 2012
Location: France
Posts: 1,238
Rep Power: 29
Yann will become famous soon enoughYann will become famous soon enough
My bad, this should be the proper syntax for the changeDictionaryDict file:

Code:
cellLevel
{
    boundaryField
    {
        front
        {
            type            empty;
        }
	back
        {
            type            empty;
        }
    }
}
saeed jamshidi likes this.
Yann is offline   Reply With Quote

Old   January 23, 2024, 06:14
Default
  #11
Senior Member
 
Saeed Jamshidi
Join Date: Aug 2019
Posts: 214
Rep Power: 8
saeed jamshidi is on a distinguished road
Ohhh yeahh, I think I need some rest to recharge my batteries

Thanks again.
saeed jamshidi is offline   Reply With Quote

Reply

Tags
blockmesh, patches, snapphhexmesh


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
[snappyHexMesh] Patches disappearing after snappyHexMesh obiscolly50 OpenFOAM Meshing & Mesh Conversion 3 April 14, 2023 14:24
[mesh manipulation] createpatch not working when using layer addition in snappyHexMesh Dikkeunit OpenFOAM Meshing & Mesh Conversion 0 February 3, 2020 10:46
This mesh contains patches of type empty but is not 1D or 2D oric OpenFOAM Running, Solving & CFD 36 November 28, 2016 08:12
[snappyHexMesh] snappyHexMesh does not create boundary patches from .stl files bug_or_feature OpenFOAM Meshing & Mesh Conversion 7 August 30, 2016 20:18
[mesh manipulation] mirrorMesh and undoing the joining of patches chegdan OpenFOAM Meshing & Mesh Conversion 3 October 21, 2015 09:09


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