adaptive mesh refinement for 3d shapes
35 views (last 30 days)
Show older comments
Hello,
I imported a 3d stl shape in matlab and i would like to refine a mesh of a part of my domain with a defined x ,y , z.....as i know it isn't possible for 3d shapes but If anyone has an opinion, I would appreciate it.
this is my code i like to have a Hmax=1um for my region and Hmax=8um for other parts...but up to now i can just plot my region and can't define adaptive mesh for it.
"clc;
clear;
model = createpde;
gmbearing = importGeometry(model, "s2my_alpha_shape1000.stl");
mesh=generateMesh(model,"Hmax",8e-6,"GeometricOrder","quadratic");
% Obtain node coordinates and tetrahedral connectivity
nodes = mesh.Nodes;
tets = mesh.Elements;
fig1=figure(1);
pdegplot(gmbearing,"CellLabels","on","FaceAlpha",0.2,"FaceLabels","on")
title('Geometry');
xlabel('x-coordinate')
ylabel('y-coordinate')
zlabel('z-coordinate')
figure(2);
pdeplot3D(model);
title('Mesh Visualization');
%%
elemIDs=findElements(mesh,"box",[-0.12e-3 0.12e-3],[-0.45e-3 0.45e-3],[0 1e-5]);
figure(3)
pdemesh(model)
hold on
pdemesh(mesh.Nodes,mesh.Elements(:,elemIDs),"EdgeColor","red")"
0 Comments
Answers (1)
Yatharth
on 5 Jan 2024
Hi Saeed,
I understand that you are facing an issue with creating an adaptive mesh for a 3D STL geometry in MATLAB, specifically refining a mesh in a localized region to a smaller element size.
Looking at your code I can see you are using “Hmax” in “generateMesh” function to have a target maximum element size. Looking at your workflow you can use “refinemesh” function to refine the mesh in a specific region after generating an initial coarse mesh. Here is the link to the documentation of the function. https://www.mathworks.com/help/pde/ug/refinemesh.html
You can also look into the following function “geometryFromMesh” to create geometry within the model. Here is the documentation for the same. https://www.mathworks.com/help/pde/ug/pde.pdemodel.geometryfrommesh.html
I hope this helps.
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!