52 { decompositionType::FACE_CENTRE_TRIS,
"faceCentre" },
53 { decompositionType::FACE_DIAG_TRIS,
"faceDiagonal" },
54 { decompositionType::PYRAMID,
"pyramid" },
60 void Foam::tetDecomposer::modifyFace
62 polyTopoChange& meshMod,
73 if (nei == -1 || own < nei)
104 void Foam::tetDecomposer::addFace
106 polyTopoChange& meshMod,
110 const label masterPointID,
111 const label masterEdgeID,
112 const label masterFaceID,
119 if (nei == -1 || own < nei)
155 Foam::label Foam::tetDecomposer::triIndex(
const label facei,
const label fp)
158 const face&
f = mesh_.faces()[facei];
159 const label fp0 =
max(0, mesh_.tetBasePtIs()[facei]);
167 else if (fp ==
f.rcIndex(fp0))
169 thisTrii =
f.size()-3;
173 thisTrii = (fp-fp0-1) % (
f.size()-2);
192 const bitSet& decomposeCell,
196 cellToPoint_.setSize(mesh_.nCells(), -1);
197 forAll(mesh_.cellCentres(), celli)
199 if (decomposeCell[celli])
202 label masterPointi = mesh_.faces()[mesh_.cells()[celli][0]][0];
204 cellToPoint_[celli] = meshMod.
addPoint
206 mesh_.cellCentres()[celli],
216 bitSet decomposeFace(mesh_.nFaces());
218 for (label facei = 0; facei < mesh_.nInternalFaces(); facei++)
220 label own = mesh_.faceOwner()[facei];
221 label nei = mesh_.faceNeighbour()[facei];
222 if (decomposeCell[own] || decomposeCell[nei])
224 decomposeFace[facei] =
true;
228 boolList neiDecomposeCell(mesh_.nBoundaryFaces());
229 forAll(neiDecomposeCell, bFacei)
231 label facei = mesh_.nInternalFaces()+bFacei;
232 label own = mesh_.faceOwner()[facei];
233 neiDecomposeCell[bFacei] = decomposeCell[own];
239 label facei = mesh_.nInternalFaces();
240 facei < mesh_.nFaces();
244 label own = mesh_.faceOwner()[facei];
245 label bFacei = facei-mesh_.nInternalFaces();
246 if (decomposeCell[own] || neiDecomposeCell[bFacei])
248 decomposeFace[facei] =
true;
255 if (decomposeType == FACE_CENTRE_TRIS)
257 faceToPoint_.setSize(mesh_.nFaces(), -1);
258 forAll(mesh_.faceCentres(), facei)
260 if (decomposeFace[facei])
263 const label masterPointi = mesh_.faces()[facei][0];
265 faceToPoint_[facei] = meshMod.
addPoint
267 mesh_.faceCentres()[facei],
279 faceOwnerCells_.setSize(mesh_.nFaces());
280 faceNeighbourCells_.setSize(mesh_.nFaces());
282 if (decomposeType == FACE_CENTRE_TRIS)
284 forAll(faceOwnerCells_, facei)
286 const face&
f = mesh_.faces()[facei];
287 faceOwnerCells_[facei].
setSize(
f.size(), -1);
288 faceNeighbourCells_[facei].setSize(
f.size(), -1);
291 else if (decomposeType == FACE_DIAG_TRIS)
294 (void)mesh_.tetBasePtIs();
296 forAll(faceOwnerCells_, facei)
298 const face&
f = mesh_.faces()[facei];
299 faceOwnerCells_[facei].
setSize(
f.size()-2, -1);
300 faceNeighbourCells_[facei].setSize(
f.size()-2, -1);
305 forAll(faceOwnerCells_, facei)
307 faceOwnerCells_[facei].setSize(1, -1);
308 faceNeighbourCells_[facei].setSize(1, -1);
315 forAll(mesh_.cells(), celli)
317 const cell& cFaces = mesh_.cells()[celli];
320 bool modifiedCell =
false;
324 label facei = cFaces[cFacei];
325 const face&
f = mesh_.faces()[facei];
330 (mesh_.faceOwner()[facei] == celli)
331 ? faceOwnerCells_[facei]
332 : faceNeighbourCells_[facei]
335 if (decomposeCell[celli])
337 if (decomposeType == FACE_CENTRE_TRIS)
355 mesh_.cellZones().whichZone(celli)
360 else if (decomposeType == FACE_DIAG_TRIS)
362 for (label triI = 0; triI <
f.size()-2; triI++)
378 mesh_.cellZones().whichZone(celli)
407 mesh_.cellZones().whichZone(celli)
425 forAll(mesh_.faces(), facei)
427 label own = mesh_.faceOwner()[facei];
428 const labelList& addedOwn = faceOwnerCells_[facei];
429 const labelList& addedNei = faceNeighbourCells_[facei];
430 const face&
f = mesh_.faces()[facei];
433 if (facei >= mesh_.nInternalFaces())
435 patchi = mesh_.boundaryMesh().whichPatch(facei);
438 label zoneI = mesh_.faceZones().whichZone(facei);
439 bool zoneFlip =
false;
442 const faceZone& fz = mesh_.faceZones()[zoneI];
449 if (decomposeType == FACE_CENTRE_TRIS && decomposeFace[facei])
501 if (decomposeCell[own])
503 label newOwn = addedOwn[
f.rcIndex(fp)];
504 label newNei = addedOwn[fp];
527 facei < mesh_.nInternalFaces()
528 && decomposeCell[mesh_.faceNeighbour()[facei]]
531 label newOwn = addedNei[
f.rcIndex(fp)];
532 label newNei = addedNei[fp];
536 triangle[2] = cellToPoint_[mesh_.faceNeighbour()[facei]];
554 else if (decomposeType == FACE_DIAG_TRIS && decomposeFace[facei])
556 label fp0 =
max(mesh_.tetBasePtIs()[facei], 0);
557 label fp =
f.fcIndex(fp0);
559 for (label triI = 0; triI <
f.size()-2; triI++)
561 label nextTri = triI+1;
562 if (nextTri >=
f.size()-2)
564 nextTri -=
f.size()-2;
566 label nextFp =
f.fcIndex(fp);
613 if (triI <
f.size()-3)
615 if (decomposeCell[own])
617 label newOwn = addedOwn[triI];
618 label newNei = addedOwn[nextTri];
642 facei < mesh_.nInternalFaces()
643 && decomposeCell[mesh_.faceNeighbour()[facei]]
646 label newOwn = addedNei[triI];
647 label newNei = addedNei[nextTri];
652 cellToPoint_[mesh_.faceNeighbour()[facei]];
696 forAll(mesh_.cells(), celli)
698 const cell& cFaces = mesh_.cells()[celli];
704 label facei = cFaces[cFacei];
706 if (decomposeCell[celli])
708 const face&
f = mesh_.faces()[facei];
713 label p1 =
f[
f.fcIndex(fp)];
717 if (edgeFnd == edgeToFace.
end())
724 label otherFacei = edgeFnd();
725 const face& otherF = mesh_.faces()[otherFacei];
731 label otherFp = otherF.find(
p0);
736 else if (otherF.
prevLabel(otherFp) == p1)
738 otherFp = otherF.rcIndex(otherFp);
748 if (mesh_.faceOwner()[facei] == celli)
762 label thisTet, otherTet;
764 if (decomposeType == FACE_CENTRE_TRIS)
766 if (mesh_.faceOwner()[facei] == celli)
768 thisTet = faceOwnerCells_[facei][fp];
772 thisTet = faceNeighbourCells_[facei][fp];
775 if (mesh_.faceOwner()[otherFacei] == celli)
778 faceOwnerCells_[otherFacei][otherFp];
783 faceNeighbourCells_[otherFacei][otherFp];
786 else if (decomposeType == FACE_DIAG_TRIS)
788 label thisTriI = triIndex(facei, fp);
789 if (mesh_.faceOwner()[facei] == celli)
791 thisTet = faceOwnerCells_[facei][thisTriI];
795 thisTet = faceNeighbourCells_[facei][thisTriI];
798 label otherTriI = triIndex(otherFacei, otherFp);
799 if (mesh_.faceOwner()[otherFacei] == celli)
802 faceOwnerCells_[otherFacei][otherTriI];
807 faceNeighbourCells_[otherFacei][otherTriI];
812 if (mesh_.faceOwner()[facei] == celli)
814 thisTet = faceOwnerCells_[facei][0];
818 thisTet = faceNeighbourCells_[facei][0];
820 if (mesh_.faceOwner()[otherFacei] == celli)
822 otherTet = faceOwnerCells_[otherFacei][0];
827 faceNeighbourCells_[otherFacei][0];
857 forAll(faceOwnerCells_, facei)
861 forAll(faceNeighbourCells_, facei)