69 bool Foam::meshCutAndRemove::isIn
84 cuts[cuts.fcIndex(index)] == twoCuts[1]
85 || cuts[cuts.rcIndex(index)] == twoCuts[1]
102 if (cuts.cellLoops()[celli].size())
111 Foam::label Foam::meshCutAndRemove::findInternalFacePoint
124 label facei = pFaces[pFacei];
126 if (
mesh().isInternalFace(facei))
133 if (pointLabels.empty())
143 Foam::label Foam::meshCutAndRemove::findPatchFacePoint
146 const label exposedPatchi
154 label pointi = f[fp];
158 const labelList& pFaces = pointFaces[pointi];
162 if (patches.whichPatch(pFaces[i]) == exposedPatchi)
173 void Foam::meshCutAndRemove::faceCells
175 const cellCuts& cuts,
176 const label exposedPatchi,
190 if (cellLoops[own].size() && firstCommon(f, anchorPts[own]) == -1)
198 if (
mesh().isInternalFace(facei))
202 if (cellLoops[nei].size() && firstCommon(f, anchorPts[nei]) == -1)
210 if (patchID == -1 && (own == -1 || nei == -1))
213 patchID = exposedPatchi;
218 void Foam::meshCutAndRemove::getZoneInfo
233 zoneFlip = fZone.flipMap()[fZone.whichFace(facei)];
238 void Foam::meshCutAndRemove::addFace
240 polyTopoChange& meshMod,
242 const label masterPointi,
252 getZoneInfo(facei, zoneID, zoneFlip);
254 if ((nei == -1) || (own != -1 && own < nei))
259 Pout<<
"Adding face " << newFace
260 <<
" with new owner:" << own
261 <<
" with new neighbour:" << nei
262 <<
" patchID:" << patchID
263 <<
" anchor:" << masterPointi
264 <<
" zoneID:" << zoneID
265 <<
" zoneFlip:" << zoneFlip
291 Pout<<
"Adding (reversed) face " << newFace.reverseFace()
292 <<
" with new owner:" << nei
293 <<
" with new neighbour:" << own
294 <<
" patchID:" << patchID
295 <<
" anchor:" << masterPointi
296 <<
" zoneID:" << zoneID
297 <<
" zoneFlip:" << zoneFlip
305 newFace.reverseFace(),
322 void Foam::meshCutAndRemove::modFace
324 polyTopoChange& meshMod,
335 getZoneInfo(facei, zoneID, zoneFlip);
339 (own !=
mesh().faceOwner()[facei])
341 mesh().isInternalFace(facei)
342 && (nei !=
mesh().faceNeighbour()[facei])
344 || (newFace !=
mesh().faces()[facei])
349 Pout<<
"Modifying face " << facei
350 <<
" old vertices:" <<
mesh().
faces()[facei]
351 <<
" new vertices:" << newFace
352 <<
" new owner:" << own
353 <<
" new neighbour:" << nei
354 <<
" new patch:" << patchID
355 <<
" new zoneID:" << zoneID
356 <<
" new zoneFlip:" << zoneFlip
360 if ((nei == -1) || (own != -1 && own < nei))
384 newFace.reverseFace(),
400 void Foam::meshCutAndRemove::copyFace
414 newFace[newFp++] = f[fp];
416 fp = (fp + 1) % f.size();
418 newFace[newFp] = f[fp];
426 void Foam::meshCutAndRemove::splitFace
442 <<
"Cannot find vertex (new numbering) " << v0
452 <<
"Cannot find vertex (new numbering) " << v1
458 f0.setSize((endFp + 1 + f.size() - startFp) % f.size());
459 f1.setSize(f.size() - f0.size() + 2);
461 copyFace(f, startFp, endFp, f0);
462 copyFace(f, endFp, startFp, f1);
466 Foam::face Foam::meshCutAndRemove::addEdgeCutsToFace(
const label facei)
const 470 face newFace(2 * f.size());
477 newFace[newFp++] = f[fp];
480 label fp1 = f.fcIndex(fp);
482 HashTable<label, edge, Hash<edge>>::const_iterator fnd =
483 addedPoints_.find(edge(f[fp], f[fp1]));
485 if (fnd != addedPoints_.end())
488 newFace[newFp++] = fnd();
492 newFace.setSize(newFp);
507 face newFace(2*loop.size());
513 label cut = loop[fp];
517 label edgeI = getEdge(cut);
521 label vertI = addedPoints_[
e];
523 newFace[newFacei++] = vertI;
528 label vertI = getVertex(cut);
530 newFace[newFacei++] = vertI;
532 label nextCut = loop[loop.fcIndex(fp)];
534 if (!isEdge(nextCut))
537 label nextVertI = getVertex(nextCut);
544 HashTable<label, edge, Hash<edge>>::const_iterator fnd =
545 addedPoints_.find(
mesh().edges()[edgeI]);
547 if (fnd != addedPoints_.end())
549 newFace[newFacei++] = fnd();
555 newFace.setSize(newFacei);
576 const label exposedPatchi,
586 addedPoints_.clear();
587 addedPoints_.resize(cuts.
nLoops());
598 if (exposedPatchi < 0 || exposedPatchi >= patches.
size())
601 <<
"Illegal exposed patch " << exposedPatchi
617 if (debug && findCutCell(cuts,
mesh().edgeCells()[edgeI]) == -1)
620 <<
"Problem: cut edge but none of the cells using it is\n" 621 <<
"edge:" << edgeI <<
" verts:" << e
633 point newPt = weight*v1 + (1.0-weight)*v0;
648 addedPoints_.insert(e, addedPointi);
652 Pout<<
"Added point " << addedPointi
654 << masterPointi <<
" of edge " << edgeI
655 <<
" vertices " << e <<
endl;
669 const labelList& loop = cellLoops[celli];
676 label cut = loop[fp];
684 const labelList& anchors = anchorPts[celli];
688 usedPoint[anchors[i]] =
true;
698 usedPoint[cPoints[i]] =
true;
709 const edge& fCut = iter();
719 if (!usedPoint[pointi])
722 <<
"Problem: faceSplitCut not used by any loop" 723 <<
" or cell anchor point" 724 <<
"face:" << iter.key() <<
" point:" << pointi
736 if (!usedPoint[pointi])
739 <<
"Problem: point is marked as cut but" 740 <<
" not used by any loop" 741 <<
" or cell anchor point" 742 <<
"point:" << pointi
753 if (!usedPoint[pointi])
759 Pout<<
"Removing unused point " << pointi <<
endl;
772 const labelList& loop = cellLoops[celli];
776 if (cutPatch[celli] < 0 || cutPatch[celli] >= patches.
size())
779 <<
"Illegal patch " << cutPatch[celli]
780 <<
" provided for cut cell " << celli
788 face newFace(loopToFace(celli, loop));
793 label masterPointi = findPatchFacePoint(newFace, exposedPatchi);
813 addedFaces_.
insert(celli, addedFacei);
817 Pout<<
"Added splitting face " << newFace <<
" index:" 818 << addedFacei <<
" from masterPoint:" << masterPointi
819 <<
" to owner " << celli <<
" with anchors:" 857 label facei = iter.key();
860 face newFace(addEdgeCutsToFace(facei));
863 const edge& splitEdge = iter();
865 label cut0 = splitEdge[0];
871 v0 = addedPoints_[
mesh().
edges()[edgeI]];
878 label cut1 = splitEdge[1];
883 v1 = addedPoints_[
mesh().
edges()[edgeI]];
892 splitFace(newFace, v0, v1, f0, f1);
898 if (
mesh().isInternalFace(facei))
906 <<
" own:" << own <<
" nei:" << nei
908 <<
" and f1:" << f1 <<
endl;
927 if (cellLoops[own].empty())
933 else if (isIn(splitEdge, cellLoops[own]))
937 if (firstCommon(f0, anchorPts[own]) != -1)
954 if (firstCommon(f, anchorPts[own]) != -1)
974 if (cellLoops[nei].empty())
979 else if (isIn(splitEdge, cellLoops[nei]))
985 if (firstCommon(f0, anchorPts[nei]) != -1)
1001 if (firstCommon(f, anchorPts[nei]) != -1)
1018 Pout<<
"f0 own:" << f0Own <<
" nei:" << f0Nei
1019 <<
" f1 own:" << f1Own <<
" nei:" << f1Nei
1030 patchID = exposedPatchi;
1037 bool modifiedFacei =
false;
1044 modFace(meshMod, facei, f0, f0Own, f0Nei, patchID);
1045 modifiedFacei =
true;
1053 modFace(meshMod, facei, f0, f0Own, f0Nei, patchID);
1054 modifiedFacei =
true;
1059 modFace(meshMod, facei, f0, f0Own, f0Nei, -1);
1060 modifiedFacei =
true;
1078 modFace(meshMod, facei, f1, f1Own, f1Nei, patchID);
1079 modifiedFacei =
true;
1083 label masterPointi = findPatchFacePoint(f1, patchID);
1105 modFace(meshMod, facei, f1, f1Own, f1Nei, patchID);
1106 modifiedFacei =
true;
1110 label masterPointi = findPatchFacePoint(f1, patchID);
1129 modFace(meshMod, facei, f1, f1Own, f1Nei, -1);
1130 modifiedFacei =
true;
1134 label masterPointi = findPatchFacePoint(f1, -1);
1136 addFace(meshMod, facei, masterPointi, f1, f1Own, f1Nei, -1);
1141 if (f0Own == -1 && f0Nei == -1 && !modifiedFacei)
1147 Pout<<
"Removed face " << facei <<
endl;
1151 faceUptodate[facei] =
true;
1164 if (edgeIsCut[edgeI])
1170 label facei = eFaces[i];
1172 if (!faceUptodate[facei])
1179 label own, nei, patchID;
1180 faceCells(cuts, exposedPatchi, facei, own, nei, patchID);
1183 if (own == -1 && nei == -1)
1189 Pout<<
"Removed face " << facei <<
endl;
1195 face newFace(addEdgeCutsToFace(facei));
1199 Pout<<
"Added edge cuts to face " << facei
1201 <<
" newFace:" << newFace <<
endl;
1215 faceUptodate[facei] =
true;
1232 if (!faceUptodate[facei])
1235 label own, nei, patchID;
1236 faceCells(cuts, exposedPatchi, facei, own, nei, patchID);
1238 if (own == -1 && nei == -1)
1244 Pout<<
"Removed face " << facei <<
endl;
1249 modFace(meshMod, facei, faces[facei], own, nei, patchID);
1252 faceUptodate[facei] =
true;
1258 Pout<<
"meshCutAndRemove:" <<
nl 1259 <<
" cells split:" << cuts.
nLoops() <<
nl 1260 <<
" faces added:" << addedFaces_.
size() <<
nl 1261 <<
" points added on edges:" << addedPoints_.size() <<
nl 1275 label celli = iter.key();
1278 label addedFacei = iter();
1282 if ((newCelli >= 0) && (newAddedFacei >= 0))
1287 && (newCelli != celli || newAddedFacei != addedFacei)
1290 Pout<<
"meshCutAndRemove::updateMesh :" 1291 <<
" updating addedFace for cell " << celli
1292 <<
" from " << addedFacei
1293 <<
" to " << newAddedFacei
1296 newAddedFaces.insert(newCelli, newAddedFacei);
1301 addedFaces_.
transfer(newAddedFaces);
1310 addedPoints_.begin();
1311 iter != addedPoints_.end();
1315 const edge& e = iter.key();
1321 label addedPointi = iter();
1325 if ((newStart >= 0) && (newEnd >= 0) && (newAddedPointi >= 0))
1327 edge newE =
edge(newStart, newEnd);
1332 && (e != newE || newAddedPointi != addedPointi)
1335 Pout<<
"meshCutAndRemove::updateMesh :" 1336 <<
" updating addedPoints for edge " << e
1337 <<
" from " << addedPointi
1338 <<
" to " << newAddedPointi
1342 newAddedPoints.insert(newE, newAddedPointi);
1347 addedPoints_.transfer(newAddedPoints);
const polyBoundaryMesh & boundaryMesh() const
Return boundary mesh.
Class containing data for face removal.
List< labelList > labelListList
A List of labelList.
const boolList & edgeIsCut() const
Is edge cut.
#define forAll(list, i)
Loop across all elements in list.
const labelList & reversePointMap() const
Reverse point map.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
A face is a list of labels corresponding to mesh vertices.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
virtual const labelList & faceNeighbour() const
Return face neighbour.
void size(const label)
Override size to be inconsistent with allocated storage.
Ostream & endl(Ostream &os)
Add newline and flush stream.
Ostream & writeCuts(Ostream &os, const labelList &, const scalarField &) const
Write cut descriptions to Ostream.
Class containing data for point addition.
void updateMesh(const mapPolyMesh &)
Force recalculation of locally stored data on topological change.
void transfer(HashTable< T, Key, Hash > &)
Transfer the contents of the argument table into this table.
Description of cuts across cells.
label size() const
Return number of elements in table.
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
A face addition data class. A face can be inflated either from a point or from another face and can e...
virtual const pointField & points() const
Return raw points.
bool insert(const Key &, const T &newElmt)
Insert a new hashedEntry.
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...
void clear()
Clear all entries from table.
virtual const labelList & faceOwner() const
Return face owner.
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.
List< label > labelList
A List of labels.
virtual const faceList & faces() const
Return raw faces.
void setRefinement(const label exposedPatchi, const cellCuts &cuts, const labelList &cutPatch, polyTopoChange &meshMod)
Do actual cutting with cut description. Inserts mesh changes.
An STL-conforming hash table.
static label getEdge(const primitiveMesh &mesh, const label eVert)
Convert eVert to edge label.
forAllConstIter(PtrDictionary< phaseModel >, mixture.phases(), phase)
errorManip< error > abort(error &err)
const polyMesh & mesh() const
void reverse(UList< T > &, const label n)
const labelList & reverseCellMap() const
Reverse cell map.
defineTypeNameAndDebug(combustionModel, 0)
label findIndex(const ListType &, typename ListType::const_reference, const label start=0)
Find first occurrence of given element and return index,.
static bool isEdge(const primitiveMesh &mesh, const label eVert)
Is eVert an edge?
label size() const
Return the number of elements in the UPtrList.
const edgeList & edges() const
Return mesh edges. Uses calcEdges.
const scalarField & edgeWeight() const
If edge is cut gives weight (ratio between start() and end())
label nLoops() const
Number of valid cell loops.
label whichZone(const label objectIndex) const
Given a global object index, return the zone it is in.
const boolList & pointIsCut() const
Is mesh point cut.
const Map< edge > & faceSplitCut() const
Gives for split face the two cuts that split the face into two.
const labelListList & cellLoops() const
For each cut cell the cut along the circumference.
label end() const
Return end vertex label.
prefixOSstream Pout(cout, "Pout")
const meshFaceZones & faceZones() const
Return face zones.
Direct mesh changes based on v1.3 polyTopoChange syntax.
Hash function class for primitives. All non-primitives used to hash entries on hash tables likely nee...
const labelListList & pointFaces() const
void resize(const label newSize)
Resize the hash table for efficiency.
const doubleScalar e
Elementary charge.
Mesh consisting of general polyhedral cells.
label whichPatch(const label faceIndex) const
Return patch index for a given face label.
meshCutAndRemove(const polyMesh &mesh)
Construct from mesh.
Class containing data for point removal.
const labelListList & edgeFaces() const
const labelListList & cellPoints() const
label start() const
Return start vertex label.
const labelList & reverseFaceMap() const
Reverse face map.
A HashTable to objects of type <T> with a label key.
const labelListList & cellAnchorPoints() const
For each cut cell the points on the 'anchor' side of the cell.
label setAction(const topoAction &action)
For compatibility with polyTopoChange: set topological action.