Having isues to read externel msh file

Hello everybody, I’ve been trying to extract boundaries from my XDMF file, but I haven’t succeeded due to an external msh file. My MSH file (before converting it) contains four boundaries named: inlet, outlet, walls, and obstacle_boundary.
When attempting to use the same boundaries i defined with gmsh, I encounter errors indicating that the specified boundary does not exist. How can I extract the boundaries from my file?

V = FunctionSpace(mesh, ("Lagrange", 1))
u_bc = Function(V)
inlet_facets = ft.find(inlet)
left_dofs = locate_dofs_topological(V, mesh.topology.dim - 1, inlet_facets)
bcs = [dirichletbc(default_scalar_type(1), left_dofs, V)]

here is the code i used to convert the msh file to xdmf file

mesh, cell_markers, facet_markers = gmshio.read_from_msh("mesh.msh", MPI.COMM_WORLD, gdim=2)
def create_mesh(mesh, cell_type, prune_z=False):
    cells = mesh.get_cells_type(cell_type)
    cell_data = mesh.get_cell_data("gmsh:physical", cell_type)
    points = mesh.points[:, :2] if prune_z else mesh.points
    out_mesh = meshio.Mesh(points=points, cells={cell_type: cells}, cell_data={"name_to_read": [cell_data.astype(np.int32)]})
    return out_mesh
if proc == 0:
    # Read in mesh
    msh = meshio.read("mesh.msh")

    # Create and save one file for the mesh, and one file for the facets
    triangle_mesh = create_mesh(msh, "triangle", prune_z=True)
    line_mesh = create_mesh(msh, "line", prune_z=True)
    meshio.write("mesh.xdmf", triangle_mesh)
    meshio.write("mt.xdmf", line_mesh)
MPI.COMM_WORLD.barrier()
with XDMFFile(MPI.COMM_WORLD, "mesh.xdmf", "r") as xdmf:
    mesh = xdmf.read_mesh(name="Grid")
    ct = xdmf.read_meshtags(mesh, name="Grid")
mesh.topology.create_connectivity(mesh.topology.dim, mesh.topology.dim - 1)
with XDMFFile(MPI.COMM_WORLD, "mt.xdmf", "r") as xdmf:
    ft = xdmf.read_meshtags(mesh, name="Grid")

You would have to:

  1. Provide the msh file or underlying gmsh model (as a python script or .geo file).
  2. Provide the full error message you are getting.
  3. Provide what version og DOLFINx you are using, and how you installed it.
  4. Check if dolfinx.io.gmshio.read_from_msh works: dolfinx.io.gmshio — DOLFINx 0.7.3 documentation
1 Like

hello sir , I’m using DOLFINx 0.7.3, and I’m encountering difficulties extracting boundaries from my MSH file. Below is my Python script:

from dolfinx import plot, mesh,fem
from mpi4py import MPI
from petsc4py import PETSc
import numpy as np
import ufl
from basix.ufl import element, mixed_element
from dolfinx import mesh, fem, plot, io
from dolfinx.fem import (Function, dirichletbc, form, functionspace,
                         locate_dofs_topological)
from dolfinx.fem.petsc import assemble_matrix_block, assemble_vector_block
from dolfinx.mesh import create_rectangle, locate_entities_boundary,CellType
from ufl import div, dx, grad, inner,as_vector,SpatialCoordinate,VectorElement, FiniteElement
import matplotlib.pyplot as plt
from dolfinx.io import XDMFFile
import pyvista
from dolfinx.plot import vtk_mesh
import warnings
from dolfinx.cpp.mesh import CellType
warnings.filterwarnings("ignore")

import meshio
import gmsh
import numpy as np

mesh, cell_markers, facet_markers = gmshio.read_from_msh("mesh_2.msh", MPI.COMM_WORLD, gdim=2)

def create_mesh(mesh, cell_type, prune_z=False):
    cells = mesh.get_cells_type(cell_type)
    cell_data = mesh.get_cell_data("gmsh:physical", cell_type)
    points = mesh.points[:, :2] if prune_z else mesh.points
    out_mesh = meshio.Mesh(points=points, cells={cell_type: cells}, cell_data={"name_to_read": [cell_data.astype(np.int32)]})
    return out_mesh

