Memosa-FVM  0.2
Cell.cpp File Reference
#include "Cell.h"
#include <iostream>
#include <math.h>
#include <algorithm>
#include "CRConnectivity.h"
#include "Quad.h"
#include "Tri.h"
#include "Hex.h"
#include "Tet.h"
#include "Pyramid.h"
#include "Prism.h"
#include "StorageSite.h"
Include dependency graph for Cell.cpp:

Go to the source code of this file.

Classes

struct  MyCoords
 

Functions

bool myCoordComparison (const MyCoords &a, const MyCoords &b)
 
void orderCellFacesAndNodes (CRConnectivity &cellFaces, CRConnectivity &cellNodes, const CRConnectivity &faceNodes, const CRConnectivity &faceCells, const Array< Vector< double, 3 > > &nodeCoordinates)
 

Variables

static Cell< Quadquad
 
static Cell< Tritri
 
static Cell< HexhexCell
 
static Cell< TettetCell
 
static Cell< PyramidpyramidCell
 
static Cell< PrismprismCell
 

Function Documentation

bool myCoordComparison ( const MyCoords a,
const MyCoords b 
)

Definition at line 235 of file Cell.cpp.

References MyCoords::x.

Referenced by orderCellFacesAndNodes().

236 {
237  return (a.x<b.x);
238 }
double x
Definition: Cell.cpp:232
void orderCellFacesAndNodes ( CRConnectivity cellFaces,
CRConnectivity cellNodes,
const CRConnectivity faceNodes,
const CRConnectivity faceCells,
const Array< Vector< double, 3 > > &  nodeCoordinates 
)

Definition at line 241 of file Cell.cpp.

References CRConnectivity::getCount(), CRConnectivity::getRowSite(), StorageSite::getSelfCount(), hexCell, myCoordComparison(), prismCell, pyramidCell, quad, tetCell, and tri.

Referenced by Mesh::getCellNodes().

246 {
247 
248  const int numCells = cellNodes.getRowSite().getSelfCount();
249 
250  for(int c=0; c<numCells; c++)
251  {
252  const int numCellNodes = cellNodes.getCount(c);
253  const int numCellFaces = cellFaces.getCount(c);
254 
255  int edgeFaceCount =0;
256  int triFaceCount = 0;
257  int quadFaceCount = 0;
258  for(int nf=0; nf<numCellFaces; nf++)
259  {
260  const int f = cellFaces(c,nf);
261  const int faceNodeCount = faceNodes.getCount(f);
262  switch(faceNodeCount)
263  {
264  case 2:
265  edgeFaceCount++;
266  break;
267  case 3:
268  triFaceCount++;
269  break;
270  case 4:
271  quadFaceCount++;
272  break;
273  default:
274  break;
275  }
276  }
277 
278  if (numCellNodes == 4 && edgeFaceCount == 4)
279  {
280  quad.orderCellFacesAndNodes(c,cellFaces,cellNodes,
281  faceNodes,faceCells,nodeCoordinates);
282  }
283  else if (numCellNodes == 3 && edgeFaceCount == 3)
284  {
285  tri.orderCellFacesAndNodes(c,cellFaces,cellNodes,
286  faceNodes,faceCells,nodeCoordinates);
287  }
288  else if (numCellNodes == edgeFaceCount)
289  {
290  vector<MyCoords> angles;
292  for(int nn=0; nn<numCellNodes; nn++)
293  mean += nodeCoordinates[cellNodes(c,nn)];
294  mean /= numCellNodes;
295  for(int nn=0; nn<numCellNodes; nn++)
296  {
297  const int nodeIndex = cellNodes(c,nn);
298  const Vector<double,3> xm =
299  nodeCoordinates[nodeIndex] - mean;
300  const double angle = atan2(xm[1], xm[0]);
301  angles.push_back(MyCoords(nodeIndex,angle));
302  }
303 
304  sort(angles.begin(),angles.end(),myCoordComparison);
305 
306  for(int nn=0; nn<numCellNodes; nn++)
307  {
308  cellNodes(c,nn) = angles[nn].i;
309  }
310  }
311  else if (numCellNodes == 8 && quadFaceCount == 6)
312  {
313  hexCell.orderCellFacesAndNodes(c,cellFaces,cellNodes,
314  faceNodes,faceCells,nodeCoordinates);
315  }
316  else if (numCellNodes == 4 && triFaceCount == 4)
317  {
318  tetCell.orderCellFacesAndNodes(c,cellFaces,cellNodes,
319  faceNodes,faceCells,nodeCoordinates);
320  }
321  else if (numCellNodes == 5 && triFaceCount == 4 &&
322  quadFaceCount == 1)
323  {
324  pyramidCell.orderCellFacesAndNodes(c,cellFaces,cellNodes,
325  faceNodes,faceCells,
326  nodeCoordinates);
327  }
328  else if (numCellNodes == 6 && triFaceCount == 2 &&
329  quadFaceCount == 3)
330  {
331  prismCell.orderCellFacesAndNodes(c,cellFaces,cellNodes,
332  faceNodes,faceCells,
333  nodeCoordinates);
334  }
335  else
336  {
337 #if 0
338  cerr << "unimplemented cell type: numCellnodes = "
339  << numCellNodes
340  << " quadFaceCount = " << quadFaceCount
341  << " triFaceCount = " << triFaceCount
342  << " edgeFaceCount = " << edgeFaceCount
343  << endl;
344 #endif
345  }
346  }
347 }
int getCount(const int i) const
int getSelfCount() const
Definition: StorageSite.h:40
static Cell< Quad > quad
Definition: Cell.cpp:210
static Cell< Pyramid > pyramidCell
Definition: Cell.cpp:214
static Cell< Tri > tri
Definition: Cell.cpp:211
static Cell< Tet > tetCell
Definition: Cell.cpp:213
static Cell< Prism > prismCell
Definition: Cell.cpp:215
bool myCoordComparison(const MyCoords &a, const MyCoords &b)
Definition: Cell.cpp:235
static Cell< Hex > hexCell
Definition: Cell.cpp:212
const StorageSite & getRowSite() const

Variable Documentation

Cell<Hex> hexCell
static

Definition at line 212 of file Cell.cpp.

Referenced by orderCellFacesAndNodes().

Cell<Prism> prismCell
static

Definition at line 215 of file Cell.cpp.

Referenced by orderCellFacesAndNodes().

Cell<Pyramid> pyramidCell
static

Definition at line 214 of file Cell.cpp.

Referenced by orderCellFacesAndNodes().

Cell<Quad> quad
static

Definition at line 210 of file Cell.cpp.

Referenced by orderCellFacesAndNodes().

Cell<Tet> tetCell
static

Definition at line 213 of file Cell.cpp.

Referenced by orderCellFacesAndNodes().

Cell<Tri> tri
static

Definition at line 211 of file Cell.cpp.

Referenced by orderCellFacesAndNodes().