What is the order of the FaceLabels

2 次查看(过去 30 天)
BLP
BLP 2022-12-29
评论: BLP 2023-3-30
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.
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.

回答(1 个)

Rasmita
Rasmita 2023-3-15
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
  1 个评论
BLP
BLP 2023-3-30
Hi Rosamita,
Thank you very much for your help. Unfortunatelly in the meantime I realized that I misundertood the problem. My new model has only one Face with several Edges. What I would likje to do is to find an informtion about what numers have the Edges to automatically assing border conditios. The model, deppending on the case, can look like
or
In teh first case one of the border condition will be
electromagneticBC(emagmodel,"Voltage",uPolar,"Edge",[1 2 3 9 16]);
and in the second one
electromagneticBC(emagmodel,"Voltage",uPolar,"Edge",[1 2 3 15 20]);
I am wandering how can I programatically determine the proper edge numbers.
In the help for findNodes (Find mesh nodes in specified region - MATLAB findNodes (mathworks.com)) I have found the way, I can find nodes associated with certain Edges
Ne57 = findNodes(mesh,"region","Edge",[5 7]);
Should I use it analogously like for Faces? I mean finding node which is closes o a point on the edge and searching Edge by Edge the Edge on which this node lies?

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Geometry and Mesh 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by