Sunteți pe pagina 1din 11

snappyHexMesh Tutorial | hydroniumion.

de

http://www.hydroniumion.de/general/snappyhexme...

hydroniumion.de About Impressum

February 8, 2009

15

snappyHexMesh Tutorial
By Jens in General, OpenFOAM, Studies

In order to use the automatic meshing tool snappyHexMesh, you have to create a raw background mesh. This can easily be achieved by using blockMesh of OpenFOAM. For this tutorial, I assume that you wish to compute the flow around a body, such as a ships hull. The users guide can be found here. 1. Create (or copy) the blockMeshDict in $CASE_DIR/constant/polyMesh. It is not necessary to create a fine background mesh, since it will be refined by snappyHexMesh.

2. Basic case directory setup For the execution of blockMesh, the case folder has to be set up correctly. This can either be seen in the User Guide or in lots of tutorials, such as icoFoam/cavity. For the icoFoam solver, an example case-directory can be seen in the screenshot. Goto your case-directory and execute
blockMesh

This creates the background mesh. One has to mention, that is is necessary to dimension it sufficiently, in order to fit the hull into that mesh and suppress numerical errors, caused by a way to small mesh. 3. Assuming, that youve already exported your geometry as an STL-file, youve to copy that file to $CASE_DIR/constant/triSurface. For the following tutorial, I assume, that the filename is hull.stl.

1 von 11

2012-01-20 16:55

snappyHexMesh Tutorial | hydroniumion.de

http://www.hydroniumion.de/general/snappyhexme...

Mesh created by blockMesh 4. Create (or copy from a snappyHexMesh tutorial) the snappyHexMeshDict in $CASE_DIR/system and insert the standard header into that file:
FoamFile { version format root case instance local class object }

2.0; ascii; ""; ""; ""; ""; dictionary; autoHexMeshDict;

5. Now we can start with creating the necessary dictionaries. First of all, tell snappyHexMesh, what to do (in a global sense)
castellatedMesh true; snap true; addLayers true;

6. Secondly, snappyHexMesh needs to know which geometry to use. You can simply add just one STL-file, or add add searchableBoxes etc. to this dictionary, if you either wish to create a geometry without an STL-file or you like to specify a region in your mesh, that should be refined specifically. Trying to map the wake field requires a specific refinement region.
geometry { hull.stl { type triSurfaceMesh; name HULL; } };

7. Now we have to configure the settings for the mesh, generated by snappyHexMesh. This is done in the castellatedMeshControls sub-dictionary. Valid
2 von 11 2012-01-20 16:55

snappyHexMesh Tutorial | hydroniumion.de

http://www.hydroniumion.de/general/snappyhexme...

settings and options can be seen in the user-guide (table 5.8) or in the snappyHexMesh tutorials. An example for that sub-dictionary is the following
castellatedMeshControls { maxLocalCells 10000000; maxGlobalCells 2000000; minRefinementCells 0; nCellsBetweenLevels 1; refinementSurfaces { HULL { level (4 5); } } resolveFeatureAngle 30; refinementRegions { HULL { mode distance; levels ((0.1 5) (0.4 4) (1 2)); } } locationInMesh (3.11 1.51 -1.1); }

Visualized levels of region refinement The most important part for a working mesh refinement are locationInMesh, which specifies a point inside the mesh generated by blockMesh, but not inside the geometry (in this case the hull). Secondly, the refinementSurfaces tells snappyHexMesh, which surfaces are the ones to be refined. The level tag defines minimum and maximum refinement level. The refinementRegions tag sets the levels of refinement in various distances to the body, this can be seen in the figure. It doesnt matter, how much refinementRegions are defined, but the scheme is
3 von 11 2012-01-20 16:55

snappyHexMesh Tutorial | hydroniumion.de

http://www.hydroniumion.de/general/snappyhexme...

always the same.


levels((maxDistance refinementLevel)...)

8. After the specification of the general meshing and refinement parameters, it is essential to set up controls for the snapping process itself. (cp. [1] table 5.9)
snapControls { nSmoothPatch 3; tolerance 4.0; nSolveIter 30; nRelaxIter 5; }

