Correctly identifying faces of geometry that is displayed with pdegplot()

24 views (last 30 days)
Hi community,
I know there are other people with similar problems like mine, but I wanted to ask for a different approach. My problem is the following:
I am using the pdegplot() function to plot my imported geometry and see the face numbers. However, my geometry has many faces, so that I can't clearly identify which face number belongs to which face. This problem other users seem to have, too. It is troubeling that I can't be sure which faces I am assigning my constraints to with the structuralBC() function.
What would help me is if there was a way to highlight certain faces in the figure by refering to their face number. For example, is there a way to highlight a face in a green shade? That way, I could iterate myself through the face numbers until I find the surface that I need.
If you see/know any other possibilities to correctly identify the face numbers, those are of course welcome, as well.
Thanks in advance for your support!
  2 Comments
AlexL
AlexL on 20 Mar 2020
Edited: AlexL on 20 Mar 2020
Great question.
I would also like to know about how g.faceLabelLocations() is calculated. There seems to be an offset between the face centre and the label location, and sometimes (when there are many faces), the label is so far away from the face that there isn't any correlation. Can this offset be adjusted to make it clearer which is which?
Once I guess a face in the vicinity, I plot it to check if I picked the right one...
% after you have calculated your model.Mesh with generateMesh, get all points that lie on test face 'face_ID'...
[~,e,~] = model.Mesh.meshToPet();
A = e.getElementFaces(face_ID);
all_points = cell2mat(arrayfun(@(n) model.Mesh.Nodes(:,A(n)), 1:numel(A),'UniformOutput',false))';
figure
pdegplot(model,'FaceLabels','on','FaceAlpha',0.5)
hold on, plot3(all_points(:,1), all_points(:,2),all_points(:,3),'r*')
A more robust method would be preferable
AlexL
AlexL on 12 Jan 2024
Another helpful way is to first plot the model
pdegplot(model,'FaceLabels','on','FaceAlpha',0.5)
then use the data cursor (mouse, data tips) to highlight a node on the model near your face of interest. Right click and select "Export Cursor Data to Workspace". You can then run the following to give you a list of some of the faces around the node.
facesAttachedToEdges(model.Geometry,nearestEdge(model.Geometry,cursor_info.Position))

Sign in to comment.

Answers (2)

ADSW121365
ADSW121365 on 30 Jul 2020
Another workaround which I use is to find nodes associated with faces and plot them onto a pdegplot to highlight specific faces:
Totfaces = 240;
for i = 1:Totfaces %Plot to highlight faces
C_n = findNodes(model.Mesh,'Region','Face',i);
figure(); pdegplot(model,'CellLabels','on','FaceAlpha',0.5) %Geometry
hold on; scatter3(nodes(1,C_n),nodes(2,C_n),nodes(3,C_n),'r.');
end

Waylon Puckett
Waylon Puckett on 13 Jul 2020
I have a work around, it works, but it's a bad work around. I use a simplified thermal model, and I set all faces to one temperature, and then set a single face to a different temperature. Then I mesh it with a course mesh, and run the model. It's simple enough that it runs in a few seconds, but it shows the surface as a completely diffferent color. So it works.

Community Treasure Hunt

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

Start Hunting!