proc = MPI.COMM_WORLD.rank
if proc == 0:
    # Read in mesh
    msh = meshio.read("mesh_2.msh")

    # Create and save one file for the mesh, and one file for the facets
    triangle_mesh = create_mesh(msh, "triangle", prune_z=True)
    line_mesh = create_mesh(msh, "line", prune_z=True)
    meshio.write("mesh.xdmf", triangle_mesh)
    meshio.write("mt.xdmf", line_mesh)
MPI.COMM_WORLD.barrier()

with XDMFFile(MPI.COMM_WORLD, "msh.xdmf", "r") as xdmf:
    msh = xdmf.read_mesh(name="Grid")
    ct = xdmf.read_meshtags(msh, name="Grid")
msh.topology.create_connectivity(msh.topology.dim, msh.topology.dim - 1)
with XDMFFile(MPI.COMM_WORLD, "mt.xdmf", "r") as xdmf:
    ft = xdmf.read_meshtags(msh, name="Grid")

# in gmsh : inlet boundary=7, outlet_boundary=8, walls=9, obstacle_boundary=10

#Here, I aim to define Dirichlet boundaries to solve the Stokes problem. However, I'm unsure how to extract information from ct (or ft) to read the boundaries.

def u_expression(x):
    return np.stack((4 * x[1] * (1.0 - x[1]), np.zeros(x.shape[1]))) 

P2 = element("Lagrange", msh.basix_cell(), 2, shape=(msh.geometry.dim,))
P1 = element("Lagrange", msh.basix_cell(), 1)
TH = mixed_element([P2, P1])
W = functionspace(msh, TH)
W0, _ = W.sub(0).collapse()
W1, W1_to_W = W.sub(1).collapse()
# Dirichlet conditions on the wall
u_wall=Function(W0)
facets_wall = locate_entities_boundary(msh, 1, ft.find(9))
dofs_wall = locate_dofs_topological((W.sub(0), W0), 1, facets_wall)
bc0 = dirichletbc(u_wall, dofs_wall, W.sub(0))
# Dirichlet conditions on the inlet
u_in=Function(W0)
u_in.interpolate(u_expression)
facets_in = locate_entities_boundary(msh, 1, ft.find(7))
dofs_in = locate_dofs_topological((W.sub(0), W0), 1, facets_in)
bc1 = dirichletbc(u_in, dofs_in, W.sub(0))
# Dirichlet conditions on the obstacle boundary
u_obst=Function(W0)
facets_obst = locate_entities_boundary(msh, 1, ft.find(10))
dofs_obst = locate_dofs_topological((W.sub(0), W0), 1, facets_obst)
bc2 = dirichletbc(u_in, dofs_obst, W.sub(0))
bcp=[bc0,bc1,bc2]

My msh file is :

