23
American Institute of Aeronautics and Astronautics 1 OBJECT BASED LIBRARY FOR 3D UNSTRUCTURED GRID REPRESENTATION AND VOLUME BASED AGGLOMERATION Samit Ahlawat * , Ralph Johnson and S. P. Vanka. University of Illinois at Urbana Champaign, Urbana, IL, 61801 The design, implementation and performance of an object-oriented library for representing unstructured grids and performing volume based agglomeration for a multigrid solver is presented. The library provides a modular, flexible and efficient framework for representing three dimensional domains. An unstructured grid is represented using a hierarchy of classes: domain, grid level, cells, faces, edges and vertices. This structure provides the machinery needed to represent physical variables (e.g. variables of a differential equation) directly in the relevant class. It also obviates the need for storing information of a logically independent entity like a cell across several arrays. We use an unstructured volume based agglomeration routine where the agglomeration front propagates inward from the boundaries. Agglomeration occurs across cells sharing a common vertex. Cell fusion rate (number of cells sharing a vertex that get fused into a coarse cell) is parameterized. Aspect ratio is defined so that it captures the degree of cell convexity and gives an indication of direction of cell stretching. This information is useful for performing directional agglomeration. Quality of agglomeration is evaluated using mean and standard deviation of cell aspect ratios, cell volume, and number of finer grid cells forming a coarse cell. We also solve a simple scalar transport equation using the generated coarse grids in order to discriminate the quality of agglomeration and the optimum number of coarse grid levels. An algorithm for improvement of cell quality that fills up cavities between coarse cells by relocating fine cells between coarse cells is also incorporated into the agglomeration library. I. Introduction U nstructured grids enable us to mesh complex geometries. They can mesh geometries with complex boundaries and shapes, unlike the structured grid technique that requires mapping a domain into a simpler shape. With the increasing robustness of unstructured grid generators, algorithms that can solve differential equations over an unstructured grid (e.g. control volume methods) coupled with multigrid methodology are getting increasing attention. Multigrid methods are used to enhance convergence rates of iterative solvers. There are several variations of multigrid method used in practice. Overset grid multigrid generates several levels of grids (progressively coarser grids with increasing element sizes) for the same domain. It then restricts and prolongs error between these grid levels based on the topography of grids. While this method gives greater control over coarse cell sizes, it makes the projection of error between grid levels complex. Nested multigrid method first creates a coarse mesh for a domain, and then introduces finer mesh within each of those coarse cells. This method has the advantage of simpler error projection between grid levels than overset grid multigrid but requires several steps of grid generation over increasingly finer spaces. Algebraic multigrid method models the effect of coarsening by modifying the discretization of governing equation. For unstructured grids, this can become complex. On the other hand, agglomeration multigrid method begins with a fine grid and creates coarser grid levels by volume-based * Graduate Research Assistant, Mechanical Engineering, #140 MEB, UIUC, Urbana IL Professor, Computer Science, #4116 Seibel Center, UIUC, Urbana IL Professor, Mechanical Engineering, #3011 MEL, UIUC, Urbana IL; [email protected] 44th AIAA Aerospace Sciences Meeting and Exhibit 9 - 12 January 2006, Reno, Nevada AIAA 2006-888 Copyright © 2006 by Samit Ahlawat, Ralph Johnson, S. P. Vanka. Published by the American Institute of Aeronautics and Astronautics, Inc., with permission.

[American Institute of Aeronautics and Astronautics 44th AIAA Aerospace Sciences Meeting and Exhibit - Reno, Nevada (09 January 2006 - 12 January 2006)] 44th AIAA Aerospace Sciences

  • Upload
    pratap

  • View
    213

  • Download
    1

Embed Size (px)

Citation preview

American Institute of Aeronautics and Astronautics1

OBJECT BASED LIBRARY FOR 3D UNSTRUCTUREDGRID REPRESENTATION AND VOLUME BASED

AGGLOMERATION

Samit Ahlawat*, Ralph Johnson† and S. P. Vanka.‡

University of Illinois at Urbana Champaign, Urbana, IL, 61801

The design, implementation and performance of an object-oriented library forrepresenting unstructured grids and performing volume based agglomeration for amultigrid solver is presented. The library provides a modular, flexible and efficientframework for representing three dimensional domains. An unstructured grid is representedusing a hierarchy of classes: domain, grid level, cells, faces, edges and vertices. Thisstructure provides the machinery needed to represent physical variables (e.g. variables of adifferential equation) directly in the relevant class. It also obviates the need for storinginformation of a logically independent entity like a cell across several arrays. We use anunstructured volume based agglomeration routine where the agglomeration frontpropagates inward from the boundaries. Agglomeration occurs across cells sharing acommon vertex. Cell fusion rate (number of cells sharing a vertex that get fused into a coarsecell) is parameterized. Aspect ratio is defined so that it captures the degree of cell convexityand gives an indication of direction of cell stretching. This information is useful forperforming directional agglomeration. Quality of agglomeration is evaluated using meanand standard deviation of cell aspect ratios, cell volume, and number of finer grid cellsforming a coarse cell. We also solve a simple scalar transport equation using the generatedcoarse grids in order to discriminate the quality of agglomeration and the optimum numberof coarse grid levels. An algorithm for improvement of cell quality that fills up cavitiesbetween coarse cells by relocating fine cells between coarse cells is also incorporated into theagglomeration library.

