SnappyHexMesh GUI Add-on for Blender Documentation

16
SnappyHexMesh GUI Add-on for Blender Documentation Release 0.9 Tuomo Keskitalo Jan 22, 2022

Transcript of SnappyHexMesh GUI Add-on for Blender Documentation

Page 1: SnappyHexMesh GUI Add-on for Blender Documentation

SnappyHexMesh GUI Add-on forBlender Documentation

Release 0.9

Tuomo Keskitalo

Jan 22, 2022

Page 2: SnappyHexMesh GUI Add-on for Blender Documentation
Page 3: SnappyHexMesh GUI Add-on for Blender Documentation

Contents:

1 SnappyHexMesh GUI Addon for Blender 11.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31.2 Current Status and Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31.3 Installation and Start-up . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31.4 Add-on visibility . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41.5 Quickstart . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41.6 Panels and Settings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41.7 Feedback . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91.8 Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91.9 FAQ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91.10 OpenFOAM Trade Mark Notice . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12

i

Page 4: SnappyHexMesh GUI Add-on for Blender Documentation

ii

Page 5: SnappyHexMesh GUI Add-on for Blender Documentation

1

Page 6: SnappyHexMesh GUI Add-on for Blender Documentation

SnappyHexMesh GUI Add-on for Blender Documentation, Release 0.9

CHAPTER 1

SnappyHexMesh GUI Addon for Blender

2 Chapter 1. SnappyHexMesh GUI Addon for Blender

Page 7: SnappyHexMesh GUI Add-on for Blender Documentation

SnappyHexMesh GUI Add-on for Blender Documentation, Release 0.9

1.1 Introduction

SnappyHexMesh is a volume mesh generation tool for OpenFOAM®, the open source CFD (computational fluiddynamics) toolbox. SnappyHexMesh GUI add-on for Blender (“the add-on” hereafter) is meant to aid OpenFOAMusers to use Blender as a CFD pre-processing tool. The aim is to

• Ease the workflow for updating, modifying and exporting 3D surface meshes to OpenFOAM.

• Allow definition of most common SnappyHexMesh settings via Blender GUI, to reduce need for manual writingof OpenFOAM dictionary definitions.

• Require minimal Blender skills. Geometry can be modelled in any 3D modelling / CAD program which exportsa surface mesh format that can be imported to Blender, such as STL or Wavefront OBJ. Add-on is operated viapanels in Blender’s GUI.

The add-on generates OpenFOAM dictionary files for the surface mesh objects in Blender. Dictionary creation isbased on string replacements using template files located in the add-on’s skel directory. The add-on is meant to workon latest LTS release of Blender and latest stable OpenFOAM Foundation version of OpenFOAM.

1.2 Current Status and Features

Currently implemented features include:

• Creation of basic OpenFOAM case structure, including export of dictionary files (most importantly snappy-HexMeshDict) and meshes as STL files

• Optional creation of definition file for hexahedral base volume mesh with a defined cell size (blockMeshDict)

• Calculation of cell count for block volume mesh

• Definition of Surface Refinement Levels for surface meshes

• Creation of Feature Edges definition file (surfaceFeaturesDict)

• Definition of Surface Layers per surface

• Calculation of minimum and maximum bounds and surface area for each mesh. These information are alsowritten to snappyHexMeshDict as comments.

• Creation of Face Zones and Cell Zones from surface meshes

• Specification of Refinement Regions (Volumes)

1.3 Installation and Start-up

• It is suggested to use newest version of Blender, download Blender here.

• Add-on code is available at https://github.com/tkeskita/snappyhexmesh_gui –> Code –> Download zip.

• Start Blender, go to “Edit” –> “Preferences” –> “Add-ons” –> “Install” –> open the add-on zip file.

• Activate the “SnappyHexMesh GUI” add-on in Preferences. Add-on is located in Object category of Blenderadd-ons.

• Click “Save Preferences” to autoload add-on every time Blender is started

1.1. Introduction 3

Page 8: SnappyHexMesh GUI Add-on for Blender Documentation

SnappyHexMesh GUI Add-on for Blender Documentation, Release 0.9

1.4 Add-on visibility

Add-on is visible in Blender’s 3D Viewport in Sidebar as a separate tab in Object Mode. To view the add-on panels,you must

• Select a mesh object (in 3D Viewport or in Outliner)

• View Sidebar (“View” –> “Toggle Sidebar” or press “N” key in 3D Viewport)

