FEATool  v1.8
Finite Element Analysis Toolbox
 All Files Functions Pages
quadmesh.m File Reference


QUADMESH Generate quadrilateral mesh using distance functions.

[ P, C ] = QUADMESH( FD, H0, BBOX, PFIX, HTOL, NCOFF ) Function to generate a grid with quadrialteral cells for geometry objects defined using distance functions. Accepts the following input and output arguments.

Property    Value/{Default}           Description
fd          anonymous function        Distance function
h0          scalar  {0.1}             Target grid size
bbox        array   [2,2]             Bounding box enclosing geometry object
pfix        array   [n_pfix,2]        Points that must be in the grid (optional)
htol        scalar  {0.2}             Cell size width fraction in grid snapping
ncoff       integer {2}               Number of extra cells to offset in
                                      surrounding rectangular grid construction
p_intf      array  [2*n_l+nan,2]      Interface line segemet array (line format)
p           array  [n_p,2]            Output array of grid vertices
c           array  [n_c,4]            Output array of quadrilateral connectivities

Example: (Uniform mesh on unit circle) fd = @(p) sqrt(sum(p.^2,2)) - 1; [p,c] = quadmesh( fd, 0.1, [-1 -1;1 1] ); patch(vertices,p,faces,c,facecolor,g), axis equal

Example: (Ellipse) fd = @(p) p(:,1).^2/2^2 + p(:,2).^2/1^2 - 1; [p,c] = quadmesh( fd, 0.1, [-2 -1;2 1]); patch(vertices,p,faces,c,facecolor,g), axis equal

Example: (Rectangle with circular hole) ddiff = @(d1,d2) max(d1,-d2); drectangle = @(p,x1,x2,y1,y2) -min(min(min(-y1+p(:,2),y2-p(:,2)),-x1+p(:,1)),x2-p(:,1)); dcircle = @(p,xc,yc,r) sqrt((p(:,1)-xc).^2+(p(:,2)-yc).^2)-r; fd = @(p) ddiff(drectangle(p,-1,1,-1,1),dcircle(p,0,0,0.5)); [p,c] = quadmesh( fd, 0.025, [-1,-1;1,1], [-1,-1;-1,1;1,-1;1,1] ); patch(vertices,p,faces,c,facecolor,g), axis equal

See also
gridgen_quad, gridalign2