I. Introduction

Unstructured grids enable us to mesh complex geometries. They can mesh geometries with complex boundaries

and shapes, unlike the structured grid technique that requires mapping a domain into a simpler shape. With theincreasing robustness of unstructured grid generators, algorithms that can solve differential equations over anunstructured grid (e.g. control volume methods) coupled with multigrid methodology are getting increasingattention. Multigrid methods are used to enhance convergence rates of iterative solvers.

There are several variations of multigrid method used in practice. Overset grid multigrid generates several levelsof grids (progressively coarser grids with increasing element sizes) for the same domain. It then restricts andprolongs error between these grid levels based on the topography of grids. While this method gives greater controlover coarse cell sizes, it makes the projection of error between grid levels complex. Nested multigrid method firstcreates a coarse mesh for a domain, and then introduces finer mesh within each of those coarse cells. This methodhas the advantage of simpler error projection between grid levels than overset grid multigrid but requires severalsteps of grid generation over increasingly finer spaces. Algebraic multigrid method models the effect of coarseningby modifying the discretization of governing equation. For unstructured grids, this can become complex. On theother hand, agglomeration multigrid method begins with a fine grid and creates coarser grid levels by volume-based

* Graduate Research Assistant, Mechanical Engineering, #140 MEB, UIUC, Urbana IL† Professor, Computer Science, #4116 Seibel Center, UIUC, Urbana IL‡ Professor, Mechanical Engineering, #3011 MEL, UIUC, Urbana IL; [email protected]

44th AIAA Aerospace Sciences Meeting and Exhibit9 - 12 January 2006, Reno, Nevada

AIAA 2006-888

Copyright © 2006 by Samit Ahlawat, Ralph Johnson, S. P. Vanka. Published by the American Institute of Aeronautics and Astronautics, Inc., with permission.

American Institute of Aeronautics and Astronautics2

agglomeration. The projection of error between grid levels is relatively simpler with this multigrid method and gridgeneration is needed only once for the finest grid level.

Agglomeration multigrid method builds coarse grid levels from fine grid levels. The performance of multigridalgorithm becomes intimately related with agglomeration quality because errors computed over coarse cells areprojected to the constituent finer cells, and if the coarse cells have odd, non-convex shapes (quantified by anunfavorable aspect ratio), the projection of error to fine cells may not be very representative. The performance ofagglomeration multigrid algorithm depends to a great extent on the on quality of agglomeration. In order to measureagglomeration quality, we need to define coarser grid cell aspect ratio that is a reliable metric of cell convexity.Hence we can expect cells with large aspect ratios to be stretched (not very convex).

We present an unstructured volume based agglomeration algorithm that generates a set of coarse grids from aninitial fine grid. This algorithm uses a modular, object-based grid representation library that stores a grid in ahierarchy of objects: domain, grid level, cells, faces, edges and vertices. This infrastructure of grid representation isvery modular and reusable and follows the design patterns outlined in Ref. 10. We have coded a single grid Poissonsolver for heat equation using this library. This library has a default file reader for grids generated using ProEngineer software. Additional file readers can be written for other input grid formats. The library provides a set ofAPIs for file readers that make the process of writing new file readers simpler. The APIs provide a convenientinterface between file readers and domain builder. The author of a new file reader need not learn the data structuresof the library in order to write the file reader.

The object based design of the grid representation library provides a set of classes that provide a convenientinterface to the library data structures. These data structures can be reused for coding other solvers over the grid. Theinitial design of library was in C++, but owing to the performance overhead incurred due to the use of C++ STL, weconverted the library to C. The library is equipped with an agglomerator, whose features are described in followingsections.

We have preferred a vertex based agglomeration algorithm that agglomerates cells around a vertex. This is incontrast with the agglomeration algorithms proposed by Carré1, and Mavriplis and Venkatakrishnan2. This methodagglomerates cells sharing a common vertex, as opposed to agglomerating cells around a particular fine cell1-2. Thisalgorithm produces more convex cells than those produced by a ‘cell based’ method. This can result in better solverconvergence. We have also developed three methods for validating and observing the quality of agglomeration:using visualization techniques, using statistical measures of quantities that capture grid quality and solving a scalartransport equation to judge the grid quality. The algorithm also controls the cell fusion rate by making it aconfigurable parameter. This means that all the cells around a vertex are not agglomerated, only the number of cellsless than or equal to the specified fusion rate parameter are fused into a coarse cell. This enables us to control therate of agglomeration and determine the strategy that gives the best convergence. Further, in order to improve gridquality, we have implemented an algorithm that attempts to fill cavities or near cavities (sharp peaks and valleys) incoarse cells by identifying the presence of cavities, identifying the finer cells that can be relocated betweenneighboring coarse cells in order to fill up that cavity, and reforming the coarse cells to eliminate the cavity.

II. Object Based Design of Grid Representation LibraryThis library provides a modular, flexible and efficient framework for representing three dimensional domains