• Select “SnappyHexMesh GUI” tab in the Sidebar

1.5 Quickstart

• Create surface meshes in any suitable 3D modelling tool and export in STL/OBJ format

• Import meshes to Blender (“File” –> “Import”) or model geometry directly in Blender

• Adjust the add-on settings per object in Blender

• Save Blender file to an empty case folder

• Click “Export” button in the add-on to create OpenFOAM directories and files under case folder

After export from Blender, you should be able to run following OpenFOAM commands in case folder in order:

• blockMesh

• surfaceFeatures (for openfoam.org version of OpenFOAM) or surfaceFeatureExtract (for openfoam.com ver-sion)

• snappyHexMesh

• checkMesh

1.6 Panels and Settings

SnappyHexMesh GUI consists of three main Panels: SnappyHexMesh GUI (top panel), Object Settings (middle panel)and Export Summary (bottom panel). By default all panels are expanded.

4 Chapter 1. SnappyHexMesh GUI Addon for Blender

Page 9: SnappyHexMesh GUI Add-on for Blender Documentation

SnappyHexMesh GUI Add-on for Blender Documentation, Release 0.9

1.6. Panels and Settings 5

Page 10: SnappyHexMesh GUI Add-on for Blender Documentation

SnappyHexMesh GUI Add-on for Blender Documentation, Release 0.9

1.6.1 SnappyHexMesh GUI Panel

This panel contains overall settings and tool buttons. You can hover mouse cursor over fields to see tool tips for moreinformation.

• Options with CPU count and two toggle icons:

– CPUs specifies the number of cores for decomposeParDict (scotch decomposition method is the defaultfor decomposePar)

– Do Snapping Phase

– Do Layer Addition Phase

• Export Scale is an optional scaling factor for STL geometry files and convertToMeters in blockMeshDict.

• Fork defines the fork of OpenFOAM for compatibility of generated files. Currently it only defines whether toproduce surfaceFeaturesDict (for openfoam.org) or surfaceFeatureExtractDict (for openfoam.com).

• Export path defines path name where the add-on creates the OpenFOAM case files when the Export tool is run.The default value “//” means that the case folder is the same folder where Blender file is saved.

• Generate Block Mesh indicates that blockMeshDict is to be generated during export using Cell Length as ameasure for cubical cell sides.

• Cell Length is the target length for the block mesh cube side, which will be created after export by running theOpenFOAM command blockMesh.

• Max Non-Ortho is the volume mesh quality measure for maximum non-orthogonality for SnappyHexMesh.Note: A small value produces mesh that is good for the numerical solution of flow equations, and a high valueyields mesh that fits to surfaces better and allows better surface layer coverage (if layers are added).

• Add Location In Mesh Object will add an Empty object to Blender scene. The coordinates of this object isapplied to specify the Location In Mesh for snappyHexMesh. If this object does not exist, zero coordinates areused for Location In Mesh.

6 Chapter 1. SnappyHexMesh GUI Addon for Blender

Page 11: SnappyHexMesh GUI Add-on for Blender Documentation

SnappyHexMesh GUI Add-on for Blender Documentation, Release 0.9

• Apply LocRotScale For All is a convenience tool for Blender modellers, which resets the Location, Rotationand Scale properties of all mesh objects to zero values. It is not necessary to run this tool to get correct location,rotation and scaling of the mesh in export. It is safe to ignore this tool, unless you use special Blender modellingfeatures whose operation depends on object location, rotation and scale (e.g. Modifiers).

• Export tool creates and saves the OpenFOAM case files under Export path using the overall settings in thispanel and Object Settings for each mesh object included in the export.

• If ASCII STL icon on right of Export tool is enabled, the STL files are written in ASCII text format instead ofbinary STL format.

1.6.2 Object Settings Panel

This panel shows settings for the active (selected) mesh object.

The panel top part shows information about the object. These information are also added as comments in snappy-HexMeshDict upon export:

• Object row shows the name of the active object.

1.6. Panels and Settings 7

Page 12: SnappyHexMesh GUI Add-on for Blender Documentation

SnappyHexMesh GUI Add-on for Blender Documentation, Release 0.9

• Copy Settings to Objects tool copies the SnappyHexMesh GUI settings from the active object to all selectedmesh objects. This allows mass modification of SnappyHexMesh settings when dealing with numerous objects.

• Object Bounds [min] [max] shows the minimum and maximum coordinates of two box corners which span thevolume included by the mesh object (bounding box).

