I try to mark different parts of boundaries with different markers.I create a unit square mesh with each direction Nx=10,Ny=10 cells.I want to mark the part {x=0,0.3<y<1} as 1 and {x=0,0<y<0.3} as 2.And I use the following code to mark faces
boundaries=[(1,lambda x:np.logical_and(np.isclose(x[0],0),np.logical_and(x[1]>=0.3,x[1]<=1))),
(2,lambda x:np.logical_and(np.isclose(x[0],0),np.logical_and(x[1]<=0.3,x[1]>=0))),
(3,lambda x:np.isclose(x[1],0)),
(4,lambda x:np.isclose(x[0],1)),
(5,lambda x:np.isclose(x[1],1))]
facet_indices,facet_markers=[],[]
fdim=domain.topology.dim-1
for (marker,locator) in boundaries:
facets=mesh.locate_entities(domain,fdim,locator)
print(facets)
facet_indices.append(facets)
facet_markers.append(np.full_like(facets,marker))
facets_indices=np.hstack(facet_indices).astype(np.int32)
facets_markers=np.hstack(facet_markers).astype(np.int32)
sorted_facets=np.argsort(facets_indices)
facet_tag=mesh.meshtags(domain,fdim,facets_indices[sorted_facets],facets_markers[sorted_facets])
where I use print
to show the indices.
However, I find that when markering marker=1 and marker=2, there has one missing face which doesnt belong to any of them, the following is the result print
shows
[243 263 280 294 305 313 318]
[166 194]
[ 0 5 14 26 41 59 80 104 131 161]
[ 2 7 16 28 43 61 82 106 133 163]
[192 218 241 261 278 292 303 311 316 319]
Is it because the marker functions I define are wrong?
Thanks in advance!