with unstructured grids. An unstructured grid is represented using a hierarchy of classes: domain, grid level, cells,faces, edges and vertices. A domain consists of all the grid levels, cells, faces, edges and vertices. A grid levelconsists of cells present at that agglomeration level. It encapsulates all the information of a grid level and is createdby the agglomeration routine from the previous grid level. Cells are composed of faces, faces are composed ofedges, edges are composed of two vertices, and each vertex is composed of three physical coordinates identifying itslocation in space. This connectivity information is sufficient to model the complete domain. In addition, a fewgeometric properties like cell volume, face normal (outward with respect to a cell), cell centroid and face centroidare also stored in the respective classes. This structure provides the machinery needed to represent physical variables(e.g. variables of a differential equation) directly in the relevant class. It also obviates the need for storinginformation of a logically independent entity like cell across several arrays. From the viewpoint of spacerequirements and efficiency, this model is as efficient as its counterpart where information is stored in severalseparate arrays. Owing to the intuitive understanding it affords, it significantly cuts down the development time of asolver and reduces the possibility of errors. This library uses dynamic allocation of memory and avoids allocation offixed amount of static memory in order to keep memory usage to a minimum.

The domain is represented by an object of class domain. It contains grid levels, cells, faces, edges and verticespresent in a (fine) grid. The grids are contained in this class. The finest grid (which is provided as input) is present as

American Institute of Aeronautics and Astronautics3

the first grid in domain object. In addition, domain also contains a mapping between faces and the two cells (can beone if face is on boundary) adjoining it, and a mapping between vertices and cells surrounding it. Grid objectcontains a list of cells forming the grid. At the first grid level, the list of cells is empty and the variable representingthe list is simply a pointer to the cell list in parent domain object. In subsequent coarse grid levels, this list containscoarse cells. Cell class describes a cell and contains a list of pointers to cell faces and number of cell faces. Thisrepresentation optimizes memory usage because the coarse cells can keep a pointer to faces stored in domain objectinstead of storing different copies of the same face. Cell class contains of other cell data too, like cell volume, facenormal signs (convention adopted is positive normal sign pointing out of cell volume), a flag identifying if the cell ison boundary, cell centroid, a list of finer level cells forming the (coarse) cell, and number of constituent finer cells.This list of constituent cells is empty for first (finest) level cells.

Face class consists of a list of pointer to edges, number of edges, face unit normal (3 components) and a flagidentifying if the face is on boundary. Similarly, edge class consists of two vertices. Vertex class contains the threecoordinates identifying the location of the vertex in space. The library can create cells with any number of faces andthe faces in turn can have any number of edges. To eliminate duplicate storage of the same information, the domainclass keeps all the resources (like cells, faces, edges and vertices), and pointers to these resources are used. Each ofthese classes has methods to serialize the object and output the object information in ASCII format. A collection ofoutput from these classes can be used to reconstruct the domain. The format of serialization output is the syntaxfollowed by default file reader.

DomainBuilder class provides an interface between file readers and routines that populate the data structures ofthe library (basically, create the domain object). It provides a set of APIs (Abstract Programming Interface) thatabstract the construction of library data structures from file reader. This also makes coding of new file readers easy.For instance, it provides a method for constructing a vertex from three coordinates; a method to create an edge fromtwo vertices passed using integers corresponding to global vertex numbers, and similar APIs for creating face andcell. These APIs can be invoked in any order, i.e. creation of an edge need not precede creation of its two vertices.Once the input is complete, an API indicating this is invoked. DomainBuilder class then checks for sufficiency andconsistency of input data and creates the domain object.

III. Agglomeration Algorithm

A. Previous WorksSeveral strategies for volume-based agglomeration have been previously developed. Carré1 begins with a cell

and agglomerates all the cells around that cell that have not already been fused into a coarse cell. If the set of cellscontains just one cell, it is discarded and is fused into a neighboring coarse cell. This process is then repeated for thenext cell (if it has not already been assigned to a coarse cell). K. A. Sørensen et al.2 first take a seed node from theset of boundary nodes. For a 2D mesh, they take all the surrounding nodes that are connected to the seed node byunused edges. They form a super node from this collection of nodes and eliminate the edges connecting them to theseed node. The edges between super nodes form super edges. Once the boundary nodes are finished, seed node ischosen randomly from the remaining nodes. D. J. Mavriplis and V. Venkatakrishnan3 pick a starting vertex on theboundary and fuse all the unagglomerated cells around that vertex into a coarse cell. A front is defined that containsthe exterior faces of unagglomerated cells. This step of agglomeration is very similar to our procedure described inthis paper, except that we do not agglomerate around a boundary vertex. After this step, a queue of edges is definedand all the exposed edges are put in this queue. A new vertex is then selected from the next edge in queue(unprocessed vertex of the edge). This process is repeated for other control volumes. Directional agglomeration inincorporated into their algorithm by assigning weights to edges. Lambropoulous et al.5 use a node centered controlvolume and agglomerate neighboring cells to create coarse grid levels. Lallemand et al.8 consider triangular (in 2D)and tetrahedral (in 3D) elements and agglomerate cells around a given cell to form a coarse cell.

B. Present ProcedureIn the present procedure we have used a vertex based agglomeration algorithm that agglomerates cells around a

vertex. A vertex front moves inward from boundaries. The algorithm parameterizes the cell fusion rate (which is thenumber of fine grid cells that get fused into a coarse cell). It is equipped with automatic detection of stretched grids,where it performs directional agglomeration and it has an algorithm for improving grid quality by filling up sharpfolds (hills and valleys) on coarse cells.

