Create a 3-D geometry using the MATLAB®
alphaShape function. First, create an
alphaShape object of a block with a cylindrical hole. Then import the geometry into a PDE model from the
Create a 2-D mesh grid.
[xg,yg] = meshgrid(-3:0.25:3); xg = xg(:); yg = yg(:);
Create a unit disk. Remove all the mesh grid points that fall inside the unit disk, and include the unit disk points.
t = (pi/24:pi/24:2*pi)'; x = cos(t); y = sin(t); circShp = alphaShape(x,y,2); in = inShape(circShp,xg,yg); xg = [xg(~in); cos(t)]; yg = [yg(~in); sin(t)];
Create 3-D copies of the remaining mesh grid points, with the
z-coordinates ranging from 0 through 1. Combine the points into an
zg = ones(numel(xg),1); xg = repmat(xg,5,1); yg = repmat(yg,5,1); zg = zg*(0:.25:1); zg = zg(:); shp = alphaShape(xg,yg,zg);
Obtain a surface mesh of the
[elements,nodes] = boundaryFacets(shp);
Put the data in the correct shape for
nodes = nodes'; elements = elements';
Create a PDE model and import the surface mesh.
model = createpde(); geometryFromMesh(model,nodes,elements);
View the geometry and face numbers.
To use the geometry in an analysis, create a volume mesh.