Difference between revisions of "Contrib/SwiftSnap"

From OpenFOAMWiki
(restructured Intro, based on the SwiftBlock page.)
(Formatted transcript complete!)
Line 11: Line 11:
  
 
<br>
 
<br>
 +
= Getting Started =
 +
Untar files into your Blender add-on directory. Then start up Blender
 +
 +
In Blender's User Preferences, enable 'Community' add-ons, and locate <tt>SwiftSnap</tt> under the <tt>OpenFOAM</tt> category. Click to enable. Locate <tt>STL file export/import</tt> and enable. Return to 3D view.
 +
 +
Import / create your geometry in Blender. Keep your geometry in one single object. Use <tt>Ctrl-J</tt> to join objects
 +
 +
Select your geometry object. Under the object tab in the <tt>Properties</tt> window, you should now find an entry called <tt>SwiftSnap</tt>, expand it and click the button to enable <tt>SwiftSnap</tt> for the selected object.
 +
 +
The <tt>SwiftSnap</tt> entry will now expand.
 +
 +
Buttons / settings:
 +
;Write: Click this button last when finished. When enabled, all files (stl, eMesh, Dict) are created. Saving the state of Blender for later work is done using Blenders native save option. Note that in the save file dialogue you can click <tt>Distribute</tt>. When clicked, the <tt>triSurface</tt> directory will be placed in <tt>constant/</tt> and <tt>blockMeshDict</tt> (if enabled) in <tt>constant/polyMesh</tt>.
 +
 +
;Convert to Meters: This number converts Blender spatial dimension to meters in the written files. If you want 1 Blender unit to represent <tt>1 mm</tt>, set this value to <tt>0.001</tt>.
 +
 +
;Make base mesh: Click to auto-generate a <tt>blockMeshDict</tt> for letting <tt>blockMesh</tt> create a base mesh for <tt>snappyHexMesh</tt>. This feature uses the objects bounding box, which can be seen in <tt>Object Mode</tt> using <tt>Bounding Box</tt> as <tt>Viewport shading</tt>. When enabled, the base resolution (in meters) should be specified.
 +
 +
;Snap mesh / add layers: These two options enable / disable the corresponding settings in <tt>snappyHexMeshDict</tt>.
 +
 +
;Set <tt>locationInMesh</tt>: Sets the corresponding entry in <tt>snappyHexMeshDict</tt> to the coordinate of Blender's 3D cursor.
 +
 +
;Detect non-manifold: Blender has a function to detect non-manifold edges. It can be enabled here. Good for finding problems and/or features in meshes.
 +
 +
;Feature angle: For use with the button below.
 +
 +
;Detect features: Selects all edges in-between faces with an angle less than given above.
 +
 +
;Feature refinement level: Sets refinement level for edges. For use with the button below.
 +
 +
;Mark as level #: Marks selected edges as features to refine to the specified level. The collection of edges are fully determined by the user, but stem frequently from the selection generated with the <tt>Detect Features</tt> button. When edges are set, they will appear at the bottom of the Feature box, from there they can be selected and modified later. Note that it is important to mark edges as features, even if no extra resolution is wanted. Without feature lines defined, <tt>snappyHexMesh</tt> will not capture the ''sharpness'' of the edges.
 +
 +
;Unmark selected: Removes selected edges from the list of feature edges.
 +
 +
;Patch name: Here the user can specify a patch name, which is used when the below button is clicked.
 +
 +
;Min/max level: Specifies which refinement levels to have for this patch.
 +
 +
;Layers (optional): Specifies how many layers to create at this patch.
 +
 +
;Set patch: In <tt>Edit Mode</tt>, 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.<br> Defined patches are listed below. Click the color box if a different color is wanted. Click the text to select faces belonging to the patch.
 +
 +
;Refinement region: Refinement regions are defined as <tt>triSurfaceMesh</tt> in <tt>snappyHexMeshDict</tt>. Other Blender mesh objects can be used as such surfaces. Create them as separate objects (do not enable <tt>SwiftSnap</tt> for those objects), and return here and fill in their names. When a valid name is entered, the set button is enabled.
 +
 +