The agglomeration algorithm can be stated in the form of following pseudo code:1) Populate the first grid using input data.

American Institute of Aeronautics and Astronautics4

2) Consider the fine grid.3) Construct a dictionary of all grid vertices identifying them with a status flag indicating its status:

• Vertex has been processed.• Vertex has not been processed, but is currently in the queue.• Vertex has not been inserted in the queue.

4) Construct a dictionary of all the cells identifying if the cell has been fused into a coarse cell or not. Initiallyall the cells are unprocessed.

5) Identify the cells located around grid vertices. Construct a mapping from vertices to cells around those.6) Construct a prioritized queue (not a priority queue) from vertices that are next to the grid boundary. These

vertices belong to boundary cells, and are themselves not on boundary. This set of vertices comprises afront that moves inward from the boundary. Priority of a vertex is given by the number of cells locatedaround that vertex (found in step 1). This step creates a vertex front.

The queue is not a priority queue. Vertices that come from a cell are sorted only among themselvesaccording to their priority and inserted in the queue. All the queue elements are not sorted according totheir priority. Only parts of the queue that came from a cell are sorted.

7) Take the first vertex from the prioritized queue (vertex front).8) Agglomerate all the cells sharing this vertex into a coarse cell. The agglomeration process has the following

features:• If all the cells around this vertex are stretched, we perform directional agglomeration normal to the cell

stretching direction.• For directional agglomeration to be applicable, all cells in this set must be stretched, and the stretch

direction must be the same for all of them.• At finest level, a cell is stretched if its aspect ratio is below a certain threshold (according to the

definition of aspect ratio, stretched cells will have low aspect ratios).• At coarse grid level, a cell is stretched if it was created out of stretched cells at finer level by

directional agglomeration.• The contraction direction of a cell is defined as the unit vector along the shortest vector from cell

centroid to a cell face centroid.• For remaining coarse cells, contraction direction is not computed (it is not needed, since coarse cells

that have not been formed by directional agglomeration will never undergo directional agglomeration).• If all the cells are non-stretched, perform isotropic agglomeration. Depending upon the value of cell

fusion rate parameter (say N), the algorithm picks a maximum of N cells such that each cell shares atleast one face with another cell from the set. These cells are then fused into a coarse cell.

• If some cells around a vertex are stretched, isotropic agglomeration is performed only on non-stretchedcells.

9) The coarse cells formed by agglomeration are flagged to indicate if they were formed by directional orisotropic agglomeration.

10) Formation of a coarse cell annihilates vertices lying inside the cell. These vertices, as well as those on thesurface of the newly formed coarse cell are marked so that they can never be inserted into vertex front, orare removed from the front if they have already been inserted.

11) After the formation of a coarse cell, the vertex front is updated at the rear by taking into account thevertices lying next to the surface of newly created coarse cell.

12) Only unprocessed, valid vertices that have not been inserted into vertex front are inserted into it.13) The next element of the prioritized queue (vertex front) is processed by going to step 8, and repeating until

the vertex front is empty.14) Once the front is empty, unagglomerated cells are processed according to the following rules:

• Non-stretched unagglomerated cells are fused with a neighboring coarse cell having highest aspectratio (higher aspect ratio indicates more convex cell). This neighboring cell should not be stretchedcell.

• Stretched unagglomerated cell is fused with a neighboring stretched coarse cell that is located normalto the direction of stretching.

15) If a cell finds no coarse cell neighbor following the two rules above, it is promoted to the next grid level,i.e. we form a coarse cell comprising of only one fine cell.

American Institute of Aeronautics and Astronautics5

16) The quality of generated coarse grid is improved by attempting to even out the steep undulations (valleysand hills) for coarse grid cells. This is done by relocating the fine cells forming the cavity from one coarsecell to another.

17) This completes the formation of one coarse grid level. Steps 2-16 are repeated using the newly formedcoarse grid as the fine grid to form further grid levels until the desired number of grid levels have beencreated.

C. Definition of Aspect RatioWe define aspect ratio (AR) of a cell to be:

3max

_43

Cell VolAR

rπ= , where rmax denotes the maximum distance from cell centre to its face centre, as shown below for a

typical cell.

Coordinates of the cell centroid are obtained by taking arithmetic average of cell vertex coordinates. Likewise,face centre coordinates are obtained by averaging face vertex coordinates.

This definition of aspect ratio allows us to distinguish convex cells from slivers and also helps in defining thedirection of cell contraction. The direction of contraction is along the vector joining cell centroid to the nearest facecentroid. This vector gives the direction of cell contraction which is useful while performing directionalagglomeration.

D. Vertex FrontVertices around which agglomeration of cells occurs come from vertex front that moves inward from

boundaries. This front is populated with non-boundary vertices of boundary cells to begin with.

The vertex front does not contain duplicates or the vertices that have been processed earlier (at that grid level).

Once vertices from boundary cells populate the vertex front, the process of formation of coarse cells begins.After a coarse cell has been formed, unagglomerated fine cells adjoining that coarse cell contribute vertices to thefront. These vertices are put at the end of the front.

Boundary face

These vertices gointo front

FaceCentroid

Cell

American Institute of Aeronautics and Astronautics6

