Skip to main content

NAO


NAO Class NATwoDimensionalIrregularGrid

Overview


The NATwoDimensionalIrregularGrid is a discrete two dimensional NARegion. The cells of the discrete region can be arbitrary polygons.

The irregular grid is:

  1. A list of vertices (which are points in the plane),
  2. A list of edges (which are pairs of integers denoting vertices),
  3. A list of faces (which are lists of integers denoting edges).

Information about which edges emanate from a vertex, which faces border an edge and so forth, is available to the user through the general discrete region interface.

Several mesh generators have been implemented or wrapped which return NATwoDimensionalIrregularGrid's. Alternatively, the user may create their own if they have a vertex list and face and/or edge lists.


User's Guide


To use this class, you must include the header file
NAO/2DIrGrid.h
and link against library
libNAOBase.a
The following constructors are provided:

The following member functions are available in addition to those provided by the abstract interface NARegion:


Programmer's Guide


The NATwoDimensionalIrregularGrid is represented as a set of lists of the cells of dimensions 0, 1 and 2 (vertices, edges and faces), and adjacency information (which edges contain a vertex, which edges bound a face etc.). This is not the most elegant, or storage efficient data structure, but it does minimize the computation involved in answering each query, at the expense of storing redundant information.

The only sublety is the numbering of edges. Because edges are directed, we store one orientation, and create a shadow index for the opposite. The shadow indices is calculated by adding the number of edges to an edge index. You cannot tell if an index is an edge by comparing it to the number of edges!

When the edges emanating from a vertex are requested, the appropriate direction is chosen so that vertex number 0 of that edge is the vertex from which the edeg emanates. Likewise, the edges around a face are returned "head to tail".

The only computation is performed in the constructors, since the user does not pass edges, only vertices and faces. Figuring out the edges from this information is potentially a complex operation. If you have a large mesh, this is probably not the class for you.


Example


This example creates an irregular grid with 4 octagons, 8 triangles and a square. The numbering used for the vertices (white) and faces (yellow) are shown below:

The whole set of points occupies a square of side 2, with lower left hand corner at the origin. Most of the program is spent calculating the positions of the vertices, and reading off the lists of vertices around the faces.

#include <NAO/2DIrGrid.h>
#include <NAO/UTDrMfld.h>
#include <stdio.h>
#include <math.h>

