Example: bachelor of science

A SIMPLE MESH GENERATOR IN MATLAB

A SIMPLE MESH GENERATOR IN MATLABPER-OLOF PERSSON AND GILBERT STRANG a mesh is the first step in a wide range of applications, including scientificcomputing and computer graphics. An unstructured simplex mesh requires a choice of meshpoints(vertex nodes) and a triangulation. We want to offer a short and SIMPLE MATLAB code, described inmore detail than usual, so the reader can experiment (and add to the code) knowing the underlyingprinciples. We find the node locations by solving for equilibrium in a truss structure (using piecewiselinear force-displacement relations) and we reset the topology by the Delaunay geometry is described implicitly by its distance function. In addition to being much shorterand simpler than other meshing techniques, our algorithm typically produces meshes of very highquality.

0 −‘) models ordinary linear springs. Our implementation uses this linear response for the repulsive forces but it allows no attractive forces: f(‘,‘ 0) = (k(‘ 0 −‘) if ‘ < ‘ 0, 0 if ‘ ≥ ‘ 0. (2.5) Slightly nonlinear force-functions might generate better meshes (for example with k = (‘ + ‘ 0)/2‘

Tags:

  Ordinary

Information

Domain:

Source:

Link to this page:

Please notify us if you found a problem with this document:

Other abuse

Transcription of A SIMPLE MESH GENERATOR IN MATLAB

1 A SIMPLE MESH GENERATOR IN MATLABPER-OLOF PERSSON AND GILBERT STRANG a mesh is the first step in a wide range of applications, including scientificcomputing and computer graphics. An unstructured simplex mesh requires a choice of meshpoints(vertex nodes) and a triangulation. We want to offer a short and SIMPLE MATLAB code, described inmore detail than usual, so the reader can experiment (and add to the code) knowing the underlyingprinciples. We find the node locations by solving for equilibrium in a truss structure (using piecewiselinear force-displacement relations) and we reset the topology by the Delaunay geometry is described implicitly by its distance function. In addition to being much shorterand simpler than other meshing techniques, our algorithm typically produces meshes of very highquality.

2 We discuss ways to improve the robustness and the performance, but our aim here issimplicity. Readers can download (and edit) the codes ~ generation, distance functions, Delaunay triangulationAMS subject , 65N501. generators tend to be complex codes that are nearlyinaccessible. They are often just used as black boxes. The meshing software isdifficult to integrate with other codes so the user gives up control. We believethat the ability to understand and adapt a mesh generation code (as one might dowith visualization, or a finite element or finite volume code, or geometry modeling incomputer graphics) is too valuable an option to goal is to develop a mesh GENERATOR that can be described in a few dozen linesof MATLAB .

3 We could offer faster implementations, and refinements of the algorithm,but our chief hope is that users will take this code as a starting point for their ownwork. It is understood that the software cannot be fully state-of-the-art, but it canbe SIMPLE and effective and essential decision is how to represent the geometry (the shape of the region).Our code uses asigned distance functiond(x,y), negative inside the region. We showin detail how to write the distance to the boundary for SIMPLE shapes, and how tocombine those functions for more complex objects. We also show how to compute thedistance to boundaries that are given implicitly by equationsf(x,y) = 0, or by valuesofd(x,y) at a discrete set of the actual mesh generation, our iterative technique is based on the physicalanalogy between a simplex mesh and a truss structure.

4 Meshpoints are nodes ofthe truss. Assuming an appropriate force-displacement function for the bars in thetruss at each iteration, we solve for equilibrium. The forces move the nodes, and(iteratively) the Delaunay triangulation algorithm adjusts the topology (it decidesthe edges). Those are the two essential steps. The resulting mesh is surprisinglywell-shaped, and Fig. shows examples. Other codes useLaplacian smoothing[4]for mesh enhancements, usually without retriangulations. This could be regardedas a force-based method, and related mesh generators were investigated by Bossenand Heckbert [1]. We mention Triangle [9] as a robust and freely available Delaunayrefinement combination of distance function representation and node movements fromforces turns out to be good.

5 The distance function quickly determines if a node is Department of Mathematics, Massachusetts Institute of Technology, 77 Massachusetts Avenue,Cambridge MA 02139 and PERSSON AND GILBERT STRANG inside or outside the region (and if it has moved outside, it is easy to determine theclosest boundary point). Thusd(x,y) is used extensively in our implementation, tofind the distance to that closest from being SIMPLE , it turns out that our algorithm generates meshes ofhigh quality. The edge lengths should be close to the relative sizeh(x) specified bythe user (the lengths are nearly equal when the user choosesh(x) = 1). Comparedto typical Delaunay refinement algorithms, our force equilibrium tends to give muchhigher values of the mesh qualityq, at least for the cases we have begin by describing the algorithm and the equilibrium equations for the , we present the complete MATLAB code for the two-dimensional case, and de-scribe every line in detail.

6 In 5, we create meshes for increasingly complex , we describe then-dimensional generalization and show examples of 3-D and4-D The the plane, our mesh generation algorithm is based ona SIMPLE mechanical analogy between a triangular mesh and a 2-D truss structure,or equivalently a structure of springs. Any set of points in thex,y-plane can betriangulated by the Delaunay algorithm [3]. In the physical model, the edges of thetriangles (the connections between pairs of points) correspond to bars, and the pointscorrespond to joints of the truss. Each bar has a force-displacement relationshipf(`,`0) depending on its current length`and its unextended length` external forces on the structure come at the boundaries.

7 At every boundarynode, there is a reaction force acting normal to the boundary. The magnitude of thisforce is just large enough to keep the node from moving outside. The positions of thejoints (these positions are our principal unknowns) are found by solving for a staticforce equilibrium in the structure. The hope is that (whenh(x,y) = 1) the lengths ofall the bars at equilibrium will be nearly equal, giving a well-shaped triangular solve for the force equilibrium, collect thex- andy-coordinates of allNmesh-points into anN-by-2 arrayp:p=[xy]( )The force vectorF(p) has horizontal and vertical components at each meshpoint:F(p) =[Fint,x(p)Fint,y(p)]+[Fext,x(p)Fext,y(p )]( )whereFintcontains the internal forces from the bars, andFextare the external forces(reactions from the boundaries).

8 The first column ofFcontains thex-components ofthe forces, and the second column contains thatF(p) depends on the topology of the bars connecting the joints. In thealgorithm, this structure is given by the Delaunay triangulation of the Delaunay algorithm determines non-overlapping triangles that fill the convexhull of the input points, such that every edge is shared by at most two triangles, andthe circumcircle of every triangle contains no other input points. In the plane, thistriangulation is known to maximize the minimum angle of all the triangles. The forcevectorF(p) is not a continuous function ofp, since the topology (the presence orabsence of connecting bars) is changed by Delaunay as the points systemF(p) =0has to be solved for a set of equilibrium is a relatively hard problem, partly because of the discontinuity in the forcefunction (change of topology), and partly because of the external reaction forces atthe SIMPLE MESH GENERATOR IN MATLAB3A SIMPLE approach to solveF(p) =0is to introduce an artificial somep(0) =p0, we consider the system of ODEs (in non-physical units!)

9 Dpdt=F(p),t 0.( )If a stationary solution is found, it satisfies our systemF(p) =0. The system ( )is approximated using the forward Euler method. At the discretized (artificial) timetn=n t, the approximate solutionpn p(tn) is updated bypn+1=pn+ tF(pn).( )When evaluating the force function, the positionspnare known and therefore also thetruss topology (triangulation of the current point-set). The external reaction forcesenter in the following way: All points that go outside the region during the updatefrompntopn+1are moved back to the closest boundary point. This conforms to therequirement that forces act normal to the boundary. The points can move along theboundary, but not go are many alternatives for the force functionf(`,`0) in each bar, and severalchoices have been investigated [1], [11].

10 The functionk(`0 `) models ordinary linearsprings. Our implementation uses this linear response for therepulsiveforces but itallows no attractive forces:f(`,`0) ={k(`0 `) if`<`0,0if` `0.( )Slightly nonlinear force-functions might generate better meshes (for example withk= (`+`0)/2`0), but the piecewise linear force turns out to give good results (kisincluded to give correct units; we setk= 1). It is reasonable to requiref= 0 for`=`0. The proposed treatment of the boundaries means that no points are forcedto stay at the boundary, they are just prevented from crossing it. It is thereforeimportant thatmost of the bars give repulsive forcesf>0, to help the points spreadout across the whole geometry.}


Related search queries