A vertex is inserted in the queue only if it is unprocessed, is valid (not on the boundary), and is not currentlypresent in the queue. Once inserted into the queue, it is flagged as unprocessed vertex present in queue.

E. Prioritized queue used for implementing vertex frontThe vertex front is implemented as a variation of priority queue. Priority of an entry (vertex) is given by the

number of cells around that vertex. All the elements of queue are not ordered according to their priority. Instead,vertices coming from a particular cell are ordered according to descending priority, and inserted into the queuetogether.

All the boundary vertices are flagged as processed. The front is initially empty. It is populated by considering theboundary cells and putting their interior vertices on the prioritized queue (after ordering vertices from a cell indescending order of their priority). The first element of the queue gets processed first to produce a coarse cell. Thevertices that lie inside this coarse cell and those that lie on its surface cannot be a part of the vertex front. They areremoved from the queue (if any vertex among them is present in the queue) and flagged as processed. This isfollowed by growth of the queue by adding unprocessed vertices of fine cells adjoining this coarse cell that has notbeen processed. These vertices are added at the end of the queue after sorting them in descending order of theirpriority.

It is essential not to order all the elements of the queue because that would destroy the front property. Forinstance, once we populate the front with vertices and produce a coarse cell, we expand the queue by adding verticesfrom newly exposed cells (which in general would be interior cells). If at this stage we sort all the elements of thequeue according to their priority, it is possible that vertices belonging to this interior cell come in front of the queue(thereby getting processed ahead of vertices coming from boundary cells, and destroying the front property).

It can be seen that only one vertex from a cell can get processed, since after the formation of a coarse cell thatcontains this fine cell, all the vertices of that fine cell will get flagged as processed and get removed from queue.

It is important to have a prioritized queue instead of a queue to keep the cell fusion rate from falling. If we havea simple queue, as we progress toward coarser levels, an increasing number of vertices will have only two neighborcells. Hence the fusion rate will fall to 2 if we have a simple queue. Use of a prioritized queue avoids this by puttingthe vertex having maximum number of coarse neighbor cells ahead of other vertices from that cell.

Coarse cell

Neighboring fine cell

Vertex front moves inward. Thisvertex goes into the front.

American Institute of Aeronautics and Astronautics7

Assume two coarse cells share the set of faces shown above. The majority of vertices on this set of faces willhave only two coarse neighbor cells. Only a handful of them (shown in bold) will have more then two coarseneighbor cells. If no priority is attached to a vertex, the vertices with two coarse neighbor cells will be more likely toget processed first for a given cell. Hence the rate of cell fusion will fall to two.

F. Formation of Coarse CellThere are three distinct phases in the agglomeration algorithm that produce coarse cells.

1) Agglomeration of cells around a vertex (directional agglomeration if necessary).2) Agglomeration of unagglomerated, ‘left over’ cells into neighboring coarse cell.3) Elimination of cavities inside coarse cells.

For a grid level, the first step of agglomeration is formation of coarse cells from cells around vertices. The vertexserving as nucleus of fusion comes from the prioritized queue of vertices. If the cells around a vertex are allstretched in the same direction, they form a set of coarse cells by undergoing directional agglomeration. Each ofthese three methods is described in greater detail below.

G. Agglomeration of cells around a vertexThis step processes the cells around a vertex. First we check for the presence of stretched cells. We check if the

aspect ratio of all cells in this set is greater than a specified threshold. If this is not true, the cells are considered to benot stretched and isotropic agglomeration is performed. If all the cells in the set are stretched, we next check if thestretch direction of all the cells is same. To do this, we take the first cell in the set, and take dot product of its stretchdirection with all the remaining cell’s stretch directions. If each of this dot product is close to one in magnitude,directional agglomeration is performed. If any dot product is not sufficiently close to one, isotropic agglomeration isperformed on the cells.

To perform directional agglomeration on a set of cells, we take the first cell of the set and consider all its faces.We compute the position vector pointing from cell centroid to face centroid and make it a unit vector. Then we takethe dot product of this unit vector with the cell contraction direction (a unit vector). We select the face that gives usthe greatest value (nearest to unity) of this dot product.

We find the cell on the other side of the face that we selected, and agglomerate it with the cell (that we beganwith) provided the adjoining cell has not already been agglomerated into a coarse cell and the two cells belong to thecell set. In this manner we perform directional agglomeration with the cell fusion rate of two in regions of stretchedgrid. Using this algorithm, the coarse cells formed by directional agglomeration grow in a direction along thedirection of contraction.

For isotropic agglomeration, we consider all the cells sharing a vertex. In order to control the rate of cell fusion,all the cells around a vertex are not agglomerated. Instead, we select a maximum of ‘cell fusion rate’ (say N) numberof cells from the set and agglomerate them into a coarse cell. We cannot pick any N cells from the set. We mustensure that every cell that we pick would share at least one face with the cells in this new set. We can formulate thisproblem as a graph problem. The vertices of the graph represent cells, and edges connecting them represent a cellface, with two cells on the sides of that face. If we denote the graph by G (V, E), we want to find a set of N verticesconnected by edges. Since these cells share a vertex, we begin with a cell and keep picking neighboring cells thathave not already been picked, until the fusion threshold is reached.

American Institute of Aeronautics and Astronautics8