• Area shows the summed surface area of all faces included in the object. Warning: Includes mesh errors, likeoverlapping faces, if there are any.

Rest of the panel includes object settings:

• Include in Export check box is used to mark which mesh objects are to be included in export.

• Type specifies the OpenFOAM patch type for this object.

• Enable snapping check box marks inclusion/exclusion of this object for SnappyHexMesh snapping phase.

• Surface Refinement Levels, Min and Max specify the minimum and maximum level of cell refinements madenext to the surfaces of this object.

• Extract Feature Edges check box marks whether Feature Edges (sharp edges) are to be extracted into eMesh for-mat from this object (done by running the featureSurfaces OpenFOAM utility). If Feature Edges are extracted,then they are also assumed to be included for Feature Edge Snapping in SnappyHexMesh.

• Feature Edge Level defines a separate cell refinement level for Feature Edges.

• Surface Layers specifies the number of surface layers that are to be added to surfaces of this object. Addition ofsurface layers also requires that the Do Layer Addition Phase option icon at top is activated.

• Face Zone Type decides the type of face zones that are to be created for surface:

– none: No face zone or cell zone are to be created.

– internal: Face zone is created with internal faces (each face is shared by two cells)

– baffle: Face zone is created as baffles (overlapping unshared boundary faces).

– boundary: Face zone is created as boundaries (unshared boundary faces).

Note: Face zone name is same as object name.

• Cell Zone Type defines the type of cell zones in relation to surface mesh, which is assumed to define a manifoldsurface which closes a volume:

– none: No cell zone is to be created.

– inside: Inside of the closed volume is to be included in cell zone.

– outside: Outside of the closed volume is to be included in cell zone.

Note: Cell zone name is same as object name.

Note 2: Cell zones requires face zones to be created as well.

• Volume Refinement specifies that some cells are to be refined accordingly:

– none: No refinement.

– inside: Cells inside of the closed volume are to be refined.

– outside: Cells outside of the closed volume are to be refined.

• Volume Refinement Level shows the number of refinements for volume refinement.

8 Chapter 1. SnappyHexMesh GUI Addon for Blender

Page 13: SnappyHexMesh GUI Add-on for Blender Documentation

SnappyHexMesh GUI Add-on for Blender Documentation, Release 0.9

1.6.3 Export Summary Panel

This panel summarizes the overall properties of export.

• Global Bounds [min] [max] shows the minimum and maximum coordinates of the bounding box for all meshobjects included in the export.

• Block Mesh Count is an estimate for the number of cubic cells in Block Mesh which covers the Global Boundsusing cube side length specified in Cell Length parameter. Block Mesh will be created by running OpenFOAMcommand blockMesh.

• Objects included lists all the mesh objects in Blender file, which will be exported when Export tool is run.

1.7 Feedback

File bug report in github

1.8 Example

A vessel example is located in the add-on’s example folder called vessel.blend, which showcases some of the features.

1.9 FAQ

Q: Why Blender?

A: Mainly because of Blender’s GUI Python API, 3D Viewport and surface mesh modelling tools. Blender haspowerful tools for polygon surface modelling and modification, and is suitable also for precision modelling requiredby engineering/scientific applications, although the learning curve to take advantage of all features is steep.

Q: How do I learn Blender?

A: See links at https://openfoamwiki.net/index.php/Blender

1.7. Feedback 9

Page 14: SnappyHexMesh GUI Add-on for Blender Documentation

SnappyHexMesh GUI Add-on for Blender Documentation, Release 0.9

Fig. 1: Vessel geometry, wall, zone and refinement volumes in surface mesh format viewed in Blender

10 Chapter 1. SnappyHexMesh GUI Addon for Blender

Page 15: SnappyHexMesh GUI Add-on for Blender Documentation

SnappyHexMesh GUI Add-on for Blender Documentation, Release 0.9

Fig. 2: Resulting volume mesh from SnappyHexMesh viewed in Paraview

1.9. FAQ 11

Page 16: SnappyHexMesh GUI Add-on for Blender Documentation

SnappyHexMesh GUI Add-on for Blender Documentation, Release 0.9

1.10 OpenFOAM Trade Mark Notice

This offering is not approved or endorsed by OpenCFD Limited, producer and distributor of the OpenFOAM softwarevia www.openfoam.com, and owner of the OPENFOAM® and OpenCFD® trade marks.

12 Chapter 1. SnappyHexMesh GUI Addon for Blender