$MeshFormat
2.2 0 8
$EndMeshFormat
$Nodes
1440
1 0 0 -0.1
2 1 0 -0.1
3 1 1 -0.1
4 0 1 -0.1
5 0.5 0.4 -0.1
6 0.5 0.6 -0.1
7 0.02941176470588239 0 -0.1
8 0.05882352941176477 0 -0.1
9 0.08823529411764718 0 -0.1
10 0.1176470588235296 0 -0.1
11 0.147058823529412 0 -0.1
12 0.1764705882352943 0 -0.1
13 0.2058823529411767 0 -0.1
14 0.235294117647059 0 -0.1
15 0.2647058823529415 0 -0.1
16 0.2941176470588239 0 -0.1
17 0.3235294117647065 0 -0.1
18 0.3529411764705889 0 -0.1
19 0.3823529411764713 0 -0.1
20 0.4117647058823538 0 -0.1
21 0.4411764705882362 0 -0.1
22 0.4705882352941187 0 -0.1
23 0.5000000000000011 0 -0.1
24 0.5294117647058832 0 -0.1
25 0.5588235294117656 0 -0.1
26 0.5882352941176479 0 -0.1
27 0.6176470588235301 0 -0.1
28 0.6470588235294124 0 -0.1
29 0.6764705882352946 0 -0.1
30 0.7058823529411768 0 -0.1
31 0.7352941176470592 0 -0.1
32 0.7647058823529413 0 -0.1
33 0.7941176470588236 0 -0.1
34 0.823529411764706 0 -0.1
35 0.8529411764705882 0 -0.1
36 0.8823529411764703 0 -0.1
37 0.9117647058823527 0 -0.1
38 0.9411764705882349 0 -0.1
39 0.9705882352941173 0 -0.1
40 1 0.02941176470588239 -0.1
41 1 0.05882352941176477 -0.1
42 1 0.08823529411764718 -0.1
43 1 0.1176470588235296 -0.1
44 1 0.147058823529412 -0.1
45 1 0.1764705882352943 -0.1
46 1 0.2058823529411767 -0.1
47 1 0.235294117647059 -0.1
48 1 0.2647058823529415 -0.1
49 1 0.2941176470588239 -0.1
50 1 0.3235294117647065 -0.1
51 1 0.3529411764705889 -0.1
52 1 0.3823529411764713 -0.1
53 1 0.4117647058823538 -0.1
54 1 0.4411764705882362 -0.1
55 1 0.4705882352941187 -0.1
56 1 0.5000000000000011 -0.1
57 1 0.5294117647058832 -0.1
58 1 0.5588235294117656 -0.1
59 1 0.5882352941176479 -0.1
60 1 0.6176470588235301 -0.1
61 1 0.6470588235294124 -0.1
62 1 0.6764705882352946 -0.1
63 1 0.7058823529411768 -0.1
64 1 0.7352941176470592 -0.1
65 1 0.7647058823529413 -0.1
66 1 0.7941176470588236 -0.1
67 1 0.823529411764706 -0.1
68 1 0.8529411764705882 -0.1
69 1 0.8823529411764703 -0.1
70 1 0.9117647058823527 -0.1
71 1 0.9411764705882349 -0.1
72 1 0.9705882352941173 -0.1
73 0.9705882352941176 1 -0.1
74 0.9411764705882353 1 -0.1
75 0.9117647058823528 1 -0.1
76 0.8823529411764705 1 -0.1
77 0.8529411764705881 1 -0.1
78 0.8235294117647057 1 -0.1
79 0.7941176470588234 1 -0.1
80 0.7647058823529409 1 -0.1
81 0.7352941176470585 1 -0.1
82 0.7058823529411761 1 -0.1
83 0.6764705882352935 1 -0.1
84 0.6470588235294111 1 -0.1
85 0.6176470588235287 1 -0.1
86 0.5882352941176462 1 -0.1
87 0.5588235294117638 1 -0.1
88 0.5294117647058814 1 -0.1
89 0.4999999999999989 1 -0.1
90 0.4705882352941168 1 -0.1
91 0.4411764705882344 1 -0.1
92 0.4117647058823521 1 -0.1
93 0.3823529411764699 1 -0.1
94 0.3529411764705876 1 -0.1
95 0.3235294117647054 1 -0.1
96 0.2941176470588232 1 -0.1
97 0.2647058823529408 1 -0.1
98 0.2352941176470587 1 -0.1
99 0.2058823529411764 1 -0.1
100 0.176470588235294 1 -0.1
101 0.1470588235294118 1 -0.1
102 0.1176470588235297 1 -0.1
103 0.0882352941176473 1 -0.1
104 0.05882352941176505 1 -0.1
105 0.02941176470588269 1 -0.1
106 0 0.9705882352941176 -0.1
107 0 0.9411764705882353 -0.1
108 0 0.9117647058823528 -0.1
109 0 0.8823529411764705 -0.1
110 0 0.8529411764705881 -0.1
111 0 0.8235294117647057 -0.1
112 0 0.7941176470588234 -0.1
113 0 0.7647058823529409 -0.1
114 0 0.7352941176470585 -0.1
115 0 0.7058823529411761 -0.1
116 0 0.6764705882352935 -0.1
117 0 0.6470588235294111 -0.1
118 0 0.6176470588235287 -0.1
119 0 0.5882352941176462 -0.1
120 0 0.5588235294117638 -0.1
121 0 0.5294117647058814 -0.1
122 0 0.4999999999999989 -0.1
123 0 0.4705882352941168 -0.1
124 0 0.4411764705882344 -0.1
125 0 0.4117647058823521 -0.1
126 0 0.3823529411764699 -0.1
127 0 0.3529411764705876 -0.1
128 0 0.3235294117647054 -0.1
129 0 0.2941176470588232 -0.1
130 0 0.2647058823529408 -0.1
131 0 0.2352941176470587 -0.1
132 0 0.2058823529411764 -0.1
133 0 0.176470588235294 -0.1
134 0 0.1470588235294118 -0.1
135 0 0.1176470588235297 -0.1
136 0 0.0882352941176473 -0.1
137 0 0.05882352941176505 -0.1
138 0 0.02941176470588269 -0.1
139 0.4718267443158571 0.4040507026385503 -0.1
140 0.4459359182544403 0.4158746467168819 -0.1
141 0.4244250425645743 0.4345139266054714 -0.1
142 0.4090368004645482 0.4584584986998114 -0.1
143 0.4010178558119067 0.4857685161726714 -0.1
144 0.4010178558119067 0.5142314838273283 -0.1
145 0.409036800464548 0.5415415013001884 -0.1
146 0.4244250425645739 0.5654860733945282 -0.1
147 0.44593591825444 0.5841253532831179 -0.1
148 0.4718267443158569 0.5959492973614496 -0.1
149 0.528173255684143 0.5959492973614497 -0.1
150 0.5540640817455597 0.5841253532831181 -0.1
151 0.5755749574354257 0.5654860733945285 -0.1
152 0.5909631995354518 0.5415415013001886 -0.1
153 0.5989821441880933 0.5142314838273286 -0.1
154 0.5989821441880933 0.4857685161726717 -0.1
155 0.590963199535452 0.4584584986998116 -0.1
156 0.5755749574354261 0.4345139266054718 -0.1
157 0.55406408174556 0.4158746467168821 -0.1
158 0.5281732556841432 0.4040507026385504 -0.1
159 0.2504682458939125 0.9743252479180556 -0.09999999999999999
160 0.02429978378788278 0.2520206075471477 -0.09999999999999999
161 0.7496261475641167 0.02898616531919823 -0.09999999999999999
162 0.9758326853582743 0.7509546773286145 -0.09999999999999999
...
...
...
1409 0.624479894816612 0.4224910480113822 -0.09999999999999999
1410 0.09782506405858954 0.5964016858333706 -0.09999999999999999
1411 0.4996377277334131 0.3314708765829324 -0.09999999999999999
1412 0.559515366001018 0.6528135620308708 -0.09999999999999999
1413 0.1681183429040136 0.9519016484934958 -0.09999999999999999
1414 0.4172275229050013 0.3535953828217367 -0.09999999999999999
1415 0.3060162306302208 0.06827106457832383 -0.09999999999999999
1416 0.4729266732350582 0.04271473602582893 -0.09999999999999999
1417 0.6321764084514025 0.9831358657475537 -0.09999999999999999
1418 0.3073697051574724 0.6041984055837978 -0.09999999999999999
1419 0.6089301501009872 0.9524780430825366 -0.09999999999999999
1420 0.8750866109415734 0.04633119699068428 -0.09999999999999999
1421 0.9298174523735604 0.46067457448854 -0.09999999999999999
1422 0.06926880497195481 0.8417863515574059 -0.09999999999999999
1423 0.9396419908803317 0.04131169961367109 -0.09999999999999999
1424 0.7371131037424707 0.09202313196438017 -0.09999999999999999
1425 0.09215553635847479 0.2647393620623119 -0.09999999999999999
1426 0.8679040003092801 0.8821927726629413 -0.09999999999999999
1427 0.9048257017127335 0.2886526405706951 -0.09999999999999999
1428 0.5386735066986276 0.3860335825043007 -0.09999999999999999
1429 0.6388445175965607 0.4566776360892524 -0.09999999999999999
1430 0.9289944156546275 0.5941050014400471 -0.09999999999999999
1431 0.4705926797412245 0.9591292156903894 -0.09999999999999999
1432 0.5100224067361629 0.3571379651822992 -0.09999999999999999
1433 0.1911446659480742 0.9830903897805335 -0.09999999999999999
1434 0.2800097194450207 0.09427800498156563 -0.09999999999999999
1435 0.06749285582646047 0.04449247558175495 -0.09999999999999999
1436 0.9573432538908391 0.2083355641549931 -0.09999999999999999
1437 0.02035874466755555 0.2289714523594583 -0.09999999999999999
1438 0.61115761811879 0.5446593636701323 -0.09999999999999999
1439 0.6056023327645539 0.3713462603999792 -0.09999999999999999
1440 0.04618747825632302 0.1592863672244866 -0.09999999999999999
$EndNodes
$Elements
2880
1 1 2 9 1 1 7
2 1 2 9 1 7 8
3 1 2 9 1 8 9
4 1 2 9 1 9 10
5 1 2 9 1 10 11
6 1 2 9 1 11 12
7 1 2 9 1 12 13
8 1 2 9 1 13 14
9 1 2 9 1 14 15
10 1 2 9 1 15 16
11 1 2 9 1 16 17
12 1 2 9 1 17 18
13 1 2 9 1 18 19
14 1 2 9 1 19 20
15 1 2 9 1 20 21
16 1 2 9 1 21 22
17 1 2 9 1 22 23
18 1 2 9 1 23 24
19 1 2 9 1 24 25
20 1 2 9 1 25 26
21 1 2 9 1 26 27
22 1 2 9 1 27 28
23 1 2 9 1 28 29
24 1 2 9 1 29 30
25 1 2 9 1 30 31
26 1 2 9 1 31 32
27 1 2 9 1 32 33
28 1 2 9 1 33 34
29 1 2 9 1 34 35
30 1 2 9 1 35 36
31 1 2 9 1 36 37
32 1 2 9 1 37 38
33 1 2 9 1 38 39
34 1 2 9 1 39 2
35 1 2 8 2 2 40
36 1 2 8 2 40 41
37 1 2 8 2 41 42
38 1 2 8 2 42 43
39 1 2 8 2 43 44
40 1 2 8 2 44 45
41 1 2 8 2 45 46
42 1 2 8 2 46 47
43 1 2 8 2 47 48
44 1 2 8 2 48 49
45 1 2 8 2 49 50
46 1 2 8 2 50 51
47 1 2 8 2 51 52
48 1 2 8 2 52 53
49 1 2 8 2 53 54
50 1 2 8 2 54 55
51 1 2 8 2 55 56
52 1 2 8 2 56 57
53 1 2 8 2 57 58
54 1 2 8 2 58 59
55 1 2 8 2 59 60
56 1 2 8 2 60 61
57 1 2 8 2 61 62
58 1 2 8 2 62 63
59 1 2 8 2 63 64
60 1 2 8 2 64 65
61 1 2 8 2 65 66
62 1 2 8 2 66 67
63 1 2 8 2 67 68
64 1 2 8 2 68 69
65 1 2 8 2 69 70
66 1 2 8 2 70 71
67 1 2 8 2 71 72
68 1 2 8 2 72 3
69 1 2 9 3 3 73
70 1 2 9 3 73 74
71 1 2 9 3 74 75
72 1 2 9 3 75 76
73 1 2 9 3 76 77
74 1 2 9 3 77 78
75 1 2 9 3 78 79
76 1 2 9 3 79 80
77 1 2 9 3 80 81
78 1 2 9 3 81 82
79 1 2 9 3 82 83
80 1 2 9 3 83 84
81 1 2 9 3 84 85
82 1 2 9 3 85 86
83 1 2 9 3 86 87
84 1 2 9 3 87 88
85 1 2 9 3 88 89
86 1 2 9 3 89 90
87 1 2 9 3 90 91
88 1 2 9 3 91 92
89 1 2 9 3 92 93
90 1 2 9 3 93 94
91 1 2 9 3 94 95
92 1 2 9 3 95 96
93 1 2 9 3 96 97
94 1 2 9 3 97 98
95 1 2 9 3 98 99
96 1 2 9 3 99 100
97 1 2 9 3 100 101
98 1 2 9 3 101 102
99 1 2 9 3 102 103
100 1 2 9 3 103 104
101 1 2 9 3 104 105
102 1 2 9 3 105 4
103 1 2 7 4 4 106
104 1 2 7 4 106 107
105 1 2 7 4 107 108
106 1 2 7 4 108 109
107 1 2 7 4 109 110
108 1 2 7 4 110 111
109 1 2 7 4 111 112
110 1 2 7 4 112 113
111 1 2 7 4 113 114
112 1 2 7 4 114 115
113 1 2 7 4 115 116
114 1 2 7 4 116 117
115 1 2 7 4 117 118
116 1 2 7 4 118 119
117 1 2 7 4 119 120
118 1 2 7 4 120 121
119 1 2 7 4 121 122
120 1 2 7 4 122 123
121 1 2 7 4 123 124
122 1 2 7 4 124 125
123 1 2 7 4 125 126
124 1 2 7 4 126 127
125 1 2 7 4 127 128
126 1 2 7 4 128 129
127 1 2 7 4 129 130
128 1 2 7 4 130 131
129 1 2 7 4 131 132
130 1 2 7 4 132 133
131 1 2 7 4 133 134
132 1 2 7 4 134 135
133 1 2 7 4 135 136
134 1 2 7 4 136 137
135 1 2 7 4 137 138
136 1 2 7 4 138 1
137 1 2 10 5 5 139
138 1 2 10 5 139 140
139 1 2 10 5 140 141
140 1 2 10 5 141 142
141 1 2 10 5 142 143
142 1 2 10 5 143 144
143 1 2 10 5 144 145
144 1 2 10 5 145 146
145 1 2 10 5 146 147
146 1 2 10 5 147 148
147 1 2 10 5 148 6
148 1 2 10 6 6 149
149 1 2 10 6 149 150
150 1 2 10 6 150 151
151 1 2 10 6 151 152
152 1 2 10 6 152 153
153 1 2 10 6 153 154
154 1 2 10 6 154 155
155 1 2 10 6 155 156
156 1 2 10 6 156 157
157 1 2 10 6 157 158
158 1 2 10 6 158 5
159 2 2 11 1 835 1363 1350
160 2 2 11 1 1038 1039 752
161 2 2 11 1 223 1166 1097
162 2 2 11 1 161 888 872
163 2 2 11 1 219 1095 829
164 2 2 11 1 221 1096 839
165 2 2 11 1 973 1132 619
166 2 2 11 1 1021 1022 605
167 2 2 11 1 829 1254 219
168 2 2 11 1 624 975 972
169 2 2 11 1 656 867 854
170 2 2 11 1 658 867 656
171 2 2 11 1 961 1327 582
172 2 2 11 1 194 1068 1067
173 2 2 11 1 872 887 161
174 2 2 11 1 656 854 654
175 2 2 11 1 1166 1365 1097
176 2 2 11 1 540 1137 1064
177 2 2 11 1 851 936 265
178 2 2 11 1 661 867 658
179 2 2 11 1 849 1116 1040
180 2 2 11 1 972 1341 624
181 2 2 11 1 1297 1299 684
182 2 2 11 1 1159 1326 952
183 2 2 11 1 952 1388 1159
...
...
...
2714 2 2 11 1 1303 1407 861
2715 2 2 11 1 1328 1334 1018
2716 2 2 11 1 958 1421 959
2717 2 2 11 1 1144 1382 726
2718 2 2 11 1 753 1346 1324
2719 2 2 11 1 679 1358 678
2720 2 2 11 1 786 1355 788
2721 2 2 11 1 625 1356 624
2722 2 2 11 1 1411 1432 857
2723 2 2 11 1 160 1437 1332
2724 2 2 11 1 69 1359 68
2725 2 2 11 1 679 1411 1358
2726 2 2 11 1 1127 1373 1346
2727 2 2 11 1 994 1415 996
2728 2 2 11 1 770 1360 880
2729 2 2 11 1 820 1361 814
2730 2 2 11 1 705 1429 1357
2731 2 2 11 1 1170 1385 551
2732 2 2 11 1 575 1362 582
2733 2 2 11 1 1379 1413 1094
2734 2 2 11 1 1295 1363 483
2735 2 2 11 1 1351 1377 1005
2736 2 2 11 1 905 1411 679
2737 2 2 11 1 1233 1364 1336
2738 2 2 11 1 1336 1364 988
2739 2 2 11 1 1112 1365 1063
2740 2 2 11 1 1291 1375 220
2741 2 2 11 1 1364 1387 183
2742 2 2 11 1 604 1380 640
2743 2 2 11 1 841 1369 1256
2744 2 2 11 1 948 1400 1348
2745 2 2 11 1 616 1367 553
2746 2 2 11 1 516 1383 1199
2747 2 2 11 1 1003 1415 994
2748 2 2 11 1 862 1377 863
2749 2 2 11 1 1256 1369 792
2750 2 2 11 1 595 1372 691
2751 2 2 11 1 1317 1392 804
2752 2 2 11 1 837 1364 1233
2753 2 2 11 1 440 1348 1294
2754 2 2 11 1 533 1373 1127
2755 2 2 11 1 837 1387 1364
2756 2 2 11 1 183 1387 950
2757 2 2 11 1 936 1404 434
2758 2 2 11 1 1005 1377 205
2759 2 2 11 1 862 1401 1377
2760 2 2 11 1 1052 1422 1053
2761 2 2 11 1 850 1391 991
2762 2 2 11 1 1150 1376 832
2763 2 2 11 1 991 1391 208
2764 2 2 11 1 890 1383 889
2765 2 2 11 1 700 1378 596
2766 2 2 11 1 1287 1395 73
2767 2 2 11 1 1288 1394 7
2768 2 2 11 1 1316 1384 831
2769 2 2 11 1 746 1381 881
2770 2 2 11 1 640 1380 1338
2771 2 2 11 1 1361 1418 814
2772 2 2 11 1 964 1382 965
2773 2 2 11 1 185 1403 1337
2774 2 2 11 1 833 1380 900
2775 2 2 11 1 1198 1379 589
2776 2 2 11 1 1377 1401 205
2777 2 2 11 1 199 1384 992
2778 2 2 11 1 969 1385 968
2779 2 2 11 1 1374 1399 664
2780 2 2 11 1 951 1388 952
2781 2 2 11 1 1387 1416 950
2782 2 2 11 1 840 1386 1115
2783 2 2 11 1 815 1387 837
2784 2 2 11 1 104 1389 103
2785 2 2 11 1 214 1390 1051
2786 2 2 11 1 1083 1392 162
2787 2 2 11 1 843 1391 850
2788 2 2 11 1 875 1419 830
2789 2 2 11 1 39 1397 226
2790 2 2 11 1 856 1432 1338
2791 2 2 11 1 105 1393 224
2792 2 2 11 1 138 1394 225
2793 2 2 11 1 72 1395 223
2794 2 2 11 1 689 1396 873
2795 2 2 11 1 1338 1432 736
2796 2 2 11 1 866 1401 862
2797 2 2 11 1 664 1399 665
2798 2 2 11 1 1320 1361 820
2799 2 2 11 1 950 1416 197
2800 2 2 11 1 205 1401 989
2801 2 2 11 1 566 1425 1304
2802 2 2 11 1 540 1398 534
2803 2 2 11 1 184 1431 1210
2804 2 2 11 1 866 1431 1401
2805 2 2 11 1 761 1363 1295
2806 2 2 11 1 838 1429 1253
2807 2 2 11 1 815 1416 1387
2808 2 2 11 1 885 1370 1325
2809 2 2 11 1 1100 1400 948
2810 2 2 11 1 152 1438 777
2811 2 2 11 1 1185 1402 779
2812 2 2 11 1 1289 1393 106
2813 2 2 11 1 703 1409 1244
2814 2 2 11 1 210 1405 1022
2815 2 2 11 1 955 1408 956
2816 2 2 11 1 856 1428 158
2817 2 2 11 1 1357 1409 705
2818 2 2 11 1 1401 1431 989
2819 2 2 11 1 1059 1426 1060
2820 2 2 11 1 827 1403 1165
2821 2 2 11 1 829 1423 861
2822 2 2 11 1 662 1412 661
2823 2 2 11 1 142 1406 227
2824 2 2 11 1 1274 1422 1052
2825 2 2 11 1 1094 1413 192
2826 2 2 11 1 629 1410 627
2827 2 2 11 1 479 1414 231
2828 2 2 11 1 954 1419 181
2829 2 2 11 1 959 1421 1327
2830 2 2 11 1 85 1417 84
2831 2 2 11 1 1281 1374 664
2832 2 2 11 1 1074 1371 1291
2833 2 2 11 1 1091 1420 1092
2834 2 2 11 1 1115 1386 1366
2835 2 2 11 1 879 1416 815
2836 2 2 11 1 1040 1425 1039
2837 2 2 11 1 226 1423 1095
2838 2 2 11 1 989 1431 184
2839 2 2 11 1 701 1439 602
2840 2 2 11 1 756 1366 1340
2841 2 2 11 1 468 1427 547
2842 2 2 11 1 100 1433 99
2843 2 2 11 1 597 1422 1274
2844 2 2 11 1 131 1437 160
2845 2 2 11 1 814 1418 1192
2846 2 2 11 1 873 1436 845
2847 2 2 11 1 1155 1430 616
2848 2 2 11 1 544 1434 1148
2849 2 2 11 1 223 1395 1287
2850 2 2 11 1 225 1394 1288
2851 2 2 11 1 1210 1431 866
2852 2 2 11 1 661 1412 1345
2853 2 2 11 1 1343 1436 873
2854 2 2 11 1 224 1393 1289
2855 2 2 11 1 162 1392 1317
2856 2 2 11 1 1325 1370 860
2857 2 2 11 1 1299 1381 746
2858 2 2 11 1 1253 1429 717
2859 2 2 11 1 871 1424 1250
2860 2 2 11 1 1340 1366 1090
2861 2 2 11 1 840 1435 1386
2862 2 2 11 1 226 1397 1293
2863 2 2 11 1 992 1384 1316
2864 2 2 11 1 1293 1397 40
2865 2 2 11 1 1269 1435 840
2866 2 2 11 1 1304 1425 1040
2867 2 2 11 1 212 1407 1303
2868 2 2 11 1 1350 1406 802
2869 2 2 11 1 434 1404 1355
2870 2 2 11 1 1337 1403 827
2871 2 2 11 1 1378 1415 1003
2872 2 2 11 1 1338 1428 856
2873 2 2 11 1 1327 1421 741
2874 2 2 11 1 1355 1404 788
2875 2 2 11 1 828 1409 1357
2876 2 2 11 1 777 1438 1374
2877 2 2 11 1 1357 1429 838
2878 2 2 11 1 700 1415 1378
2879 2 2 11 1 1398 1426 1059
2880 2 2 11 1 540 1426 1398
$EndElements

