Skip to main content

optim

Function optim 

Source
pub unsafe extern "C" fn optim(
    x: *const c_double,
    y: *const c_double,
    z: *const c_double,
    na: *const c_int,
    list: *mut c_int,
    lptr: *mut c_int,
    lend: *mut c_int,
    nit: *mut c_int,
    iwk: *mut c_int,
    ier: *mut c_int,
)
Expand description

Optimizes the quadrilateral portion of a triangulation.

Given a set of na triangulation arcs, this subroutine optimizes the portion of the triangulation consisting of the quadrilaterals (pairs of adjacent triangles) which have the arcs as diagonals by applying the circumcircle test and appropriate swaps to the arcs.

An iteration consists of applying the swap test and swaps to all na arcs in the order in which they are stored. The iteration is repeated until no swap occurs or nit iterations have been performed. The bound on the number of iterations may be necessary to prevent an infinite loop caused by cycling (reversing the effect of a previous swap) due to floating point inaccuracy when four or more nodes are nearly cocircular.

ยงArguments

  • x[*], y[*], z[*] - Input. The nodal coordinates.
  • na - Input. The number of arcs in the set. na >= 0.
  • list[6 * (n - 2)], lptr[6 * (n - 2)], lend[n] - Input/output. The data structure defining the triangulation, created by trmesh. On output, updated to reflect the swaps.
  • nit - Input/output. On input, the maximum number of iterations to be performed. nit = 4 * na should be sufficient. nit >= 1. On output, the number of iterations performed.
  • iwk[2][na] - Input/output. The nodal indexes of the arc endpoints (paris of endpoints are stored in columns). On output, endpoint indexes of the new set of arcs reflecting the swaps.
  • ier - Output. Error indicator:
    • 0, if no errors were encountered.
    • 1, if a swap occurred on the last of maxit iterations, where maxit is the value of nit on input. The new set of arcs is not necessarily optimal in this case.
    • 2, if na < 0 or nit < 1 on input
    • 3, if iwk[2][i] is not a neighbor of iwk[1][i] for some i in the range 1 to na. A swap may have occurred in this case.
    • 4, if a zero pointer was returned by subroutine swap.