Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Mesh generation for an arbitrary 3D closed surface

Asked by AP on 25 Jun 2011

I have an arbitrary 3D surface and I want to generate some grids inside the surface like a CFD/FEM pre-processor to be able to do some analysis on that. Can MATLAB do this?

Thank you.

0 Comments

AP

Tags

Products

No products are associated with this question.

1 Answer

Answer by Kevin Moerman on 6 Feb 2012

I’m not aware of a specific command for this. By mesh and grid do you mean just a mesh of evenly spaced points (e.g. as produced by meshgrid but then only defined inside your closed surface)? Do you only have a surface description in the form of say vertices and faces? Do you perhaps also have a starting FE model (This may contain a 3D tessellation of your shape which is useful)? There are various methods to create the points but the trick is to do this ONLY INSIDE the closed surface. This involves checking whether points are inside/on/outside the surface. In 2D there is the inpolygon command but as far as I know there is no 3D equivalent like something like “inclosedsurf”. Matlab does have a command to check whether a set of points are inside a tessellation for a given set of other points, see for instance the “tsearchn” (and related) command. t = tsearchn(X,TES,XI); Here TES is a tessellation for the coordinates X and XI your query points. The output t contains the TES features (e.g. tetrahedrons) in which your points XI are found. If they are outside the function returns NaN. Therefore this returns a logic array for the points inside the tessellation: L=~isnan(t); Although TES should perhaps strictly speaking be a Delaunay tessellation, you could test whether this works for other tessellations. I’ve used this a bit for FE models but haven’t tested this thoroughly yet. Say if you have a hexahedral mesh definition for your CFD/FEA model. Then you can import that data into Matlab, convert the hexahedral mesh (tessellation) to a tetrahedral tessellation. Then you define your set of mesh points you wanted to create say using meshgrid and you check using tsearchn whether they are inside your model or outside. Something like: [x,y,z]=meshgrid(…); XI=[x(:) y(:) z(:)]; t = tsearchn(X_tes,TES,XI); L=~isnan(t); XI_inside=XI(L,:);

Kevin

0 Comments

Kevin Moerman

Contact us