;Level: Sets the refinement level to be used inside/outide of the refinement region.
 +
 +
;Distance: Sets the distance from the surface, in which refinement to the level specified above is done. (<tt>snappyHexMesh</tt> allows for one surface to have several refinement levels at different distance. This is currently not supported by <tt>SwiftSnap</tt>.)
 +
 +
;Refine inside: If clicked, refinement will take place inside the surface.
 +
 +
;Set refinement region: When clicked the above given object will be used  as a refinement <tt>triSurface</tt> object in <tt>snappyHexMesh</tt> with the given settings. If the object is found, it will be added to a list below the button. Click list items to remove them.
 +
 +
== General notes ==
 +
<tt>SwiftSnap</tt> frequently switches the users selection and view mode. This is because different operations require different such settings. The user is also likely to jump between <tt>Edit Mode</tt> and <tt>Object Mode</tt> (<tt>Tab</tt> key). In <tt>Edit Mode</tt>, manipulation on the mesh can be performed, while in <tt>Object Mode</tt>, manipulation on the object as a whole can be performed. In <tt>Edit Mode</tt>, the user have good use of switching between <tt>Vertex/Edge/Face</tt> selection mode (<tt>Ctrl-Tab</tt>). For instance, use edge selection to modify feature edges, or use face selection to specify patches.
 +
 +
