create a grid with a fracture in one of the sides
Hi there! I am using gmsh to create meshes for FEniCSx. I created a fracture in the middle of my domain (see picture) and this workflow works just fine. Because this is a symmetric domain and I want to speed up the solution time, I want to only do one quarter of the current domain (1st quadrant or upper right part). I tried just modifying the coords of the point but I get an error and also I am not sure how to place the fracture along the boundary.
This is part of my code with the fracture located in the middle of the domain
def Gmsh_model(name=None,width=None,height=None,ms=None,mf=None): gmsh.initialize() gdim = 2 if rank == 0: gmsh.initialize() gmsh.model.add(name) # model name
# BOUNDARY NODES
ll = gmsh.model.occ.addPoint(0,0,0,ms,1)
lr = gmsh.model.occ.addPoint(width,0,0,ms,2)
ur = gmsh.model.occ.addPoint(width,height,0,ms,3)
ul = gmsh.model.occ.addPoint(0,height,0,ms,4)
# BOUNDARY LINES
bt = gmsh.model.occ.addLine(ll,lr,1)
rt = gmsh.model.occ.addLine(lr,ur,2)
tp = gmsh.model.occ.addLine(ur,ul,3)
lt = gmsh.model.occ.addLine(ul,ll,4)
# BOUNDARY CURVE LOOP
bd = gmsh.model.occ.addCurveLoop([bt,rt,tp,lt],1)
# BOUNDARY SURFACE
s = gmsh.model.occ.addPlaneSurface([bd])
# FRACTURE GEOMETRY
fl = gmsh.model.occ.addPoint(width*0.50,height*0.40,0,mf,5) # Lower fracture node
fr = gmsh.model.occ.addPoint(width*0.50,height*0.60,0,mf,6) # Top fracture node
fe = gmsh.model.occ.addLine(fl,fr) # Define boundary line for fracture
#synchronize
gmsh.model.occ.synchronize()
gmsh.model.mesh.embed(1,[fe],2,s)
gmsh.model.mesh.embed(0,[fl,fr],2,s)
# We can then generate a 2D mesh
gmsh.model.mesh.generate(2)
gdim = 2 # Number of dimensions
# Physical tags
gmsh.model.setPhysicalName(gdim-1, 1, 'Base')
gmsh.model.addPhysicalGroup(gdim-1, [rt],tag=2)
gmsh.model.setPhysicalName(gdim-1, 2, 'Right')
gmsh.model.addPhysicalGroup(gdim-1, [tp],tag=3)
gmsh.model.setPhysicalName(gdim-1, 3, 'Top')
gmsh.model.addPhysicalGroup(gdim-1, [lt],tag=4)
gmsh.model.setPhysicalName(gdim-1, 4, 'Left')
gmsh.model.addPhysicalGroup(gdim-1, [fe],tag=5)
gmsh.model.addPhysicalGroup(gdim, [s],tag=10)
gmsh.model.setPhysicalName(gdim, 10, 'Omega')
gmsh.model.addPhysicalGroup(gdim-2, [ur],tag=20)
gmsh.model.setPhysicalName(gdim-2, 20, 'Point')
gmsh.plugin.setNumber('Crack','Dimension',1)
gmsh.plugin.setNumber('Crack','PhysicalGroup',5)
gmsh.plugin.setNumber('Crack','NewPhysicalGroup',6)
gmsh.plugin.run("Crack")
gmsh.model.setPhysicalName(gdim-1, 5, 'Fracture_minus') # fracture left side (slave)
gmsh.model.setPhysicalName(gdim-1, 6, 'Fracture_plus') # fracture right side (master)
gmsh.model.mesh.renumberNodes()
# synchronize
gmsh.model.geo.synchronize()
gmsh.option.setNumber("Mesh.Algorithm", 6)
gmsh.model.mesh.generate(gdim)
# extract node coordenates and node global connectivity
cell_types, cell_tags, cell_node_tags = gmsh.model.mesh.getElements(dim=2)
cell_tags = cell_tags[0]
cell_node_tags = cell_node_tags[0].reshape((len(cell_tags),3))
cell_node_tags -= 1
node_tags, coord, param_coords = gmsh.model.mesh.getNodes()
coord = coord.reshape((int(len(coord)/3),3))
node_slave,coord_slave = gmsh.model.mesh.getNodesForPhysicalGroup(1,5)
node_master,coord_master = gmsh.model.mesh.getNodesForPhysicalGroup(1,6)
coord_slave = coord_slave.reshape((int(len(coord_slave)/3),3))
coord_master = coord_master.reshape((int(len(coord_master)/3),3))
# Write mesh file
gmsh.write("Fracture_mesh.msh")
# gmsh.finalize()
Edited by Javier Guerrero