Due to the large size of my MSH file, I have removed some lines to adhere to the maximum character limit.

I have the folowing error:

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
Cell In[30], line 11
      9 # Dirichlet conditions on the wall
     10 u_wall=Function(W0)
---> 11 facets_wall = locate_entities_boundary(msh, 1, ft.find(9))
     12 dofs_wall = locate_dofs_topological((W.sub(0), W0), 1, facets_wall)
     13 bc0 = dirichletbc(u_wall, dofs_wall, W.sub(0))

File ~/micromamba/envs/fenicsx/lib/python3.12/site-packages/dolfinx/mesh.py:233, in locate_entities_boundary(mesh, dim, marker)
    208 def locate_entities_boundary(mesh: Mesh, dim: int, marker: typing.Callable) -> np.ndarray:
    209     """Compute mesh entities that are connected to an owned boundary
    210     facet and satisfy a geometric marking function.
    211 
   (...)
    231 
    232     """
--> 233     return _cpp.mesh.locate_entities_boundary(mesh._cpp_object, dim, marker)

TypeError: locate_entities_boundary(): incompatible function arguments. The following argument types are supported:
    1. (mesh: dolfinx.cpp.mesh.Mesh_float32, dim: int, marker: Callable[[numpy.ndarray[numpy.float32]], numpy.ndarray[bool]]) -> numpy.ndarray[numpy.int32]
    2. (mesh: dolfinx.cpp.mesh.Mesh_float64, dim: int, marker: Callable[[numpy.ndarray[numpy.float64]], numpy.ndarray[bool]]) -> numpy.ndarray[numpy.int32]

Invoked with: <dolfinx.cpp.mesh.Mesh_float64 object at 0x7f603c789a90>, 1, array([   1,    3,   11,   26,   49,   69,  111,  157,  208,  267,  332,
        407,  484,  568,  664,  766,  878,  995, 1117, 1245, 1287, 1371,
       1373, 1497, 1499, 1620, 1622, 1747, 1753, 1865, 1874, 1973, 1985,
       2073, 2088, 2177, 2195, 2282, 2302, 2390, 2411, 2504, 2527, 2623,
       2646, 2753, 2776, 2887, 2910, 3009, 3132, 3249, 3353, 3455, 3554,
       3639, 3720, 3794, 3855, 3916, 3967, 4013, 4052, 4083, 4109, 4131,
       4148, 4158], dtype=int32)

This does not make sense, don’t you just mean facets_wall=ft.find(9)?

Note that without the actual mesh, this is just best guesses from my end. Please provide a MWE to get more support.