In order to prevent the region of isotropic agglomeration from growing into region of stretched cells, we filterout cells marked stretched from those undergoing isotropic agglomeration. This is illustrated in the following figure.

H. Agglomeration of left over cellsAfter the stage of agglomeration of cells around vertices, we agglomerate left over cells. An unagglomerated cell

is agglomerated with a neighboring coarse cell that has the highest value of aspect ratio (is most convex). For a threedimensional grid, using our algorithm, it is not possible to end up with a left over cell that has no coarse cellneighbors. If this were the case, we would have a vertex around which fine cells are present, which implies thisvertex did not get inserted into the queue. This is not possible with the front moving inward from the boundaries.However this situation is possible for the three dimensional equivalent of a two dimensional grid (as described in thefollowing section). The algorithm for this stage of agglomeration can be succinctly stated in the following steps:

1) Consider a left over cell. Find all its neighboring coarse cells. Merge it with the coarse cell having highestaspect ratio (is most convex). If any of the neighboring coarse cells has been marked with a flag indicatingit cannot receive any more fine cells, skip it.

2) If no unmarked coarse cell neighbor exists, get all the neighboring left over cells for this cell. Fuse thesecells into a coarse cell and mark this coarse cell with a flag that indicates it cannot receive any more leftover cells later during this stage of agglomeration. This is necessary to prevent lumping of cells into verybig coarse cells (in a three dimensional equivalent of two dimensional grid, described in next section).

3) If no left over neighbor cell exists, create a coarse cell out of this left over cell.

I. Elimination of cavities within coarse cellsThis step improves the quality of grid by eliminating cavities within coarse cells at a grid level. A cavity within a

coarse cell can be any one among the following:

1) A coarse cell within another coarse cell.2) A coarse cell having one fine cell of a neighboring coarse cell nearly inside it.3) A coarse cell having a set of fine cells forming a coarse cell nearly inside it.

These possibilities are depicted in the figure below.

Vertex from frontStretchedcells

These cells are not stretched

American Institute of Aeronautics and Astronautics9

To capture the presence of any of these three kinds of cavities between two coarse cells, we define a qualitymeasure of an ordered pair of neighboring coarse cells (C1, C2) as follows:

1) We construct a set of fine cells belonging to coarse cell C1 that are well connected (each fine cell in the setshares at least one face with another cell in the set) and share a face with coarse cell C2.

2) We count the number of faces shared by cells in this set with the coarse cell C2. Let us denote it by N1.3) We count the number of external faces of this cell set, i.e. the number of faces of a hypothetical cell

constructed from the fine cells in the set. Let us denote it by N2.

The cell set is constructed as follows:

First we enumerate the number of faces that each fine cell of C1 shares with cell C2. We take the fine cellcorresponding to the maximum shared faces, and insert it in a list. We then look at fine neighbors of cells in list(currently the list has just one cell) that belong to C1 and share a face with C2. We insert such cells in the list. Thisalgorithm ensures that the cells in the list are well connected. When we can find no new fine cells of C1 to add to thelist, we stop. The cells in the list at this point comprise the cell set.

2

1

N

Nmeasure = (1)

If this measure is greater than a critical threshold (say 70%), then the first cell (C2) has a cavity that can be filledup with finer cells comprising the set identified earlier (from cell C1).

This algorithm identifies all three kinds of cavities and fills them up. In the cavity of first kind, all the constituentcells of cell C2 will get fused into cell C1, effectively merging the two coarse cells into one cell.

Cavities of the second and third kind are also handled as expected, with the finer cells being relocated from onecoarse cell to the other. If during this process, any coarse cell becomes empty, we remove it from the grid (it is justmarked as deleted).

Coarse cell C2

Coarse cell C1

Cavity of type 1

Coarse cell C1

Coarse cell C1

Coarse cell C2

Coarse cell C2

Cavity of type 2

Cavity of type 3

One fine cell of acoarse cell forminga cavity

Two fine cells of acoarse cell forminga cavity

American Institute of Aeronautics and Astronautics10

J. Special case of two-dimensional gridsA two dimensional grid cannot be processed directly by the program. This is because the data structure used for

three-dimensional grids cannot be used for two-dimensional grids. The core data structure used in the programconsists of a hierarchy of objects: cells, faces, edges and vertices. In two dimensional grids, cells are more like threedimensional faces in terms of their properties like cell volume (which is face area). Whereas faces close three-dimensional cells, two-dimensional cells are closed by edges. However we cannot create two-dimensional cells asfaces because we would like to form coarse cells by agglomeration but faces cannot be fused to get bigger faces. Inorder to have a similar agglomeration code for two dimensional grids, we would need to write a separate version ofprogram with hierarchy of objects: cells, edges, and vertices, and make the relevant changes in agglomerator.

Another approach is to convert the two dimensional grid into a three dimensional one by projecting the grid inthird dimension by a unit distance, thereby creating three-dimensional cells (one cell in the third direction). Thiswould create a whole set of new faces, edges and vertices. For such a grid, the agglomeration algorithm will not findany vertices to insert in the vertex front. Hence the entire agglomeration of the grid will occur in the second stage ofagglomeration of left over cells (which for this case will be all the cells in the grid).

IV. Selected Examples

