forAll (cellFaces_, cellI) { const faceList& curFaces = cellFaces_[cellI]; // Get model faces faceList shapeFaces = cellShapes_[cellI].faces(); forAll (shapeFaces, faceI) { bool found = false; forAll (curFaces, i) { if (shapeFaces[faceI] == curFaces[i]) { found = true; break; } } if (!found) { Info << "Purging cell shape " << cellI << endl; cellShapes_[cellI] = cellShape(*unknownPtr_, labelList(0)); break; } }
void Foam::rotatedBoxToCell::combine(topoSet& set, const bool add) const { // Define a cell for the box pointField boxPoints(8); boxPoints[0] = origin_; boxPoints[1] = origin_ + i_; boxPoints[2] = origin_ + i_ + j_; boxPoints[3] = origin_ + j_; boxPoints[4] = origin_ + k_; boxPoints[5] = origin_ + k_ + i_; boxPoints[6] = origin_ + k_ + i_ + j_; boxPoints[7] = origin_ + k_ + j_; labelList boxVerts(8); forAll(boxVerts, i) { boxVerts[i] = i; } const cellModel& hex = *(cellModeller::lookup("hex")); // Get outwards pointing faces. faceList boxFaces(cellShape(hex, boxVerts).faces()); // Precalculate normals vectorField boxFaceNormals(boxFaces.size()); forAll(boxFaces, i) { boxFaceNormals[i] = boxFaces[i].normal(boxPoints); Pout<< "Face:" << i << " position:" << boxFaces[i].centre(boxPoints) << " normal:" << boxFaceNormals[i] << endl; }
void sammMesh::addSAMMcell ( const label typeFlag, const labelList& globalLabels, const label nCreatedCells ) { // grab the shape from the table if (!sammShapeLookup[typeFlag] || !sammAddressingTable[typeFlag]) { FatalErrorIn ( "sammMesh::addRegularCell(const labelList& labels, " "const label nCreatedCells)" ) << "SAMM type " << typeFlag << " has no registered label. BUG!" << abort(FatalError); } const cellModel& curModel = *(sammShapeLookup[typeFlag]); // get reference to the addressing list const label* addressing = sammAddressingTable[typeFlag]; // make a list of labels labelList sammCellLabels(curModel.nPoints(), -1); forAll(sammCellLabels, labelI) { sammCellLabels[labelI] = globalLabels[addressing[labelI]]; } cellShapes_[nCreatedCells] = cellShape(curModel, sammCellLabels); }
Foam::cellShape Foam::tetCell::tetCellShape() const { static const cellModel* tetModelPtr_ = NULL; if (!tetModelPtr_) { tetModelPtr_ = cellModeller::lookup("tet"); } const cellModel& tet = *tetModelPtr_; return cellShape(tet, *this); }
Foam::cellShape Foam::degenerateMatcher::match ( const faceList& faces, const labelList& owner, const label cellI, const labelList& cellFaces ) { // Recognize in order of assumed occurrence. if (hex.matchShape(false, faces, owner, cellI, cellFaces)) { return cellShape(hex.model(), hex.vertLabels()); } else if (tet.matchShape(false, faces, owner, cellI, cellFaces)) { return cellShape(tet.model(), tet.vertLabels()); } else if (prism.matchShape(false, faces, owner, cellI, cellFaces)) { return cellShape(prism.model(), prism.vertLabels()); } else if (pyr.matchShape(false, faces, owner, cellI, cellFaces)) { return cellShape(pyr.model(), pyr.vertLabels()); } else if (wedge.matchShape(false, faces, owner, cellI, cellFaces)) { return cellShape(wedge.model(), wedge.vertLabels()); } else if (tetWedge.matchShape(false, faces, owner, cellI, cellFaces)) { return cellShape(tetWedge.model(), tetWedge.vertLabels()); } else { return cellShape(*(cellModeller::lookup(0)), labelList(0)); } }
void starMesh::addRegularCell ( const labelList& labels, const label nCreatedCells ) { // Momory management static labelList labelsHex(8); static labelList labelsPrism(6); static labelList labelsPyramid(5); static labelList labelsTet(4); static labelList labelsTetWedge(5); label regularTypeFlag = -1; // grab the shape from the table const cellModel* curModelPtr = reinterpret_cast<cellModel*>(NULL); if // Tetrahedron ( labels[2] == labels[3] && labels[4] == labels[5] && labels[5] == labels[6] && labels[6] == labels[7] ) { regularTypeFlag = 0; curModelPtr = tetPtr_; } else if // Square-based pyramid ( labels[4] == labels[5] && labels[5] == labels[6] && labels[6] == labels[7] ) { regularTypeFlag = 1; curModelPtr = pyrPtr_; } else if // Tet Wedge ( labels[2] == labels[3] && labels[4] == labels[5] && labels[6] == labels[7] ) { regularTypeFlag = 2; curModelPtr = tetWedgePtr_; } else if // Triangular prism ( labels[2] == labels[3] && labels[6] == labels[7] ) { regularTypeFlag = 3; curModelPtr = prismPtr_; } else if // Wedge ( labels[4] == labels[7] ) { regularTypeFlag = 4; curModelPtr = wedgePtr_; } else // Hex { regularTypeFlag = 5; curModelPtr = hexPtr_; } labelList regularCellLabels(curModelPtr->nPoints(), -1); // get reference to the addressing list const label* addressing = regularAddressingTable[regularTypeFlag]; forAll (regularCellLabels, labelI) { regularCellLabels[labelI] = labels[addressing[labelI]]; } cellShapes_[nCreatedCells] = cellShape(*curModelPtr, regularCellLabels); }
void starMesh::addSAMMcell ( const labelList& labels, const label nCreatedCells ) { // get type, reg and permutation flag label typeFlag = labels[21]; // label regularityFlag = labels[22]; // Not used. label permutationFlag = labels[23]; // grab the shape from the table label sammTypeFlag = -1; const cellModel* curModelPtr = reinterpret_cast<cellModel*>(NULL); switch (typeFlag) { case 1: { sammTypeFlag = 1; curModelPtr = sammTrim1Ptr_; break; } case 2: { sammTypeFlag = 2; curModelPtr = sammTrim2Ptr_; break; } case 7: { if (labels[0] != -1) { sammTypeFlag = 3; curModelPtr = sammTrim3Ptr_; } else { sammTypeFlag = 5; curModelPtr = sammTrim5Ptr_; } break; } case 8: { sammTypeFlag = 4; curModelPtr = sammTrim4Ptr_; break; } case 85: { sammTypeFlag = 8; curModelPtr = sammTrim8Ptr_; break; } default: { FatalErrorIn ( "starMesh::addSAMMcell" "(const labelList& labels, const label nCreatedCells)" ) << "SAMM type " << sammTypeFlag << " is invalid" << abort(FatalError); } } // make a list of labels labelList sammCellLabels(curModelPtr->nPoints(), -1); // get reference to the addressing list const label* addressing = sammAddressingTable[sammTypeFlag]; forAll (sammCellLabels, labelI) { sammCellLabels[labelI] = labels[addressing[labelI]]; } cellShapes_[nCreatedCells] = cellShape(*curModelPtr, sammCellLabels); // set permutation flag for cell starCellPermutation_[nCreatedCells] = permutationFlag; }
void sammMesh::addRegularCell ( const labelList& labels, const label nCreatedCells ) { // Momory management static labelList labelsHex(8); static labelList labelsWedge(7); static labelList labelsPrism(6); static labelList labelsPyramid(5); static labelList labelsTet(4); static labelList labelsTetWedge(5); if // Tetrahedron ( labels[2] == labels[3] && labels[4] == labels[5] && labels[5] == labels[6] && labels[6] == labels[7] ) { labelsTet[0] = labels[0]; labelsTet[1] = labels[1]; labelsTet[2] = labels[2]; labelsTet[3] = labels[4]; cellShapes_[nCreatedCells] = cellShape(*tetPtr_, labelsTet); } else if // Square-based pyramid ( labels[4] == labels[5] && labels[5] == labels[6] && labels[6] == labels[7] ) { labelsPyramid[0] = labels[0]; labelsPyramid[1] = labels[1]; labelsPyramid[2] = labels[2]; labelsPyramid[3] = labels[3]; labelsPyramid[4] = labels[4]; cellShapes_[nCreatedCells] = cellShape(*pyrPtr_, labelsPyramid); } else if // Tet Wedge ( labels[2] == labels[3] && labels[4] == labels[5] && labels[6] == labels[7] ) { labelsTetWedge[0] = labels[0]; labelsTetWedge[1] = labels[1]; labelsTetWedge[2] = labels[2]; labelsTetWedge[3] = labels[4]; labelsTetWedge[4] = labels[6]; cellShapes_[nCreatedCells] = cellShape(*tetWedgePtr_, labelsTetWedge); } else if // Triangular prism ( labels[2] == labels[3] && labels[6] == labels[7] ) { labelsPrism[0] = labels[0]; labelsPrism[1] = labels[1]; labelsPrism[2] = labels[2]; labelsPrism[3] = labels[4]; labelsPrism[4] = labels[5]; labelsPrism[5] = labels[6]; cellShapes_[nCreatedCells] = cellShape(*prismPtr_, labelsPrism); } else if // Wedge ( labels[4] == labels[7] ) { labelsWedge[0] = labels[7]; labelsWedge[1] = labels[6]; labelsWedge[2] = labels[5]; labelsWedge[3] = labels[3]; labelsWedge[4] = labels[2]; labelsWedge[5] = labels[1]; labelsWedge[6] = labels[0]; cellShapes_[nCreatedCells] = cellShape(*wedgePtr_, labelsWedge); } else // Hex { labelsHex[0] = labels[0]; labelsHex[1] = labels[1]; labelsHex[2] = labels[2]; labelsHex[3] = labels[3]; labelsHex[4] = labels[4]; labelsHex[5] = labels[5]; labelsHex[6] = labels[6]; labelsHex[7] = labels[7]; cellShapes_[nCreatedCells] = cellShape(*hexPtr_, labelsHex); } }