Blender has some functions for making clever selections of mesh components. Refer to [http://wiki.blender.org/index.php/Doc:2.6/Manual/Modeling/Meshes/Selecting Blender's wiki about selection] for how to work efficiently. For example:
 +
;Ctrl+NumPadPlus: select neighbours
 +
;Ctrl+Alt+Shift+F: select based on angle
 +
;Alt+RMB: edge loops
 +
 +
Blender cannot currently read typical CAD formats, but the user frequently has to import geometries to Blender as STL files. The user typically has to use some kind of CAD tool to strip complex drawings from unnecessary details before importing the geometry in Blender.
 +
 +
= Example =
 +
== T-pipe bend ==
 +
 +
[[File:SwiftSnap Example T-pipe bend.jpg|thumb|450px|center]]
 +
 +
A T-pipe bend modelled. The grey <tt>Cylinder</tt> is a refinement region. Yellow color is walls, which will have two layers of boundary cells. Red color is inlet which will be refined two times from the base mesh. The small pipe have an inlet called <tt>stream</tt> colored in blue. Outlet patch (not seen) is green. Not that due to <tt>snappyHexMesh</tt>'s patch naming convention and Blenders STL exported, final patch names will be like <tt>inlet_exportedfromblender</tt> a simple sed-script ran after <tt>snappyHexMesh</tt> would solve that problem.
 +
 +
= Final Notes =
 +
Feel free to contribute to this page and improvements to the scripts!
 +
 +
For questions, problems, and similar, use the dedicated thread at the forum [http://www.cfd-online.com www.cfd-online.com]: [http://www.cfd-online.com/Forums/openfoam-meshing/100604-swiftsnap-swiftblock-guis-openfoams-meshers.html SwiftSnap and SwiftBlock, GUIs for OpenFOAM's meshers]

Revision as of 16:59, 28 April 2012

1 Introduction

This is a plug-in which turns Blender 3D into a graphical user interface for snappyHexMesh.

The file that has this plug-in, as well as user guide on how to use it
Swiftsnap.tar.gz‎
Compatible Blender versions
v2.5 and above.

The text below is an improved transcript of the document already inside the Swiftsnap.tar.gz‎ tarball. These instructions also assume that the reader will get familiar with Blender on his/her own. Feel free to contribute to both this page and to the plug-in as well!

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


2 Getting Started

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

In Blender's User Preferences, enable 'Community' add-ons, and locate SwiftSnap under the OpenFOAM category. Click to enable. Locate STL file export/import and enable. Return to 3D view.

Import / create your geometry in Blender. Keep your geometry in one single object. Use Ctrl-J to join objects

Select your geometry object. Under the object tab in the Properties window, you should now find an entry called SwiftSnap, expand it and click the button to enable SwiftSnap for the selected object.

The SwiftSnap entry will now expand.

Buttons / settings:

Write
Click this button last when finished. When enabled, all files (stl, eMesh, Dict) are created. Saving the state of Blender for later work is done using Blenders native save option. Note that in the save file dialogue you can click Distribute. When clicked, the triSurface directory will be placed in constant/ and blockMeshDict (if enabled) in constant/polyMesh.
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.
Make base mesh
Click to auto-generate a blockMeshDict for letting blockMesh create a base mesh for snappyHexMesh. This feature uses the objects bounding box, which can be seen in Object Mode using Bounding Box as Viewport shading. When enabled, the base resolution (in meters) should be specified.
Snap mesh / add layers
These two options enable / disable the corresponding settings in snappyHexMeshDict.
Set locationInMesh
Sets the corresponding entry in snappyHexMeshDict to the coordinate of Blender's 3D cursor.
Detect non-manifold
Blender has a function to detect non-manifold edges. It can be enabled here. Good for finding problems and/or features in meshes.
Feature angle
For use with the button below.
Detect features
Selects all edges in-between faces with an angle less than given above.
Feature refinement level
Sets refinement level for edges. For use with the button below.
Mark as level #
Marks selected edges as features to refine to the specified level. The collection of edges are fully determined by the user, but stem frequently from the selection generated with the Detect Features button. When edges are set, they will appear at the bottom of the Feature box, from there they can be selected and modified later. Note that it is important to mark edges as features, even if no extra resolution is wanted. Without feature lines defined, snappyHexMesh will not capture the sharpness of the edges.
Unmark selected
Removes selected edges from the list of feature edges.
Patch name
Here the user can specify a patch name, which is used when the below button is clicked.
Min/max level
Specifies which refinement levels to have for this patch.
Layers (optional)
Specifies how many layers to create at this patch.
Set patch
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 are listed below. Click the color box if a different color is wanted. Click the text to select faces belonging to the patch.
Refinement region
Refinement regions are defined as triSurfaceMesh in snappyHexMeshDict. Other Blender mesh objects can be used as such surfaces. Create them as separate objects (do not enable SwiftSnap for those objects), and return here and fill in their names. When a valid name is entered, the set button is enabled.
Level
Sets the refinement level to be used inside/outide of the refinement region.
Distance
Sets the distance from the surface, in which refinement to the level specified above is done. (snappyHexMesh allows for one surface to have several refinement levels at different distance. This is currently not supported by SwiftSnap.)
Refine inside
If clicked, refinement will take place inside the surface.
Set refinement region
When clicked the above given object will be used as a refinement triSurface object in snappyHexMesh with the given settings. If the object is found, it will be added to a list below the button. Click list items to remove them.

2.1 General notes

SwiftSnap frequently switches the users selection and view mode. This is because different operations require different such settings. The user is also likely to jump between Edit Mode and Object Mode (Tab key). In Edit Mode, manipulation on the mesh can be performed, while in Object Mode, manipulation on the object as a whole can be performed. In Edit Mode, the user have good use of switching between Vertex/Edge/Face selection mode (Ctrl-Tab). For instance, use edge selection to modify feature edges, or use face selection to specify patches.

Blender has some functions for making clever selections of mesh components. Refer to Blender's wiki about selection for how to work efficiently. For example:

Ctrl+NumPadPlus
select neighbours
Ctrl+Alt+Shift+F
select based on angle
Alt+RMB
edge loops

Blender cannot currently read typical CAD formats, but the user frequently has to import geometries to Blender as STL files. The user typically has to use some kind of CAD tool to strip complex drawings from unnecessary details before importing the geometry in Blender.

3 Example

3.1 T-pipe bend

SwiftSnap Example T-pipe bend.jpg

A T-pipe bend modelled. The grey Cylinder is a refinement region. Yellow color is walls, which will have two layers of boundary cells. Red color is inlet which will be refined two times from the base mesh. The small pipe have an inlet called stream colored in blue. Outlet patch (not seen) is green. Not that due to snappyHexMesh's patch naming convention and Blenders STL exported, final patch names will be like inlet_exportedfromblender a simple sed-script ran after snappyHexMesh would solve that problem.

4 Final Notes

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