Simple Hex-only (not pyramid mesh)
Hi,
I am tryin to generate a simple hex-only mesh (a cuboid with an embedded surface that I want to apply the "crack" plugin to). If I try to generate mesh of a simple box, it proceeds fine, namely
import gmsh
import sys
import numpy as np
import os
import pathlib
import meshio
gmsh.initialize(sys.argv)
gmsh.initialize(readConfigFiles=False)
gmsh.model.add("simple cuboid")
min_mesh_size = 0.1
max_mesh_size = 1.0
gmsh.option.set_number("Mesh.CharacteristicLengthMin", min_mesh_size)
gmsh.option.set_number("Mesh.CharacteristicLengthMax", max_mesh_size)
gmsh.option.setNumber("Mesh.RecombineAll", 1)
gmsh.option.setNumber("Mesh.RecombinationAlgorithm", 1)
gmsh.option.setNumber("General.NumThreads", 5)
gmsh.option.setNumber("Geometry.OCCBoundsUseStl", 1)
gmsh.option.setNumber("Mesh.SubdivisionAlgorithm", 3)
gmsh.option.setNumber("Mesh.Algorithm", 8)
L = 5.0
H = 15.0
thick = 1.0 # dim/20 just for check
c = 1.0
gmsh.model.occ.add_box(0, 0, 0, L, H, thick, tag=1)
gmsh.model.occ.synchronize()
gmsh.model.mesh.setTransfiniteAutomatic()
gmsh.model.mesh.generate(3)
gmsh.write("simple_cuboid.vtk")
gmsh.finalize()
gives a structured hex mesh as expected
However, when I try to embed a rectangular surface as an initial crack in the domain, it fails to generate a hex-only mesh, namely
import gmsh
import sys
import numpy as np
import os
import pathlib
import meshio
gmsh.initialize(sys.argv)
gmsh.initialize(readConfigFiles=False)
gmsh.model.add("simple cuboid")
min_mesh_size = 0.1
max_mesh_size = 1.0
gmsh.option.set_number("Mesh.CharacteristicLengthMin", min_mesh_size)
gmsh.option.set_number("Mesh.CharacteristicLengthMax", max_mesh_size)
gmsh.option.setNumber("Mesh.RecombineAll", 1)
gmsh.option.setNumber("Mesh.RecombinationAlgorithm", 1)
gmsh.option.setNumber("General.NumThreads", 5)
# gmsh.option.setNumber("Geometry.OCCBoundsUseStl", 1)
gmsh.option.setNumber("Mesh.SubdivisionAlgorithm", 3)
# gmsh.option.setNumber("Mesh.Algorithm", 6)
L = 5.0
H = 15.0
thick = 1.0 # dim/20 just for check
c = 1.0
gmsh.model.occ.add_box(0, 0, 0, L, H, thick, tag=1)
gmsh.model.occ.synchronize()
# cut a rectangle surface
p1 = gmsh.model.occ.add_point(0, H / 2.0, 0, tag=20)
p2 = gmsh.model.occ.add_point(c, H / 2.0, 0, tag=30)
p3 = gmsh.model.occ.add_point(c, H / 2.0, thick, tag=40)
p4 = gmsh.model.occ.add_point(0, H / 2.0, thick, tag=50)
l1 = gmsh.model.occ.add_line(p4, p3, tag=60)
l2 = gmsh.model.occ.add_line(p3, p2, tag=70)
l3 = gmsh.model.occ.add_line(p2, p1, tag=80)
l4 = gmsh.model.occ.add_line(p1, p4, tag=90)
gmsh.model.occ.synchronize()
line_loop = gmsh.model.occ.add_curve_loop([l1, l2, l3, l4], tag=100)
surf1 = gmsh.model.occ.add_plane_surface([line_loop], tag=110)
gmsh.model.occ.synchronize()
# fragment the rectangle surface
o, m = gmsh.model.occ.fragment([(3, 1)], [(2, surf1)])
gmsh.model.occ.synchronize()
gmsh.model.mesh.setTransfiniteAutomatic()
gmsh.model.mesh.generate(3)
# recombine all elements
# gmsh.model.mesh.recombine()
gmsh.write("simple_cuboid.vtk")
gmsh.finalize()
# get mesh statistics
import meshio
mesh = meshio.read("simple_cuboid.vtk")
print(mesh)
gives a mesh with pyramids instead of hexahedra as seen here.
Any clues what I'm doing wrong or how to make it work?
Thanks,
Edited by Bhavesh Shrimali