How to modify the mesh generated from meshgrid to create a rectangular void in the middle of the mesh

9 vues (au cours des 30 derniers jours)
Hi , I'm new to matlab and trying to create a void or remove the points within a rectangular area in the mesh grid. I have to use this meshgrid to generate structured mesh for FEA.
The mesh grid is ;
[x y] = meshgrid([0: 1: 15],[0: 0.5 :13])
The x & y coordinates for the four corner points of rectangular area ; p1= [5.6 3.8] ; p2= [9.4 3.8] ; p3 =[9.4 9.2] ; p4= [3.8 9.2]
How do I do this?If this is not possible, please provide advise how to select the points/element nodes witin the rectangular area. I appreciate if someone can provide some help on this.
Thanks

Réponses (2)

Epsilon
Epsilon le 27 Nov 2024
Modifié(e) : Epsilon le 27 Nov 2024
Hi Prasad,
To create a void set the values at the indices to 'NaN'.
[x, y] = meshgrid(0:1:15, 0:0.5:13);
voidIndices = (x >= 5.6 & x <= 9.4) & (y >= 3.8 & y <= 9.2);
% Remove points inside the rectangle by setting them to NaN
x(voidIndices) = NaN;
y(voidIndices) = NaN;
plot(x, y, 'b.');
To know more about 'NaN' refer to the link: https://www.mathworks.com/help/matlab/ref/nan.html?
  3 commentaires
Walter Roberson
Walter Roberson le 28 Nov 2024
You cannot do this using delaunayTriangulation . delaunayTriangulation does not give the possibility of excluding an area. delaunayTriangulation() only accepts finite coordinates.
If you extract the non-nan values from x and y:
[x, y] = meshgrid(0:1:15, 0:0.5:13);
voidIndices = (x >= 5.6 & x <= 9.4) & (y >= 3.8 & y <= 9.2);
% Remove points inside the rectangle by setting them to NaN
x(voidIndices) = NaN;
y(voidIndices) = NaN;
XY = rmmissing([x(:), y(:)]);
DT = delaunayTriangulation(XY(:,1), XY(:,2))
DT =
delaunayTriangulation with properties: Points: [388x2 double] ConnectivityList: [692x3 double] Constraints: []
triplot(DT)
Notice that you get triangles crossing the void. The large space shown there is not void -- it is a pair of large triangles occupying the area enclosed.
Prasad
Prasad le 28 Nov 2024
Thank you for your advise with the outputs. I appreciate your support. Now understand the issue. Any other suggetions to obtain triangluar element mesh with a void for Finite Element Analysis.
Thanks

Connectez-vous pour commenter.


Walter Roberson
Walter Roberson le 27 Nov 2024
You might be better off taking a different approach. You might be better off decomposing a geometry
If you follow the steps from the examples at https://www.mathworks.com/help/pde/ug/decsg.html you should be able to build a decomposed mesh. You might then fegeometry the result.
  2 commentaires
Prasad
Prasad le 28 Nov 2024
Hi Walter,
Thank you for your advise. I'm struggling to get the mesh that I mentioned in the reply to Epsilon. I appreciate if you could provide your thoughts.
Thanks
Walter Roberson
Walter Roberson le 28 Nov 2024
You can follow the steps given at https://www.mathworks.com/help/pde/ug/create-geometry-at-the-command-line.html to create two rectangles, and then set the function to be R1-R2 and then [dl,bt] = decsg(gd,sf,ns); to get the decomposed geometry in a form suitable for use with the PDE toolbox.

Connectez-vous pour commenter.

Tags

Produits


Version

R2024a

Community Treasure Hunt

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

Start Hunting!

Translated by