A. Method of VisualizationIt becomes hard to visualize all the grid points in three dimensions even for grids of modest sizes with a few

thousand nodes. We have written a module that cuts the grids across a specified cutting plane and shows the cutsurface. The cut surface exposes the agglomerating cells. This section presents a few examples.

B. A Cylinder triangulated with tetrahedraThis grid consists of 4961 cells, 10388 faces, 6515 edges and 1089 vertices. Color in the following diagram

indicates the height (in Z direction). It is rendered automatically by MATLAB.

The agglomerated grids on various levels are shown below for a cutting plane of x = 0.5.First grid level:

American Institute of Aeronautics and Astronautics11

Second grid level: cutting plane: x = 0.5

American Institute of Aeronautics and Astronautics12

C. Driven cavityThe grid has 6455 cells, 13586 faces, 8582 edges and 1452 vertices.

First grid level, cutting plane: x = 0.5:

Second grid level, cutting plane: x = 0.5

American Institute of Aeronautics and Astronautics13

Third grid level, cutting plane: x = 0.5

Fourth grid level, cutting plane: x = 0.5

American Institute of Aeronautics and Astronautics14

D. Backward Facing StepThis grid consists of 7465 cells, 15830 faces, 10110 edges and 1746 vertices.

First grid level, cutting plane: x = 0.5

American Institute of Aeronautics and Astronautics15

Second grid level, cutting plane: x = 0.5

Third grid level, cutting plane: x = 0.5

American Institute of Aeronautics and Astronautics16

Fourth grid level, cutting plane x = 0.5

American Institute of Aeronautics and Astronautics17

E. Flat PlateFirst grid level, cutting plane x = 0

Second grid level, cutting plane x = 0

Third grid level, cutting plane: x = 0

Fourth grid level, cutting plane: x = 0

F. Football

American Institute of Aeronautics and Astronautics18

Second level

Third level

Fourth level

V. Validation of Grid QualityWe use four methods of grid testing:1) Visualization

American Institute of Aeronautics and Astronautics19

We have written a module that allows us to cut a grid across a specified plane (ax + by + cz + d = 0) andview the cut surface of the grid. With increasing sizes of coarse grid cells, internal faces begindisappearing, and this shows the growth of coarse cells in that plane.

2) Grid statisticsWe print average, maximum, minimum and standard deviations of cell aspect ratios, fine cells forming a

coarse cell, and volume of coarse cells at a particular grid level to understand grid level quality.3) Multigrid scalar transport equation solver4) Multigrid Navier-Stokes equation solver

A. Metrics for a few test casesThe following cases have been run with fusion control parameter set to four, and grid quality improvement

algorithm turned off.1) Flat plate (27936 cells at the finest grid level)

Grid number Number of cells Maximum aspect ratio Minimum aspect ratio Average aspectratio

1 12629 1.1517 2.2675E-6 0.10322 6572 0.9335 6.4961E-7 0.13843 3763 0.9192 6.1094E-7 0.14754 1779 0.8146 3.2226E-6 0.12115 910 0.7741 4.1903E-6 0.10456 612 0.6407 1.089E-6 9.9446E-2

2) Football (48049 cells at the finest grid level)

Grid number Number of cells Maximum aspect ratio Minimum aspect ratio Average aspectratio

1 9512 2.9525 2.2572E-2 0.52712 2085 2.4043 5.9626E-3 0.21393 826 0.8932 3.0181E-3 0.15844 301 0.8562 2.3551E-3 7.4046E-2 5 98 0.1612 2.0456E-3 4.5257E-2 6 38 0.2741 2.7551E-3 4.6309E-2

Flat plate consists of a considerable number of stretched cells. Hence directional agglomeration is theagglomeration method used for most cells. Consequently, the rate of cell fusion is approximately equal to two. Wesee that cell quality declines considerably beyond fifth grid level.

For the football case, the rate of cell fusion is between 4 and 3. The cell quality (average cell aspect ratio)declines beyond third grid level.

B. Effect of cavity fillingCavity filling improves the quality of grids only to a small extent. For instance, with cavity filling turned on, we

got the following statistics for football grid.

Grid number Number of cells Maximum aspect ratio Minimum aspect ratio Average aspectratio

1 9512 2.9525 2.2572E-2 0.52712 2099 2.4043 5.9626E-3 0.21393 831 0.8932 3.0181E-3 0.15434 300 0.8562 2.3551E-3 7.9814E-2 5 97 0.1789 2.6050E-3 4.8030E-2 6 32 0.2152 6.2658E-3 5.1749E-2

C. Multigrid Scalar Transport Equation

American Institute of Aeronautics and Astronautics20

Multigrid scalar transport equation is solved using agglomeration multigrid method in order to get an estimate ofgrid quality. The equation solver follows a modular design pattern, similar to the one outlined by Munthe et al.6. Thescalar transport equation is given by:

∂∂+

∂∂

Γ=∂∂+

∂∂+

∂∂

2

2

2

2

y

c

x

c

y

vc

x

uc

t

c (2)

In this equation, c is the scalar, u and v are the velocity components along x and y directions and Г is thediffusivity. We use a Cartesian grid with cubical elements and Dirichlet conditions on the boundaries.

