Difference between revisions of "SnappyHexMesh"
(added missing line breaks. And I can't believe I had forgotten to add the link to the "snappyWiki") |
(→Tutorials and Guides) |
||
Line 53: | Line 53: | ||
* Tutorial by Jens H. at personal blog: [http://www.hydroniumion.de/posts/snappyhexmesh-tutorial/ snappyHexMesh Tutorial (part 1)] | * Tutorial by Jens H. at personal blog: [http://www.hydroniumion.de/posts/snappyhexmesh-tutorial/ snappyHexMesh Tutorial (part 1)] | ||
+ | |||
+ | * A Concise Introduction to Pre-Processing, Meshing, and Running OpenFOAM® Cases with HELYX-OS - 8th OpenFOAM Workshop: | ||
+ | ** Original source: [http://http://www.openfoamworkshop2013.org/file/Tue/Track2-3_DanielCombest.tar] | ||
+ | |||
+ | * Advanced Preprocessing and Meshing with snappyHexMesh | ||
+ | ** Original source: [http://www.openfoamworkshop2013.org/file/Tue/Track2-4_DanielCombest.tar] | ||
* Tutorials by T. Holzmann at personal homepage (update 08.07.2013): [http://www.holzmann-cfd.de/index.php/tutorials all snappyHexMesh Tutorials] | * Tutorials by T. Holzmann at personal homepage (update 08.07.2013): [http://www.holzmann-cfd.de/index.php/tutorials all snappyHexMesh Tutorials] | ||
* Dedicated wiki to {{tt|snappyHexMesh}} by Elia Agnani: [https://sites.google.com/site/snappywiki snappyWiki] | * Dedicated wiki to {{tt|snappyHexMesh}} by Elia Agnani: [https://sites.google.com/site/snappywiki snappyWiki] | ||
− | |||
= Tips = | = Tips = |
Revision as of 06:50, 14 October 2013
Contents
- 1 Introduction
- 2 Tutorials and Guides
- 3 Tips
- 3.1 Can't find the resulting mesh
- 3.2 Generate 2D meshes
- 3.3 Multi-region meshes
- 3.4 Running in parallel
- 3.5 GUI (Graphical User Interfaces)
- 3.6 Another way of projection of a mesh on an STL surface
- 3.7 Isolate and Conquer
- 3.8 Valid and invalid solid names
- 3.9 Handling inclined surfaces
- 3.10 Fixing STL files
1 Introduction
In a nutshell, snappyHexMesh is a mesh generator that takes an already existing mesh (usually created with blockMesh) and chisels it into the mesh you want. But for this, it requires:
- A very well defined dictionary, namely system/snappyHexMeshDict.
- Good geometrical definitions, such as:
- STL/OBJ files with well defined surfaces;
- eMesh feature edge files, that define feature edges that have describe sharp corners.
Note: feature edges only available in:
Configuring both the dictionary file and providing good geometries can be a very arduous task. Therefore, at the moment of this writing (11:06, 18 August 2012 (CEST)), this wiki page will try to point you in the right direction, without describing each and every detail related to using snappyHexMesh. Feel free to contribute to this page!
1.1 Synopsis
snappyHexMesh [OPTIONS]
1.2 Description
snappyHexMesh is more of a mesh sculptor than a mesh generator, because it requires an already existing base mesh to work with. Depending on the options given through the file "system/snappyHexMeshDict", it can:
- refine the mesh;
- adjust the mesh to fit onto provided geometries;
- and add boundary layers near the requested patches.
The following options can be used with snappyHexMesh:
-case DIR
- Execute the command on the case directory DIR. If not provided, use the current directory
-checkGeometry
-noFunctionObjects
- Skip the execution of the functionObjects
-overwrite
- Overwrite existing mesh/results files
-parallel
- Run the utility in parallel
-roots "(DIR1 [...DIRN])"
- Directories through which the data are distributed
-help
- Display the help and exit
2 Tutorials and Guides
Here are listed links to tutorials and guides on using snappyHexMesh:
- Official OpenFOAM User Guide, chapter 5.4 - Mesh generation with the snappyHexMesh utility
- A Comprehensive Tour of snappyHexMesh - 7th OpenFOAM Workshop (25 June 2012):
- Original source: EugenedeVilliers-TrainingSlides.tgz
- Local copy here at openfoamwiki.net: Final-AndrewJacksonSlidesOFW7.pdf
- Tutorial by Jens H. at personal blog: snappyHexMesh Tutorial (part 1)
- A Concise Introduction to Pre-Processing, Meshing, and Running OpenFOAM® Cases with HELYX-OS - 8th OpenFOAM Workshop:
- Original source: [1]
- Advanced Preprocessing and Meshing with snappyHexMesh
- Original source: [2]
- Tutorials by T. Holzmann at personal homepage (update 08.07.2013): all snappyHexMesh Tutorials
- Dedicated wiki to snappyHexMesh by Elia Agnani: snappyWiki
3 Tips
On this chapter are listed links and direct tips on using snappyHexMesh.
3.1 Can't find the resulting mesh
Creating a mesh with snappyHexMesh requires the following crucial steps:
- To already have a mesh ready, even if it's a simple brick-like mesh. For example, a simple mesh generated with blockMesh that has the dimensions of 10x4x2 meters and is divided in cells of 1 meter.
- The dictionary file snappyHexMeshDict should be properly configured. Look into the examples and tutorials for more information.
- snappyHexMesh must be executed with success.
If after these steps you can only find the original base mesh that was generated with blockMesh, then there are a few possibilities:
- snappyHexMesh might not have ran with success.
- If the option -overwrite was not used, then the resulting meshes should be in the next time folders, possibly inside the folders "1", "2" and/or "3".
- If the location in mesh given is on the outside of the geometry, then in ParaView you should either use the filter Clip or Extract Cells by Region, for inspecting how the mesh looks inside.
3.2 Generate 2D meshes
Instructions/examples on how to generate 2D meshes using snappyHexMesh can be found in at least two places:
- Here at the wiki: Main_ContribExamples/2DsHM
- In the tutorial incompressible/pimpleDyMFoam/wingMotion/wingMotion_snappyHexMesh
Other tutorials:
- This is an awesome tutorial: Dynamic Mesh for a Gear Pump.
3.3 Multi-region meshes
There are a few instructions/examples on how to generate multi-region meshes with snappyHexMesh:
- See the tutorial heatTransfer/chtMultiRegionFoam/snappyMultiRegionHeater.
- Instructions on how to remove an external unwanted region: Background Mesh in snappy with multi domain (CHT) post #3
- Note: this happens whenever the base mesh doesn't coincide with the outer limits of the target surface geometry. The tutorial heatTransfer/chtMultiRegionFoam/snappyMultiRegionHeater is such an example where the outside of the original STL files coincides with the base mesh.
- Discussion on this topic for simplified multi-tubes connected between two boxes: multiple regions at cfd-online.com.
- The resulting example case is provided here: Exhaust gas heat exchanger (in German)
- Not 100% multi-region, but more specifically a single mesh domain with a porous region: Multiple regions with a porous zone - post #5 - at cfd-online.com
3.4 Running in parallel
Currently there are several official tutorials on how to use snappyHexMesh in parallel:
- incompressible/windSimpleFoam/turbineSiting - Valid versions:
- incompressible/simpleFoam/turbineSiting - Valid versions:
- incompressible/pisoFoam/les/motorBike/motorBike - Valid versions:
Other tutorials:
- Modified motorBike tutorial to be used as a benchmark case for running in parallel: Runtimes of OpenFOAM vs blueCFD - Valid versions:
3.5 GUI (Graphical User Interfaces)
Currently there are several interactive ways (using GUI) of generating meshes with snappyHexMesh. Here will only be listed the ones that are open-source:
- Discretizer
- Check the Screencasts page for more information.
- SwiftSnap
- A very useful plug-in for Blender for configuring snappyHexMeshDict. There is SwiftBlock for blockMeshDict as well!
- HelyxOS
- A GUI for using OpenFOAM. See the video tutorials:
3.6 Another way of projection of a mesh on an STL surface
Adding boundary layers with snappyHexMesh can sometimes be very stressing, specially when it sometimes stops the layers in the wrong places. Trying to improve this feature was one of several works made in the MSc/PhD course in CFD with OpenSource software, 2011 at Chalmers, namely:
Other important links:
- Thread dedicated to discussing on this subject: [3]
- Adjusted code for working with the latest OpenFOAM versions: [4]
3.7 Isolate and Conquer
Since snappyHexMesh has so many mesh quality parameters, these sometimes to get in the way of the meshes you're trying to generate. The solution apparently is simple:
- Disable all quality controls.
- Diagnose visually the resulting mesh.
- Gradually turn back on one quality indicator at a time, while checking the resulting mesh with both checkMesh and ParaView.
For more on this, read the following posts/threads:
- Troubles with layer adding in my mesh - post #3
- (I know there are more threads at cfd-online.com, but currently I'm unable to find them -- Wyldckat (talk) 22:04, 3 September 2012 (CEST))
3.8 Valid and invalid solid names
There are 2 details to always keep in mind when exporting to STL:
- Always export to STL in ASCII or "coded" format (this means it'll be plain text).
- Edit the resulting file with a text editor and look for the lines that start with "solid". Next to the word "solid" is the name of said solid; that name should be a single C/C++ word.
Examples of valid words/names:
- wall
- ladder
- part_001_73_
Invalid names:
- This was generated by productnamehere
- part 001-73:
- 70 inch wall
3.9 Handling inclined surfaces
Q: Do you have a geometry that has an inclined surface and gets a very bad mesh, due to the cells not adjusting properly to the geometry, namely the inclined surfaces?
A: Check the following thread at CFD-Online: How to get a snapped mesh with SnappyHexMesh? post #4 and #5
3.10 Fixing STL files
If you need to fill or fix small gaps, here is a list of possible applications that can help:
- adMesh
- Can be installed on Debian/Ubuntu by running:
sudo apt-get install admesh
- Can be installed on Debian/Ubuntu by running:
- ReMESH
- MeshLab
- Can be installed on Debian/Ubuntu by running:
sudo apt-get install meshlab
- Can be installed on Debian/Ubuntu by running:
- Blender
- Check the wiki page Blender for more information.
- Fixing holes is explained in the following link, but the instructions are for the old Blender 2.49b: Unstructured Grids for OpenFOAM With Blender and enGrid 1.2, chapter Modelling with Blender
- As of you have the following OpenFOAM utilities that can assist in doing surface manipulations and checks, which is listed here: Main OFUtilities, section Surface mesh
Short list of topic related threads at CFD-Online's forums: