Contrib/SwiftBlock

From OpenFOAMWiki
< Contrib
Revision as of 15:11, 28 April 2012 by Wyldckat (Talk | contribs)

1 Introduction

This is a plug-in which turns Blender 3D into a graphical user interface for blockMesh. The file below contains the script as well as user guide on how to use it. For questions, problems, and similar, use the dedicated thread at the forum www.cfd-online.com: SwiftSnap and SwiftBlock, GUIs for OpenFOAM's meshers

This page also assumes that the reader will get familiar with Blender on his/her own.

The file that has this plug-in: Swiftblock.tar.gz

Compatible Blender versions: v2.5 and above.

The text below is an improved transcript of the document already inside the Swiftblock.tar.gz tarball. Feel free to contribute to both this page and to the plug-in as well!


2 Getting Started

Untar files into your Blender add-on directory. Then start up Blender.

In Blender's User Preferences, enable 'Community' addons, and locate SwiftBlock under the OpenFOAM category. Click to enable and return to 3D view.

Select an object which will represent your block structure. This could be the Blender default box. Under the object tab in the Properties window, you should now find an entry called SwiftBlock, expand it and click the button to enable SwiftBlock for the selected object.

The SwiftBlock entry will now expand.

Blender will also switch to Edit mode. You may at any time switch between Edit and Object mode by pressing Tab key while having the mouse pointer in the 3D view pane.

Buttons / settings:

Write
Generates and writes out the blockMeshDict.
Convert to Meters
This number converts Blender spatial dimension to meters in the written files. If you want 1 Blender unit to represent 1 mm, set this value to 0.001.
Resolution
This is the desired resolution you wish for the generated block mesh. As many edges usually are inter-dependent, a mean resolution is sought for.
Set edges
When clicked, type in the name the object from which edges will be fetched. If an edge in your block structure has both vertices co-located with vertices from the typed object, SwiftBlock will find out the closest path in the mesh of the object, and use this path as a polyLine in the blockMeshDict. By this way, you can fit your block structure to more general geometries. Be aware though, that SwiftBlock may find unexpected paths, and sometimes you might need to do some cutting in the Geometry object and/or add straight lines to it. Also note that blockMesh does not currently allow the user to specify the shape of surfaces. This implies some limits on which shapes that could be meshed. Sometimes, the user may circumvent it by dividing the block structure into more blocks.
Patch name
In Edit Mode, selected faces will be marked as a patch with individual settings. Patches are internally tracked using Blender's materials, where each material represents a unique patch. At save-out, the object (a copy of it) is split by material, and each patch/material is saved as an STL file.
Defined patches appear at the bottom of the Patch settings box. Click the color box if a different color is wanted. Click the text to select faces belonging to the patch
Patch type
When setting at patch, you may define it's type here.
Set name
Sets the selected faces according to the name and type given above.

Now use your Blender skills to create your block structure. Be aware that Blender may sometimes drop internal edges in your block structure (after all, it is a surface modelling tool). Recreate edges by selecting two vertices and press F.

2.1 General notes

SwiftBlock does not support:

  • Creation of wedges, only strictly hexahedral blocks are handled
  • Edge grading
  • Other types of edge definitions except polyLine
  • More complete description of patches than name and type

If your block structure fails, for instance finding more or less blocks than expected, there are some help files generated:

  • log.swiftblock will give you some more detailed output of the block detection.
  • The facesFound.obj file can be opened in ParaView and shows all the quad-faces that were found (the algorithm first finds loops of 4 connected vertices, then using these 'faces' it finds hexahedral blocks consisting of 6 such 'faces'). As of OpenFOAM 2.0.0, you can use ParaView to open the openInParaview.blockMesh file. When placed in your $FOAM_CASE directory, it will use ParaView to graphically represent the content in the blockMeshDict file. This is of great value when debugging blockMeshDicts.
 Side note: From the command line, one can view the blockMeshDict in ParaView by running: paraFoam -block 
 But keep in mind that this requires that OpenFOAM's official plug-ins are properly compiled.


Some block structures are tricky. For instance, the classical way of block meshing a cylinder is to divide it into 5 blocks. One center and four outer blocks. However, a hexa-block finding algorithm will find 8 formal blocks in that structure! Except the 5 wanted/obvious, there is one flat block structure at either end of the cylinder, and one block is defined by the outermost egdes in the structure. The SwiftBlock code does several steps to detect and rule out such spurious blocks. As the code is rather new though, this filtering might cause some unexpected behaviour.

To co-locate a block vertex with a vertex of a Geometry object (to allow for non-straight block edges), use Blender's snapping magnet in vertex mode.

Be careful when creating your block structure not to have two co-located vertices. To avoid this SwiftBlock by default enables AutoMerge editing. You can also select your whole block structure and use the Remove Doubles tool to handle this (in Edit Mode).

It is convenient to set view mode as wireframe, as you then can see through faces. Using the Z key you can also switch to Viewport mode.

You do not have to create outer faces in your block structure. The block finding algorithm does not consider Blender's faces. Blender faces are only used for setting up patches, and if absent, blockMesh will push non-defined patches into defaultPatches.

When working with SwiftBlock, keep in mind to only use mesh objects as block structure and Geometry object. There is no support for NURBS.

3 Example

3.1 Meshing a cylinder

SwiftBlock Example Cylinder.jpg

The highlighted (yellow glow) object has the block structure of a typical cylinder mesh. Its corner vertices are co-located with the vertices of another Blender object, “Cylinder”, seens as a black wire frame. As “Set edges” is enabled and the name “Cylinder” was given, blockMeshDict will now contain entries for setting the block edges. Three patches are defined (defaultName has no users here), inlet, outlet, and wall. As the Viewport is in transparent Edit Mode, the patches's colors are not seen.


4 Final Notes

Happy swift blocking! Feel free to contribute to this page and improvements to the scripts!

For questions, problems, and similar, use the dedicated thread at the forum www.cfd-online.com: SwiftSnap and SwiftBlock, GUIs for OpenFOAM's meshers