How to extract geometric information of discrete geometry faces (working with STL files in PDE Toolbox)?
20 views (last 30 days)
Show older comments
Consider the built-in STL file BracketWithHole.stl, which looks like this:

The code below
model = createpde('structural','static-solid');
importGeometry(model,'BracketWithHole.stl');
pdegplot(model,'FaceLabels','on')
generates this figure:

The figure above shows labels for geometric "faces" that MATLAB interprets from the original STL file (for those familiar with 3D CAD/NURBS: this geometrically analogous to MATLAB taking an STL file and reverse engineering parametric solid or surface geometry). Digging around the documentation has shown me that using the importGeometry command with a 3D STL file generates a DiscreteGeometry object within the PDE model object.
Per this tutorial, I can "select" the labelled faces from this diagram and assign boundary coditions to them (e.g. I could say that face "F10" is rigidly fixed, and face "F9" has certain load applied to it). These boundary conditions are applied to the nodes of the finite element mesh that is generated later in the tutorial.
BC's are presumably applied to relevant mesh nodes by setting a small tolerance distance (presumably as proportion of avg. edge length) and applying relevant BC's to nodes that are a distance≤tolerance from the relevant face.
How can I extract information from the PDE model regarding faces that are of interest to me, so that I can apply boundary conditions, using the method described above, on a mesh that I generate using my own methods (not MATLAB PDE toolbox)?
Thank you in advance!
0 Comments
Answers (1)
Altaïr
on 2 Jan 2025
The PDE toolbox offers the findNodes function to extract node indices corresponding to specific faces, although a temporary mesh needs to be generated first. Below is a code snippet demonstrating how to extract the face vertices.
% Create a PDE model for a static structural analysis
model = createpde('structural', 'static-solid');
% Import the geometry from an STL file
importGeometry(model, 'BracketWithHole.stl');
% Plot the geometry with face labels
figure;
pdegplot(model, 'FaceLabels', 'on');
title('Geometry with Face Labels');
generateMesh(model, "Hmax", 0.5);
% Find nodes associated with face 10
faceID = 10;
faceNodes = findNodes(model.Mesh,'region', 'Face', faceID);
% Extract the coordinates of the vertices on face 10
faceVertices = model.Mesh.Nodes(:, faceNodes);
figure
pdegplot(model,"FaceLabels","on","EdgeLabels","on")
hold on
plot3(faceVertices(1,:),faceVertices(2,:),faceVertices(3,:),"ok","MarkerFaceColor","g")
The Hmax parameter in the generateMesh function should be set to a value greater than the largest dimension in the geometry to prevent subdivision of the faces, thereby creating a mesh with only the original nodes.
For more information, please refer to the documentation page for findNodes by running the following command in the MATLAB command window:
web(fullfile(docroot, 'pde/ug/pde.femesh.findnodes.html'))
0 Comments
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!
