69 bool Foam::meshCutAndRemove::isIn
84 cuts[cuts.fcIndex(index)] == twoCuts[1]
85 || cuts[cuts.rcIndex(index)] == twoCuts[1]
103 if (cuts.cellLoops()[cellI].size())
116 Foam::label Foam::meshCutAndRemove::findInternalFacePoint
129 label faceI = pFaces[pFaceI];
131 if (
mesh().isInternalFace(faceI))
138 if (pointLabels.empty())
142 "meshCutAndRemove::findInternalFacePoint(const labelList&)" 153 Foam::label Foam::meshCutAndRemove::findPatchFacePoint
156 const label exposedPatchI
164 label pointI = f[fp];
168 const labelList& pFaces = pointFaces[pointI];
172 if (patches.whichPatch(pFaces[i]) == exposedPatchI)
185 void Foam::meshCutAndRemove::faceCells
187 const cellCuts& cuts,
188 const label exposedPatchI,
202 if (cellLoops[own].size() && firstCommon(f, anchorPts[own]) == -1)
210 if (
mesh().isInternalFace(faceI))
214 if (cellLoops[nei].size() && firstCommon(f, anchorPts[nei]) == -1)
222 if (patchID == -1 && (own == -1 || nei == -1))
225 patchID = exposedPatchI;
230 void Foam::meshCutAndRemove::getZoneInfo
245 zoneFlip = fZone.flipMap()[fZone.whichFace(faceI)];
251 void Foam::meshCutAndRemove::addFace
253 polyTopoChange& meshMod,
255 const label masterPointI,
265 getZoneInfo(faceI, zoneID, zoneFlip);
267 if ((nei == -1) || (own != -1 && own < nei))
272 Pout<<
"Adding face " << newFace
273 <<
" with new owner:" << own
274 <<
" with new neighbour:" << nei
275 <<
" patchID:" << patchID
276 <<
" anchor:" << masterPointI
277 <<
" zoneID:" << zoneID
278 <<
" zoneFlip:" << zoneFlip
304 Pout<<
"Adding (reversed) face " << newFace.reverseFace()
305 <<
" with new owner:" << nei
306 <<
" with new neighbour:" << own
307 <<
" patchID:" << patchID
308 <<
" anchor:" << masterPointI
309 <<
" zoneID:" << zoneID
310 <<
" zoneFlip:" << zoneFlip
318 newFace.reverseFace(),
335 void Foam::meshCutAndRemove::modFace
337 polyTopoChange& meshMod,
348 getZoneInfo(faceI, zoneID, zoneFlip);
352 (own !=
mesh().faceOwner()[faceI])
354 mesh().isInternalFace(faceI)
355 && (nei !=
mesh().faceNeighbour()[faceI])
357 || (newFace !=
mesh().faces()[faceI])
362 Pout<<
"Modifying face " << faceI
363 <<
" old vertices:" <<
mesh().
faces()[faceI]
364 <<
" new vertices:" << newFace
365 <<
" new owner:" << own
366 <<
" new neighbour:" << nei
367 <<
" new patch:" << patchID
368 <<
" new zoneID:" << zoneID
369 <<
" new zoneFlip:" << zoneFlip
373 if ((nei == -1) || (own != -1 && own < nei))
397 newFace.reverseFace(),
414 void Foam::meshCutAndRemove::copyFace
428 newFace[newFp++] = f[fp];
430 fp = (fp + 1) % f.size();
432 newFace[newFp] = f[fp];
440 void Foam::meshCutAndRemove::splitFace
457 "meshCutAndRemove::splitFace" 458 ", const face&, const label, const label, face&, face&)" 459 ) <<
"Cannot find vertex (new numbering) " << v0
470 "meshCutAndRemove::splitFace(" 471 ", const face&, const label, const label, face&, face&)" 472 ) <<
"Cannot find vertex (new numbering) " << v1
478 f0.setSize((endFp + 1 + f.size() - startFp) % f.size());
479 f1.setSize(f.size() - f0.size() + 2);
481 copyFace(f, startFp, endFp, f0);
482 copyFace(f, endFp, startFp, f1);
488 Foam::face Foam::meshCutAndRemove::addEdgeCutsToFace(
const label faceI)
const 492 face newFace(2 * f.size());
499 newFace[newFp++] = f[fp];
502 label fp1 = f.fcIndex(fp);
504 HashTable<label, edge, Hash<edge> >::const_iterator fnd =
505 addedPoints_.find(edge(f[fp], f[fp1]));
507 if (fnd != addedPoints_.end())
510 newFace[newFp++] = fnd();
514 newFace.setSize(newFp);
529 face newFace(2*loop.size());
535 label cut = loop[fp];
539 label edgeI = getEdge(cut);
543 label vertI = addedPoints_[
e];
545 newFace[newFaceI++] = vertI;
550 label vertI = getVertex(cut);
552 newFace[newFaceI++] = vertI;
554 label nextCut = loop[loop.fcIndex(fp)];
556 if (!isEdge(nextCut))
559 label nextVertI = getVertex(nextCut);
566 HashTable<label, edge, Hash<edge> >::const_iterator fnd =
567 addedPoints_.find(
mesh().edges()[edgeI]);
569 if (fnd != addedPoints_.end())
571 newFace[newFaceI++] = fnd();
577 newFace.setSize(newFaceI);
598 const label exposedPatchI,
608 addedPoints_.clear();
609 addedPoints_.resize(cuts.
nLoops());
620 if (exposedPatchI < 0 || exposedPatchI >= patches.
size())
624 "meshCutAndRemove::setRefinement(" 625 ", const label, const cellCuts&, const labelList&" 627 ) <<
"Illegal exposed patch " << exposedPatchI
643 if (debug && findCutCell(cuts,
mesh().edgeCells()[edgeI]) == -1)
647 "meshCutAndRemove::setRefinement(" 648 ", const label, const cellCuts&, const labelList&" 650 ) <<
"Problem: cut edge but none of the cells using it is\n" 651 <<
"edge:" << edgeI <<
" verts:" << e
663 point newPt = weight*v1 + (1.0-weight)*v0;
678 addedPoints_.insert(e, addedPointI);
682 Pout<<
"Added point " << addedPointI
684 << masterPointI <<
" of edge " << edgeI
685 <<
" vertices " << e <<
endl;
699 const labelList& loop = cellLoops[cellI];
706 label cut = loop[fp];
714 const labelList& anchors = anchorPts[cellI];
718 usedPoint[anchors[i]] =
true;
728 usedPoint[cPoints[i]] =
true;
739 const edge& fCut = iter();
749 if (!usedPoint[pointI])
753 "meshCutAndRemove::setRefinement(" 754 ", const label, const cellCuts&, const labelList&" 756 ) <<
"Problem: faceSplitCut not used by any loop" 757 <<
" or cell anchor point" 758 <<
"face:" << iter.key() <<
" point:" << pointI
770 if (!usedPoint[pointI])
774 "meshCutAndRemove::setRefinement(" 775 ", const label, const cellCuts&, const labelList&" 777 ) <<
"Problem: point is marked as cut but" 778 <<
" not used by any loop" 779 <<
" or cell anchor point" 780 <<
"point:" << pointI
791 if (!usedPoint[pointI])
797 Pout<<
"Removing unused point " << pointI <<
endl;
810 const labelList& loop = cellLoops[cellI];
814 if (cutPatch[cellI] < 0 || cutPatch[cellI] >= patches.
size())
818 "meshCutAndRemove::setRefinement(" 819 ", const label, const cellCuts&, const labelList&" 821 ) <<
"Illegal patch " << cutPatch[cellI]
822 <<
" provided for cut cell " << cellI
830 face newFace(loopToFace(cellI, loop));
835 label masterPointI = findPatchFacePoint(newFace, exposedPatchI);
855 addedFaces_.
insert(cellI, addedFaceI);
859 Pout<<
"Added splitting face " << newFace <<
" index:" 860 << addedFaceI <<
" from masterPoint:" << masterPointI
861 <<
" to owner " << cellI <<
" with anchors:" 899 label faceI = iter.key();
902 face newFace(addEdgeCutsToFace(faceI));
905 const edge& splitEdge = iter();
907 label cut0 = splitEdge[0];
913 v0 = addedPoints_[
mesh().
edges()[edgeI]];
920 label cut1 = splitEdge[1];
925 v1 = addedPoints_[
mesh().
edges()[edgeI]];
934 splitFace(newFace, v0, v1, f0, f1);
940 if (
mesh().isInternalFace(faceI))
948 <<
" own:" << own <<
" nei:" << nei
950 <<
" and f1:" << f1 <<
endl;
969 if (cellLoops[own].empty())
975 else if (isIn(splitEdge, cellLoops[own]))
979 if (firstCommon(f0, anchorPts[own]) != -1)
996 if (firstCommon(f, anchorPts[own]) != -1)
1016 if (cellLoops[nei].empty())
1021 else if (isIn(splitEdge, cellLoops[nei]))
1027 if (firstCommon(f0, anchorPts[nei]) != -1)
1043 if (firstCommon(f, anchorPts[nei]) != -1)
1060 Pout<<
"f0 own:" << f0Own <<
" nei:" << f0Nei
1061 <<
" f1 own:" << f1Own <<
" nei:" << f1Nei
1072 patchID = exposedPatchI;
1079 bool modifiedFaceI =
false;
1086 modFace(meshMod, faceI, f0, f0Own, f0Nei, patchID);
1087 modifiedFaceI =
true;
1095 modFace(meshMod, faceI, f0, f0Own, f0Nei, patchID);
1096 modifiedFaceI =
true;
1101 modFace(meshMod, faceI, f0, f0Own, f0Nei, -1);
1102 modifiedFaceI =
true;
1120 modFace(meshMod, faceI, f1, f1Own, f1Nei, patchID);
1121 modifiedFaceI =
true;
1125 label masterPointI = findPatchFacePoint(f1, patchID);
1147 modFace(meshMod, faceI, f1, f1Own, f1Nei, patchID);
1148 modifiedFaceI =
true;
1152 label masterPointI = findPatchFacePoint(f1, patchID);
1171 modFace(meshMod, faceI, f1, f1Own, f1Nei, -1);
1172 modifiedFaceI =
true;
1176 label masterPointI = findPatchFacePoint(f1, -1);
1178 addFace(meshMod, faceI, masterPointI, f1, f1Own, f1Nei, -1);
1183 if (f0Own == -1 && f0Nei == -1 && !modifiedFaceI)
1189 Pout<<
"Removed face " << faceI <<
endl;
1193 faceUptodate[faceI] =
true;
1206 if (edgeIsCut[edgeI])
1212 label faceI = eFaces[i];
1214 if (!faceUptodate[faceI])
1221 label own, nei, patchID;
1222 faceCells(cuts, exposedPatchI, faceI, own, nei, patchID);
1225 if (own == -1 && nei == -1)
1231 Pout<<
"Removed face " << faceI <<
endl;
1237 face newFace(addEdgeCutsToFace(faceI));
1241 Pout<<
"Added edge cuts to face " << faceI
1243 <<
" newFace:" << newFace <<
endl;
1257 faceUptodate[faceI] =
true;
1274 if (!faceUptodate[faceI])
1277 label own, nei, patchID;
1278 faceCells(cuts, exposedPatchI, faceI, own, nei, patchID);
1280 if (own == -1 && nei == -1)
1286 Pout<<
"Removed face " << faceI <<
endl;
1291 modFace(meshMod, faceI, faces[faceI], own, nei, patchID);
1294 faceUptodate[faceI] =
true;
1300 Pout<<
"meshCutAndRemove:" <<
nl 1301 <<
" cells split:" << cuts.
nLoops() <<
nl 1302 <<
" faces added:" << addedFaces_.
size() <<
nl 1303 <<
" points added on edges:" << addedPoints_.size() <<
nl 1317 label cellI = iter.key();
1320 label addedFaceI = iter();
1324 if ((newCellI >= 0) && (newAddedFaceI >= 0))
1329 && (newCellI != cellI || newAddedFaceI != addedFaceI)
1332 Pout<<
"meshCutAndRemove::updateMesh :" 1333 <<
" updating addedFace for cell " << cellI
1334 <<
" from " << addedFaceI
1335 <<
" to " << newAddedFaceI
1338 newAddedFaces.insert(newCellI, newAddedFaceI);
1343 addedFaces_.
transfer(newAddedFaces);
1352 addedPoints_.begin();
1353 iter != addedPoints_.end();
1357 const edge& e = iter.key();
1363 label addedPointI = iter();
1367 if ((newStart >= 0) && (newEnd >= 0) && (newAddedPointI >= 0))
1369 edge newE =
edge(newStart, newEnd);
1374 && (e != newE || newAddedPointI != addedPointI)
1377 Pout<<
"meshCutAndRemove::updateMesh :" 1378 <<
" updating addedPoints for edge " << e
1379 <<
" from " << addedPointI
1380 <<
" to " << newAddedPointI
1384 newAddedPoints.insert(newE, newAddedPointI);
1389 addedPoints_.transfer(newAddedPoints);
const labelListList & cellPoints() const
void setRefinement(const label exposedPatchI, const cellCuts &cuts, const labelList &cutPatch, polyTopoChange &meshMod)
Do actual cutting with cut description. Inserts mesh changes.
label setAction(const topoAction &action)
For compatibility with polyTopoChange: set topological action.
const faceZoneMesh & faceZones() const
Return face zone mesh.
A face addition data class. A face can be inflated either from a point or from another face and can e...
static bool isEdge(const primitiveMesh &mesh, const label eVert)
Is eVert an edge?
label size() const
Return the number of elements in the PtrList.
const labelList & reverseFaceMap() const
Reverse face map.
label findIndex(const ListType &, typename ListType::const_reference, const label start=0)
Find first occurence of given element and return index,.
const boolList & edgeIsCut() const
Is edge cut.
label whichZone(const label objectIndex) const
Given a global object index, return the zone it is in.
const edgeList & edges() const
Return mesh edges. Uses calcEdges.
const Map< edge > & faceSplitCut() const
Gives for split face the two cuts that split the face into two.
Class containing data for point removal.
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
const labelList & reversePointMap() const
Reverse point map.
static label getEdge(const primitiveMesh &mesh, const label eVert)
Convert eVert to edge label.
bool insert(const Key &, const T &newElmt)
Insert a new hashedEntry.
An STL-conforming hash table.
A HashTable to objects of type <T> with a label key.
const labelListList & cellLoops() const
For each cut cell the cut along the circumference.
label nLoops() const
Number of valid cell loops.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
void resize(const label newSize)
Resize the hash table for efficiency.
void size(const label)
Override size to be inconsistent with allocated storage.
static const labelSphericalTensor labelI(1)
Identity labelTensor.
An edge is a list of two point labels. The functionality it provides supports the discretisation on a...
Class containing data for face removal.
const labelListList & cellAnchorPoints() const
For each cut cell the points on the 'anchor' side of the cell.
forAllConstIter(PtrDictionary< phaseModel >, mixture.phases(), phase)
A face is a list of labels corresponding to mesh vertices.
Hash function class for primitives. All non-primitives used to hash entries on hash tables likely nee...
const double e
Elementary charge.
Ostream & endl(Ostream &os)
Add newline and flush stream.
void clear()
Clear all entries from table.
virtual const pointField & points() const
Return raw points.
Ostream & writeCuts(Ostream &os, const labelList &, const scalarField &) const
Write cut descriptions to Ostream.
label whichPatch(const label faceIndex) const
Return patch index for a given face label.
label size() const
Return number of elements in table.
const labelListList & pointFaces() const
errorManip< error > abort(error &err)
virtual const labelList & faceOwner() const
Return face owner.
const polyBoundaryMesh & boundaryMesh() const
Return boundary mesh.
#define FatalErrorIn(functionName)
Report an error message using Foam::FatalError.
const boolList & pointIsCut() const
Is mesh point cut.
Mesh consisting of general polyhedral cells.
const labelListList & edgeFaces() const
label end() const
Return end vertex label.
List< label > labelList
A List of labels.
const polyMesh & mesh() const
void updateMesh(const mapPolyMesh &)
Force recalculation of locally stored data on topological change.
void reverse(UList< T > &, const label n)
const labelList & reverseCellMap() const
Reverse cell map.
void transfer(HashTable< T, Key, Hash > &)
Transfer the contents of the argument table into this table.
Direct mesh changes based on v1.3 polyTopoChange syntax.
label start() const
Return start vertex label.
Class containing data for point addition.
virtual const faceList & faces() const
Return raw faces.
const scalarField & edgeWeight() const
If edge is cut gives weight (ratio between start() and end())
label findEdge(const edgeList &edges, const labelList &candidates, const label v0, const label v1)
Return edge among candidates that uses the two vertices.
List< labelList > labelListList
A List of labelList.
virtual const labelList & faceNeighbour() const
Return face neighbour.
Combines edge or vertex in single label. Used to specify cuts across cell circumference.
static label getVertex(const primitiveMesh &mesh, const label eVert)
Convert eVert to vertex label.
defineTypeNameAndDebug(combustionModel, 0)
prefixOSstream Pout(cout,"Pout")
Description of cuts across cells.