Cubit Mesh#

Geometry#

We construct the geometry by taking a horizontal cross-section of a 3D block. Alternatively, we could have constructed the geometry by building it up from points and curves like we did with Gmsh. Fig. 51 shows the geometry and variables names of the vertices and curves.

Geometry created in Cubit for generating the mesh.

Fig. 51 Geometry created in Cubit for generating the finite-element mesh. The names of the verties and curves match the ones we use in the Cubit journal files.#

Meshing using Journal Scripts#

We use Cubit journal files mesh_tri.jou and mesh_quad.jou to generate triangular and quadrilateral meshes, respectively. Both of these journal files make use of the geometry.jou, gradient.jou, and createbc.jou files for creating the geometry, setting the discretization size, and tagging boundary conditions, faults, and materials, respectively. We use the Cubit graphical user interface to play the Journal files.

Important

We use IDless journaling in CUBIT. This allows us to reference objects in a manner that should be independent of the version of CUBIT that is being used. In the journal files, the original command used is typically commented out, and the following command is the equivalent IDless command.

Note

Examine how we set the discretization size in Gmsh and Cubit. In both cases the discretization size increases at a geometric rate with distance from the fault. For this simple geometry, it required less than 10 lines of Python code in Gmsh and about the same number of lines in Cubit. In Gmsh the code is very general and remains the same even as the domain geometry becomes more complex, whereas in Cubit the number of commands increases with the complexity of the geometry.

Once you have run either the mesh_tri.jou or mesh_quad.jou journal file to construct the geometry and generate the mesh, you will have a corresponding Exodus-II file (mesh_tri.exo or mesh_quad.exo). These are NetCDF files, and they can be loaded into ParaView. This can be done by either running ParaView and loading the file, or using the script provided in the viz directory. For example, if ParaView is in your path, you can run the following command:

Listing 67 Start paraview and run the viz/plot_mesh.py Python script to view the mesh with triangular cells.#
paraview --script=viz/plot_mesh.py
Finite-element mesh with triangular cells generated by Cubit.

Fig. 52 Finite-element mesh with triangular cells generated by Cubit.#

To load the mesh with quadrilateral cells, open the Python Shell in ParaView and set the EXODUS_FILE variable, and then run the viz/plot_mesh.py Python script. See ParaView Python Scripts for more information about running ParaView Python scripts.

Listing 68 Load a different Exodus file generated by Cubit by setting the EXODUS_FILE variable in the ParaView Python Shell.#
EXODUS_FILE = "mesh_quad.exo"
Finite-element mesh with quadrilateral cells generated by Cubit.

Fig. 53 Finite-element mesh with quadrilateral cells generated by Cubit.#