Difference between revisions of "BlockMesh"

From OpenFOAMWiki
(Graphical User Interfaces for visualizing and designing {{tt|blockMeshDict}})
(22 intermediate revisions by 6 users not shown)
Line 1: Line 1:
Trick:
+
__FORCETOC__
  
1. use the -blockTopology argument to dump out a blockTopology.obj file.
+
= Introduction =
 +
<tt>blockMesh</tt> is one of the most basic mesh generators in OpenFOAM. It relies on a single dictionary file <tt>blockMeshDict</tt>, usually placed inside the folder <tt>constant/polyMesh</tt>. The latest official documentation on how to use <tt>blockMesh</tt> can be found on the OpenFOAM User Guide and online at the OpenFOAM Foundation website at this page: [http://www.openfoam.org/docs/user/blockMesh.php 5.3 blockMesh]
  
2. the vertex numbering in this file is consistent with that of the vertices in the blockMeshDict
+
{{VersionInfo}} {{version1.0}} {{version1.1}} {{version1.2}} {{version1.3}} {{version1.4}} {{version1.5}} {{version1.6}} {{version1.7}} {{version2.0}} {{version2.1}} {{version2.2}} {{version2.3}} {{version1.4-dev}} {{version1.5-dev}} {{version1.6-ext}} {{version3.0-ext}}
  
3. visualize in javaview or with 'objToVTK blockTopology.obj blockTopology.vtk' in Paraview.
+
Feel free to contribute to this page!
<div id="aflknwerkamfs" style="overflow:auto;height:2px;">[http://guccireplica.web-log.nl/ replica gucci designer handbag] [http://weblogs.bnn.nl/roxysmfas/ roxy school bag] [http://weblogs.bnn.nl/roxybtowv/ roxy beach bag] [http://weblogs.bnn.nl/roxybchhnz/ roxy book bag] [http://weblogs.bnn.nl/roxytcehe/ roxy tote bag] [http://weblogs.bnn.nl/roxymxqnra/ roxy messenger bag] [http://weblogs.bnn.nl/roxybtohjx/ roxy bag] [http://weblogs.bnn.nl/stoneufygh/ stone mountain hand bag] [http://weblogs.bnn.nl/stonecbcm/ stone mountain bag] [http://weblogs.bnn.nl/sakdikjc/ sak diaper bag] [http://weblogs.bnn.nl/sakbazug/ sak bag] [http://weblogs.bnn.nl/bagdiyupa/ bag diaper sak stork] [http://weblogs.bnn.nl/tignaeyq/ tignanello bag] [http://weblogs.bnn.nl/baghitiefv/ bag hilfiger tommy] [http://weblogs.bnn.nl/bagdibvdpz/ bag diaper hilfiger tommy] [http://weblogs.bnn.nl/beadgcntny/ bead girl bag] [http://weblogs.bnn.nl/organwhenj/ organza bag with bead] [http://weblogs.bnn.nl/beanbcwjdt/ bean bag bead] [http://weblogs.bnn.nl/beadbhfksg/ bead bag] [http://weblogs.bnn.nl/bagbrmbdwq/ bag brocade diaper] [http://weblogs.bnn.nl/leathctva/ leather shooting bag] [http://weblogs.bnn.nl/bagjafdptb/ bag jacket leather pants] [http://weblogs.bnn.nl/cheapjlz/ cheap leather bag] [http://weblogs.bnn.nl/manlemra/ man leather carrying bag] [http://weblogs.bnn.nl/bagleosk/ bag leather weekender] [http://weblogs.bnn.nl/indiayilvf/ indian bag leather] [http://weblogs.bnn.nl/leathuds/ leather bag oem] [http://weblogs.bnn.nl/bagcorwn/ bag colored leather wholesale] [http://weblogs.bnn.nl/acceswxs/ accessory bag clip golf leather] [http://weblogs.bnn.nl/toolemhuwm/ tooled leather bag] [http://weblogs.bnn.nl/bagbenyqyt/ bag belt custom leather pouch] [http://weblogs.bnn.nl/bagleteyt/ bag leather portfolio] [http://weblogs.bnn.nl/womenkypg/ womens leather laptop bag] [http://weblogs.bnn.nl/leathbaj/ leather healthy back bag] [http://weblogs.bnn.nl/leathlgr/ leather shopping bag] [http://weblogs.bnn.nl/pinklqte/ pink leather bag] [http://weblogs.bnn.nl/leatheencb/ leather courier bag] [http://weblogs.bnn.nl/blacksldl/ black leather tote bag] [http://weblogs.bnn.nl/baglebzwas/ bag leather possibles] [http://weblogs.bnn.nl/baglefbkhj/ bag leather marrakesh] [http://weblogs.bnn.nl/leathllp/ leather horse saddle bag] [http://weblogs.bnn.nl/fashiyhpqj/ fashion leather bag] [http://weblogs.bnn.nl/bagcorzl/ bag connecting handle leather making saddle together] [http://weblogs.bnn.nl/canvaolqmd/ canvas leather messenger bag] [http://weblogs.bnn.nl/leathwhh/ leather nail pouch leather tool bag] [http://weblogs.bnn.nl/fendixyvd/ fendi leather bag] [http://weblogs.bnn.nl/redlefxyaw/ red leather bag] [http://weblogs.bnn.nl/vintaazjka/ vintage leather bag] [http://weblogs.bnn.nl/leathvulm/ leather mail bag] [http://weblogs.bnn.nl/leathegsui/ leather school bag] [http://weblogs.bnn.nl/leathjzof/ leather clutch bag] [http://weblogs.bnn.nl/leathxchdc/ leather shaving bag] [http://weblogs.bnn.nl/leathpsxls/ leather briefcase bag] [http://weblogs.bnn.nl/explocqk/ explorer leather bag] [http://weblogs.bnn.nl/leathqzqh/ leather windshield bag] [http://weblogs.bnn.nl/leathzhy/ leather messenger bag laptop] [http://weblogs.bnn.nl/leathklg/ leather waist bag] [http://weblogs.bnn.nl/baglechkri/ bag leather motorcycle tool] [http://weblogs.bnn.nl/ladylwgq/ lady leather bag] [http://weblogs.bnn.nl/leathiijnl/ leather carry on bag] [http://weblogs.bnn.nl/leathhyk/ leather carpet bag] [http://weblogs.bnn.nl/blacklfx/ black leather bag] [http://weblogs.bnn.nl/106anjbdre/ 106 angle bag bolt leather saddle wide] [http://weblogs.bnn.nl/westehzv/ western leather saddle bag] [http://weblogs.bnn.nl/custoprxq/ custom leather bag] [http://weblogs.bnn.nl/leathdcpo/ leather cosmetic bag] [http://weblogs.bnn.nl/browncqfyo/ brown leather messenger bag] [http://weblogs.bnn.nl/womangxav/ woman leather bag] [http://weblogs.bnn.nl/bagleaoglq/ bag leather man travel] [http://weblogs.bnn.nl/italiwhc/ italian leather bag and man] [http://weblogs.bnn.nl/leathzgalx/ leather purse bag] [http://weblogs.bnn.nl/handmmftmp/ handmade leather bag] [http://weblogs.bnn.nl/leathxll/ leather business bag] [http://weblogs.bnn.nl/pradaqlbe/ prada leather bag] [http://weblogs.bnn.nl/manleegnqv/ man leather shoulder bag] [http://weblogs.bnn.nl/leathzqu/ leather gym bag] [http://weblogs.bnn.nl/bagcazus/ bag canada ebay leather root] [http://weblogs.bnn.nl/leathcvpke/ leather flight bag] [http://weblogs.bnn.nl/browndmluq/ brown leather bag] [http://weblogs.bnn.nl/bagbrhseqi/ bag brighton handbag leather] [http://weblogs.bnn.nl/leathxrjuw/ leather toiletry bag] [http://weblogs.bnn.nl/italigsb/ italian leather bag] [http://weblogs.bnn.nl/baggowzig/ bag goods lancel leather luggage] [http://weblogs.bnn.nl/gucciwrm/ gucci leather bag] [http://weblogs.bnn.nl/custobaiw/ custom made leather bag] [http://weblogs.bnn.nl/leathmjmr/ leather motorcycle saddle bag] [http://weblogs.bnn.nl/leathdiy/ leather camera bag] [http://weblogs.bnn.nl/leathipk/ leather bag manufacturer] [http://weblogs.bnn.nl/leathvpbnb/ leather belt bag] [http://weblogs.bnn.nl/leathtxkqw/ leather sissy bar bag] [http://weblogs.bnn.nl/coacheey/ coach leather bag] [http://weblogs.bnn.nl/whiteinn/ white leather bag] [http://weblogs.bnn.nl/leathgcx/ leather bean bag chair] [http://weblogs.bnn.nl/leathjkvuh/ leather weekend bag] [http://weblogs.bnn.nl/leathbwo/ leather overnight bag] [http://weblogs.bnn.nl/leathyxg/ leather book bag] [http://weblogs.bnn.nl/leathiyknp/ leather garment bag] [http://weblogs.bnn.nl/desigeyfpw/ designer leather bag] [http://weblogs.bnn.nl/wholeuxpb/ wholesale leather bag] [http://weblogs.bnn.nl/leathwbzc/ leather hobo bag] [http://weblogs.bnn.nl/greatghe/ great american leather bag] [http://weblogs.bnn.nl/leathdkvr/ leather duffel bag] [http://weblogs.bnn.nl/leathdbjj/ leather sling bag] [http://weblogs.bnn.nl/leathwbhha/ leather duffle bag] [http://weblogs.bnn.nl/leathfktq/ leather computer bag] [http://weblogs.bnn.nl/leathznex/ leather doctor bag] [http://weblogs.bnn.nl/manlemmme/ man leather messenger bag] [http://weblogs.bnn.nl/leathuobnw/ leather saddle bag] [http://weblogs.bnn.nl/leathhdbn/ leather shoulder bag] [http://weblogs.bnn.nl/leathttx/ leather tool bag] [http://weblogs.bnn.nl/leatharti/ leather golf bag] [http://weblogs.bnn.nl/leathupms/ leather laptop bag] [http://weblogs.bnn.nl/leathvdmke/ leather motorcycle bag] [http://weblogs.bnn.nl/manlelxmn/ man leather bag] [http://weblogs.bnn.nl/leathbafej/ leather travel bag] [http://weblogs.bnn.nl/leathecxqu/ leather bean bag] [http://weblogs.bnn.nl/leathvkuxh/ leather tote bag] [http://weblogs.bnn.nl/leathahgc/ leather diaper bag] [http://weblogs.bnn.nl/leathzrqj/ leather messenger bag] [http://weblogs.bnn.nl/leathwit/ leather bag] [http://weblogs.bnn.nl/leathxcf/ leather like bag] [http://weblogs.bnn.nl/licenmrf/ license plate bag] [http://weblogs.bnn.nl/bagbebanx/ bag bed in linen] [http://weblogs.bnn.nl/bagliiczaw/ bag linen] [http://weblogs.bnn.nl/nylonevws/ nylon ditty bag] [http://weblogs.bnn.nl/nylonwsqoq/ nylon laptop bag] [http://weblogs.bnn.nl/nylonmdxlt/ nylon mesh beach bag] [http://weblogs.bnn.nl/nylonmic/ nylon beach bag] [http://weblogs.bnn.nl/nylonixuol/ nylon duffel bag] [http://weblogs.bnn.nl/nylonbfwlv/ nylon mesh laundry bag] [http://weblogs.bnn.nl/nylonizbq/ nylon lunch bag] [http://weblogs.bnn.nl/nylonxsqar/ nylon duffle bag] [http://weblogs.bnn.nl/pradauqp/ prada nylon bag] [http://weblogs.bnn.nl/nylonqiu/ nylon messenger bag] [http://weblogs.bnn.nl/nylonrxhx/ nylon mesh bag] [http://weblogs.bnn.nl/pradalbyic/ prada nylon messenger bag] [http://weblogs.bnn.nl/nylontiuen/ nylon laundry bag] [http://weblogs.bnn.nl/nylonrbwpj/ nylon garment bag] [http://weblogs.bnn.nl/polynkkq/ poly nylon bag] [http://weblogs.bnn.nl/nylonrzhu/ nylon drawstring bag] [http://weblogs.bnn.nl/nylonkfs/ nylon tote bag] [http://weblogs.bnn.nl/nylonmpltr/ nylon bag] [http://weblogs.bnn.nl/bagfagwa/ bag fabric quilted tote] [http://weblogs.bnn.nl/bagdinndei/ bag diaper quilted wholesale] [http://weblogs.bnn.nl/bagjaizrw/ bag jacobs marc quilted stam] [http://weblogs.bnn.nl/baggaoqfkn/ bag garment quilted] [http://weblogs.bnn.nl/bagfrlnzdq/ bag free pattern quilted] [http://weblogs.bnn.nl/bagblmuajw/ bag black chanel huge quilted tote] [http://weblogs.bnn.nl/bagqunjolt/ bag quilted wholesale] [http://weblogs.bnn.nl/bagdugnaiw/ bag duffel quilted] [http://weblogs.bnn.nl/bagfrtde/ bag free pattern quilted tote] [http://weblogs.bnn.nl/bagduktwee/ bag duffle quilted] [http://weblogs.bnn.nl/bagpahufkx/ bag pattern quilted tote] [http://weblogs.bnn.nl/bagpajmv/ bag pattern quilted] [http://weblogs.bnn.nl/bagjadrjc/ bag jacobs marc quilted] [http://weblogs.bnn.nl/baglawaj/ bag layne quilted taylor] [http://weblogs.bnn.nl/bagchgmx/ bag chanel quilted] [http://weblogs.bnn.nl/bagdioysgp/ bag diaper quilted] [http://weblogs.bnn.nl/bagqujpd/ bag quilted tote] [http://weblogs.bnn.nl/bagquwyjcx/ bag quilted] [http://weblogs.bnn.nl/satinqtd/ satin gift bag] [http://weblogs.bnn.nl/satinwvg/ satin evening bag] [http://weblogs.bnn.nl/satingllnh/ satin favor bag] [http://weblogs.bnn.nl/silvemgeio/ silver satin clutch bag] [http://weblogs.bnn.nl/satinerbtl/ satin diaper bag] [http://weblogs.bnn.nl/satinwlnx/ satin bed in a bag] [http://weblogs.bnn.nl/satinukp/ satin bag] [http://weblogs.bnn.nl/largekrfn/ large straw bag] [http://weblogs.bnn.nl/largefsq/ large straw beach bag] [http://weblogs.bnn.nl/michaipjnn/ michael kors straw bag] [http://weblogs.bnn.nl/strawvizwi/ straw hand bag] [http://weblogs.bnn.nl/strawros/ straw bag wholesale] [http://weblogs.bnn.nl/coachkcbnn/ coach straw bag] [http://weblogs.bnn.nl/strawgwt/ straw tote bag] [http://weblogs.bnn.nl/strawyptg/ straw beach bag] [http://weblogs.bnn.nl/strawitzc/ straw bag] [http://weblogs.bnn.nl/tapesyelvd/ tapestry carpet bag] [http://weblogs.bnn.nl/bagtapgv/ bag tapestry wholesale] [http://weblogs.bnn.nl/totebgggm/ tote bag tapestry bag] [http://weblogs.bnn.nl/tapesshret/ tapestry tote bag] [http://weblogs.bnn.nl/tapesckl/ tapestry bag] </div>
+
 
 +
 
 +
==Synopsis==
 +
blockMesh [OPTIONS]
 +
 
 +
==Description==
 +
As the name implies, {{tt|blockMesh}} helps the user build the mesh with blocks. It relies on a single dictionary file {{tt|blockMeshDict}}, usually located at {{tt|constant/polyMesh/blockMeshDict}}. Inside that dictionary file should be defined:
 +
# all of the reference vertices of mesh;
 +
# all of the building blocks for the mesh, each block composed of:
 +
#* 8 vertices (repeat vertices, for collapsing edges);
 +
#* grading definition;
 +
#* cell count over each major axis;
 +
# optionally, one can assign special edge definitions for specific edges on blocks, such as arcs and splines;
 +
# assign faces of blocks to patch names;
 +
# and finally, be able to define special face merging, but associating/merging patches.
 +
 
 +
The following options can be used with {{tt|blockMesh}}:
 +
 
 +
'''-case''' ''DIR''
 +
:Execute the command on the case directory ''DIR''. If not provided, use the current directory.
 +
'''-dict''' ''FILE''
 +
:Read dictionary from specified location.
 +
'''-blockTopology'''
 +
: Write block edges and centres as {{tt|.obj}} files, for visual inspection elsewhere.
 +
'''-noFunctionObjects'''
 +
:Skip the execution of the [[functionObjects]]
 +
'''-region''' ''NAME''
 +
:Generate the mesh only for a specific region (e.g. for multi-region simulations).
 +
'''-help'''
 +
:Display the help and exit
 +
 
 +
 
 +
= Tips =
 +
On this chapter are listed links and direct tips on using <tt>snappyHexMesh</tt>.
 +
 
 +
== Using {{tt|blockMesh}} to export {{tt|blockMeshDict}} to {{tt|.obj}}  ==
 +
Before there were any nice graphical user interfaces for visually designing and inspecting the {{tt|blockMeshDict}} files, {{tt|blockMesh}} can interpret the dictionary file and export it to an {{tt|.obj}} file, which can be opened by any compatible 3D software, such as ParaView, JavaView and so on. There steps are as follows:
 +
 
 +
# Use the {{tt|-blockTopology}} argument to dump out a {{tt|blockTopology.obj}} file: <bash>blockMesh -blockTopology</bash>
 +
# The vertex numbering in this file is consistent with that of the vertices in the {{tt|blockMeshDict}} file.
 +
# The file {{tt|blockTopology.obj}} can be visualized in the following 3D software:
 +
#* Visualize directly with JavaView;
 +
#* Visualize directly in ParaView or convert the file to VTK if you prefer: <bash>objToVTK blockTopology.obj blockTopology.vtk</bash>
 +
#* Import in Blender.
 +
#* ''(fell free to add more...)''
 +
 
 +
 
 +
== Graphical User Interfaces for visualizing and designing {{tt|blockMeshDict}} ==
 +
 
 +
;{{tt|paraFoam -block}}: Introduced in OpenFOAM 2.0.0, this argument for the {{tt|paraFoam}} script requires that the respective OpenFOAM plugin is built for ParaView. This means that ParaView has to be built from source code or to use the Deb/RPM packages provided by the OpenFOAM Foundation.
 +
 
 +
;{{tt|blockMesh -blockTopology}}: Already explained in the section [[#Using blockMesh to export blockMeshDict to .obj|Using {{tt|blockMesh}} to export {{tt|blockMeshDict}} to {{tt|.obj}}]]
 +
 
 +
;{{tt|pyFoamDisplayBlockMesh.py}}: This Python script provides a way to visually inspect the current {{tt|blockMeshDict}} settings in 3D. It is part of [[Contrib/PyFoam|PyFoam]], which relies on VTK and Qt for the graphical interface. For more information, see section [[Contrib/PyFoam#pyFoamDisplayBlockMesh.py|pyFoamDisplayBlockMesh.py]] in the page [[Contrib/PyFoam]].
 +
 
 +
;SwiftBlock: This is also a Python script, but it's a powerful add-on for Blender, which provides an interactive way to design the {{tt|blockMeshDict}} directly in 3D. For more information, see the respective wiki page: [[Contrib/SwiftBlock]]
 +
 
 +
;HexBlocker: This is a dedicated application for visually editing in 3D the {{tt|blockMeshDict}} file. For more information, see this forum page: [http://www.cfd-online.com/Forums/openfoam-meshing/114773-hexblocker-gui-blockmeshdict-alpha-release.html HexBlocker a GUI for blockMeshDict, alpha release]
 +
 
 +
;FreeCAD: If you are looking for out of the box and cross platform solutions, there are attempts to import blockMeshDict topologies into FreeCAD. The other advantage is that it does not require the mesh, so if you have problems with mesh generation it help you to visualize in advance and debug the topology. An early version of the Python script can be found [https://gist.github.com/Foadsf/9ef9975d31bb01fa2bb88b6db7e0bda9 here]. To follow up on this project you may follow [https://forum.freecadweb.org/viewtopic.php?f=37&t=30426 this thread] in FreeCAD forum.
 +
 
 +
== Calculating the grading ==
 +
 
 +
There is [[Scripts/blockMesh_grading_calculation|this utility]] here on the Wiki and [http://www.cfd-online.com/Forums/openfoam-meshing-blockmesh/61785-blockmesh-grading-calculator.html this thread with a utility on the MessageBoard].
 +
 
 +
== Programmatically generating {{tt|blockMeshDict}} files ==
 +
Since the {{tt|blockMeshDict}} files are essentially text files, they can be generated by any means necessary. In this section is addressed the currently known documented ways of using scripts to generate {{tt|blockMeshDict}} files.
 +
 
 +
; {{tt|#codeStream}}: This is a feature that was introduced in OpenFOAM 2.0.0: [http://openfoam.org/release/2-0-0/run-time-control-code-compilation/ OpenFOAM® v2.0.0: Run-time Control] - Examples:
 +
:* The main tutorial provided in OpenFOAM for this feature in {{tt|blockMeshDict}}: {{tt|$FOAM_TUTORIALS/basic/potentialFoam/cylinder}}
 +
 
 +
;GNU m4, ''aka'' {{tt|blockMeshDict.m4}}:
 +
:* The [https://www.gnu.org/software/m4/m4.html GNU m4 (manual)] is a macro processor, which is essentially a simple programming language for calculating values and definitions to be written in the resulting file. In the following wiki page is a good example on this topic: [[HowTo blockMesh with m4]]. For more examples, run in the command line: <bash>find $FOAM_TUTORIALS -name "blockMeshDict.m4"</bash>
 +
:* A report by Erwin Adi Hartono for the [http://www.tfd.chalmers.se/~hani/kurser/OS_CFD_2010/ MSc/PhD course in CFD with OpenSource software, 2010] at Chalmers University of Technology:  [http://www.tfd.chalmers.se/~hani/kurser/OS_CFD_2010/erwinAdiHartono/erwinAdiHartonoReport.pdf Python Scripting and M4-Scripting for Automatization and Parameterization in OpenFOAM]
 +
 
 +
;MATLAB:
 +
:* BananaSplit: This is a MATLAB script for generating {{tt|blockMeshDict}} files. For more information, see this forum thread: [http://www.cfd-online.com/Forums/openfoam-meshing/108336-bananasplit-helper-openfoam-blockmesh.html BananaSplit helper for OpenFOAM blockMesh]
 +
 
 +
; Using Python scripts:
 +
:* Generating a pipe: [http://www.cfd-online.com/Forums/openfoam-meshing-blockmesh/82520-how-create-large-mesh.html#post285979 How to create large Mesh? - post #4]
 +
:* Python library {{tt|ofblockmeshdicthelper}} available at PyPi: [https://pypi.python.org/pypi/ofblockmeshdicthelper ofblockmeshdicthelper]
 +
:* Blog post on how to use {{tt|numpy}} for creating the {{tt|blockMeshDict}} file:  [http://dambreak.blogspot.pt/2013/06/generating-openfoam-mesh-from-point.html Generating an OpenFOAM mesh from a point cloud (x,y,z)]
 +
 
 +
<br>
 +
 
 +
== Generating double-graded meshes ==
 +
Although {{tt|blockMesh}} is considerably powerful as it is, the community has provided a modified version named {{tt|blockMeshDG}} for generating double graded meshes, in the sense of having an easy way to define symmetrical geometrical grading. For more information, see the dedicated wiki page: [[Contrib_blockMeshDG|blockMeshDG]]
 +
 
 +
 
 +
== Generating multi-graded meshes ==
 +
 
 +
A new feature was introduced into OpenFOAM 2.3.x, some weeks after the release of 2.3.1, which is the ability to do multi-grading. This was introduced in the commit [https://github.com/OpenFOAM/OpenFOAM-2.3.x/commit/cf370883644ec59782be375041b2434eb3e2c4ed cf370883644e] and is documented in the comment of the commit with the usage instructions. Quoting from said comment:
 +
<pre>
 +
    '''blockMesh: Add support for multi/sectional grading in a block'''
 +
 
 +
    Consider a block describing a channel with two opposite walls.
 +
    Currently in order to grade the mesh towards the walls and have a
 +
    uniform region in the centre the channel would need to be spit into 3
 +
    blocks.  With the new multi/sectional grading this can be achieved in a
 +
    single block e.g.
 +
 
 +
    blocks
 +
    (
 +
        hex (0 1 2 3 4 5 6 7) (20 60 20)
 +
        simpleGrading
 +
        (
 +
            1
 +
            ((0.2 0.3 4) (0.6 0.4 1) (0.2 0.3 0.25))
 +
            1
 +
        )
 +
    );
 +
 
 +
    In this example the block is divided uniformly in the x and z -directions
 +
    and split into three grading sections in the y-direction described by
 +
    three triples:  ((0.2 0.3 4) (0.6 0.4 1) (0.2 0.3 0.25)).  Each of the
 +
    grading sections is described by a triple consisting of the fraction of
 +
    the block, the fraction of the divisions and the grading ratio (size of
 +
    first division/size of last division).  Both the fraction of the block
 +
    and the fraction of the divisions are normalized automatically so they
 +
    can be specified scaled in anyway, e.g. as percentages:
 +
 
 +
    blocks
 +
    (
 +
        hex (0 1 2 3 4 5 6 7) (20 60 20)
 +
        simpleGrading
 +
        (
 +
            1
 +
            ((2 3 4) (6 4 1) (2 3 0.25))
 +
            1
 +
        )
 +
    );
 +
 
 +
    and they need not sum to 1 or 100.
 +
 
 +
    This is very new functionality and not well tested but backward
 +
    compatibility has been well tested so all existing blockMeshDicts should
 +
    parse correctly.
 +
</pre>
 +
 
 +
If you want to use this feature in older versions of OpenFOAM, follow the instructions given on this forum post: [http://www.cfd-online.com/Forums/openfoam-meshing-blockmesh/70798-blockmesh-double-grading-5.html#post567551 blockMesh with double grading. - post #86]
 +
 
 +
== Generating meshes with smoothed mesh transitions ==
 +
Sometimes it's necessary to transition between different mesh formats, such as going from a cube-shaped block to a sphere-shaped block. This is where the {{tt|extBlockMesh}} add-on for {{tt|blockMesh}} comes in handy: [http://www.cfd-online.com/Forums/openfoam-meshing/132628-extend-blockmesh-smoothing-capability.html#post484113 Extend blockMesh with smoothing capability]
 +
 
 +
== Defining cellZones ==
 +
Blocks are assigned to cellZones (which can be used for example to apply fvOptions to a selected region) the name of the cellZone can be specified in the block definition between the vertex numbers and the number of cells in each direction. This information is then used to generate a "cellZones" file in the polyMesh folder:
 +
''hex (0 1 2 3 4 5 6 7) myCellZone (20 1 1) simpleGrading (1 1 1)''
 +
 
 +
 
 +
[[Category:Mesh generation utilities]]

Revision as of 11:28, 23 August 2018


1 Introduction

blockMesh is one of the most basic mesh generators in OpenFOAM. It relies on a single dictionary file blockMeshDict, usually placed inside the folder constant/polyMesh. The latest official documentation on how to use blockMesh can be found on the OpenFOAM User Guide and online at the OpenFOAM Foundation website at this page: 5.3 blockMesh

Valid versions: OF version 10.png OF version 11.png OF version 12.png OF version 13.png OF version 14.png OF version 15.png OF version 16.png OF version 17.png OF Version 20.png OF Version 21.png OF Version 22.png OF Version 23.png OF Version 14dev.png OF Version 15dev.png OF Version 16ext.png OF Version 30ext.png

Feel free to contribute to this page!


1.1 Synopsis

blockMesh [OPTIONS]

1.2 Description

As the name implies, blockMesh helps the user build the mesh with blocks. It relies on a single dictionary file blockMeshDict, usually located at constant/polyMesh/blockMeshDict. Inside that dictionary file should be defined:

  1. all of the reference vertices of mesh;
  2. all of the building blocks for the mesh, each block composed of:
    • 8 vertices (repeat vertices, for collapsing edges);
    • grading definition;
    • cell count over each major axis;
  3. optionally, one can assign special edge definitions for specific edges on blocks, such as arcs and splines;
  4. assign faces of blocks to patch names;
  5. and finally, be able to define special face merging, but associating/merging patches.

The following options can be used with blockMesh:

-case DIR

Execute the command on the case directory DIR. If not provided, use the current directory.

-dict FILE

Read dictionary from specified location.

-blockTopology

Write block edges and centres as .obj files, for visual inspection elsewhere.

-noFunctionObjects

Skip the execution of the functionObjects

-region NAME

Generate the mesh only for a specific region (e.g. for multi-region simulations).

-help

Display the help and exit


2 Tips

On this chapter are listed links and direct tips on using snappyHexMesh.

2.1 Using blockMesh to export blockMeshDict to .obj

Before there were any nice graphical user interfaces for visually designing and inspecting the blockMeshDict files, blockMesh can interpret the dictionary file and export it to an .obj file, which can be opened by any compatible 3D software, such as ParaView, JavaView and so on. There steps are as follows:

  1. Use the -blockTopology argument to dump out a blockTopology.obj file:
    blockMesh -blockTopology
  2. The vertex numbering in this file is consistent with that of the vertices in the blockMeshDict file.
  3. The file blockTopology.obj can be visualized in the following 3D software:
    • Visualize directly with JavaView;
    • Visualize directly in ParaView or convert the file to VTK if you prefer:
      objToVTK blockTopology.obj blockTopology.vtk
    • Import in Blender.
    • (fell free to add more...)


2.2 Graphical User Interfaces for visualizing and designing blockMeshDict

paraFoam -block
Introduced in OpenFOAM 2.0.0, this argument for the paraFoam script requires that the respective OpenFOAM plugin is built for ParaView. This means that ParaView has to be built from source code or to use the Deb/RPM packages provided by the OpenFOAM Foundation.
blockMesh -blockTopology
Already explained in the section Using blockMesh to export blockMeshDict to .obj
pyFoamDisplayBlockMesh.py
This Python script provides a way to visually inspect the current blockMeshDict settings in 3D. It is part of PyFoam, which relies on VTK and Qt for the graphical interface. For more information, see section pyFoamDisplayBlockMesh.py in the page Contrib/PyFoam.
SwiftBlock
This is also a Python script, but it's a powerful add-on for Blender, which provides an interactive way to design the blockMeshDict directly in 3D. For more information, see the respective wiki page: Contrib/SwiftBlock
HexBlocker
This is a dedicated application for visually editing in 3D the blockMeshDict file. For more information, see this forum page: HexBlocker a GUI for blockMeshDict, alpha release
FreeCAD
If you are looking for out of the box and cross platform solutions, there are attempts to import blockMeshDict topologies into FreeCAD. The other advantage is that it does not require the mesh, so if you have problems with mesh generation it help you to visualize in advance and debug the topology. An early version of the Python script can be found here. To follow up on this project you may follow this thread in FreeCAD forum.

2.3 Calculating the grading

There is this utility here on the Wiki and this thread with a utility on the MessageBoard.

2.4 Programmatically generating blockMeshDict files

Since the blockMeshDict files are essentially text files, they can be generated by any means necessary. In this section is addressed the currently known documented ways of using scripts to generate blockMeshDict files.

#codeStream
This is a feature that was introduced in OpenFOAM 2.0.0: OpenFOAM® v2.0.0: Run-time Control - Examples:
  • The main tutorial provided in OpenFOAM for this feature in blockMeshDict: $FOAM_TUTORIALS/basic/potentialFoam/cylinder
GNU m4, aka blockMeshDict.m4
MATLAB
Using Python scripts


2.5 Generating double-graded meshes

Although blockMesh is considerably powerful as it is, the community has provided a modified version named blockMeshDG for generating double graded meshes, in the sense of having an easy way to define symmetrical geometrical grading. For more information, see the dedicated wiki page: blockMeshDG


2.6 Generating multi-graded meshes

A new feature was introduced into OpenFOAM 2.3.x, some weeks after the release of 2.3.1, which is the ability to do multi-grading. This was introduced in the commit cf370883644e and is documented in the comment of the commit with the usage instructions. Quoting from said comment:

    '''blockMesh: Add support for multi/sectional grading in a block'''

    Consider a block describing a channel with two opposite walls.
    Currently in order to grade the mesh towards the walls and have a
    uniform region in the centre the channel would need to be spit into 3
    blocks.  With the new multi/sectional grading this can be achieved in a
    single block e.g.

    blocks
    (
        hex (0 1 2 3 4 5 6 7) (20 60 20)
        simpleGrading
        (
            1
            ((0.2 0.3 4) (0.6 0.4 1) (0.2 0.3 0.25))
            1
        )
    );

    In this example the block is divided uniformly in the x and z -directions
    and split into three grading sections in the y-direction described by
    three triples:  ((0.2 0.3 4) (0.6 0.4 1) (0.2 0.3 0.25)).  Each of the
    grading sections is described by a triple consisting of the fraction of
    the block, the fraction of the divisions and the grading ratio (size of
    first division/size of last division).  Both the fraction of the block
    and the fraction of the divisions are normalized automatically so they
    can be specified scaled in anyway, e.g. as percentages:

    blocks
    (
        hex (0 1 2 3 4 5 6 7) (20 60 20)
        simpleGrading
        (
            1
            ((2 3 4) (6 4 1) (2 3 0.25))
            1
        )
    );

    and they need not sum to 1 or 100.

    This is very new functionality and not well tested but backward
    compatibility has been well tested so all existing blockMeshDicts should
    parse correctly.

If you want to use this feature in older versions of OpenFOAM, follow the instructions given on this forum post: blockMesh with double grading. - post #86

2.7 Generating meshes with smoothed mesh transitions

Sometimes it's necessary to transition between different mesh formats, such as going from a cube-shaped block to a sphere-shaped block. This is where the extBlockMesh add-on for blockMesh comes in handy: Extend blockMesh with smoothing capability

2.8 Defining cellZones

Blocks are assigned to cellZones (which can be used for example to apply fvOptions to a selected region) the name of the cellZone can be specified in the block definition between the vertex numbers and the number of cells in each direction. This information is then used to generate a "cellZones" file in the polyMesh folder:

hex (0 1 2 3 4 5 6 7) myCellZone (20 1 1) simpleGrading (1 1 1)