Indices of subset of mesh elements belonging to specified faces of 2-D geometry
pdesdt is not recommended. Use
Find the indices of the mesh elements belonging to the specified faces.
Define two circles and a rectangle and place these in one matrix.
R1 = [3,4,-1,1,1,-1,0.5,0.5,-0.75,-0.75]'; C1 = [1,-0.5,-0.25,0.25]'; C2 = [1,0.5,-0.25,0.25]'; C1 = [C1;zeros(length(R1) - length(C1),1)]; C2 = [C2;zeros(length(R1) - length(C2),1)]; gd = [R1,C1,C2];
Create a set formula that adds the circles to the rectangle.
sf = 'R1+C1+C2';
Create and plot the geometry.
ns = char('R1','C1','C2'); ns = ns'; gd = decsg(gd,sf,ns); pdegplot(gd,'FaceLabels','on')
Create a mesh.
[p,e,t] = initmesh(gd);
Plot the mesh with the element labels.
Find the indices of the mesh elements that belong to face 2. Display the result as a column vector.
i = pdesdt(t,2); i.'
ans = 16×1 5 8 19 20 21 22 75 76 139 140 ⋮
t— Mesh elements
Mesh elements, specified as a
of triangles, where
Nt is the number of triangles in the mesh. For
details on the mesh data representation, see
FaceID— Face IDs
Face IDs, specified as a vector of integers.
i— Mesh elements belonging to specified faces
Mesh elements belonging to the specified faces, returned as a vector of integers.