int main (int argc, char *argv[])
 {
  int i,j;

  int nVertices=28;
  double *x;
  int nFaces=13;
  int *nNodes;
  long **nodes;

  double dt=NATWOPI/8;
  double t0=dt/2;

// This builds four octagons, 8 triangles and a square in a tesselation

// vertices

  x=new double[2*nVertices];

  i=0;
  x[2*i  ]=0.                 ;x[2*i+1]=0.                ;i++;    //  0
  x[2*i  ]= .5+.5*cos(t0+5*dt);x[2*i+1]=0.                ;i++;    //  1
  x[2*i  ]= .5+.5*cos(t0+6*dt);x[2*i+1]=0.                ;i++;    //  2
  x[2*i  ]=1.5+.5*cos(t0+5*dt);x[2*i+1]=0.                ;i++;    //  3
  x[2*i  ]=1.5+.5*cos(t0+6*dt);x[2*i+1]=0.                ;i++;    //  4
  x[2*i  ]=2.                 ;x[2*i+1]=0.                ;i++;    //  5

  x[2*i  ]=0.                 ;x[2*i+1]=.5+.5*sin(t0+4*dt);i++;    //  6
  x[2*i  ]=1.                 ;x[2*i+1]=x[2*6+1]          ;i++;    //  7
  x[2*i  ]=2.                 ;x[2*i+1]=x[2*6+1]          ;i++;    //  8

  x[2*i  ]=0.                 ;x[2*i+1]=.5+.5*sin(t0+3*dt);i++;    //  9
  x[2*i  ]=1.                 ;x[2*i+1]=x[2*9+1]          ;i++;    // 10
  x[2*i  ]=2.                 ;x[2*i+1]=x[2*9+1]          ;i++;    // 11

  x[2*i  ]=x[2*1  ]           ;x[2*i+1]=1.                ;i++;    // 12
  x[2*i  ]=x[2*2  ]           ;x[2*i+1]=1.                ;i++;    // 13
  x[2*i  ]=x[2*3  ]           ;x[2*i+1]=1.                ;i++;    // 14
  x[2*i  ]=x[2*4  ]           ;x[2*i+1]=1.                ;i++;    // 15

  x[2*i  ]=x[2*6  ]           ;x[2*i+1]=1.+x[2*6+1]       ;i++;    // 16
  x[2*i  ]=x[2*7  ]           ;x[2*i+1]=1.+x[2*7+1]       ;i++;    // 17
  x[2*i  ]=x[2*8  ]           ;x[2*i+1]=1.+x[2*8+1]       ;i++;    // 18

  x[2*i  ]=x[2*9  ]           ;x[2*i+1]=1.+x[2*9+1]       ;i++;    // 19
  x[2*i  ]=x[2*10 ]           ;x[2*i+1]=1.+x[2*10+1]      ;i++;    // 20
  x[2*i  ]=x[2*11 ]           ;x[2*i+1]=1.+x[2*11+1]      ;i++;    // 21

  x[2*i  ]=x[2*0  ]           ;x[2*i+1]=2.                ;i++;    // 22
  x[2*i  ]=x[2*1  ]           ;x[2*i+1]=2.                ;i++;    // 23
  x[2*i  ]=x[2*2  ]           ;x[2*i+1]=2.                ;i++;    // 24
  x[2*i  ]=x[2*3  ]           ;x[2*i+1]=2.                ;i++;    // 25
  x[2*i  ]=x[2*4  ]           ;x[2*i+1]=2.                ;i++;    // 26
  x[2*i  ]=x[2*5  ]           ;x[2*i+1]=2.                ;i++;    // 27

// faces

  nNodes=new int[nFaces];
  nodes=new long*[nFaces];

  i=0;
  nNodes[i]=3;      //  0
  nodes[i]=new long[nNodes[i]];
  j=0;
  (nodes[i])[j]= 0;j++; 
  (nodes[i])[j]= 1;j++; 
  (nodes[i])[j]= 6;j++; 
  i++;

  nNodes[i]=3;      //  1
  nodes[i]=new long[nNodes[i]];
  j=0;
  (nodes[i])[j]= 2;j++; 
  (nodes[i])[j]= 3;j++; 
  (nodes[i])[j]= 7;j++; 
  i++;

  nNodes[i]=3;      //  2
  nodes[i]=new long[nNodes[i]];
  j=0;
  (nodes[i])[j]= 4;j++; 
  (nodes[i])[j]= 5;j++; 
  (nodes[i])[j]= 8;j++; 
  i++;

  nNodes[i]=8;      //  3
  nodes[i]=new long[nNodes[i]];
  j=0;
  (nodes[i])[j]= 1;j++; 
  (nodes[i])[j]= 2;j++; 
  (nodes[i])[j]= 7;j++; 
  (nodes[i])[j]=10;j++; 
  (nodes[i])[j]=13;j++; 
  (nodes[i])[j]=12;j++; 
  (nodes[i])[j]= 9;j++; 
  (nodes[i])[j]= 6;j++; 
  i++;

  nNodes[i]=8;      //  4
  nodes[i]=new long[nNodes[i]];
  j=0;
  (nodes[i])[j]= 3;j++; 
  (nodes[i])[j]= 4;j++; 
  (nodes[i])[j]= 8;j++; 
  (nodes[i])[j]=11;j++; 
  (nodes[i])[j]=15;j++; 
  (nodes[i])[j]=14;j++; 
  (nodes[i])[j]=10;j++; 
  (nodes[i])[j]= 7;j++; 
  i++;

  nNodes[i]=3;      //  5
  nodes[i]=new long[nNodes[i]];
  j=0;
  (nodes[i])[j]= 9;j++; 
  (nodes[i])[j]=12;j++; 
  (nodes[i])[j]=16;j++; 
  i++;

  nNodes[i]=4;      //  6
  nodes[i]=new long[nNodes[i]];
  j=0;
  (nodes[i])[j]=10;j++; 
  (nodes[i])[j]=14;j++; 
  (nodes[i])[j]=17;j++; 
  (nodes[i])[j]=13;j++; 
  i++;

  nNodes[i]=3;      //  7
  nodes[i]=new long[nNodes[i]];
  j=0;
  (nodes[i])[j]=11;j++; 
  (nodes[i])[j]=18;j++; 
  (nodes[i])[j]=15;j++; 
  i++;

  nNodes[i]=8;      //  8
  nodes[i]=new long[nNodes[i]];
  j=0;
  (nodes[i])[j]=12;j++; 
  (nodes[i])[j]=13;j++; 
  (nodes[i])[j]=17;j++; 
  (nodes[i])[j]=20;j++; 
  (nodes[i])[j]=24;j++; 
  (nodes[i])[j]=23;j++; 
  (nodes[i])[j]=19;j++; 
  (nodes[i])[j]=16;j++; 
  i++;

  nNodes[i]=8;      //  9
  nodes[i]=new long[nNodes[i]];
  j=0;
  (nodes[i])[j]=14;j++; 
  (nodes[i])[j]=15;j++; 
  (nodes[i])[j]=18;j++; 
  (nodes[i])[j]=21;j++; 
  (nodes[i])[j]=26;j++; 
  (nodes[i])[j]=25;j++; 
  (nodes[i])[j]=20;j++; 
  (nodes[i])[j]=17;j++; 
  i++;

  nNodes[i]=3;      // 10
  nodes[i]=new long[nNodes[i]];
  j=0;
  (nodes[i])[j]=19;j++; 
  (nodes[i])[j]=23;j++; 
  (nodes[i])[j]=22;j++; 
  i++;

  nNodes[i]=3;      // 11
  nodes[i]=new long[nNodes[i]];
  j=0;
  (nodes[i])[j]=20;j++; 
  (nodes[i])[j]=25;j++; 
  (nodes[i])[j]=24;j++; 
  i++;

  nNodes[i]=3;      // 12
  nodes[i]=new long[nNodes[i]];
  j=0;
  (nodes[i])[j]=21;j++; 
  (nodes[i])[j]=27;j++; 
  (nodes[i])[j]=26;j++; 
  i++;

  NAManifold *tesselation=new NATwoDimensionalIrregularGrid(nVertices,2,x,nFaces,nNodes,nodes);
  NADraw(tesselation,"gold3");
  NAGraphicsPause();
  NAGraphicsClose();

  tesselation-<unReference();

  delete [] x;
  delete [] nNodes;
  for(i=0;i

This is what I see when I run this:

 drawing a discrete 2-Manifold in 2-Space! (TwoDimensionalIrregularGrid)
shpause: Hit enter when you are ready to continue. "q" quits.



~NATopLevel: Just deleted the last NATopLevel Object
    total TopLevels allocated 3
          PointOnManifolds    2     smartPtr's 0
          Manifolds           1     smartPtr's 0
          FunctionSpaces      0     smartPtr's 0
          Functions           0     smartPtr's 0
          OperatorSpaces      0     smartPtr's 0
          Operators           0     smartPtr's 0
          Algorithms          0     
          Problems            0     
          Lists               0     

If we turn around and pass this irregular grid to the routine

NACreateTriangulatedPolygonalGrid
then we get back the grid

If we pass this triangular grid to the routine

NACreateRefinedTwoDimensionalGrid
then we get back the grid


Related Classes and Subroutines


The parent of this class:

Siblings of this class:

You may be interested in some of the routines which return NATwoDimensionalIrregularGrid's:


Created: Fri Oct 9 06:45:09 EDT 1998

[Comments | NAO home page ]

[Research home page]

[ IBM home page | Order | Privacy | ContactIBM | Legal ]