For the PDE toolbox, how to get the Edges/ faces IDs of a geometry without plotting them?

19 views (last 30 days)
I am using the geometryFromEdges function to generate the geometry in which I want to solve the PDE. All the geometry will be formed by rectangles, but the number of rectangles could vary. So I need to identify the FaceLabel ID for every rectangle to set the PDE coefficients properly. Following you can see a section of my code where I define the geometry:
%Create the PDE model with a single dependent variable.
numberOfPDE = 1;
model = createpde(numberOfPDE);
% Geometry description:
DIE = [3, 4, -x_ds/2, x_ds/2, x_ds/2, -x_ds/2, -y_ds/2, -y_ds/2, y_ds/2, y_ds/2]';
MR = [3, 4, xinfMR, xsupMR, xsupMR, xinfMR, yinfMR, yinfMR, ysupMR, ysupMR]';
AR = [3, 4, xinfAR, xsupAR, xsupAR, xinfAR, yinfAR, yinfAR, ysupAR, ysupAR]';
DR = [3, 4, xinfDR, xsupDR, xsupDR, xinfDR, yinfDR, yinfDR, ysupDR, ysupDR]';
%Define geometry
gm=[DIE,MR,AR,DR];
sf='DIE+MR+AR+DR';
ns=char('DIE','MR','AR','DR');
ns=ns';
g=decsg(gm,sf,ns);
geometryFromEdges(model,g);
So is there any way to map the geometry labels from gm variable (DIE, MR, AR and DR) to the Face labels ID after generating the geometry for the pde?
Thanks in advanced for any help on that.

Accepted Answer

Siju Thomas
Siju Thomas on 13 Sep 2019
I have written a small helper function (See attachment: getFaceID.m) that can help you find the Face Label (Or Face ID) of a particular point. You can download the Matlab script to your current working directory and call the helper function (getFaceID). But first make sure that you generate a mesh for your PDEModel oobject using generateMesh.
The subsequent commands are as follows:
model.generateMesh();
coords = [0 0]; % Coordinates of the query point
faceID = getFaceID(model,coords); % faceID will return ID of the Face closest to the query point
Please note, the error handling for the function is not great at all. Also, if a geometry and/or mesh is missing from the pdeModel object, then the function will error.

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!