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 in 2D case (https://www.cfd-online.com/Forums/openfoam-meshing/61497-snappyhexmesh-2d-case.html)

sjs July 23, 2008 16:26

SnappyHexMesh in 2D case
 
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.
Sylvia

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.

Thanks.
Sylvia

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.

Francesco

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 05: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

http://www.cfd-online.com/OpenFOAM_D...your_image.gif


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.

Andreas

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

lord_kossity February 11, 2009 05:38

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

http://www.cfd-online.com/OpenFOAM_D...your_image.gif

eugene February 11, 2009 05: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.

Eugene

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.

Steve

elmo555 November 29, 2017 11:19

Apparently, there are a few solutions to use SnappyHexMesh for 2D cases:
http://openfoamwiki.net/index.php/Sn...rate_2D_meshes

The simples one seems to be from Alejandro Roger Ull:
https://www.cfd-online.com/Forums/op...tml#post368540

I'll quickly summarize what to do here:
  1. Crease base mesh with blockMesh with separate "empty" patches named "front" and "back"
  2. Create mesh with snappyHexMesh as you like
  3. Run "extrudeMesh" with an extrudeMeshDict like the one provided below.

Here's a simple extrudeMeshDict that will do the job:
Code:

constructFrom      patch;

sourceCase          ".";

sourcePatches      (front);

exposedPatchName    back;

flipNormals        false;

extrudeModel        linearNormal;

nLayers            1;

expansionRatio      1.0;

linearNormalCoeffs
{
    thickness      0.01;
}

mergeFaces          false;


Chubmaster August 15, 2018 19:41

extrudeMesh does
Code:

Writing mesh to "/mnt/c/Users/Avedis/Desktop/Fluids_stuff/flateplate02D/constant/region0"
, it does not write to the most recent polymesh. When I check the constant directory its not there. If I look at the most recent time in paraview, its the same mesh as before. I don't think it did anything.

mAlletto November 8, 2019 04:51

Maybe it is of interest for someone: in the openfoam.com version 1906 there is a tutorial how to create a 2d mesh from snappy. The procedure is like described above: first create a 3d mesh with snappy and then use the utility extrudeMesh to create a mesh with only one cell in spanwise direction. The tutorial can be found in $FOAM_TUTORIAL/incompressible/overSimpleFoam/aeroFoil


All times are GMT -4. The time now is 23:31.