9. Patch name in an ASCII STL file The layer addition is controlled by the addLayersControls dictionary, whose options can be seen in table 5.10 of the user guide (cp. [1]). These options are skipped for this tutorial, and sample values can be found in the user guide as well. Nevertheless, the layers sub-directory is important to talk about. As stated in [1], it tells snappyHexMesh which patches need layers attached and the number of those layers. Since this is an mesh oriented option, not the surface geometry has to be specified, but the patch name. If you have an ASCII STL file, you can open simply open it with an texteditor of your choice and the word after solid is the patch name. In my case, this was OBJECT.
addLayersControls { layers { HULL_OBJECT { nSurfaceLayers 1; } } }

10. Finally, controlling the meshs quality is a crucial part of the whole meshing

4 von 11

2012-01-20 16:55

snappyHexMesh Tutorial | hydroniumion.de

http://www.hydroniumion.de/general/snappyhexme...

process. Thus snappyHexMesh provides a dictionary to control the quality, which is namely the meshQualityControls sub-dictionary. All options related to this can be found in table 5.11 in the user guide [1].
meshQualityControls{ //Insert your options here }

11. Model's position compared to the background mesh It is essential to get your model into the right position within your background mesh, created with blockMesh. You can easily check this by comparing both, the mesh and the model, with paraFoam or paraview. If you are on a linux machine, simply type
paraFoam & // & to run paraFoam in background

If you calculate on a linux machine and do the postprocessing on e.g. a mac, you have to convert your mesh by
foamToVTK

and then open paraview and your VTK file manually. After that, load your STL model into paraview/paraFoam as well. To simplify the orientation within the mesh, you should enable the option show cube axes for the mesh. If you have a symmetry plane, it is beneficial to highlight this as well. After that, the picture you get should be in a way similar to mine. 12. Move the mesh until the model is inside and in its desired position. The coordinates are obtained from paraFoam/paraview and the axes shown in there. Moving the mesh is kind of easy
transformPoints -translate "(x y z)"

One has to state that the coordinates have to be specified in dashes as shown, otherwise the bash will skrew up on that command. 13. Look again at the models position in the mesh. If it is not correct, move it

5 von 11

2012-01-20 16:55

snappyHexMesh Tutorial | hydroniumion.de

http://www.hydroniumion.de/general/snappyhexme...

again. 14. Now its time to execute execute


snappyHexMesh

snappyHexMesh

by moving to your case directory and

15. After having run the meshing without any errors, three new timestep folders appear in your case directory. The naming differs, depending on your deltaT in your system/controlDict, but always reflects the first three timesteps. Opening the case using paraFoam gives a good nice understanding, how snappyHexMeshworks. The first timestep (folder 0) shows the background mesh, without any refinements. Timestep 1 shows the refined mesh as well as no faces, that are snapped to the geometry. The final result is provided by timestep 2.

timestep 0: simply timestep 1: Refined timestep 2: final the background mesh, but no result with mesh snapped faces snapped faces 16. If running the solver, the improved mesh will not be used, because the old mesh is still written in constant/polyMesh. Hence the folder "lastTimeStep"/polyMesh has to be copied to constant/polyMesh. 17. Run your solver

[Update]
Have a look to the second part of the snappyHexMesh tutorial! [1] OpenFOAM The Open Source CFD Toolbox User Guide, Version 1.5 Tags: CFD, OpenFOAM, snappyHexMesh iRhino STL export Man gnnt sich ja sonst nichts

15 Responses to snappyHexMesh Tutorial

6 von 11

2012-01-20 16:55

snappyHexMesh Tutorial | hydroniumion.de

http://www.hydroniumion.de/general/snappyhexme...

1.

John says: 8. April 2009 at 20:02 Thank you very much about this tutorial! Im just starting to learn OpenFoam and this tutorial is a big help. Reply

2.

Jens says: 12. May 2009 at 12:34 Thanks alot, John. Im glad, that I the tutorial was a help to you. Reply

3.

Ted says: 25. October 2009 at 20:07 Thanks for the tutorial! Ive been playing around with snappyHexMesh to do some CFD on a design Im working on. I was curious if you could elaborate on what the levels mean under the castellatedMeshControls. Does higher levels just mean more refinement so going from 2 to 3 just means running an extra iteration of refinement? Thanks Reply Jens says: 26. October 2009 at 09:43 Hi Ted, You are completely right. A higher refinement level means more refinement in that area. To be honest: I actually dont use snappyHexMesh any more, since it does not work that good for my case of application. Reply

4.

peter says: 28. February 2010 at 19:40 how i can define the integrate the geometry in a project, maybe this hull-project by you ? the problem here is for me that i cant imagine how here has something to go inside and outside, a where this system know from what is what ? thank you for answer

7 von 11

2012-01-20 16:55

snappyHexMesh Tutorial | hydroniumion.de

http://www.hydroniumion.de/general/snappyhexme...

(i am a newbie) gruss Reply 5. brunno says: 15. March 2010 at 22:31 Thank you so much for this tutorial ! How did you solve the problem with the edges ? You implemented *.eMesh file into snappyHexMesh ? Thanks again Reply 6. marine says: 20. April 2010 at 17:38 Hello! I was wondering if you have some experience with the addlayer part of snappy, Im meshing a hull just as you did but Im having a really hard time to set the parameters of the boundary layer. If you have any advice it would be welcome! thank you! Marine Reply 7. Salome mesh with NETGEN 1D-2D-3D for OF -- CFD Online Discussion Forums says: 13. June 2010 at 14:18 [...] giving snappyHexMesh a try. Thanks for the hint. Is there a good tutorial for it? I found this one: http://www.hydroniumion.de /allgemeinmesh-tutorial/ Is there a possibility to define edges/surfaces in Salome (e.g. with groups) that will be refined [...] Reply 8. Ulisses says: 14. June 2010 at 23:11 Thanks for the tutorial!!!! You help me a lot!!! Reply

8 von 11

2012-01-20 16:55

snappyHexMesh Tutorial | hydroniumion.de

http://www.hydroniumion.de/general/snappyhexme...

9.

Jens says: 7. July 2010 at 17:37 First of all, I need to apologize for the immense delay time. I somehow lost this blog out of sight. @peter: Im not sure if I get your question correctly. You want to know, how snappy knows which cells are inside the domain and which are not? This is done by the locationInMesh entry in your snappyHexMeshDict. @brunno: I did not solve the issue with snappy, that edges cannot be resolved with a sharp line. AFAIK, the *.eMesh file is not implemented (yet). @marine: Yes, I have some experience with the addLayers. What are your problems with the boundary layer construction?

Reply 10. snappyHexMesh Tutorial Part 2 | hydroniumion.de says: 8. July 2010 at 18:35 [...] first snappyHexMesh tutorial is more or less a little extended listing of the information gained from the OpenFOAM User's Guide. [...] Reply 11. Tomislav says: 1. December 2010 at 14:02 :p I found the explanation to the locationInMesh! Thanks! Reply 12. Ali says: 27. January 2011 at 18:05 Can anyone please desribe what does refinement level mean in refinement regions? Reply 13. Jens says: 27. January 2011 at 18:09 The refinementLevel describes how many times each edge of a cell is sliced into two parts. For a hexahedral cell, a refinementLevel of 1 gives 8 cells (2 times 2 times 2) and so on.

9 von 11

2012-01-20 16:55

snappyHexMesh Tutorial | hydroniumion.de

http://www.hydroniumion.de/general/snappyhexme...

Reply 14. Justin says: 10. May 2011 at 22:35 Thank you very much! It helps a lot! Reply

Leave a Reply
Name (required)

Mail (will not be published) (required)

Website

Submit Comment
Categories Apple (11) General (21) Me (28) OpenFOAM (8) Studies (12) Travel (12) Web (14) Windsurfing (8) Tags
Affen Amazon Ansys Apple BibDesk Braii

CFD

DST Excel FEM Fundstck Gardenroute Gewinnspiel

10 von 11

2012-01-20 16:55

snappyHexMesh Tutorial | hydroniumion.de

http://www.hydroniumion.de/general/snappyhexme...

gnuplot Gravis
portable

I am Legend iPod JBL

Kapstadt LaTeX Leopard linux Literatur Long


Spots Strau

Street MacBook Air MikTeX

nur so Octave OpenFOAM Ostern OS X Photoshop Pinguine


Studienarbeit

Quatsch Schelde sed snappyHexMesh Software V&A Waterfront Windsurfing Zubehr

Archives November 2010 (1) October 2010 (1) September 2010 (1) July 2010 (3) November 2009 (3) July 2009 (1) February 2009 (2) January 2009 (3) December 2008 (2) November 2008 (1) October 2008 (1) September 2008 (1) August 2008 (1) July 2008 (1) May 2008 (1) April 2008 (4) March 2008 (2) January 2008 (8) December 2007 (4) November 2007 (7) October 2007 (8) September 2007 (5) August 2007 (8) Top RSS Home Fifty Fifth Street theme by Tammy Hart Designs Powered by WordPress

11 von 11

2012-01-20 16:55

S-ar putea să vă placă și