[Gmsh] Strange meshing behaviour

Peter Johnston p.johnston at griffith.edu.au
Wed Mar 11 12:40:46 CET 2020


I have just observed some strange behaviour with my python script running gmsh. Attached is a cut down version of a larger script that used to work under gmsh 4.4.1. This script creates a 3D volume using OCC and contains multiple surfaces. When I mesh the surface (ie use the 2D meshing button on the gui) surface number three gives some strange results; so strange that I cannot create a volume mesh. I have also attached a picture of the mesh on surface 3, indicating the places where the mesh is misbehaving. I am currently using gmsh 4.5.4.

(Please note that I had to change the file extension to escape institutional spam filters. It is really a python script.)

Any insights would be much appreciated.

Thanks very much,


Associate Professor Peter Johnston (FAustMS, FIMA)
School of Environment and Science
Griffith University | Nathan | QLD 4111 | Technology (N44) Room 3.19
T +61 7 373 57748| F +61 7 373 57656 Email p.johnston at griffith.edu.au<mailto:c.l.brown at griffith.edu.au>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://onelab.info/pipermail/gmsh/attachments/20200311/dc28f8b3/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: gmsh-prob.png
Type: image/png
Size: 619923 bytes
Desc: gmsh-prob.png
URL: <http://onelab.info/pipermail/gmsh/attachments/20200311/dc28f8b3/attachment-0001.png>
-------------- next part --------------
import gmsh
import sys
import numpy as np

# set up parameters (eventually will read from file). 
# Data from streeter (1977?)
d_epi = 3.77
d_endo = 3.75
l_epi = 0.69
l_endo = 0.49
mu_base = 120.0/180.8*np.pi

# create unit spheres
radius = 1.0

# set CharacteristicLengthMax
char_l_max = 0.2
#char_l_max = 0.06

# my parameters to create the RV
lr_epi = 1.1
lr_endo = 1.05

# derived quantities
a_epi = d_epi*np.cosh(l_epi)
b_epi = d_epi*np.sinh(l_epi)
c_epi = d_epi*np.sinh(lr_epi)
a_endo = d_endo*np.cosh(l_endo)
b_endo = d_endo*np.sinh(l_endo)
c_endo = d_epi*np.sinh(lr_endo)
ra_endo = 0.5*(a_epi+a_endo)
rb_endo = 0.5*(b_epi+b_endo)

# start of main code

# to print errors
gmsh.option.setNumber("General.Terminal", 1)

# mesh parameters

# create spheres for left and right blood and blood+tissue regions
# create entire left ventricle
lv_bl = gmsh.model.occ.addSphere(0,0,0, radius, -1, np.pi/2-mu_base,
                                   np.pi/2, 2*np.pi)

#create left ventricle blood region
lv_bl_tiss = gmsh.model.occ.addSphere(0,0,0, radius, -1, np.pi/2-1.1*mu_base,
                                   np.pi/2, 2*np.pi)

# create right ventricle (half ellipsoid)
rv_bl = gmsh.model.occ.addSphere(0,0,0, radius,-1, np.pi/2-mu_base,
                                   np.pi/2, np.pi)

# create right ventricle blood region
rv_bl_tiss = gmsh.model.occ.addSphere(0,0,0, radius,-1, np.pi/2-1.1*mu_base,
                                   np.pi/2, np.pi)

# get lv tissue region
lv_tiss, _ = gmsh.model.occ.cut([(3,lv_bl)],[(3,lv_bl_tiss)], -1, True, True)
print('lv_tiss = ',lv_tiss)
# get rv tissue region
rv_tiss, _  = gmsh.model.occ.cut([(3,rv_bl)],[(3,rv_bl_tiss)], -1, True, True)
print('rv_tiss = ',rv_tiss)
# get rv tissue region not in lv
rv_tiss_fin, _  = gmsh.model.occ.cut([rv_tiss],[lv_tiss], -1, True, False)
print('rv_tiss_fin = ',rv_tiss_fin)
# merge lv and rv tissue regions 
tissue, _  = gmsh.model.occ.fuse([lv_tiss],[rv_tiss_fin], -1, True, True)
## uncomment the following line to display the mesh

More information about the gmsh mailing list