52 if (
findIndex(elems2, elems1[elemI]) != -1)
61 bool Foam::meshCutter::isIn
76 cuts[cuts.fcIndex(index)] == twoCuts[1]
77 || cuts[cuts.rcIndex(index)] == twoCuts[1]
94 if (cuts.cellLoops()[celli].size())
103 Foam::label Foam::meshCutter::findInternalFacePoint
116 label facei = pFaces[pFacei];
118 if (
mesh().isInternalFace(facei))
125 if (pointLabels.empty())
135 void Foam::meshCutter::faceCells
137 const cellCuts& cuts,
150 if (cellLoops[own].size() && uses(f, anchorPts[own]))
152 own = addedCells_[own];
157 if (
mesh().isInternalFace(facei))
161 if (cellLoops[nei].size() && uses(f, anchorPts[nei]))
163 nei = addedCells_[nei];
169 void Foam::meshCutter::getFaceInfo
179 if (!
mesh().isInternalFace(facei))
192 zoneFlip = fZone.flipMap()[fZone.whichFace(facei)];
197 void Foam::meshCutter::addFace
199 polyTopoChange& meshMod,
206 label patchID, zoneID, zoneFlip;
208 getFaceInfo(facei, patchID, zoneID, zoneFlip);
210 if ((nei == -1) || (own < nei))
215 Pout<<
"Adding face " << newFace
216 <<
" with new owner:" << own
217 <<
" with new neighbour:" << nei
218 <<
" patchID:" << patchID
219 <<
" zoneID:" << zoneID
220 <<
" zoneFlip:" << zoneFlip
246 Pout<<
"Adding (reversed) face " << newFace.reverseFace()
247 <<
" with new owner:" << nei
248 <<
" with new neighbour:" << own
249 <<
" patchID:" << patchID
250 <<
" zoneID:" << zoneID
251 <<
" zoneFlip:" << zoneFlip
259 newFace.reverseFace(),
275 void Foam::meshCutter::modFace
277 polyTopoChange& meshMod,
284 label patchID, zoneID, zoneFlip;
286 getFaceInfo(facei, patchID, zoneID, zoneFlip);
290 (own !=
mesh().faceOwner()[facei])
292 mesh().isInternalFace(facei)
293 && (nei !=
mesh().faceNeighbour()[facei])
295 || (newFace !=
mesh().faces()[facei])
300 Pout<<
"Modifying face " << facei
301 <<
" old vertices:" <<
mesh().
faces()[facei]
302 <<
" new vertices:" << newFace
303 <<
" new owner:" << own
304 <<
" new neighbour:" << nei
305 <<
" new zoneID:" << zoneID
306 <<
" new zoneFlip:" << zoneFlip
310 if ((nei == -1) || (own < nei))
334 newFace.reverseFace(),
350 void Foam::meshCutter::copyFace
364 newFace[newFp++] = f[fp];
366 fp = (fp + 1) % f.size();
368 newFace[newFp] = f[fp];
372 void Foam::meshCutter::splitFace
388 <<
"Cannot find vertex (new numbering) " << v0
398 <<
"Cannot find vertex (new numbering) " << v1
404 f0.setSize((endFp + 1 + f.size() - startFp) % f.size());
405 f1.setSize(f.size() - f0.size() + 2);
407 copyFace(f, startFp, endFp, f0);
408 copyFace(f, endFp, startFp, f1);
412 Foam::face Foam::meshCutter::addEdgeCutsToFace(
const label facei)
const 416 face newFace(2 * f.size());
423 newFace[newFp++] = f[fp];
426 label fp1 = f.fcIndex(fp);
428 HashTable<label, edge, Hash<edge>>::const_iterator fnd =
429 addedPoints_.find(edge(f[fp], f[fp1]));
431 if (fnd != addedPoints_.end())
434 newFace[newFp++] = fnd();
438 newFace.setSize(newFp);
450 face newFace(2*loop.size());
456 label cut = loop[fp];
460 label edgeI = getEdge(cut);
464 label vertI = addedPoints_[
e];
466 newFace[newFacei++] = vertI;
471 label vertI = getVertex(cut);
473 newFace[newFacei++] = vertI;
475 label nextCut = loop[loop.fcIndex(fp)];
477 if (!isEdge(nextCut))
480 label nextVertI = getVertex(nextCut);
487 HashTable<label, edge, Hash<edge>>::const_iterator fnd =
488 addedPoints_.find(
mesh().edges()[edgeI]);
490 if (fnd != addedPoints_.end())
492 newFace[newFacei++] = fnd();
498 newFace.setSize(newFacei);
537 addedPoints_.clear();
538 addedPoints_.resize(cuts.
nLoops());
559 edgeOnCutCell[cEdges[i]] =
true;
567 if (cuts.
edgeIsCut()[edgeI] && !edgeOnCutCell[edgeI])
572 <<
"Problem: cut edge but none of the cells using" 574 <<
"edge:" << edgeI <<
" verts:" << e
600 point newPt = weight*v1 + (1.0-weight)*v0;
615 addedPoints_.insert(e, addedPointi);
619 Pout<<
"Added point " << addedPointi
621 << masterPointi <<
" of edge " << edgeI
622 <<
" vertices " << e <<
endl;
633 if (cellLoops[celli].size())
645 mesh().cellZones().whichZone(celli)
649 addedCells_.
insert(celli, addedCelli);
653 Pout<<
"Added cell " << addedCells_[celli] <<
" to cell " 666 const labelList& loop = cellLoops[celli];
673 face newFace(loopToFace(celli, loop));
676 label masterPointi = findInternalFacePoint(anchorPts[celli]);
696 addedFaces_.
insert(celli, addedFacei);
714 Pout<<
"Added splitting face " << newFace <<
" index:" 716 <<
" to owner " << celli
717 <<
" neighbour " << addedCells_[celli]
739 label facei = iter.key();
742 face newFace(addEdgeCutsToFace(facei));
745 const edge& splitEdge = iter();
747 label cut0 = splitEdge[0];
753 v0 = addedPoints_[
mesh().
edges()[edgeI]];
760 label cut1 = splitEdge[1];
765 v1 = addedPoints_[
mesh().
edges()[edgeI]];
774 splitFace(newFace, v0, v1, f0, f1);
780 if (
mesh().isInternalFace(facei))
788 <<
" own:" << own <<
" nei:" << nei
790 <<
" and f1:" << f1 <<
endl;
806 if (cellLoops[own].empty())
811 else if (isIn(splitEdge, cellLoops[own]))
815 if (uses(f0, anchorPts[own]))
817 f0Owner = addedCells_[own];
823 f1Owner = addedCells_[own];
830 if (uses(f, anchorPts[own]))
832 label newCelli = addedCells_[own];
844 label f0Neighbour = -1;
845 label f1Neighbour = -1;
849 if (cellLoops[nei].empty())
854 else if (isIn(splitEdge, cellLoops[nei]))
858 if (uses(f0, anchorPts[nei]))
860 f0Neighbour = addedCells_[nei];
866 f1Neighbour = addedCells_[nei];
873 if (uses(f, anchorPts[nei]))
875 label newCelli = addedCells_[nei];
876 f0Neighbour = newCelli;
877 f1Neighbour = newCelli;
888 addFace(meshMod, facei, f0, f0Owner, f0Neighbour);
890 modFace(meshMod, facei, f1, f1Owner, f1Neighbour);
892 faceUptodate[facei] =
true;
905 if (edgeIsCut[edgeI])
911 label facei = eFaces[i];
913 if (!faceUptodate[facei])
916 face newFace(addEdgeCutsToFace(facei));
920 Pout<<
"Added edge cuts to face " << facei
922 <<
" newFace:" << newFace <<
endl;
927 faceCells(cuts, facei, own, nei);
929 modFace(meshMod, facei, newFace, own, nei);
931 faceUptodate[facei] =
true;
944 if (cellLoops[celli].size())
948 forAll(cllFaces, cllFacei)
950 label facei = cllFaces[cllFacei];
952 if (!faceUptodate[facei])
957 if (debug && (f != addEdgeCutsToFace(facei)))
960 <<
"Problem: edges added to face which does " 961 <<
" not use a marked cut" <<
endl 962 <<
"facei:" << facei <<
endl 963 <<
"face:" << f <<
endl 964 <<
"newFace:" << addEdgeCutsToFace(facei)
970 faceCells(cuts, facei, own, nei);
981 faceUptodate[facei] =
true;
989 Pout<<
"meshCutter:" <<
nl 990 <<
" cells split:" << addedCells_.
size() <<
nl 991 <<
" faces added:" << addedFaces_.
size() <<
nl 992 <<
" points added on edges:" << addedPoints_.size() <<
nl 1009 label celli = iter.key();
1012 label addedCelli = iter();
1016 if (newCelli >= 0 && newAddedCelli >= 0)
1021 && (newCelli != celli || newAddedCelli != addedCelli)
1024 Pout<<
"meshCutter::topoChange :" 1025 <<
" updating addedCell for cell " << celli
1026 <<
" from " << addedCelli
1027 <<
" to " << newAddedCelli <<
endl;
1029 newAddedCells.insert(newCelli, newAddedCelli);
1034 addedCells_.
transfer(newAddedCells);
1042 label celli = iter.key();
1045 label addedFacei = iter();
1049 if ((newCelli >= 0) && (newAddedFacei >= 0))
1054 && (newCelli != celli || newAddedFacei != addedFacei)
1057 Pout<<
"meshCutter::topoChange :" 1058 <<
" updating addedFace for cell " << celli
1059 <<
" from " << addedFacei
1060 <<
" to " << newAddedFacei
1063 newAddedFaces.insert(newCelli, newAddedFacei);
1068 addedFaces_.
transfer(newAddedFaces);
1077 addedPoints_.begin();
1078 iter != addedPoints_.end();
1082 const edge& e = iter.key();
1088 label addedPointi = iter();
1092 if ((newStart >= 0) && (newEnd >= 0) && (newAddedPointi >= 0))
1094 edge newE =
edge(newStart, newEnd);
1099 && (e != newE || newAddedPointi != addedPointi)
1102 Pout<<
"meshCutter::topoChange :" 1103 <<
" updating addedPoints for edge " << e
1104 <<
" from " << addedPointi
1105 <<
" to " << newAddedPointi
1109 newAddedPoints.insert(newE, newAddedPointi);
1114 addedPoints_.transfer(newAddedPoints);
const polyBoundaryMesh & boundaryMesh() const
Return boundary mesh.
List< labelList > labelListList
A List of labelList.
const labelListList & cellEdges() const
const boolList & edgeIsCut() const
Is edge cut.
#define forAll(list, i)
Loop across all elements in list.
FvWallInfoData< WallInfo, label > label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
meshCutter(const polyMesh &mesh)
Construct from mesh.
A face is a list of labels corresponding to mesh vertices.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
#define forAllConstIter(Container, container, iter)
Iterate across all elements in the container object of type.
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.
Holds information (coordinate and normal) regarding nearest wall point.
Class containing data for point addition.
const cellList & cells() const
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.
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.
Class containing data for cell addition.
const labelList & reverseFaceMap() const
Reverse face map.
linePointRef line(const pointField &) const
Return edge line.
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 mesh-to-mesh mapping information after a change in polyMesh topology.
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.
const labelList & reversePointMap() const
Reverse point map.
List< label > labelList
A List of labels.
virtual const faceList & faces() const
Return raw faces.
An STL-conforming hash table.
static label getEdge(const primitiveMesh &mesh, const label eVert)
Convert eVert to edge label.
errorManip< error > abort(error &err)
void setRefinement(const cellCuts &cuts, polyTopoChange &meshMod)
Do actual cutting with cut description. Inserts mesh changes.
const polyMesh & mesh() const
defineTypeNameAndDebug(combustionModel, 0)
label findIndex(const ListType &, typename ListType::const_reference, const label start=0)
Find first occurrence of given element and return index,.
const labelList & reverseCellMap() const
Reverse cell map.
static bool isEdge(const primitiveMesh &mesh, const label eVert)
Is eVert an edge?
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 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.
#define WarningInFunction
Report a warning using Foam::Warning.
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.
T returnReduce(const T &Value, const BinaryOp &bop, const int tag=Pstream::msgType(), const label comm=UPstream::worldComm)
void topoChange(const polyTopoChangeMap &)
Force recalculation of locally stored data on topological change.
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.
const labelListList & edgeFaces() const
label start() const
Return start vertex label.
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.