Generating the Mesh

To provide two-dimensional meshing, we embedded the open source Aquaveo XMS Mesher into ModelBuilder-2D. XMS Mesher is a full-feature tool for geometry discretization with features such as edge and line refinement, vertex and point refinement, and linear sizing functions. For this walkthrough, however, we only expose a global mesh size (constant). (For those interested, the full XMS feature set can be accessed through the modelbuilder operation view; the operation name is smtk::mesh::xms::GenerateMesh).

11. Add a RenderView

To start, we are going to add a second view to display the results of the meshing operation. There are several ways to do this; for this walkthrough we are going to create a separate layout. In the tab bar above the current RenderView, find and click the + button to create a second tab. A new tab labeled Layout #2 will be displayed, showing a Create View label and a vertical list of buttons. Click the Render View button, which is the first one in the list, which will display the geometry model.

_images/toolbutton-new-layout.png

In this new layout we are going to do two things: (i) reset the camera to be centered and scaled to our geometry, then (ii) hide the model. First, find the camera Reset button in the main toolbars and click on it, which will update the display so that you can see the geometric model centered in the view.

_images/toolbutton-camera-reset.png

Then right-click over the model and select the Hide` item in the context menu, leaving an empty view. You can also rename each tab by right-clicking over the Layout # label and selecting the Rename option. Use that to rename Layout #1 to Model and Layout #2 to Mesh.

_images/second-layout.png

12. Select the Mesher

Although XMS is the only mesher currently available in ModelBuilder-2D, you must still select it in the Analysis tab. In the Attribute Editor, click on the Analysis tab and find the selector next to the Mesher label, and set it to XMSMesher. (We could have done this any time after creating the project, of course.)

_images/mesher-selected.png

13. Set the Mesh Size

When you set the mesher, a new tab “Meshing Configuration” appears in the Attribute editor. Click on the Meshing Configuration` tab to see it has one field labeled Global Sizing Constraint (Relative). You can enter a number in the range (0.0, 1.0) to control the number of mesh elements that get created. Enter 0.25 and hit the <Enter> key. You should see the field’s background change from yellow to white, indicating that the value you entered is different than the default.

_images/meshsize-set.png

14. Generate the Mesh

With the global mesh size set to 0.25, go to the CMB2D menu and select the Generate Mesh item. In response, modelbuilder will input the project’s model resource to the XMS mesher, run the meshing operation, translate the meshing results into a new mesh resource and add that mesh resource to the project. When this is complete (should only take a few seconds), ModelBuilder-2D will display the mesh resource. Click the Camera Reset button to again center the view. To see the mesh elements, right-click over the object and in the context menu change the Representation from Surface to Surface With Edges.

_images/mesh-generated.png

15. Save the Project

With the mesh now generated and added to the project, let’s again write the project changes to your file system. Go to the CMB2D menu and select the Save Project item.