distmeshnd             package:geometry             R Documentation

_A _s_i_m_p_l_e _m_e_s_h _g_e_n_e_r_a_t_o_r _f_o_r _n_o_n-_c_o_n_v_e_x _r_e_g_i_o_n_s _i_n _n-_D _s_p_a_c_e

_D_e_s_c_r_i_p_t_i_o_n:

     An unstructured simplex requires a choice of meshpoints (vertex
     nodes) and a triangulation. This is a simple and short algorithm
     that improves the quality of a mesh by relocating the meshpoints
     according to a relaxation scheme of forces in a truss structure.
     The topology of the truss is reset using Delaunay triangulation. A
     (sufficiently smooth) user supplied signed distance function
     ('fd') indicates if a given node is inside or outside the region.
     Points outside the region are projected back to the boundary.

_U_s_a_g_e:

     distmeshnd(fdist, fh, h, box, pfix = array(dim = c(0,
              ncol(box))), ..., ptol = 0.001, ttol = 0.1, deltat =
              0.1, geps = 0.1 * h, deps = sqrt(.Machine$double.eps)
              * h)

_A_r_g_u_m_e_n_t_s:

   fdist: Vectorized signed distance function, accepting an 'm'-by-'n'
          matrix, where 'm' is arbitrary, as the first argument. 

      fh: Vectorized function that returns desired edge length as a
          function of position. Accepts an 'm'-by-'n' matrix, where 'n'
          is arbitrary, as its first argument.

       h: Initial distance between mesh nodes. 

     box: '2'-by-'n' matrix that specifies the bounding box. (See
          distmesh2d for an example.) 

    pfix: 'nfix'-by-2 matrix with fixed node positions. 

     ...: parameters that are passed to 'fdist' and 'fh' 

    ptol: Algorithm stops when all node movements are smaller than
          'dptol' 

    ttol: Controls how far the points can move (relatively) before a
          retriangulation with 'delaunayn'. 

  deltat: Size of the time step in Eulers method. 

    geps: Tolerance in the geometry evaluations. 

    deps: Stepsize Delta x in numerical derivative computation for
          distance function. 

_D_e_t_a_i_l_s:

     This is an R implementation of original Matlab software of
     Per-Olof Persson.

     Excerpt (modified) from the reference below:

     'The algorithm is based on a mechanical analogy between a
     triangular mesh and a n-D truss structure. In the physical model,
     the edges of the Delaunay triangles of a set of points correspond
     to bars of a truss. Each bar has a force-displacement relationship
     F(L,L0) depending on its current length L  and its unextended
     length L0.'

     'External forces on the structure come at the boundaries, on which
     external forces have normal orientations. These external forces
     are just large enough to prevent nodes from moving outside the
     boundary. The position of the nodes are the unknowns, and are
     found by solving for a static force equilibrium. The hope is that
     (when 'fh = function(p) return(rep(1,nrow(p)))'), the lengths of
     all the bars at equilibrium will be nearly equal, giving a
     well-shaped triangular mesh.'

     See the references below for all details. Also, see the comments
     in the source file of 'distmesh2d'.

_V_a_l_u_e:

     'm'-by-'n' matrix with node positions.

_W_i_s_h_l_i_s_t:

   * Implement in C/Fortran

   * Translate other functions of the matlab package

_A_u_t_h_o_r(_s):

     Raoul Grasman; translated from original Matlab sources of Per-Olof
     Persson.

_R_e_f_e_r_e_n_c_e_s:

     <URL: http://www-math.mit.edu/~persson/mesh/>

     P.-O. Persson, G. Strang, A Simple Mesh Generator in MATLAB. SIAM
     Review, Volume 46 (2), pp. 329-345, June 2004

_S_e_e _A_l_s_o:

     'distmesh2d', 'tri.mesh', 'delaunayn', 'mesh.dsphere',
     'mesh.hunif',
      'mesh.diff', 'mesh.union', 'mesh.intersect'

_E_x_a_m_p_l_e_s:

     ## Not run: 
     # examples distmeshnd
     require(rgl)

     fd = function(p, ...) sqrt((p^2)%*%c(1,1,1)) - 1
          # also predefined as `mesh.dsphere'
     fh = function(p,...)  rep(1,nrow(p))
          # also predefined as `mesh.hunif'
     bbox = matrix(c(-1,1),2,3)
     p = distmeshnd(fd,fh,0.2,bbox, maxiter=100)
         # this may take a while:
         # press Esc to get result of current iteration

     # example with non-convex region
     fd = function(p, ...) mesh.diff( p , mesh.drectangle, mesh.dcircle, radius=.3)
          # fd defines difference of square and circle

     p = distmesh2d(fd,fh,0.05,bbox,radius=0.3,maxiter=4)
     p = distmesh2d(fd,fh,0.05,bbox,radius=0.3, maxiter=10)
          # continue on previous mesh
     ## End(Not run)

