This tutorial assumes that you've already read the
introduction and
2D
meshing tutorial for this external mesh series.
First, the base geometry consisting of a cuboid and a hemisphere will be
generated using
brick x 2 y 2 z 1
create sphere radius 0.5
move Volume 2 z 0.5 include_merged
In order to remove the part of the cuboid where it overlaps with the sphere,
a boolean subtraction can be performed with
subtract volume 2 from volume 1 keep_tool
Next, the sphere can be webcut in order to remove the upper portion of it;
this leaves behind the bottom hemisphere.
webcut volume 2 with plane from surface 9
delete volume 2
Next, overlapping surfaces are merged in order to consolidate common surface
entities using
Before commencing with the meshing of the geometry, a series of webcuts need
to be applied to the geometry. These will be used in order to guide the
mesher when constructing the discretization. In particular, cutting the
geometry into quadrants through the origin in the
xz- and
yz-planes will
make the polyhedron meshing scheme particularly well-suited for this
geometry. This webcutting can be achieved with
webcut volume all with plane xplane offset 0
webcut volume all with plane yplane offset 0
merge surface all
As noted previously, the polyhedron meshing scheme will be applied to all of
the geometric entities with
volume all scheme polyhedron
Next, the element sizes can again be approximated using the same approach as
detailed in the 2D example. Here we will consider the following material
properties:
Entity | Physics | VP | VS | RHO |
---|
Hemisphere | Acoustic | 1500 | N/A | 1000 |
Cuboid | Elastic | 4500 | 3000 | 2000 |
We'll again discretize the domain with approximately 2.0 elements per
wavelength, but for this simulation we'll use a source frequency of 20 kHz.
This results in the approximate element sizes
Δx of
Δxhem​​=20000[Hz]×2.01500[m/s]​=0.0375[m]​
and
Δxcub​​=20000[Hz]×2.03000[m/s]​=0.075[m].​
These element sizes can then be applied with
volume 3 5 7 9 size 0.0375
volume 1 4 6 8 size 0.075
volume 3 5 7 9 sizing function type skeleton min_size auto max_size 0.0375 max_gradient 1 min_num_layers_3d 1 min_num_layers_2d 1 min_num_layers_1d 1
volume 1 4 6 8 sizing function type skeleton min_size auto max_size 0.075 max_gradient 1 min_num_layers_3d 1 min_num_layers_2d 1 min_num_layers_1d 1
The polyhedron scheme requires all of the regions of the domain to be meshed
at once. Thus, we can simply run
The uniformity of the elements can be improved using mesh smoothing through
the use of
surface all smooth scheme edge length
surface smooth all
volume all smooth scheme equipotential
smooth volume all
Here's what the mesh looks like, along with a cut-away to reveal its internal
structure:
Finally, each of the individual parts in the hemisphere and the cuboid can be
added to a single block; this will become useful later when attempting to
assign material properties to discrete blocks within the domain. This can be
achieved using
block 1 add volume 3 5 7 9
block 2 add volume 1 4 6 8
As before, the mesh can be exported to Exodus using
set exodus netcdf4 on
export mesh "/path/to/file/sample_3D.e" dimension 3
Similar to the 2D example, here's a complete list of the journal commands
necessary for creating the mesh:
# Create the cuboid
brick x 2 y 2 z 1
# Create the sphere and shift it upwards
create sphere radius 0.5
move Volume 2 z 0.5 include_merged
# Subtract the sphere from the cuboid
subtract volume 2 from volume 1 keep_tool
# Remove the top part of the sphere
webcut volume 2 with plane from surface 9
delete volume 2
# Combine the bowl parts of the surfaces
merge surface all
# Make webcuts so that we can use the polyhedron scheme on everything
webcut volume all with plane xplane offset 0
webcut volume all with plane yplane offset 0
# Merge the webcut surfaces
merge surface all
# Use the polyhedron scheme to mesh everything
volume all scheme polyhedron
# Set the element sizes
volume 3 5 7 9 size 0.0375
volume 1 4 6 8 size 0.075
volume 3 5 7 9 sizing function type skeleton min_size auto max_size 0.0375 max_gradient 1 min_num_layers_3d 1 min_num_layers_2d 1 min_num_layers_1d 1
volume 1 4 6 8 sizing function type skeleton min_size auto max_size 0.075 max_gradient 1 min_num_layers_3d 1 min_num_layers_2d 1 min_num_layers_1d 1
# Mesh everything
mesh volume all
# Smooth the mesh a bit
surface all smooth scheme edge length
smooth surface all
volume all smooth scheme equipotential
smooth volume all
# Assign everything as two blocks
block 1 add volume 3 5 7 9
block 2 add volume 1 4 6 8
# Export to Exodus
set exodus netcdf4 on
export mesh "/path/to/file/sample_3D.e" dimension 3
Importing meshes in 3D is extremely similar to how it is performed in 2D. In
fact, we'll re-use many of the functions we defined in the previous example
for the 3D mesh.