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]);
187 thisTrii =
f.
size()-3;
191 const label fpB = fp+
f.
size();
192 thisTrii = (fpB-fp0-1);
196 thisTrii = (fp-fp0-1);
204 Foam::tetDecomposer::tetDecomposer(
const polyMesh&
mesh)
214 const decompositionType decomposeType,
215 const bitSet& decomposeCell,
219 cellToPoint_.setSize(mesh_.nCells(), -1);
220 forAll(mesh_.cellCentres(), celli)
222 if (decomposeCell[celli])
225 label masterPointi = mesh_.faces()[mesh_.cells()[celli][0]][0];
227 cellToPoint_[celli] = meshMod.
addPoint 229 mesh_.cellCentres()[celli],
239 bitSet decomposeFace(mesh_.nFaces());
241 for (label facei = 0; facei < mesh_.nInternalFaces(); facei++)
243 label own = mesh_.faceOwner()[facei];
244 label nei = mesh_.faceNeighbour()[facei];
245 if (decomposeCell[own] || decomposeCell[nei])
247 decomposeFace[facei] =
true;
251 boolList neiDecomposeCell(mesh_.nBoundaryFaces());
252 forAll(neiDecomposeCell, bFacei)
254 label facei = mesh_.nInternalFaces()+bFacei;
255 label own = mesh_.faceOwner()[facei];
256 neiDecomposeCell[bFacei] = decomposeCell[own];
262 label facei = mesh_.nInternalFaces();
263 facei < mesh_.nFaces();
267 label own = mesh_.faceOwner()[facei];
268 label bFacei = facei-mesh_.nInternalFaces();
269 if (decomposeCell[own] || neiDecomposeCell[bFacei])
271 decomposeFace[facei] =
true;
278 if (decomposeType == FACE_CENTRE_TRIS)
280 faceToPoint_.setSize(mesh_.nFaces(), -1);
281 forAll(mesh_.faceCentres(), facei)
283 if (decomposeFace[facei])
286 const label masterPointi = mesh_.faces()[facei][0];
288 faceToPoint_[facei] = meshMod.
addPoint 290 mesh_.faceCentres()[facei],
302 faceOwnerCells_.setSize(mesh_.nFaces());
303 faceNeighbourCells_.setSize(mesh_.nFaces());
305 if (decomposeType == FACE_CENTRE_TRIS)
307 forAll(faceOwnerCells_, facei)
309 const face&
f = mesh_.faces()[facei];
311 faceNeighbourCells_[facei].setSize(
f.
size(), -1);
314 else if (decomposeType == FACE_DIAG_TRIS)
317 (void)mesh_.tetBasePtIs();
319 forAll(faceOwnerCells_, facei)
321 const face&
f = mesh_.faces()[facei];
323 faceNeighbourCells_[facei].setSize(
f.
size()-2, -1);
328 forAll(faceOwnerCells_, facei)
330 faceOwnerCells_[facei].setSize(1, -1);
331 faceNeighbourCells_[facei].setSize(1, -1);
338 forAll(mesh_.cells(), celli)
340 const cell& cFaces = mesh_.cells()[celli];
343 bool modifiedCell =
false;
347 label facei = cFaces[cFacei];
348 const face&
f = mesh_.faces()[facei];
353 (mesh_.faceOwner()[facei] == celli)
354 ? faceOwnerCells_[facei]
355 : faceNeighbourCells_[facei]
358 if (decomposeCell[celli])
360 if (decomposeType == FACE_CENTRE_TRIS)
378 mesh_.cellZones().whichZone(celli)
383 else if (decomposeType == FACE_DIAG_TRIS)
385 for (label triI = 0; triI <
f.
size()-2; triI++)
401 mesh_.cellZones().whichZone(celli)
430 mesh_.cellZones().whichZone(celli)
448 forAll(mesh_.faces(), facei)
450 label own = mesh_.faceOwner()[facei];
451 const labelList& addedOwn = faceOwnerCells_[facei];
452 const labelList& addedNei = faceNeighbourCells_[facei];
453 const face&
f = mesh_.faces()[facei];
456 if (facei >= mesh_.nInternalFaces())
458 patchi = mesh_.boundaryMesh().whichPatch(facei);
461 label zoneI = mesh_.faceZones().whichZone(facei);
462 bool zoneFlip =
false;
465 const faceZone& fz = mesh_.faceZones()[zoneI];
466 zoneFlip = fz.flipMap()[fz.whichFace(facei)];
472 if (decomposeType == FACE_CENTRE_TRIS && decomposeFace[facei])
481 triangle[2] = faceToPoint_[facei];
524 if (decomposeCell[own])
526 label newOwn = addedOwn[
f.
rcIndex(fp)];
527 label newNei = addedOwn[fp];
530 triangle[1] = cellToPoint_[own];
531 triangle[2] = faceToPoint_[facei];
550 facei < mesh_.nInternalFaces()
551 && decomposeCell[mesh_.faceNeighbour()[facei]]
554 label newOwn = addedNei[
f.
rcIndex(fp)];
555 label newNei = addedNei[fp];
558 triangle[1] = faceToPoint_[facei];
559 triangle[2] = cellToPoint_[mesh_.faceNeighbour()[facei]];
577 else if (decomposeType == FACE_DIAG_TRIS && decomposeFace[facei])
579 label fp0 =
max(mesh_.tetBasePtIs()[facei], 0);
582 for (label triI = 0; triI <
f.
size()-2; triI++)
584 label nextTri = triI+1;
585 if (nextTri >=
f.
size()-2)
587 nextTri -=
f.
size()-2;
598 triangle[0] =
f[fp0];
600 triangle[2] =
f[nextFp];
636 if (triI <
f.
size()-3)
638 if (decomposeCell[own])
640 label newOwn = addedOwn[triI];
641 label newNei = addedOwn[nextTri];
643 triangle[0] =
f[fp0];
644 triangle[1] =
f[nextFp];
645 triangle[2] = cellToPoint_[own];
665 facei < mesh_.nInternalFaces()
666 && decomposeCell[mesh_.faceNeighbour()[facei]]
669 label newOwn = addedNei[triI];
670 label newNei = addedNei[nextTri];
672 triangle[0] =
f[nextFp];
673 triangle[1] =
f[fp0];
675 cellToPoint_[mesh_.faceNeighbour()[facei]];
717 EdgeMap<label> edgeToFace;
719 forAll(mesh_.cells(), celli)
721 const cell& cFaces = mesh_.cells()[celli];
727 label facei = cFaces[cFacei];
729 if (decomposeCell[celli])
731 const face&
f = mesh_.faces()[facei];
737 const edge
e(
p0, p1);
739 EdgeMap<label>::const_iterator edgeFnd = edgeToFace.find(
e);
740 if (edgeFnd == edgeToFace.end())
742 edgeToFace.insert(
e, facei);
747 label otherFacei = edgeFnd();
748 const face& otherF = mesh_.faces()[otherFacei];
754 label otherFp = otherF.find(
p0);
755 if (otherF.nextLabel(otherFp) == p1)
759 else if (otherF.prevLabel(otherFp) == p1)
761 otherFp = otherF.rcIndex(otherFp);
771 if (mesh_.faceOwner()[facei] == celli)
775 triangle[2] = cellToPoint_[celli];
781 triangle[2] = cellToPoint_[celli];
785 label thisTet, otherTet;
787 if (decomposeType == FACE_CENTRE_TRIS)
789 if (mesh_.faceOwner()[facei] == celli)
791 thisTet = faceOwnerCells_[facei][fp];
795 thisTet = faceNeighbourCells_[facei][fp];
798 if (mesh_.faceOwner()[otherFacei] == celli)
801 faceOwnerCells_[otherFacei][otherFp];
806 faceNeighbourCells_[otherFacei][otherFp];
809 else if (decomposeType == FACE_DIAG_TRIS)
811 label thisTriI = triIndex(facei, fp);
812 if (mesh_.faceOwner()[facei] == celli)
814 thisTet = faceOwnerCells_[facei][thisTriI];
818 thisTet = faceNeighbourCells_[facei][thisTriI];
821 label otherTriI = triIndex(otherFacei, otherFp);
822 if (mesh_.faceOwner()[otherFacei] == celli)
825 faceOwnerCells_[otherFacei][otherTriI];
830 faceNeighbourCells_[otherFacei][otherTriI];
835 if (mesh_.faceOwner()[facei] == celli)
837 thisTet = faceOwnerCells_[facei][0];
841 thisTet = faceNeighbourCells_[facei][0];
843 if (mesh_.faceOwner()[otherFacei] == celli)
845 otherTet = faceOwnerCells_[otherFacei][0];
850 faceNeighbourCells_[otherFacei][0];
880 forAll(faceOwnerCells_, facei)
884 forAll(faceNeighbourCells_, facei)
void size(const label n)
Older name for setAddressableSize.
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
static const Enum< decompositionType > decompositionTypeNames
label addCell(const label masterPointID, const label masterEdgeID, const label masterFaceID, const label masterCellID, const label zoneID)
Add cell. Return new cell label.
#define forAll(list, i)
Loop across all elements in list.
label fcIndex(const label i) const noexcept
The forward circular index. The next index in the list which returns to the first at the end of the l...
const dimensionedScalar e
Elementary charge.
void setSize(const label n)
Alias for resize()
errorManip< error > abort(error &err)
void setRefinement(const decompositionType decomposeType, const bitSet &decomposeCell, polyTopoChange &meshMod)
Insert all changes into meshMod to convert the polyMesh into.
defineTypeNameAndDebug(combustionModel, 0)
void inplaceRenumber(const labelUList &oldToNew, IntListType &input)
Inplace renumber the values (not the indices) of a list.
A bitSet stores bits (elements with only two states) in packed internal format and supports a variety...
Enum is a wrapper around a list of names/values that represent particular enumeration (or int) values...
Direct mesh changes based on v1.3 polyTopoChange syntax.
label addPoint(const point &pt, const label masterPointID, const label zoneID, const bool inCell)
Add point. Return new point label.
List< label > labelList
A List of labels.
label rcIndex(const label i) const noexcept
The reverse circular index. The previous index in the list which returns to the last at the beginning...
List< bool > boolList
A List of bools.
void updateMesh(const mapPolyMesh &)
Force recalculation of locally stored data on topological change.
const volScalarField & p0