What is the order of the FaceLabels
3 views (last 30 days)
Show older comments
Hello everybody,
I am trying to simulate an electrosdtatic field in a chamber coposed of several elements. I have defined the geometry of basic shapes, their names and the formula defining the union of them. Than I made o plot of the geommetry with FaceLabels on.
emagmodel = createpde("electromagnetic","electrostatic");
elMeus = [[3; 4];...
[-1.25; -1.25; 1.25; 1.25];...
[-3.5; 10; 10; -3.5]];
elPot = [[2; 12];...
[2; 3.75; 3.75; -3.75; -3.75; -2; -2; -6.25; -6.25; 6.25; 6.25; 2]; ...
[0; 0; 12.5; 12.5; 0; 0; -3.5; -3.5; 15; 15; -3.5; -3.5; ]];
isol1l = [[3; 4]; ...
[-1.5; -1.5; -1.25; -1.25];...
[-3.5; 0; 0; -3.5]];
isol1r = [[3; 4];...
[1.25; 1.25; 1.5; 1.5];...
[-3.5; 0; 0; -3.5]];
elGl = [[3; 4];...
[-1.75; -1.75; -1.5; -1.5];...
[-3.5; 0; 0; -3.5]];
elGr = [[3; 4];...
[1.5; 1.5; 1.75; 1.75];...
[-3.5; 0; 0; -3.5]];
isol2l = [[3; 4];...
[-2; -2; -1.75; -1.75];...
[-3.5; 0; 0; -3.5]];
isol2r = [[3; 4];...
[1.75; 1.75; 2; 2];...
[-3.5; 0; 0; -3.5]];
elMeus = [elMeus;zeros(length(elPot) - length(elMeus),1)];
isol1l = [isol1l;zeros(length(elPot) - length(isol1l),1)];
isol1r = [isol1r;zeros(length(elPot) - length(isol1r),1)];
elGl = [elGl;zeros(length(elPot) - length(elGl),1)];
elGr = [elGr;zeros(length(elPot) - length(elGr),1)];
isol2l = [isol2l;zeros(length(elPot) - length(isol2l),1)];
isol2r = [isol2r;zeros(length(elPot) - length(isol2r),1)];
gd = [elMeus elPot isol1l isol1r elGl elGr isol2l isol2r];
ns = char('elMeus','elPot','isol1l','isol1r','elGl','elGr','isol2l','isol2r');
ns = ns';
sf = 'elMeus+elPot+isol1l+isol1r+elGl+elGr+isol2l+isol2r';
[dl,bt] = decsg(gd,sf,ns);
pdegplot(dl,'EdgeLabels','off','FaceLabels','on')
xlim([-6.5,6.5])
axis equal
What I expected was that the faces will be numbered in the same order in which the basic shapes are defined in the names array. To my surprise the face representing the 3rd shape named 'isol1l', which should be on the left side of the axes, is marked as F4, the next shape 'isol1r', which should be on the right side of the axes, is marked as F3, and so on.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1246787/image.jpeg)
I would like to use the faces numbers as RegionID to specify a different value of relative permittivity for each face.
Is there any way to gues the face labels or any method for numbering the faces (labelling them) in a predictable way?
Thanks in advance for help.
0 Comments
Answers (1)
Rasmita
on 15 Mar 2023
Hi BLP,
It is my understanding that, you want to know how the face numbers are assigned so that you can use that face number as ‘RegionID’ to specify a different value of relative permittivity for each face.
You can find the desired ‘FaceLabel IDs’ by following below steps:
% Steps to find Face ID:
% 1. Generate mesh for the PDE Model
generateMesh(emagmodel);
% 2. Get the total number Faces of the geometry
numFaces = emagmodel.Geometry.NumFaces;
% 3. Get closest Mesh Node to the coordinate of choice
closestNode = emagmodel.Mesh.findNodes('nearest',refCoord');
% 4. Split the mesh node IDs based on Face numbers. Each row represents a Face ID.
for ii = 1:numFaces
fList = emagmodel.Mesh.findNodes('region','Face',ii);
if (find(fList == closestNode))
faceID = ii;
break;
end
end
% --- Face ID found.
For more information on this refer to below documentations:
Hope this helps!
Regards,
Rasmita
See Also
Categories
Find more on Geometry and Mesh in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!