from mpi4py import MPI
import numpy as np
import ufl
import gmsh
import dolfinx
from mpi4py import MPI
from dolfinx.io import (VTXWriter, distribute_entity_data, gmshio)
from dolfinx.fem.petsc import LinearProblem
from basix.ufl import element, mixed_element
from dolfinx import default_scalar_type, plot
from dolfinx.fem import (functionspace, dirichletbc)
# Physical parameters
D = 1
Ht = 1.62 # height till top
Hb = 1.9 # height till bottom
L = 6
H = Ht+Hb
c_x = 0
c_y = 0
r = D/2
# Numerical parameters
resolution = 0.1 # Target characteristic length factor #0.05
# EPS = np.finfo(float).eps # Machine epsilon for float
model_rank = 0
mesh_comm = MPI.COMM_WORLD
gdim=2
# Create gmsh geometry
gmsh.initialize()
# Create channel
rectangle = gmsh.model.occ.addRectangle(-L/2, -Hb, 0, L, H)
# Create circle
obstacle = gmsh.model.occ.addDisk(c_x, c_y, 0, r, r)
gmsh.model.occ.cut([(gdim, rectangle)], [(gdim, obstacle)])
gmsh.model.occ.synchronize()
# # Set mesh resolution
gmsh.option.setNumber("Mesh.CharacteristicLengthFactor", resolution)
gmsh.option.setNumber("Mesh.Algorithm", 8)
gmsh.option.setNumber("Mesh.RecombinationAlgorithm", 2)
gmsh.option.setNumber("Mesh.RecombineAll", 1)
gmsh.option.setNumber("Mesh.SubdivisionAlgorithm", 1)
gmsh.model.mesh.generate(gdim)
gmsh.model.mesh.setOrder(2)
gmsh.model.mesh.optimize("Netgen")
#
#
gmsh.write("mesh2.msh")
#
# # gmsh.fltk().run()
# # Convert gmsh mesh to dolfinx mesh
mesh_obj, _, _ = gmshio.model_to_mesh(gmsh.model, mesh_comm, model_rank, gdim=gdim)
gmsh.finalize()
Getting this error
Info : Meshing 1D...
Info : [ 0%] Meshing curve 5 (Ellipse)
Info : [ 20%] Meshing curve 6 (Line)
Info : [ 40%] Meshing curve 7 (Line)
Info : [ 60%] Meshing curve 8 (Line)
Info : [ 80%] Meshing curve 9 (Line)
Info : Done meshing 1D (Wall 0.000345293s, CPU 9e-05s)
Info : Meshing 2D...
Info : Meshing surface 1 (Plane, Frontal-Delaunay for Quads)
[0]PETSC ERROR: ------------------------------------------------------------------------
[0]PETSC ERROR: Caught signal number 11 SEGV: Segmentation Violation, probably memory access out of range
[0]PETSC ERROR: Try option -start_in_debugger or -on_error_attach_debugger
[0]PETSC ERROR: or see https://petsc.org/release/faq/#valgrind
[0]PETSC ERROR: or try http://valgrind.org on GNU/linux and Apple Mac OS X to find memory corruption errors
[0]PETSC ERROR: configure using --with-debugging=yes, recompile, link, and run
[0]PETSC ERROR: to get more information on the crash.
[0]PETSC ERROR: Run with -malloc_debug to check if memory corruption is causing the crash.
--------------------------------------------------------------------------
MPI_ABORT was invoked on rank 0 in communicator MPI_COMM_WORLD
with errorcode 59.
NOTE: invoking MPI_ABORT causes Open MPI to kill all MPI processes.
You may or may not see output from other processes, depending on
exactly when Open MPI kills them.
--------------------------------------------------------------------------
Process ended with exit code 59.