Professional Documents
Culture Documents
1. Introduction
The last decade has witnessed a resurgence of interest in Cartesian mesh methods
for CFD. In contrast to body-fitted structured or unstructured methods, Cartesian
grids are inherently non-body-fitted; i.e. the volume mesh structure is independent of
the surface discretization and topology. This characteristic promotes extensive auto-
mation, dramatically eases the burden of surface preparation, and greatly simplifies
the re-analysis processes when the topology of a configuration changes. By taking
advantage of these important characteristics, well-designed Cartesian approaches
virtually eliminate the difficulty of grid generation for complex configurations. Typi-
cally, meshes with millions of cells can be generated in minutes on moderately pow-
erful workstations.[1][2]
Although Cartesian grid methods date back to the 1970's, it was only with the
advent of adaptive mesh refinement (AMR) that their use became practical.[11] With-
out some provision for grid refinement, Cartesian grids would lack the ability to effi-
ciently resolve fluid and geometry features of various sizes and scales. This
−1−
Adaptive Cartesian Mesh Generation
resolution is readily incorporated into structured meshes via grid point clustering.
Many algorithms for automatic Cartesian grid refinement have, however, been
developed in the last decade, largely alleviating this shortcoming. Figure 1-1 illus-
trates a typical grid with refinement for discretizing the flow around the General
Dynamics F16XL.
Early work with Cartesian grids used a stair-cased representation of the boundary.
In contrast, modern Cartesian grids allow planar surface approximations at walls,
and some even retain sub-cell descriptions of the boundary within the body-inter-
sected cells. Obviously, this additional complexity places a greater burden on the flow
solver, and recent research has focussed on developing numerical methods to accu-
rately integrate along the surface boundaries of a Cartesian grid.[3][8][9][19][26][27]
The most serious current drawback of Cartesian grids is that their use is restricted
to inviscid or low Reynolds number flows.[28][20] An area of active research is their
−2−
Adaptive Cartesian Mesh Generation
A fairly extensive literature on the flow solvers developed for Cartesian grids with
embedded adaptation is now available. This chapter therefore focuses on efficient
approaches for Cartesian mesh generation. Section 2 contains an overview of Carte-
sian grids, including the geometric information needed by our finite volume flow
solver, and a brief discussion of data structures. Most important are the surface
geometry requirements for the volume mesh generator. Section 3 presents the
details of the volume mesh generation, including the geometric adaptation criteria
and the treatment of the cut cells. Section 4 contains a variety of examples of both
Cartesian meshes and flow solutions. Section 5 includes a discussion of remaining
research issues including approaches for viscous flow. For more thorough discussions
of Cartesian mesh topics, see references [1], [33], or the alternative approaches doc-
umented in [15], [22], or [43].
Cartesian grids pose some unique challenges to the design of efficient finite volume
schemes, accurate surface boundary conditions, and associated data structures.
While most of the cells in the volume mesh may be regular, cells at the boundary
between refinement levels and cells that intersect the surface may have irregular
neighbor connections and computational stencils. Nevertheless, a cell-centered
finite-volume scheme is easily implemented as a summation of flux contributions
from each of a cell's faces:
∂
q dV + ∑ f ⋅ n̂dS = 0
∂t∫
(2.1)
faces
where the flux, f , is computed using the normal vector n̂ and surface area dS associ-
ated with each face. For a simple first-order scheme, the contributions from the flow
faces require the face area vector. More accurate approaches require the positions of
the face and volume centroids. This level of geometric information is sufficient to
support a linear reconstruction of the solution to the face centroid and a second-order
midpoint rule for the flux quadrature.
−3−
Adaptive Cartesian Mesh Generation
Since the cells of a Cartesian grid can intersect the surface geometry in a completely
arbitrary way, general strategies for imposing the surface boundary conditions and
computing the flux contributions from the surface faces must be devised. For inviscid
flow simulations about solid objects, the surface pressure, normal direction, and area
must be available to form the flux contribution from the solid face. Decisions about
the surface representation within each mesh cell must therefore be made. Fre-
quently, schemes utilize the average surface normal and surface area within each cut
cell. Applying the divergence theorem to cell C and its closed boundary ∂C yields:
∫ ( ∇•F ) dV = ∫ ( F ⋅ n̂ )dS
°
C ∂C
Substituting the vector function F = (1, 0, 0) yields an expression for nx, the x-compo-
nent of the surface vector within cell C:
A+x
A-x
n̂ ⋅ A
x S
∫ n x ( dS ) = A – x – A +x = n̂ x ⋅ A Surface (2.2)
bodySurface
A-x and A+x are the exposed areas of the cell’s x-normal faces. This approach for
determining the components of the average surface normal is consistent with the use
of a zeroth-order (constant) extrapolation of the pressure to the surface. Improved
accuracy requires at least a linear extrapolation of the pressure to the surface. Thus,
volume centroids of the cut-cells and area centroids and normals of the individual
surface facets within each cut-cell are required. Borrowing the terminology from
Harten, we refer to this additional geometric data as subcell information.[29]
Although the accuracy improvement that this provides is still being quantified,[9] the
mesh generation algorithm described in this chapter is designed to extract this max-
imal level of geometric detail. The surface flux contributions are incorporated into
the summation of eq. (2.1) in a straightforward manner.
The final piece of geometric information required for an accurate flow solution is pro-
vided by an algorithm for recognition and treatment of “split-cells”, i.e., those Carte-
sian cells that are divided into two or more disjoint regions by thin pieces of surface
geometry. Without an accurate treatment of split cells, the effective chord of a thin
wing may be reduced up to 15% due to an inadequate resolution of thin leading and
trailing edges.[33][30] Successive grid refinements could be used to resolve thin pieces
of geometry. This approach, however, quickly becomes prohibitively expensive in
−4−
Adaptive Cartesian Mesh Generation
three dimensions[34]. Although it complicates the mesh generation, it is far more eco-
nomical to recognize split-cells during the grid generation process and subdivide a
cell into its distinct and separate flow regions.
A second alternative is the use of block structured Cartesian meshes, typically asso-
ciated with the Adaptive Mesh Refinement (AMR) approach.[10][7][11][39][43] In this
approach, cells at a given level of refinement are organized into rectangular grid
patches, usually containing on the order of hundreds to thousands of cells per patch.
This blocking process necessarily flags for inclusion some cells that do not need
refinement. However, this overhead is typically less than 30% of the flagged cells in
time dependent simulations. When the refinement stems from geometry alone, this
number approaches 50%[6]. Nevertheless, the use of a structured array with pre-
scribed connectivity permits an entire grid patch to be stored very compactly in
approximately 20 words of memory. Offsetting this advantage is the fact that effi-
cient schemes for patch-to-patch communication are relatively complex to program.
The third alternative, and the one adopted throughout this chapter, is to use an
unstructured data structure where the connectivity is explicitly stored with the
mesh. The simplifications of using Cartesian grids lead to an extremely compact
data structure. We use a face-based data structure, where the mesh is described by a
list of cell faces that point to the Cartesian cells on either side. Adjacent cells at dif-
ferent levels of refinement (which can differ by at most 1 level) are incorporated into
this structure by having the refined faces point to their respective finer cells on one
side, and the same coarse cell on the other side. Despite the unstructured framework
−5−
Adaptive Cartesian Mesh Generation
for this approach, the Cartesian nature of the hexahedra permit cell and face struc-
tures in the volume mesh to be stored with approximately 9 words per cell. This
number increases to an average of 15 words per cell when including storage for the
geometry and cut-cell information.[2]
−6−
Adaptive Cartesian Mesh Generation
A major criterion for the design of the preprocessor is the robust treatment of geo-
metric degeneracies. In three dimensions, the vast majority of coding effort can be
consumed by the special case handling required for perhaps less than 1% of the
intersections.[24][16] The following presentation initially assumes that no degenera-
cies arise. This restriction is lifted in later sections, where a consistent algorithmic
approach for treating degeneracies is discussed. The approach is automatic, and does
not require special case coding.
For robustness, the intersection of two triangles is computed in two steps. First, the
topological connectivity is determined using geometric primitives and robust arith-
metic. This step treats the input triangles as “exact”. Once the logical connectivity
has been established, the actual location of the intersection points of the two trian-
gles is computed using (unreliable) floating-point arithmetic. For example, due to the
limited precision of floating-point math, a constructed intersection point may actu-
ally lie slightly outside a triangle’s interior. To avoid robustness problems arising
from such circumstances, these situations are resolved using the robustly computed
logical connectivity.
−7−
Adaptive Cartesian Mesh Generation
Both of these tests can be recast as the evaluation of the signed volume of a tetrahe-
3
dron, where the points p, q, r, s are vertices of triangles in R . The volume of a tetra-
hedron is
p0 p1 p2 1
q0 q1 q2 1
6V ( T p, q, r, s ) = (2.3)
r0 r1 r2 1
s0 s1 s2 1
For example, let triangle T1 have vertices {0,1,2} and let (a,b) be an edge of triangle
T2. The edge intersects the plane of T1 if V( T 0, 1, 2, a ) has a different sign than
V( T 0, 1, 2, b ). The edge intersects in the interior of T1 if V( T a, 1, 2, b ), V( T a, 0, 1, b ) and
V( T a, 2, 0, b ) all have the same sign. Thus at most five determinant evaluations are
done for each of the six triangle edges. Note that the only information needed from
the evaluation of the determinant is its sign.
Using the adaptive floating point precision package of Ref.[47], for example, this
determinant can be computed reliably and quickly, even for degenerate cases where
the determinant evaluates to exactly zero (indicating a degeneracy, see §2.3.4). Most
of the time, the computation of the sign of the determinant can be done using ordi-
nary floating-point arithmetic. This sign is valid, provided that it is larger than an
error bound which is computed using knowledge of the properties guaranteed by the
IEEE floating-point arithmetic standard.[48],[1] Only if the error bound exceeds the
computed value of the determinant does a more accurate evaluation need to done
using an adaptive-precision floating-point library (see [42] or [47]). After the exist-
ence of an intersection is robustly established, the algorithm uses the usual floating-
point arithmetic to construct the actual location of the intersection point.
The result of the preceeding intersection step is a list of line segments linked to each
intersected triangle. These segments divide the intersecting triangles into polygonal
regions that are either completely inside or outside the body. In order to remove the
portions of the triangles that are interior, we first triangulate the polygonal regions,
treating the original intersection segments as constraints, and then discard those
triangles lying inside the body. In an effort to maintain well-behaved triangles, we
use a constrained Delaunay triangulation algorithm to maximize the minimum
−8−
Adaptive Cartesian Mesh Generation
Component A
Component B
Intersection
2.3.3 Inside/Outside
The final step in the intersection process is the classification of the resulting set of
triangles into those that are either internal to the geometry or exposed and on the
wetted surface of the configuration. The algorithm for inside/outside classification is
also used during volume mesh generation and is presented in §3.2.3.
The preceding discussion assumed that the input geometry was free from degenerate
data. In other words, the determinants in §2.3.1 always evaluate to a non-zero num-
ber. However, degeneracies are common in input geometry, and most of the complica-
tion in the grid generation arises from such cases.[16] For example, if four input
points are exactly co-planar, the determinant in eq. (2.3) will return exactly zero. For
an algorithm to be robust, such degeneracies must be resolved in a consistent man-
ner[58][57].
−9−
Adaptive Cartesian Mesh Generation
enough to break all degeneracies but small enough to not perturb the general data.
As long as all determinant evaluations use this same perturbation, this tie-breaking
algorithm consistently resolves degeneracies by reporting the sign of the perturbed
determinant as positive or negative. By basing it on the global index of a node, the
perturbation is consistent across all points in the geometry.
iδ – j
2
( E ) i, j = ε i, j = ε , 1 < j < d, δ≥d (2.4)
1⁄2 1⁄4
T =
a0 a1
,E = ε ε (2.5)
b0 b1 2 1
ε ε
Then
1⁄4 1⁄2 3⁄2 2 9⁄4
det ( T + E ) = det ( T ) + ( – b 0 )ε + ( b 1 )ε + ( a 0 )ε + ε + ( – a 1 )ε + ( – 1 )ε (2.6)
The fifth term in the expansion has a coefficient of 1. Thus, if each of the first four
terms evaluate to 0, the sign of the result would be taken to be positive. In three
dimensions there are 15 possible terms in the expansion that generalizes eq. (2.6)
before a constant term is reached (the sign of which conclusively establishes the sign
of the original determinant). In practice, rarely are more than two or three terms
evaluated before a non-zero coefficient is found. The virtual perturbation computa-
tions can be easily incorporated into the low-level subroutine which evaluates the
determinant in eq. (2.3).
− 10 −
Adaptive Cartesian Mesh Generation
3.1 Overview
Cartesian mesh generation is ostensibly a simple task, where the only complications
stem from the presence of body-cut cells and refinement boundaries. Since these
occur as lower-dimensional features, the vast majority of the cells in the final mesh
are regular, non-body-intersecting, Cartesian hexahedra. Since generation of uni-
form Cartesian cells is extremely fast, the performance of the overall algorithm
depends directly on the treatment of cut-cells and the scheme used for adaptive
refinement. The following discussions place special emphasis on the performance of
the algorithms for generating large numbers (106–108) of cells. Wherever possible,
the methods seek to maintain linear or logarithmic time complexity so that the
expense of generating the volume mesh is not dominated by poor algorithmic perfor-
mance on lower-dimensional collections of cells.
This section begins by highlighting the important algorithms for volume mesh gen-
eration, including the detection of cells which lie within solid portions of the geome-
try and the geometric criteria for cell division. Note that in addition to geometric
refinement, flow-field refinement is possible, and in fact, essential. Finally, a variety
of algorithms are presented which permit very rapid computation of the geometric
information necessary to describe the body-cut cells themselves.
The mesh generation process begins with an initial coarse mesh (or even a single
cell) covering the domain of interest. This mesh is then repeatedly subdivided to
resolve the boundary of the geometry. After each refinement, cells which lie com-
pletely inside the body are removed from the mesh. Only when the generation of the
volume mesh is complete does the algorithm compute the details of the cut-cell inter-
sections with the surface geometry. Adopting this strategy decouples operations
within the body-cut cells from the volume mesh generation process.
Figure 3-1 shows an example of a coordinate aligned Cartesian mesh defined by its
minimum and maximum coordinates x o and x 1 . This region is subdivided with Mj
possible coordinates in each dimension, j = { 0, 1, 2 } . Thus, each node in the mesh
− 11 −
Adaptive Cartesian Mesh Generation
may be specified exactly by the integer vector, i , and the Cartesian coordinates, x i ,
of any allowable location in this mesh are reconstructed when needed from
ij
x i = x 0 + ------- ( x 1 – x 0 ) (3.1)
j j Mj j j
( x 1 0 , x 1 1, x 1 2 )
M2 partitions
1
0
( x o0, x o1, x o2 )
M0
pa
rti
ns
titio
tio
par
ns
M 1
Figure 3-1: Cartesian mesh with Mj total divisions in each direction discretizing
the region from xo to x1.
Assume that the intersection algorithm of section 2.3 returns a set of triangles {T}
which describe the wetted surface of the configuration. If theNT surface triangles in
{T} are inserted into a efficient spatial data structure such as an ADT, then locating
the subset {Ti} of triangles actually intersected by the ith Cartesian cell will have
complexity proportional to log ( N T ) . When a cell is subdivided, a child cell inherits
the triangle list of its parent. As the mesh subdivision continues, the triangle lists
connected to a surface intersecting (“cut”) Cartesian cell will get shorter by approxi-
− 12 −
Adaptive Cartesian Mesh Generation
Cut-Cell i “Children of i”
Figure 3-2: List of triangles associated with children of a cut-cell may be obtained using ADT, or
by exhaustively searching over the parent cell’s triangle list.
mately a factor of 4 with each successive subdivision. Figure 3-2 illustrates the pass-
ing of a parent cell’s triangle list to its children.
This observation implies that there is a machine dependent crossover beyond which
it becomes faster to simply perform an exhaustive search over a parent cell’s triangle
list rather than perform an ADT lookup to get a list of intersection candidates for cell
i. This is easy to envision, since all of the triangles that are linked to a child cut-cell
must have originally been members of the parent cell’s triangle list. If a parent cell
intersects only a very small number of triangles, then there is no reason to perform a
full intersection check using the ADT. The crossover point is primarily determined
by the number of elements in NT and the processor’s data cache size.
A body-intersecting parent cell may find that some of its children cells lie completely
inside the body. These cells must be identified and removed from the mesh. Determi-
nation of a cell’s status as “flow”, or “solid” is a specific application of thepoint-in-
polyhedron problem that is frequently encountered in computational geometry.
Figure 3-3 illustrates two common containment tests for a cell q and a simply con-
nected polygon P. On the left side of the sketch, the winding number[25] is computed
by completely traversing the closed boundary P from the perspective of an observer
located on cell q, and keeping a running total of the signed angles between succes-
sive polygonal edges. As shown in the left of the sketch, if q ∉ P then the positive
− 13 −
Adaptive Cartesian Mesh Generation
∂P ∂P r
q q
P P
Figure 3-3: Illustration of point-in-polygon testing using the (left) winding number and
(right) “ray-casting” approac hes for determining if q is inside or outside of P.
angles are erased by the negative contributions, and the total angular turn is identi-
cally zero. If, however, q ∈ P , then the winding number is 2π.
While both approaches are conceptually straightforward, they are considerably dif-
ferent computationally. Computation of the winding number involves floating-point
computation of many small angles, each of which is prone to round-off error. The run-
ning sum will make these errors cumulative, increasing the likelihood of robustness
pitfalls. In addition, the method answers the topological question “Inside or outside?”
with a floating-point comparison. By contrast, the ray-casting algorithm poses the
inside/outside question in topological terms (i.e., “Does it cross?”).
The ray-casting approach fits well within the search and intersection framework
developed earlier. Let point q lie on any non-intersected cell in the domain. Then
assume r is cast along a coordinate axis (+x for example) and truncated just outside
the +x face of the bounding-box for the entire configuration. This ray may then be
represented by a line segment from the test point (q0, q1, q2) to ( ∂Ω x + ε, q 1, q 2 ) and
the problem reduces to that of finding a list of intersection candidates for the seg-
ment-triangle intersection algorithm as in §2.3.1. The tree returns the list of inter-
section candidates while the signed volume in eq. (2.3) checks for intersections.
Counting the number of such intersections determines a cell’s status as inside or out-
side. Using a spatial data structure like an ADT to return the list of intersection can-
didates for r makes it possible to identify this list in a time proportional to log ( N T ) .
− 14 −
Adaptive Cartesian Mesh Generation
In addition, computing intersections between the Cartesian cells and surface trian-
gulation via signed volume computations opens the possibility of utilizing exact
arithmetic and generalized tie-breaking algorithms from §2.3.4 to address issues of
robustness.
The ray casting operation in the preceeding section takes log ( N T ) time. However, it
is common to have to perform the in/out test on potentially large lists of Cartesian
cells. A painting algorithm makes it possible to avoid casting as many rays as there
are cells. Such an algorithm traverses a topologically connected set of cells while
passing the status (“flow”/“solid”) of one cell to other cells in its neighborhood. Some
details of such an algorithm are presented in [1] where it is demonstrated that mesh
traversal may be accomplished with a linear time bound. These techniques make it
possible to cast only as many rays as there are topologically disjoint regions of cells.
All surface intersecting Cartesian cells in the domain are initially automatically
refined a specified number of timesR(min)j. Typically this level is set to be four divi-
sions less than the maximum allowable number of divisions (Rmax)j in each direction.
Anytime a cut-cell is tagged for division, the refinement must be propagated several
(usually 3-5) layers into the mesh using a “buffering” algorithm whic h operates by
sweeps over the faces of the cells. Buffering is required to maintain mesh smooth-
ness and avoid corruption of the difference stencil in the immediate vicinity of the
body.
Further refinement is based upon a curvature detection strategy similar to that orig-
inally presented in [33]. This is a two-pass strategy which first detects angular vari-
ation of the surface normal, n̂ , within each cut cell and then examines the average
surface normal behavior between adjacent cut cells.
− 15 −
Adaptive Cartesian Mesh Generation
Cell r Cell s
Cell i φ
n̂ r
θ n̂ s
Ti
Figure 3-4.a: Measurement of Figure 3-4.b: Measurement of
the maximum angular vari- the angular variation
ation within cut-cell i. between adjacent cut-cells.
Taking k as a running index to sweep over the set of triangles {Ti}, let V j represent
the jth component of the vector subtraction between the maximum and minimum
components of the normal vectors in each Cartesian direction:
The direction cosines of V then provide a measure of the angular variation of the
surface normal within cell i.
Vj
cos ( θ ji ) = ------- (3.3)
V
Similarly, (φj)r,s measures the jth component of the angular variation of the surface
normals between any two adjacent cut cells r and s. With n̂ i denoting the average
unit normal vector within any cut cell i, the components of φ r, s are:
nj – nj
cos ( φ j ) r s
-.
= --------------------- (3.4)
r, s n̂ r – n̂ s
If θj or φj in any cell exceeds a preset angle threshold, the offending cell is tagged for
subdivision in direction j. Figures 3-4.a and 3-4.b illustrate the construction of φ and
θ in two dimensions.
Obviously, by varying these thresholds, one may control the number of cut-cells that
are tagged for geometric refinement. When both thresholds are identically 0˚, all the
cut cells will be tagged for refinement, and when they are 180˚ only those at sharp
cusps will be tagged. Reference [1] presents an exploration of the sensitivity to varia-
tion of these parameters for angles ranging from 0˚ to 179˚ on several example con-
figurations. In practice, both of these thresholds are generally set at 20˚.
− 16 −
Adaptive Cartesian Mesh Generation
In three dimensions, the surface triangulation will cut arbitrarily through the body
intersecting Cartesian cells. The resulting intersections can therefore be quite com-
plex. We can begin to understand the details of such an intersection by considering
the generic cut-cell illustrated in Figure 3-5. The abstraction shown in the sketch
presents a single cut-cell, c, which is linked to a set {Tc } of four triangles (T0-T3)
which comprise the small swatch of the configuration’s surface triangulation inter-
sected by the cell. Since both the Cartesian cell and the triangles are convex, the
intersection of each triangle with the cell produces a convex polygon referred to as a
triangle-polygon, tp. Edges of the triangle-polygons are formed by the clipped edges
of the triangles themselves, and the face-segments, fs, which result from the intersec-
tion of the triangles with the faces of the Cartesian cell. On the Cartesian cells them-
selves, these segments lead to face-polygons, fp, which consist of edges from the
Cartesian cell and the face segments from the triangle-face intersection. Note that
triangle-polygons are always convex, while face-polygons may not be (e.g. face-poly-
gons fp0,1, fp5,0, and fp5,1 in Figure 3-5).
Clearly, these intersections may become very complex. It is easy to envision the
pathological case where an entire configuration intersects only one or two Cartesian
cells, creating tens of thousands of triangle polygons. Thus, an efficient implementa-
tion is of paramount importance. Many of the algorithms for efficiently constructing
this geometry rely on techniques from the literature on computer graphics and are
highly specialized for useAnatomy
with coordinate aligned
of an Abstract Cell [18][51] In principle, similar
regions.
Cut
fp30
fp01
fs00 fp51
fs01
fs50 tp0 T2
fs51 fs52 T0
tp1 tp2
tp3 T3
fp00 T1
x1
fp50
F[0−5] − Hex cell faces
fp[face#][poly#] − Face polygons x0
fs[face#][seg#] − Face segments x2
T[0−n] − Intersected Triangles
tp[0−n] − Intersected Triangle polygons
Figure 3-5: Anatomy of an abstract cut-cell.
− 17 −
Adaptive Cartesian Mesh Generation
methods could be adopted for non-Cartesian hexahedra, or even other cell types,
however, speed and simplicity would be compromised. Since rapid cut-cell intersec-
tion is an important part of Cartesian mesh generation, we present a few central
operations in detail.
Figure 3-6 shows a two-dimensional Cartesian cell c that covers the region [ c, d ] .
The points (p, q,...,v) are assumed to be vertices of c’s candidate triangle list Tc. Each
vertex is assigned an “outcode”associated with its location with respect to cell c. This
code is really an array of flags which has a “low” and a “high” bit for eac h coordinate
direction, [ lo 0, hi 0, …, lo d – 1, hi d – 1 ] . Since the region is coordinate aligned, a single
inequality must be evaluated to set each bit in the outcode of the vertices. Points
inside the region, [c, d], have no bits set in their outcode.
Using the operators & and | to denote bitwise applications of the “and” and “or” Bool-
ean primitives, candidate edges (like rs) can be trivially rejected as not intersecting
cell c if:
This reflects the fact that the outcodes of both r and s will have their low x bit set,
thus neither point can be inside the region. Similarly, since
(outcodet | outcodev) = 0, the segment tv must be completely contained by the
region [c, d] in the figure.
p
1001 0001 0101
s
(d0, d1) p’
facecode3=0001
r q
facecode1=0100
facecode0=1000
t u
t’
facecode2=0010
(c0, c1)
− 18 −
Adaptive Cartesian Mesh Generation
If all the edges of a triangle, like ∆tuv, cannot be trivially rejected, then there is a pos-
sibility that it intersects the 0000 region. Such a polygon can be tested against the
face-planes of the region by constructing a logical bounding box (using a bitwise “or”)
and testing against each facecode of the region. In Fig. 3-6, testing
produces a non-zero result only for the 0100 face. In eq. (3.6), the logical bounding
box of ∆tuv is constructed by taking the bitwise “or” of the outcodes of its vertices
.
There are clearly many alternative approaches for implementing the types of simple
queries that this section describes. However, an efficient implementation of these
operations is central to the success of a Cartesian mesh code. The bitwise operations
and comparisons detailed in the proceeding paragraphs generally execute in a single
machine instruction making this a particularly attractive approach. Further discus-
sion of the use of outcodes may be found in [18].
With the fast spatial comparison operators in the previous section outlined, we are
ready to construct the triangle-polygons and face-segments that describe the surface
within the Cartesian cell. The triangle-polygons (tp0-tp4) in Figure 3-5 are the
regions of the triangles that lie within the cut-cells. Thus, extraction of the triangle-
polygons is properly thought of as a clipping operation performed on each triangle.
The term “clipping” refers to a process where one object acts as a “window” and we
compute the parts of a second object visible through this window[25]. Numerous algo-
− 19 −
Adaptive Cartesian Mesh Generation
rithms have been proposed for the clipping of an object against a rectangular or cubi-
cal window.[32][37] In this section we apply an algorithm due to Sutherland and
Hodgman for clipping against any convex window[51]. While slightly more general
than is absolutely necessary, this algorithm has the attractive property that the out-
put polygon is kept as an ordered list of vertices.
The asymptotic complexity of this clipping algorithm is O(pq), where p is the degree
of the clip window and q is the degree of the clipped object. While this time bound is
formally quadratic, p for a 3-D Cartesian cell is only 6, and the fast intersection
checks of the previous section permit very effective filtering of trivial cases.
The algorithm is conveniently implemented as two nested loops. The outer loop
sweeps over the clip-border (cell faces in 3-D), while the inner is over the edges of the
polygon. In our application to the intersected triangles, the initial input polygon is
Input Polygon
Output Polygon
Clip
Clip Window
Output Polygon
Infinite Clip Boundary
− 20 −
Adaptive Cartesian Mesh Generation
facecode1=0100
facecode0=1000
1000 0000 v 0100
2
p T tp
v1
facecode2=0010
(c0, c1)
the triangle T, and the clip-window is the cut Cartesian cell. Implementation of the
algorithm requires testing of the input triangle’s edges against the clip region, so it
is useful to combine this algorithm with the outcode flags discussed in the previous
section.
Figure 3-8 illustrates the clipping problem (in 2-D) for generating the triangle-poly-
gons shown in the view of an abstract cut-cell in Figure 3-5. In the sketch above, the
triangle T is formed by the set of directed edges, v 1 v 0 , v 2 v 1 , and v 0 v 2 , and the clipped
polygon, tp, is a quadrilateral.
As the edges of the input polygon are processed by each clip-boundary the output
polygon is formed according to a set of four rules. For each directed edge in the input
polygon we denote the vertex at the origin of the edge as “ orig” and the vertex of the
destination as “
dest”. “IN” implies that the test vertex is on the same side of the clip-
boundary as the clip-window. We may test for this by examining the outcode of each
vertex, and comparing to the facecode of the current-clip boundary. A test vertex is
“IN” if its outcode does not ha ve the bit associated with the facecode of the clip-
boundary set, while “OUT” implies that this bit is set. Using the bitwise operators
from the previous section:
With these definitions, the output polygon is constructed by traversing around the
perimeter of the input polygon and applying the following rules to each edge.
Table 3.1 summarizes the actions of the Sutherland-Hodgman algorithm.
− 21 −
Adaptive Cartesian Mesh Generation
Notice that both SH.2 and SH.4 describe cases where the edge of the input polygon
crosses the clip-boundary. In both of these cases, we must add the point of intersec-
tion of the edge with the clip-boundary to the output polygon. This point may be
almost trivially constructed since the clip-boundary is coordinate aligned. For the
example in Figure 3-8, the constructor for point p, which is the intersection of edge
v 2 v 1 with the right side of the clip-boundary, reduces to
p = v1 + α ( v2 – v1 ) (3.9)
where α is simply the distance fraction in the horizontal coordinate of the clip bound-
ary between vertices v1 and v2.
Returning to the cut-cell shown in Figure 3-5, we note that the face-segments are the
edges of the triangle-polygons (just created) that result from a clip. The face-poly-
gons are formed by simply connecting loops of cut-cell edges with these face-seg-
ments. Thus, all the necessary elements of the cut-cell have been constructed.
Since the Sutherland-Hodgman algorithm was originally developed for window clip-
ping in computer graphics, both hardware and software versions of it are available
on many platforms. Thus, on platforms with advanced graphics hardware, it is fre-
quently possible to make direct calls to the hardware clipping routines to perform
the polygon clipping discussed in the preceding paragraphs. Such hardware imple-
mentations typically execute tens to hundreds of times faster than software imple-
mentations. Similarly, many of the fast bitwise comparisons in the previous section
are often available as hardware routines.
Figure 3-9 shows an example of the intersection between the body-cut Cartesian
cells and the surface triangulation of a High Wing Transport configuration. In this
case approximately 500,000 cells in the Cartesian mesh intersected the surface tri-
angulation. The figure shows a view of the port side of the aircraft and two zoom-
boxes with successive enlargements of the triangle-polygons resulting from the
− 22 −
Adaptive Cartesian Mesh Generation
Figure 3-9: Triangle-polygons on surface of High Wing Transport configuration resulting from
intersection of body-cut Cartesian cells with surface triangulation.
4. Examples
− 23 −
Adaptive Cartesian Mesh Generation
Figure 4-1: Adapted mesh and computed isobars for inviscid flow over an ONERA M6 wing at
Mach 0.84 and α = 3.06˚.
4.1.1 ONERA M6
The flow field about the ONERA M6 wing w as computed at the standard test condi-
[4][46]
tions of Mach 0.84 and α = 3.06˚. The cells in the original mesh were subdivided
up to nine times, resulting in a total of 1.2 million cells. The left frame in Figure 4-1
shows an isometric view of this final mesh, including the symmetry plane and por-
tions of the mesh at three outboard stations, while the frame at the right contains
the corresponding surface and flow field isobars . Figure 4-2 compares computed
pressure distributions for this wing at five locations along the span with experimen-
tal data [46].
20% Span 44% Span 65% Span
-1.4 -1.4 -1.4
-1.2 -1.2 -1.2
-1.0 -1.0 -1.0
-0.8 -0.8 -0.8
-0.6 -0.6 -0.6
-0.4 -0.4 -0.4
Cp
-0.2 -0.2
0.0 0.0
0.2 0.2
0.4 0.4
0.6 0.6
0.8 0.8
0.0 0.2 0.5 0.7 1.0 0.0 0.2 0.5 0.7 1.0
x/c x/c
Figure 4-2: . Cp vs x/c at 2y/b = 0.2, 0.4, 0.65, 0.8 and 0.95.
− 24 −
Adaptive Cartesian Mesh Generation
As is typical of other high-resolution Euler computations for this case, these solu-
tions overpredict the strength of the main shock, but in general, the pressure distri-
butions compare well with those presented by other researchers. Additional
information about these computations is presented in [33]. The lift and drag coeffi-
cients for this case were 0.275 and 0.0128 respectively.
The next four examples of Cartesian grids and steady-state simulations illustrate
the geometric complexity that is now routinely simulated with Cartesian methods.
Designers, project engineers, and other non-CFD-experts must often repeatedly ana-
lyze realistic configurations such as these in order to improve aerodynamic perfor-
mance. The level of automation attainable with Cartesian approaches makes them
particularly attractive for time-critical applications.
Figure 4-3 shows a Cartesian mesh with 5.81M cells discretizing the space around a
McDonnell Douglas Apache attack helicopter. The configuration is composed of
320,000 triangles describing 85 separate components, including armaments, wing
stores, night-vision equipment, and avionics packages. The surrounding flow field
mesh was generated in 320 seconds on a moderately powerful engineering worksta-
tion (MIPS 195Mhz R10000 CPU). The only user inputs to the mesh program were
the dimensions of the bounding box of the outer domain, a clustering parameter that
controls the refinement on the surface, and a target number of cells in the final
mesh. Figure 4-4 displays the computed isobars on this same configuration on a
coarser mesh of approximately 1.2M cells.
Figure 4-3: Upper: Cartesian mesh for attack helicopter configuration with 5.81M cells. Lower:
Close-up of mesh through left wing and stores.
− 25 −
Adaptive Cartesian Mesh Generation
Figure 4-5 shows two views of a mesh generated after positioning three F-15 aircraft
in formation with the Apache helicopter. The helicopter is offset from the axis of the
lead fighter to emphasize the asymmetry of the mesh. Each fighter has flow-through
inlets and is described by 13 individual component triangulations and 201,000 trian-
gles. After surface preprocessing, the entire four-aircraft configuration contained 121
Figure 4-5: Cutting planes through mesh of multiple aircraft configuration with 5.61M
cells and 683,000 triangles in the triangulation of the wetted surface.
− 26 −
Adaptive Cartesian Mesh Generation
components described with 683,000 triangles. The lower frame in Figure 4-5 shows
portions of three cutting planes through the mesh and geometry, while the upper
frame shows one cutting plane at the tail of the rear two aircraft, and another just
under the helicopter geometry. The final mesh includes 5.61M cells, and required a
maximum of 365Mb to compute. Mesh generation time was approximately 6 minutes
and 30 seconds on a workstation with a MIPS 195Mhz R10000 CPU.
Figure 4-6: HWT example with high-lift system deployed. The mesh contains 1.65M cells at 10
levels of refinement. The mesh is presented by cutting planes at 3 spanwise locations and the
cutting plane on the starboard wing is flooded by isobars of the discrete solution.
− 27 −
Adaptive Cartesian Mesh Generation
tion is inviscid, the sharp outboard corner of the flap has correctly spawned a flap
vortex, which is evidenced by the twisting stream ribbon in the figure. Additional
information about the solution can be found in [3].
5. Research Issues
Figure 5-1: Density contours and adapted quadtree grids showing a time history of a
projectile penetration problem (reprinted from Ref. [40] with permission).
− 28 −
Adaptive Cartesian Mesh Generation
6. Summary
The adaptive Cartesian mesh approach demonstrates great potential for dramati-
cally accelerating the routine inviscid analyses of complex configurations. Many of
the advantages of Cartesian grids arise from the independence of the surface
description from the flow field discretization and the resultant ease and speed with
which grids can be generated. Incorporating a component-based Cartesian
approach also streamlines the surface definition process. New configurations can
be quickly assembled from libraries of existing components, and individual compo-
nents can be easily repositioned using simple transformations. Additionally, con-
ventional inviscid finite volume flow solver sc hemes can be straightforwardly
modified and implemented on Cartesian grids.
− 29 −
Adaptive Cartesian Mesh Generation
Although many of the geometric algorithms described in this chapter have their
roots in the fields of computer graphics and computational geometry , they are well-
suited for robust Cartesian grid generation. With appropriate attention to algorith-
mic complexity and careful programming, the resulting codes can be designed to run
extremely efficiently on current workstations. By taking full advantage of the natu-
ral simplicity of Cartesian grids, a fast, automated, robust, and low-memory grid
generation scheme can be developed.
Acknowledgments
This work was supported in part by NASA Ames Research center, by DOE Grants
DE-FG02-88ER25053 and DE-FG02-92ER25139, and by AFOSR grant F49620-97-
0322. Thanks also to RIACS, whose support of Dr. M. Berger is gratefully acknowl-
edged.
References
[1] Aftosmis, M.J., Solution adaptive Cartesian grid methods for aerodynamic flows with
complex geometries, von Karman Institute for Fluid Dynamics, Lecture Series 1997-02,
Rhode-Saint-Genèse, Belgium, Mar. 3-7, 1997.
[2] Aftosmis, M.J., Berger, M.J., Melton, J.E., “Robust and efficient Cartesian mesh gener-
ation for component-based geometry,” AIAA Paper 97-0196, Jan. 1997.
[3] Aftosmis, M.J., Melton, J.E., and Berger, M.J., “ Adaptation and Surface Modeling for
Cartesian Mesh Methods,” AIAA Paper 95-1725-CP, Jun., 1995.
[4] AGARD Fluid Dynamics Panel, “T est cases for inviscid flow field methods
,” AGARD
Advisory Report AR-211. May 1985.
[5] Bayyuk, S., Euler Flows with Arbitrary Geometries and Moving Boundaries. Ph.D the-
sis, Dept. of Aero. and Mech. Eng., Univ. of Mich., 1996.
[6] Berger M.J., Aftosmis, M.J., and Melton, J.E., “ Accuracy, adaptive methods and com-
plex geometry,” Proc. 1st AFOSR Conf. on Dynam. Mot. in CFD. Rutgers, NJ 1996.
[7] Berger M.J., and Colella, P., “Local adaptive mesh refinement for shoc k hydrodynam-
ics.” Jol. of Comp. Physics, 82:64-84, 1989
[8] Berger, M., and LeVeque, R., “Stable Boundary Conditions for Cartesian Grid Calcula-
tions”, ICASE Report No. 90-37, 1990.
[9] Berger, M., and Melton, J.E., “ An Accuracy Test of a Cartesian Grid Method for Steady
flow in Complex Geometries,” Proc. 8thrIntl. Conf. Hyp. Problems, Uppsala, Stony-
brook, NY, Jun., 1995. also RIACS Report 95-02.
[10] Berger, M.J., and LeVeque, R., “Cartesian Meshes and Adaptive Mesh Refinement for
Hyperbolic Partial Differential Equations”, Proc. 3rd Intl. Conf. Hyp. Problems, Upp-
sala, Sweden, 1990.
[11] Berger, M.J., and Oliger, J., “Adaptive mesh refinement for hyperbolic partial differen-
tial equations.” Jol. of Comp. Physics. 53:482-512, 1984.
[12] Bonet, J., and Peraire, J., “An alternating digital tree (ADT) Algorithm for Geometric
Searching and Intersection Problems.” Int. J. Num. Meth. Engng, 31:1-17, 1991.
[13] Chan, W. M. and Meakin, R. L., “ Advances towards automatic surface domain decom-
position and grid generation for overset grids,” AIAA Paper 97-1979, in Proceed. of the
AIAA 13th Comp.Fluid Dyn. Conf., Snowmass, Colorado, Jun. 1997.
[14] Charlton. E.F., and Powell, K.G., “ An octree solution to conservation-laws over arbi-
trary regions (OSCAR).” AIAA Paper 97-0198, Jan. 1997.
− 30 −
Adaptive Cartesian Mesh Generation
[15] Charlton. E.F., An octree solution to conservation-laws over arbitrary regions (OSCAR) with
applications to aircraft aerodynamics.Ph.D. Thesis, Univ. of Mich., Dept. of Aero. and Astro.
Engr., 1997.
[16] Chazelle, B., et al., Application Challenges to Computational Geometry: CG Impact Task
Force Report. TR-521-96. Princeton Univ., Apr. 1996.
[17] Chew, L.P., “Constrained Delauna y triangulations,” Algorithmica, 4:97-108, 1989.
[18] Cohen, E., “Some Mathematical T ools for a Modeler’s Workbench,” IEEE Comp. Graph. and
App., 3(7), Oct. 1983.
[19] Coirier, W. J., and Powell, K. G., “ An Accuracy Assessment of Cartesian-Mesh Approaches
for the Euler Equations”, AIAA Paper 93-3335-CP, July, 1993.
[20] Coirier, W.J., “An Adaptively-Refined, Cartesian, Cell-Based Scheme for the Euler Equa-
tions,” NASA TM-106754, Oct., 1994. also Ph.D. Thesis, Univ. of Mich., Dept. of Aero. and
Astro. Engr., 1994.
[21] De Floriani, L., and Puppo, E. "An on-line algorithm for constrained Delaunay triangula-
tion," CVGIP: Graphical Models and Image Proc. 54(3)290:300., 1992.
[22] De Zeeuw, D., and Powell, K., “ An Adaptively-Refined Cartesian Mesh Solver for the Euler
Equations,” AIAA Paper 91-1542, 1991.
[23] DT_NURBS Spline Geometry Subprogram Library Theory Document, version 3.3. USN Sur-
face Warfare Center/Carderock Div. David Taylor Model Basin, Bethesda MD. CARD-
EROCKDIV-94/000, Dec. 1996.
[24] Edelsbrunner H., and Mücke E.P., “Simulation of Simplicity: A T echnique to cope with
degenerate cases in geometric algorithms.” ACM Transactions on Graphics, 9(1):66-104,
Jan. 1990.
[25] Foley, J., van Dam, A., Feiner, S., Hughes, J., Computer Graphics: Principles and Practice,
ISBN 0-201-84840-6, Addison-Wesley, Reading, MA, 1995.
[26] Forrer, H., Boundary Treatment for a Cartesian Grid Method, Seminar für Angewandte
Mathmatic, ETH Zürich, ETH Research Report No. 96-04, 1996.
[27] Forrer, H., Second Order Accurate Boundary Treatment for Cartesian Grid Methods, Semi-
nar für Angewandte Mathmatic, ETH Zürich, ETH Research Report No. 96-13, 1996.
[28] Gooch, C.F., “Solution of the Na vier-Stokes Equations on Locally-Refined Cartesian
Meshes,” Ph.D. Dissertation, Dept. of Aero. Astro. Stanford Univ., Dec., 1993.
[29] Harten, A., "ENO Schemes with Subcell Resolution," ICASE Report 87-56, Aug. 1987.
[30] Karman, S.L.Jr., “SPLITFLOW : A 3D Unstructured Cartesian/Prismatic Grid CFD Code for
Complex Geometries,” AIAA 95-0343, Jan., 1995.
[31] Keener, E. R., “Pressure-Distribution Measurements on a Transonic Low-Aspect Ratio
Wing,” NASA TM-86683, 1985.
[32] Liang, Y., and Barsky, B.A., “ An analysis and algorithm for polygon clipping,” Comm. of the
ACM, 26(3):868-877, 1983.
[33] Melton, J.E., Automated Three-Dimensional Cartesian Grid Generation and Euler Flow
Solutions for Arbitrary Geometries, Ph.D. thesis, Univ. CA. Davis, Davis, CA, 1996.
[34] Melton, J.E., Berger, M.J., Aftosmis, M.J., and Wong, M.D., “3D Applications of a Cartesian
Grid Euler Method,” AIAA Paper 95-0853, Jan., 1995.
[35] Melton, J.E., Enomoto, F.Y., and Berger, M.J., “3D Automatic Cartesian Grid Generation for
Euler Flows,” AIAA Paper -93-3386-CP, Jul., 1993.
[36] Melton, J.E., Pandya, S., and Steger, J., "3-D Euler solutions using unstructured Cartesian
and prismatic grids", AIAA Paper 93-0331, Jul. 1993.
[37] Newman, W.M., Sproull, R.F., Principles of Interactive Computer Graphics, 2nd ed.,
McGraw-Hill, NY, 1979.
[38] O’Rourke, J., Computational Geometry in C, Cambridge Univ. Press, NY, 1993.
[39] Pember, R.B., Bell, J.B., Colella, P., Crutchfield, W.Y., and Welcome, M.L., “
An adaptive Car-
tesian grid method for unsteady compresible flow in irregular regions,” Jol. of Comp. Phy.,
120:278-304, 1995.
[40] Powell, K., Solution of the Euler and Magnetohydrodynamic Equations on Solution-Adap-
tive Cartesian Grids, von Karman Institute for Fluid Dynamics, Lecture Series 1994-05,
Rhode-Saint-Genèse, Belgium, Mar. 1996.
[41] Preparata, F.P., and Shamos, M.I., Computational Geometry: An Introduction, Springer-Ver-
lag, 1985
[42] Priest, D.M., “ Algorithms for arbitrary precision floating point arithmetic,” Tenth Sympo-
sium on Computer Arithmetic, pp. 132-143, IEEE Comp. Soc. Press, 1991.
− 31 −
Adaptive Cartesian Mesh Generation
[43] Quirk, J., “An alternative to unstructured grids for computing gas dynamic flows around
arbitrarily complex two dimensional bodies,” ICASE Report 92-7, 1992.
[44] R. A. Finkel and J. L. Bentley. Quad trees: a data structure for retrieval on composite keys.
Acta Informatica, 4(1):1-9, 1974.
[45] Samet, H., The Design and Analysis of Spatial Data Structures. Addison-Wesley Series on
Computer Science and Information Processing. Addison-Wesley Publishing Company,
1990.
[46] Schmitt, V., and Charpin, F., “Pressure Distributions on the ONERA-M6-W ing at Tran-
sonic Mach Numbers,” Experimental Data Base for Computer Program Assessment,
AGARD Advisory Report AR-138, 1979.
[47] Shewchuk, J.R., “Robust adaptive floating-point geometric predicates ,” Proceedings of the
Twelfth Annual Symposium on Computational Geometry, pp.141-150, ACM, May 1996.
[48] Shewchuk, J.R., ‘‘Adaptive Precision Floating-Point Arithmetic and Fast Robust Geometric
Predicates.” CMU-CS-96-140, Sc hool of Computer Science, Carnegie Mellon Univ., 1996.
[49] Sloan S.W., “ A fast algorithm for generating constrained Delaunay triangulations,” Com-
puters and Structures, Pergammon Press Ltd., 47(3):441-450, 1993.
[50] Stern, L.G., An Explicitly Conservative Method for Time-Accurate Solution of Hyperbolic
Partial Differential Equations on Embedded Chimera Grids, Ph.D. thesis, U. of Wash,
1996.
[51] Sutherland, I.E., and Hodgman, G.W., “Reentrant polygon lipping,”
c Comm of the ACM,
17(1):32-42, 1974.
[52] Van Vlack, L.H., Elements of Material Science and Engineering, Addison-Wesley Inc.,
1980.
[53] Voorhies, D., Graphics Gems II: Triangle-Cube Intersections. Academic Press, Inc. 1992.
[54] Wang, Z.J., Przekwas, A., and Hufford, G., “Adaptive Cartesian/adaptive prism grid gener-
ation for complex geometry,” AIAA Paper 97-0860, Jan. 1997.
[55] Watson, D.F., “Computing the n-dimensional Delauna y tessellation with application to
Voronoi polytopes,” The Computer Jol. 24(2);167-171, 1981.
[56] Welterlen, T.J., and Karman, S.L.Jr., “Rapid Assessment of F-16 Store Trajectories Using
Unstructured CFD,” AIAA 95-0354, Jan., 1995.
[57] Yap, C., Dubé, T., “The exact computation paradigm, ” Computing in Euclidean Geometry,
(2nd Ed.), Eds, D.-Z. Du, and F.K. Hwang, World Scientific Press, pp. 452-492, 1995.
[58] Yap, C-.K., “Geometric consistency theorem for a symbolic perturbation sc heme,” Jol. of
Comp. and Sys. Sci. 40(1):2-18, 1990.
Figure A-1 demonstrates that on a mesh with Nj prescribed nodes, performing Rj cell
refinements in each direction will produce a mesh with a maximum integer coordinate
of 2 Rj ( N j – 1 ) + 1 which must be resolvable in m bits.
− 32 −
Adaptive Cartesian Mesh Generation
R m
2 j( N j – 1) + 1 ≤ 2 (A.1)
Thus, the maximum number of cell subdivisions that may be addressed by a set of m-bit
integer coordinates is:
m
( R max ) = log ( 2 – 1 ) – log2( N j – 1 ) (A.2)
j 2
where the floor “ ” indicates rounding down to the next lower integer. Substituting
back into eq. (A.1) gives the total number of vertices which we can address in each coor-
dinate direction using m-bit integers and with Nj prescribed nodes in the direction.
Rma x j
Mj = 2 (N j – 1) + 1 (A.3)
Thus, the floor in eq. (A.2) insures that Mj can never exceed 2m. The mesh in Figure 3-1
is an illustration of this numbering scheme in three dimensions.
The examples in this chapter use up to m = 21 bits per direction which provides over
2.1 × 10 addressible locations in each coordinate direction. This choice has the advan-
6
tage that all three indices may then be packed into a single 64-bit integer for storage*.
Cell-to-Node Pointers
Figure A-2 gives an example of the vertex numbering within an individual Cartesian
cell. This system has been adopted by analogy to the study of crystalline structures spe-
Num. of Cell
Divisions Nj = # of prescribed locations
0
x0 x1 jth Direction
# of locations = 21 (Nj – 1) + 1
1
x0 x1
# of locations = 22 (Nj – 1) + 1
2
x0 x1
*. This is a choice of convenience. All three integer coordinates may, of course, be stored separately, permitting 264 -
1 = 1.84 x 1019 addressible locations using 64-bit integers.
− 33 −
Adaptive Cartesian Mesh Generation
cialized for cubic lattices[52]. Within this framework, the cell vertices are numbered
with a boolean index of 0 (low) or 1 (high) in each direction. Following this ordering,
Figure A-2 shows the crystal direction of each vertex in square brackets (with no
commas). Reinterpreting this 3-bit pattern as an integer yields a unique numbering
scheme (from 0-7) for each vertex on the cell.
For any cell i, V 0 is the integer position vector ( V 00, V 01, V 02 ) of its vertex nearest to
the x0 corner of the domain. Knowing the number of times that cell i has been
divided in each direction, Rj, one may express its other 7 vertices directly.
Rmax 2 – R 2
V1 = V0 + ( 0, 0, 2 )
Rmax 1 – R 1
V2 = V0 + ( 0, 2 , 0)
Rmax 1 – R 1 Rmax 2 – R 2
V3 = V0 + ( 0, 2 ,2 )
V 4 = V 0 + (2
Rmax 0 – R 0
, 0, 0) (A.4)
Rmax 0 – R 0 Rmax 2 – R 2
V 5 = V 0 + (2 , 0, 2 )
Rmax 0 – R 0 Rmax 1 – R 1
V 6 = V 0 + (2 ,2 , 0)
Rmax 0 – R 0 Rmax 1 – R 1 Rmax 2 – R 2
V 7 = V 0 + (2 ,2 ,2 )
Since the powers of two in this expression are simply a left shift of the bitwise repre-
sentation of the integer subtraction R ma x j – R j , vertices V 1 through V 7 can be com-
puted from V 0 and Rj at very low cost. In addition, the total number of refinements
in each direction will be a (relatively) small integer, thus it is possible to pack all
three components of R into a single 32-bit word.
V3
V1 [011]
[001]
V7
V5
[111]
[101]
2
V2
1 [010]
V0
0 [000]
V6
V4 [110]
[100]
Figure A-2: Vertex numbering within a cell. Square brackets [-] indicate crystal directions .
− 34 −
Adaptive Cartesian Mesh Generation
− 35 −