CFD Online Discussion Forums

CFD Online Discussion Forums (
-   OpenFOAM Mesh Utilities (
-   -   SnappyHexMesh in 2D case (

sjs July 23, 2008 16:26

I am trying to look at an airf
I am trying to look at an airfoil shape in 2D. Geometry is like the airfoil in a big box, with wind along the chord direction. I set up "empty" patches on the walls perpendicular to the span of the airfoil. This works fine. However, then when I try to use snappyHexMesh to mesh nicely around the foil shape, it doesn't work. With a blockdict specifying only 1 cell in that span direction, snappyHexMesh won't work (it does work if I don't have empty patches on those boundary). If I make 2 cells in the span direction, snappyHexMesh works, however when I try to run icoFoam, I get this error:

This mesh contains patches of type empty but is not 1D or 2D by virtue of the fact that the number of faces of this empty patch is not divisible by the number of cells.

Suggestion for how I can use this excellent snappyHexMesh tool for a 2D case?

Thank you.

eugene July 24, 2008 08:33

You cant. The best you could d
You cant. The best you could do is to make a slightly 3D case and use symmetry planes on the spanwise boundaries.

sjs July 24, 2008 13:09

Thank you for the advice. I tr
Thank you for the advice. I tried symmetry planes with 1 cell in the span direction. snappyHexMesh failed. So I use 2 cells in the span direction, with symmetry plane boundary conditions. From a physical point of view, how accurate is this for a 2D case? For accuracy, do I just need to use an outside mesher so I can make it more properly 2D (ie empty side planes and only 1 cell in the span direction)? It looks like the naca airfoil example in soniceTurbFoam works fine with empty planes on either side and only one cell in the spanwise direction.


fra76 July 24, 2008 13:44

If you import a 2D mesh, made
If you import a 2D mesh, made for example with gambit, the converter extrudes it to a 3D mesh with 1 cell in the extrusion direction, with empty planes as boundary conditions. OpenFOAM does not have a 2D solver, but that is the right way of performing 2D simulations.


sjs July 25, 2008 13:51

By the way, I also tried symme
By the way, I also tried symmetry planes, both on rhoSonicFoam and on icoFoam. Both systems diverged within 0.02 s of integration time. I don't know if this has anything to do with the mesh, but it seemed to work ok with slip boundary conditions (which is not at all what I want) or without the snappyHexMesh (which also is not what I want). Has anyone else tried to use snappyHexMesh extending to side planes with b.c. that are anyting besides slip?

mgz1985 August 25, 2008 04:59

HI Sylvia, Regarding your e
HI Sylvia,

Regarding your error with running icoFoam, it is due to the fact of having cells in the 3D. I had the same problem.

To solve 2-D cases in OpenFOAM u need to specify only 1 cell in z-direction of type empty. if snappyHexMesh is adding 2 cells in the z-direction, u r bound to get the error

If u define more than 1 cell in the z-direction u get the above error. I have not worked with snappyHexMesh but i know with my experience of meshing an airfoil, the reason for the above error.

lord_kossity February 11, 2009 06:36

Hello Eugene, hello FOAMers,
Hello Eugene,
hello FOAMers,

I've got one additional question applying snappyHexMesh for a 2D-case.

For an analysis of lift and drag, i tried to create a 2D-mesh of a car.

I did the following to cheat a bit, since I already knew that snappyHex is not planned to work in 2D.

1) create a blockMesh with one cell in spanwise direction

2) change the level of refinementSurfaces to (0 0) in order to avoid additional cells in spanwise direction

3) snapping runs with standard parameters

4) change surfaceLayers to 2 in addLayersControls

snappyHexMesh runs fine. But it does not insert layers.

For copyright reasons, I can only show a part of the frontend

In order that anybody can run the case, I additionaly attach the blockMeshDict and snappyHexMeshDict for a 2D Cube (one cell in y-direction).

Please let me know, if you are able to insert layers.


btw: anybody knows how to get rid of the diagonals in paraview?

lord_kossity February 11, 2009 06:38

one more try for the picture:
one more try for the picture:

eugene February 11, 2009 06:55

Hi Andreas, No, you cannot
Hi Andreas,

No, you cannot insert layers in pseudo-2D. At present, layers cannot just stop. They have to gradually go from no layer cells to many layer cells in a step-wise fashion. Thus 1 layer would never be possible.


hansel July 8, 2009 17:42

It would be nice to have a utility that would take a 2d (one layer thick) slice out of a 3d mesh. I was hoping flattenMesh would do it, but that's for something else.

For taking a z slice at height Z:

1) Find all faces and edges that cross Z
2) preserve those faces and edges, and discard the others.
3) Run flattenMesh on the results.

hmmm I guess you also have to close the top and bottom. Maybe it's not so simple.


All times are GMT -4. The time now is 01:10.