COVISE Core
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros
coDoUnstructuredGrid.h
Go to the documentation of this file.
1 /* This file is part of COVISE.
2 
3  You can use it under the terms of the GNU Lesser General Public License
4  version 2.1 or later, see lgpl-2.1.txt.
5 
6  * License: LGPL 2+ */
7 
8 #ifndef CO_DO_UNSTRUCTURED_GRID_H
9 #define CO_DO_UNSTRUCTURED_GRID_H
10 
12 {
13  TYPE_NONE = 0,
14  TYPE_BAR = 1,
16  TYPE_QUAD = 3,
22  TYPE_POINT = 10,
24 };
25 
26 #ifndef CELL_TYPES_ONLY
27 #include "coDoGrid.h"
28 
29 /***********************************************************************\
30  ** **
31  ** Unstructured classe Routines Version: 1.0 **
32  ** **
33  ** **
34  ** Description : Classes for the handling of unstructured grids **
35  ** in a distributed manner. **
36  ** **
37  ** Classe : coDoUnstructuredGrid **
38  ** **
39  ** **
40  ** Copyright (C) 1995 by University of Stuttgart **
41  ** Computer Center (RUS) **
42  ** Allmandring 30 **
43  ** 7000 Stuttgart 80 **
44  ** **
45  ** **
46  ** Author : Uwe Woessner **
47  ** **
48  ** History : **
49  ** 10.02.95 Ver 1.0 **
50  ** **
51  ** **
52 \***********************************************************************/
53 namespace covise
54 {
55 
57 
58 class coDoOctTree;
59 
61 {
62  friend class coDoInitializer;
63  static coDistributedObject *virtualCtor(coShmArray *arr);
64 
65 private:
66  enum
67  {
68  SHM_OBJ = 12
69  };
70  coIntShm numelem; // number of elements
71  coIntShm numconn; // number of connections
72  coIntShm numcoord; // number of coords
73  coIntShm numneighbor; // number of neighbors
74  coFloatShmArray x_coord; // coordinates in x-direction (length numcoord)
75  coFloatShmArray y_coord; // coordinates in y-direction (length numcoord)
76  coFloatShmArray z_coord; // coordinates in z-direction (length numcoord)
77  coIntShmArray connections; // connection list (length numconn)
78  coIntShmArray elements; // element list (length numelem)
79  coIntShmArray elementtypes; // elementtypes list (length numelem)
80  coIntShmArray neighborlist; // neighborlist list (length numneighbor)
81  coIntShmArray neighborindex; // neighborindex list (length numcoord)
82  mutable const coDistributedObject *oct_tree;
83 
84  int testACell(float *v_interp, const float *point,
85  int cell, int no_arrays, int array_dim,
86  float tolerance, const float *const *velo) const;
87  /*
88  bool IsInBBox(int cell,const float *point);
89  void BBoxForElement(float *cell_bbox,int elem);
90  float *cellBBoxes_; // do not delete this in the destructor!!!
91  // this should be destroyed by the module.
92  */
93 
94  void MakeOctTree(const char *octSurname) const;
95 
96  int hastypes;
98  mutable int *lnl; // lists all elements that contain a certain vertex
99  // consecutively
100  mutable int *lnli; // points into the lnl array to the starting index for
101  // each vertex
102  mutable int *el, *cl, *tl;
103 
104 protected:
105  int rebuildFromShm();
106  int getObjInfo(int, coDoInfo **) const;
107  coDoUnstructuredGrid *cloneObject(const coObjInfo &newinfo) const;
108 
109 public:
111  : coDoGrid(info)
112  , oct_tree(NULL)
113  , lnl(0)
114  , lnli(0)
115  {
116  setType("UNSGRD", "UNSTRUCTURED GRID");
117  hastypes = 0;
118  hasneighbors = 0;
119  if (name != (char *)0L)
120  {
121  if (getShmArray() != 0)
122  {
123  if (rebuildFromShm() == 0)
124  {
125  print_comment(__LINE__, __FILE__, "rebuildFromShm == 0");
126  }
127  }
128  else
129  {
130  print_comment(__LINE__, __FILE__, "object %s doesn't exist", name);
131  new_ok = 0;
132  }
133  }
134  };
135 
136  coDoUnstructuredGrid(const coObjInfo &info, coShmArray *arr);
137 
138  coDoUnstructuredGrid(const coObjInfo &info, int nelem, int nconn, int ncoord, int ht);
139  coDoUnstructuredGrid(const coObjInfo &info, int nelem, int nconn, int ncoord, int ht, int nneighbor);
140  coDoUnstructuredGrid(const coObjInfo &info, int nelem, int nconn, int ncoord,
141  int *el, int *cl, float *xc, float *yc, float *zc);
142  coDoUnstructuredGrid(const coObjInfo &info, int nelem, int nconn, int ncoord,
143  int *el, int *cl, float *xc, float *yc, float *zc,
144  int *tl);
145 
146  virtual ~coDoUnstructuredGrid();
147 
148  void computeNeighborList() const;
149 
150  void freeNeighborList() const
151  {
152  delete[] lnl;
153  lnl = NULL;
154  delete[] lnli;
155  lnli = NULL;
156  };
157 
158  void getAddresses(int **elem, int **conn,
159  float **x_c, float **y_c, float **z_c) const
160  {
161  *x_c = (float *)x_coord.getDataPtr();
162  *y_c = (float *)y_coord.getDataPtr();
163  *z_c = (float *)z_coord.getDataPtr();
164  *elem = (int *)elements.getDataPtr();
165  *conn = (int *)connections.getDataPtr();
166  };
167 
168  void getGridSize(int *e, int *c, int *p) const
169  {
170  *e = numelem;
171  *c = numconn;
172  *p = numcoord;
173  }
174 
175  int getNumPoints() const
176  {
177  return numcoord;
178  }
179 
180  int getNeighbor(int element, std::vector<int> face_nodes_list);
181  int getNeighbor(int element, int n1, int n2, int n3, int n4);
182  int getNeighbor(int element, int n1, int n2, int n3);
183  int getNeighbor(int element, int n1, int n2);
184  int getNeighbors(int element, int n1, int n2, int *neighbors);
185  int getNeighbors(int element, int n1, int *neighbors);
186 
187  void getNeighborList(int *n, int **l, int **li) const
188  {
189  if (!lnl)
190  computeNeighborList();
191  *l = lnl;
192  *li = lnli;
193  *n = numconn;
194  }
195 
196  void getTypeList(int **l) const
197  {
198  *l = (int *)elementtypes.getDataPtr();
199  }
200 
201  int hasNeighborList() const
202  {
203  return hasneighbors;
204  }
205 
206  int hasTypeList() const
207  {
208  return (elementtypes.get_length() > 0 ? 1 : 0);
209  }
210 
217  int setSizes(int numElem, int numConn, int numCoord);
218 
219  // use oct-trees for cell location and field interpolation
220  // Interpolates fields of any nature given a point and an input field
221  // on the gitter nodes.
222  // return -1: point is not in domain
223  // return 0: is in domain, velo is interpolated in v_interp if this
224  // pointer and velo are not NULL.
225  // Inputs: point, no_arrays, array_dim, velo.
226  // Outputs: v_interp, cell.
227 
228  // For interpolation the function assumes that the input
229  // onsists of vertex-based data.
230  // velo is an array of $no_arrays pointers to float arrays,
231  // whose contents are grouped in groups of $array_dim floats.
232  // These groups are values for a point. This organisation
233  // is so complicated because of the unfelicitous fact that
234  // scalars and tensors are defined in a unique array and
235  // vectors in three. So if you get a scalar, you typically
236  // have no_arrays==1 and array_dim==1. If you get a vector,
237  // no_arrays==3 and array_dim==1. And if you get a tensor,
238  // then no_arrays==1 and array_dim==dimensionality of tensor type.
239  // The organisation of the output is as follows:
240  // cell is an array with 3 integer values determining the cell.
241  // v_interp contains no_arrays groups of array_dim floats:
242  // the caller is responsible for memory allocation.
243  int interpolateField(float *v_interp, const float *point,
244  int *cell, int no_arrays, int array_dim,
245  float tolerance, const float *const *velo) const;
246 
247  // Map scalar fields (used in PStreamline; analogous to interpolateField)
248  int mapScalarField(float *v_interp, const float *point,
249  int *cell, int no_arrays, int array_dim,
250  /*float tolerance,*/ const float *const *velo);
251 
252  // Interpolate data within the cell (analogous to testACell)
253  void mapInCell(float *v_interp, const float *point,
254  int cell, int no_arrays, int array_dim,
255  const float *const *velo);
256 
257  // searchCell in OctTree (create OctTree if not available)
258  int getCell(const float *point, float tolerance);
259 
260  const coDoOctTree *GetOctTree(const coDistributedObject *reuseOctTree,
261  const char *OctTreeSurname) const;
262 
263  // checks all hexahedron elements if their connectivity
264  // leads to PRISMs, QUADs or TETRAHEDRONs and fix them
265  void compressConnectivity();
266  int getNumConnOfElement(int elem) const;
267 };
268 }
269 #endif /* CELL_TYPES_ONLY */
270 
271 #endif
int UnstructuredGrid_Num_Nodes[20]
Definition: coDoUnstructuredGrid.cpp:17
coIntShmArray elements
Definition: coDoUnstructuredGrid.h:78
ELEM_TYPE
Definition: coDoUnstructuredGrid.h:11
coIntShm numconn
Definition: coDoUnstructuredGrid.h:71
Definition: coDoGrid.h:16
coIntShmArray neighborindex
Definition: coDoUnstructuredGrid.h:81
int hasneighbors
Definition: coDoUnstructuredGrid.h:97
coFloatShmArray z_coord
Definition: coDoUnstructuredGrid.h:76
void freeNeighborList() const
Definition: coDoUnstructuredGrid.h:150
Definition: coDoUnstructuredGrid.h:20
coIntShm numelem
Definition: coDoUnstructuredGrid.h:70
coDoUnstructuredGrid(const coObjInfo &info)
Definition: coDoUnstructuredGrid.h:110
Definition: coDoUnstructuredGrid.h:18
int hastypes
Definition: coDoUnstructuredGrid.h:96
Definition: covise_shm.h:479
coIntShm numcoord
Definition: coDoUnstructuredGrid.h:72
static coShmArray * getShmArray(const char *name)
Definition: coDistributedObject.cpp:60
coIntShm numneighbor
Definition: coDoUnstructuredGrid.h:73
Definition: coDoUnstructuredGrid.h:22
Definition: coDoUnstructuredGrid.h:23
int * lnl
Definition: coDoUnstructuredGrid.h:98
Definition: covise_statics.cpp:54
Definition: coDoUnstructuredGrid.h:19
void getAddresses(int **elem, int **conn, float **x_c, float **y_c, float **z_c) const
Definition: coDoUnstructuredGrid.h:158
void print_comment(int line, const char *filename, const char *fmt,...)
Definition: coLog.cpp:25
#define NULL
Definition: covise_list.h:22
Definition: coDoUnstructuredGrid.h:60
const coDistributedObject * oct_tree
Definition: coDoUnstructuredGrid.h:82
GLdouble n
Definition: khronos-glext.h:8447
Definition: coDoUnstructuredGrid.h:15
Definition: coObjID.h:230
void getGridSize(int *e, int *c, int *p) const
Definition: coDoUnstructuredGrid.h:168
Definition: coDoUnstructuredGrid.h:16
#define DOEXPORT
Definition: coExport.h:307
Definition: coDoUnstructuredGrid.h:17
Definition: coDistributedObject.h:265
Definition: coDoOctTree.h:31
Definition: coDoUnstructuredGrid.h:13
int hasTypeList() const
Definition: coDoUnstructuredGrid.h:206
int * lnli
Definition: coDoUnstructuredGrid.h:100
coFloatShmArray x_coord
Definition: coDoUnstructuredGrid.h:74
coIntShmArray connections
Definition: coDoUnstructuredGrid.h:77
Definition: coDoUnstructuredGrid.h:21
coIntShmArray elementtypes
Definition: coDoUnstructuredGrid.h:79
coFloatShmArray y_coord
Definition: coDoUnstructuredGrid.h:75
const GLubyte * c
Definition: khronos-glext.h:9864
GLfloat GLfloat p
Definition: khronos-glext.h:9861
Definition: coDoUnstructuredGrid.h:14
coIntShmArray neighborlist
Definition: coDoUnstructuredGrid.h:80
Definition: coDistributedObject.h:294
int * tl
Definition: coDoUnstructuredGrid.h:102
void getTypeList(int **l) const
Definition: coDoUnstructuredGrid.h:196
int hasNeighborList() const
Definition: coDoUnstructuredGrid.h:201
GLuint const GLchar * name
Definition: khronos-glext.h:6722
int getNumPoints() const
Definition: coDoUnstructuredGrid.h:175
void getNeighborList(int *n, int **l, int **li) const
Definition: coDoUnstructuredGrid.h:187