The multigrid solver uses V Cycle and computes fluxes and residuals at a grid level based on fine grid facefluxes. It sums the fluxes of all external faces of a coarse grid cell to compute the flux for the cell. The sum of fluxesis used to compute a residual, which is used to get the correction (increment in time) for the value of the scalar. Weuse a uniform prolongation, and put this correction on all the constituent fine cells forming a coarse cell. In thisscheme, all variables are stored at finest grid cell centers only.

The algorithm can be stated below:1) March one time step (explicit) on the finest grid cells using the equation:

TDIFFUSIONVCONVECTIONUCONVECTIONVTT

cc nnn

∆+−−=∆∆∆−+

)__(1

2) Visit a coarser grid level. Compute the face fluxes for all faces existing at the next coarse level using thefine grid values. For the coarse cells at this level, compute:

TDIFFUSIONVCONVECTIONUCONVECTIONVTT

Correction n

facesfinefacesfinefacesfinecoarse

coarse

∆+−−=∆∆∆ ∑∑∑ )__(

___

3) The coarse grid time step is larger than the fine grid time step. We have used the following formula torelate the time step on a coarse cell and the time step on its constituent finer cells:

∆=∆

celltconstituenfine

coarsefinecoarse Vol

Voltt

__

4) Volfine_constituent_cell is the volume of the finest constituent cell for a particular coarse cell. Different coarsecells can have different coarse time steps since we are only interested in the steady state.

5) Correction obtained in step 2 is applied uniformly to all the finest constituent cells for this coarse cell(prolongation).

6) After correcting the fine cell values, steps (2) – (3) are performed a specified number of times for thiscoarse level.

7) We move to the next coarser level and repeat steps (2) – (4) for this grid level.8) The process is repeated for the down-leg of V Cycle. We do not perform the up-leg.

We keep the cell Peclet number below 2, and use second order central scheme for convection and diffusionterms. We use 50 cycles and define convergence rate as follows:

Convergence rate =cyclesnum

residueinitial

residuefinal _

1

_

_

Results of multigrid scalar transport equation solverGrid: 8 X 8 X 8

Convergence rate Final residue

First gridlevel

Second gridlevel

Third gridlevel

American Institute of Aeronautics and Astronautics21

Single grid 8.57E-1 6.5E-3 Two grids (1, 3) 5.64E-1 5.6E-12Three grids (1, 1, 3) 5.61E-1 4.1E-12

Grid: 16 X 16 X 16

Convergence rate Final residueSingle grid 9.63E-1 2.3Two grids (1, 3) 8.01E-1 3.1E-4 Three grids (1, 1, 3) 7.88E-1 1.0E-4 Four grids (1, 1, 1, 3) 7.75E-1 4.4E-5

The convergence rates show that adding grid levels beyond the third grid level will not improve the convergenceof multigrid solver much. This happens because the agglomeration is dependent on the order in which vertices areprocessed, and after a few grid levels, the agglomeration begins to differ more from what one might expect ingeometric agglomeration for such a grid.

SECTIONS AT PLANE Z = 0.5Grid 8 X 8 X 8

American Institute of Aeronautics and Astronautics22

Grid 16 X 16 X 16

References1Gilles Carré, “An Implicit Multigrid Method by Agglomeration Applied To Turbulent Flows,” Computers and Fluids, Vol.

26, No. 3.2Mavriplis, D. J., Venkatakrishnan, V., “A 3D Agglomeration Multigrid Solver for the Reynolds-Averaged Navier-Stokes

Equations on Unstructured Meshes,” AIAA-95-0345.3Mavriplis, D. J., “Directional Coarsening and Smoothing for Anisotropic Navier-Stokes Problems,” Electronic Transactions

on Numerical Analysis, Vol. 6.4Sørensen, K. A., Hassan, O., Morgan, K., and Weatherill, N. P., “Agglomerated Multigrid on Hybrid Unstructured Meshed

for Compressible Flow,” International Journal for Numerical Methods in Fluids, 2002, 40:593-603.5Lambropoulos, N. K., Koubogiannis, D. G., and Giannakoglou, K. C., “Acceleration of a Navier-Stokes equation solver for

unstructured grids using agglomeration multigrid and parallel processing,” Computer Methods in Applied Mechanics andEngineering, 193 (2004), pp. 781-803.

6Munthe, O., Langtangen, H. P., “Finite Elements and Object Oriented Implementation Techniques in Computational FluidDynamics,” Computer Methods in Applied Mechanics and Engineering, 190 (2000), pp. 865-888.

American Institute of Aeronautics and Astronautics23

7Peskin, A. P., Hardin, G. R., “An Object Oriented Approach to General Purpose Fluid Dynamics Software,” Computerschem. Engineering, Vol. 20, No. 8, pp. 1043-1058, 1996

8Lallemand, M. H., Steve, H., Dervieux, A., “Unstructured Multigridding by Volume Agglomeration: Current Status,”Computers Fluids, Vol. 21, No. 3, pp. 397-433, 1992.

9Kromer, V., Duffose, F., Gueury, M., “An Object Oriented Design of a Finite Element Code: Application to MultibodySystems Analysis,” Advances in Engineering Software, 35 (2004), pp. 273-287.

10Gamma, E., Helm, R., Johnson, R., Vlissides, J., “Design Patterns: Elements of Reusable Object-Oriented Software,”Addison-Wesley Professional Computing Series.