35 unsigned int Tet::faceNodes[4][3] = { {0,1,2}, {0,3,1}, {1,3,2}, {2,3,0}};
51 template<
class CellTrait>
54 for(
int n=0; n<numNodes; n++) _nodeFirstFaceSig[n] = 0;
56 for(
int f=0; f<numFaces; f++)
58 _faceAllNodesSig[f] = 0;
59 for(
unsigned int nf=0; nf<CellTrait::faceNodeCount[f]; nf++)
61 unsigned int n = CellTrait::faceNodes[f][nf];
62 _faceAllNodesSig[f] |= (1<<n);
64 _nodeFirstFaceSig[n] = 1<<n;
68 for(
int f=0; f<numFaces; f++)
70 _faceFirstFaceNodesSig[f] = 0;
71 for(
unsigned int nf=0; nf<CellTrait::faceNodeCount[f]; nf++)
73 unsigned int n = CellTrait::faceNodes[f][nf];
74 _faceFirstFaceNodesSig[f] |= _nodeFirstFaceSig[n];
76 _faceFirstFaceNodesSigMap[_faceFirstFaceNodesSig[f]] = f;
80 for(
int f=0; f<numFaces; f++)
81 cout << _faceAllNodesSig[f] <<
" ";
84 for(
int n=0; n<numNodes; n++)
85 cout << _nodeFirstFaceSig[n] <<
" " ;
88 for(
int f=0; f<numFaces; f++)
89 cout << _faceFirstFaceNodesSig[f] <<
" " ;
95 template<
class CellTrait>
106 int face0NodeCount=0;
107 bool reverseFace0Nodes =
false;
109 for(
int nf=0; nf<numFaces; nf++)
111 const int f = cellFaces(c,nf);
112 if ((
unsigned int)faceNodes.
getCount(f) == CellTrait::faceNodeCount[0])
115 face0NodeCount = faceNodes.
getCount(f);
116 if (faceCells(f,0) != c)
118 if (faceCells(f,1) != c)
119 cerr <<
"malformed grid " << endl;
120 reverseFace0Nodes =
true;
126 map<int, unsigned int> thisNodesFirstFaceNodesSig;
128 for(
unsigned int nn=0; nn<(
unsigned int)face0NodeCount; nn++)
130 int node = faceNodes(face0,nn);
131 if (reverseFace0Nodes) node = faceNodes(face0,face0NodeCount-nn-1);
132 thisNodesFirstFaceNodesSig[node] = 1<<nn;
135 int orderedFaces[numFaces];
137 for(
int nf=0; nf<numFaces; nf++)
139 unsigned int thisFaceFirstFaceNodesSig = 0;
140 const int f = cellFaces(c,nf);
142 for(
int nn=0; nn<faceNodes.
getCount(f); nn++)
144 const int n = faceNodes(f,nn);
146 if (thisNodesFirstFaceNodesSig.find(n) !=
147 thisNodesFirstFaceNodesSig.end())
148 thisFaceFirstFaceNodesSig |= thisNodesFirstFaceNodesSig[n];
151 int faceOrder = _faceFirstFaceNodesSigMap[thisFaceFirstFaceNodesSig];
152 orderedFaces[faceOrder] = f;
155 for(
int nf=0; nf<numFaces; nf++)
156 cellFaces(c,nf) = orderedFaces[nf];
159 map<int, unsigned int> thisNodesAllFaceNodesSig;
161 for(
int nf=0; nf<numFaces; nf++)
164 const int f = cellFaces(c,nf);
168 const int faceNodeCount = faceNodes.
getCount(f);
169 for(
int nn=0; nn<faceNodeCount; nn++)
171 int n = faceNodes(f,nn);
172 if (reverseFace0Nodes) n = faceNodes(f,faceNodeCount-nn-1);
174 if (thisNodesAllFaceNodesSig.find(n) ==
175 thisNodesAllFaceNodesSig.end())
177 thisNodesAllFaceNodesSig[n] =
178 _faceAllNodesSig[nf];
182 thisNodesAllFaceNodesSig[n] &=
183 _faceAllNodesSig[nf];
188 for( map<int,unsigned int>::const_iterator pos =
189 thisNodesAllFaceNodesSig.begin();
190 pos != thisNodesAllFaceNodesSig.end();
193 const int node = pos->first;
195 const int index = (int) log2(pos->second);
197 cellNodes(c,index) = node;
250 for(
int c=0; c<numCells; c++)
252 const int numCellNodes = cellNodes.
getCount(c);
253 const int numCellFaces = cellFaces.
getCount(c);
255 int edgeFaceCount =0;
256 int triFaceCount = 0;
257 int quadFaceCount = 0;
258 for(
int nf=0; nf<numCellFaces; nf++)
260 const int f = cellFaces(c,nf);
261 const int faceNodeCount = faceNodes.
getCount(f);
262 switch(faceNodeCount)
278 if (numCellNodes == 4 && edgeFaceCount == 4)
280 quad.orderCellFacesAndNodes(c,cellFaces,cellNodes,
281 faceNodes,faceCells,nodeCoordinates);
283 else if (numCellNodes == 3 && edgeFaceCount == 3)
285 tri.orderCellFacesAndNodes(c,cellFaces,cellNodes,
286 faceNodes,faceCells,nodeCoordinates);
288 else if (numCellNodes == edgeFaceCount)
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++)
297 const int nodeIndex = cellNodes(c,nn);
299 nodeCoordinates[nodeIndex] - mean;
300 const double angle = atan2(xm[1], xm[0]);
301 angles.push_back(
MyCoords(nodeIndex,angle));
306 for(
int nn=0; nn<numCellNodes; nn++)
308 cellNodes(c,nn) = angles[nn].i;
311 else if (numCellNodes == 8 && quadFaceCount == 6)
313 hexCell.orderCellFacesAndNodes(c,cellFaces,cellNodes,
314 faceNodes,faceCells,nodeCoordinates);
316 else if (numCellNodes == 4 && triFaceCount == 4)
318 tetCell.orderCellFacesAndNodes(c,cellFaces,cellNodes,
319 faceNodes,faceCells,nodeCoordinates);
321 else if (numCellNodes == 5 && triFaceCount == 4 &&
324 pyramidCell.orderCellFacesAndNodes(c,cellFaces,cellNodes,
328 else if (numCellNodes == 6 && triFaceCount == 2 &&
331 prismCell.orderCellFacesAndNodes(c,cellFaces,cellNodes,
338 cerr <<
"unimplemented cell type: numCellnodes = "
340 <<
" quadFaceCount = " << quadFaceCount
341 <<
" triFaceCount = " << triFaceCount
342 <<
" edgeFaceCount = " << edgeFaceCount
static unsigned int faceNodes[numFaces][3]
int getCount(const int i) const
void orderCellFacesAndNodes(const int c, CRConnectivity &cellFaces, CRConnectivity &cellNodes, const CRConnectivity &faceNodes, const CRConnectivity &faceCells, const Array< Vector< double, 3 > > &nodeCoordinates)
static unsigned int faceNodeCount[numFaces]
static Cell< Pyramid > pyramidCell
MyCoords(const MyCoords &o)
static Cell< Tet > tetCell
static Cell< Prism > prismCell
void orderCellFacesAndNodes(CRConnectivity &cellFaces, CRConnectivity &cellNodes, const CRConnectivity &faceNodes, const CRConnectivity &faceCells, const Array< Vector< double, 3 > > &nodeCoordinates)
static unsigned int faceNodes[numFaces][2]
bool myCoordComparison(const MyCoords &a, const MyCoords &b)
static unsigned int faceNodeCount[numFaces]
static unsigned int faceNodes[numFaces][4]
static Cell< Hex > hexCell
static unsigned int faceNodeCount[numFaces]
static unsigned int faceNodes[numFaces][4]
static unsigned int faceNodes[numFaces][4]
static unsigned int faceNodes[numFaces][2]
static unsigned int faceNodeCount[numFaces]
static unsigned int faceNodeCount[numFaces]
static unsigned int faceNodeCount[numFaces]
MyCoords(int i_, const double x_)
const StorageSite & getRowSite() const