relax

relax smooths the interior nodes of a face, a list of faces or a block, moving them iteration by iteration toward an even, equipotential mesh whose boundary is the region’s own boundary nodes.

Syntax

relax imin jmin kmin imax jmax kmax { & imin jmin kmin imax jmax kmax } iterations min_change weight

Each group of six numbers is a region, as for lin: a face or a block. Two or more faces are joined by &, which may end a line, and the list may run over several lines.

  • iterations is the largest number of iterations to run, a positive integer.
  • min_change is a distance in the part’s own coordinates, zero or more. The run stops after the first iteration in which no coordinate of any node moved by more than it. Zero ends the run early only if an iteration moves no node at all.
  • weight is above 0 and at most 1. In each iteration a node moves that fraction of the way from its old position to the new one; 1 takes the new position and suits most meshes.

The three numbers may stand on a line of their own after the regions.

What it does

relax solves, by iteration, the equations that make the mesh lines equipotential lines of the region’s boundary, so the elements become even and a skewed or folded interior straightens out. The boundary nodes never move, so the spacing along the boundary stays, but the spacing you gave an edge inside the region is lost. A face that a surface constrains stays on it: James puts every node back on its surfaces in each iteration, and a node on two surfaces slides along their intersection. A face on no surface relaxes free in space, so project a face before you relax it.

A list of faces is smoothed as one system. The edges the faces share move too, and so does a block’s corner where three of the listed faces meet. A node moves only where the listed faces close around it in one ring; a node on the open edge of the list stays, and so does a node on an edge that three listed faces share. A block moves its interior nodes and keeps its six faces; the vertices, edges and partition faces inside a region that spans several blocks are interior and move.

A list is for faces that lie on surfaces. An edge two listed faces share is held to its shape only by the surfaces under it. With none, as on the flat faces of a block, nothing holds the edge: relax draws it in toward the two faces, and the block’s corner is cut. A list whose faces close on themselves and lie on no surface, the six faces of a block, has no fixed node at all and collapses toward its centre, with no warning. For a unit block of ten elements a side, after 200 iterations every coordinate lies between 0.427 and 0.573. Smooth such faces one by one, with relaxi or a relax each, which keeps every edge.

When James applies it

Step 11 for a list of faces, after the faces are interpolated and projected, and step 17 for a block, after the solids are interpolated. Commands at one step run in the order you wrote them. At step 13, after steps 11 and 12, James lays out again the edges next to the smoothed faces, and interpolates and projects again the faces next to them, so that they meet the moved nodes. An edge that a spacing command grades is laid out again with its grading. An edge laid out again is laid out piece by piece between the vertices a smoother held, each piece keeping the grading’s ratio, so no node passes a held vertex. An edge that cur put on a curve keeps the nodes the curve gave it, so if a smoothed face moves the vertex at its end, the edge ends in a kink there; curf on the edge holds the vertex. relax is legal only in the Part phase.

Rules James adds

  • A region that is an edge or a vertex is an error (E1300).
  • A list of two or more regions holds faces only (E1301). One block on its own is accepted.
  • A list holds at most 64 regions. A 65th is an error (E0104).
  • A node next to a deleted region stays where it is, so a hole’s edge acts as boundary. A curf node never moves.
  • Four quadrilaterals of the list meet at almost every node that moves: inside a face, on an edge two faces share, on a step where three planes meet. In this version the one node of a list where any other number meet is the corner of a block where three listed faces meet, and it goes to the average of its neighbours along the mesh lines.
  • Every node of an iteration moves from the positions the previous iteration left, so the result does not depend on the order in which James visits the nodes. A symmetric mesh stays symmetric to rounding: nodes that are images of one another under an exchange of the part’s indices, and mirror images, agree to the last digit or so, because the mesh relax starts from is itself symmetric only to rounding.
  • min_change is measured before a node is put back on its surfaces. On a curved face the change seldom falls below it, so the run usually does all its iterations.
  • The smoothing gives the same result in every pass of mxp: the count of iterations is yours whatever mxp is.
  • On a cylinder part, James smooths the stored radius, angle and height as three numbers, and min_change is in those units.
  • relax does not promise sound elements. Where the boundary has a sharp corner that juts into the mesh, an element beside the corner can end inverted, and the part’s warning about elements with a negative Jacobian reports it (Shaping a part shows one).

Diagnostics

  • E1300: a region is an edge or a vertex.
  • E1301: a list of two or more regions holds a solid block.
  • E1302: the iteration count is missing or is not a positive integer.
  • E1303: min_change is negative.
  • E1304: the weight is not above 0 and at most 1.
  • E0104: a region, min_change or the weight is missing or not a number, or a & stands where the numbers should begin.
  • E0105: a & follows the three numbers, which end the command.
  • E0102: a reduced index lies outside the part.
  • E0106: a range of a region is written high to low.

Example

The script tests/corpus/202-relax-six-faces-list/input.tg, which make test runs:

c relax the six faces of a block on a sphere as one system, the list
c written across lines with & at the line ends
block 1 9;1 9;1 9;-1 1;-1 1;-1 1;
sd 1 sp 0 0 0 1
sfi -1 -2; -1 -2; -1 -2;sd 1
relax 1 1 1 1 2 2 & 2 1 1 2 2 2 &
1 1 1 2 1 2 & 1 2 1 2 2 2 &
1 1 1 2 2 1 & 1 1 2 2 2 2
200 .0001 1
endpart

The block, eight elements a side, has its six faces projected onto the unit sphere. The relax list names the same six faces across three lines, with the numbers on a fourth: at most 200 iterations, stop once no coordinate moves more than 0.0001, weight 1. James stores one row of six faces for step 11 and smooths them as one system, the cube’s edges and corners included, every node staying on the sphere.

See also

  • relaxi: the same command with an index progression, each region smoothed on its own.
  • tme: the smoother that carries the boundary’s spacing inward.
  • sfi: projects the faces that relax then keeps on their surfaces.
  • Shaping a part: the order of steps.

James 0.8.0.

This site uses Just the Docs, a documentation theme for Jekyll.