51 if (
findIndex(elems2, elems1[elemI]) != -1)
60 bool Foam::meshCutter::isIn
75 cuts[cuts.fcIndex(index)] == twoCuts[1]
76 || cuts[cuts.rcIndex(index)] == twoCuts[1]
93 if (cuts.cellLoops()[cellI].size())
102 Foam::label Foam::meshCutter::findInternalFacePoint
115 label faceI = pFaces[pFaceI];
117 if (
mesh().isInternalFace(faceI))
124 if (pointLabels.empty())
126 FatalErrorIn(
"meshCutter::findInternalFacePoint(const labelList&)")
134 void Foam::meshCutter::faceCells
136 const cellCuts& cuts,
149 if (cellLoops[own].size() && uses(f, anchorPts[own]))
151 own = addedCells_[own];
156 if (
mesh().isInternalFace(faceI))
160 if (cellLoops[nei].size() && uses(f, anchorPts[nei]))
162 nei = addedCells_[nei];
168 void Foam::meshCutter::getFaceInfo
178 if (!
mesh().isInternalFace(faceI))
191 zoneFlip = fZone.flipMap()[fZone.whichFace(faceI)];
196 void Foam::meshCutter::addFace
198 polyTopoChange& meshMod,
205 label patchID, zoneID, zoneFlip;
207 getFaceInfo(faceI, patchID, zoneID, zoneFlip);
209 if ((nei == -1) || (own < nei))
214 Pout<<
"Adding face " << newFace
215 <<
" with new owner:" << own
216 <<
" with new neighbour:" << nei
217 <<
" patchID:" << patchID
218 <<
" zoneID:" << zoneID
219 <<
" zoneFlip:" << zoneFlip
245 Pout<<
"Adding (reversed) face " << newFace.reverseFace()
246 <<
" with new owner:" << nei
247 <<
" with new neighbour:" << own
248 <<
" patchID:" << patchID
249 <<
" zoneID:" << zoneID
250 <<
" zoneFlip:" << zoneFlip
258 newFace.reverseFace(),
274 void Foam::meshCutter::modFace
276 polyTopoChange& meshMod,
283 label patchID, zoneID, zoneFlip;
285 getFaceInfo(faceI, patchID, zoneID, zoneFlip);
289 (own !=
mesh().faceOwner()[faceI])
291 mesh().isInternalFace(faceI)
292 && (nei !=
mesh().faceNeighbour()[faceI])
294 || (newFace !=
mesh().faces()[faceI])
299 Pout<<
"Modifying face " << faceI
300 <<
" old vertices:" <<
mesh().
faces()[faceI]
301 <<
" new vertices:" << newFace
302 <<
" new owner:" << own
303 <<
" new neighbour:" << nei
304 <<
" new zoneID:" << zoneID
305 <<
" new zoneFlip:" << zoneFlip
309 if ((nei == -1) || (own < nei))
333 newFace.reverseFace(),
349 void Foam::meshCutter::copyFace
363 newFace[newFp++] = f[fp];
365 fp = (fp + 1) % f.size();
367 newFace[newFp] = f[fp];
371 void Foam::meshCutter::splitFace
388 "meshCutter::splitFace" 389 ", const face&, const label, const label, face&, face&)" 390 ) <<
"Cannot find vertex (new numbering) " << v0
401 "meshCutter::splitFace(" 402 ", const face&, const label, const label, face&, face&)" 403 ) <<
"Cannot find vertex (new numbering) " << v1
409 f0.setSize((endFp + 1 + f.size() - startFp) % f.size());
410 f1.setSize(f.size() - f0.size() + 2);
412 copyFace(f, startFp, endFp, f0);
413 copyFace(f, endFp, startFp, f1);
417 Foam::face Foam::meshCutter::addEdgeCutsToFace(
const label faceI)
const 421 face newFace(2 * f.size());
428 newFace[newFp++] = f[fp];
431 label fp1 = f.fcIndex(fp);
433 HashTable<label, edge, Hash<edge> >::const_iterator fnd =
434 addedPoints_.find(edge(f[fp], f[fp1]));
436 if (fnd != addedPoints_.end())
439 newFace[newFp++] = fnd();
443 newFace.setSize(newFp);
455 face newFace(2*loop.size());
461 label cut = loop[fp];
465 label edgeI = getEdge(cut);
469 label vertI = addedPoints_[
e];
471 newFace[newFaceI++] = vertI;
476 label vertI = getVertex(cut);
478 newFace[newFaceI++] = vertI;
480 label nextCut = loop[loop.fcIndex(fp)];
482 if (!isEdge(nextCut))
485 label nextVertI = getVertex(nextCut);
492 HashTable<label, edge, Hash<edge> >::const_iterator fnd =
493 addedPoints_.find(
mesh().edges()[edgeI]);
495 if (fnd != addedPoints_.end())
497 newFace[newFaceI++] = fnd();
503 newFace.setSize(newFaceI);
542 addedPoints_.clear();
543 addedPoints_.resize(cuts.
nLoops());
564 if (debug && findCutCell(cuts,
mesh().edgeCells()[edgeI]) == -1)
568 "meshCutter::setRefinement(const cellCuts&" 570 ) <<
"Problem: cut edge but none of the cells using it is\n" 571 <<
"edge:" << edgeI <<
" verts:" << e
583 point newPt = weight*v1 + (1.0-weight)*v0;
598 addedPoints_.insert(e, addedPointI);
602 Pout<<
"Added point " << addedPointI
604 << masterPointI <<
" of edge " << edgeI
605 <<
" vertices " << e <<
endl;
616 if (cellLoops[cellI].size())
628 mesh().cellZones().whichZone(cellI)
632 addedCells_.
insert(cellI, addedCellI);
636 Pout<<
"Added cell " << addedCells_[cellI] <<
" to cell " 649 const labelList& loop = cellLoops[cellI];
656 face newFace(loopToFace(cellI, loop));
659 label masterPointI = findInternalFacePoint(anchorPts[cellI]);
679 addedFaces_.
insert(cellI, addedFaceI);
697 Pout<<
"Added splitting face " << newFace <<
" index:" 699 <<
" to owner " << cellI
700 <<
" neighbour " << addedCells_[cellI]
722 label faceI = iter.key();
725 face newFace(addEdgeCutsToFace(faceI));
728 const edge& splitEdge = iter();
730 label cut0 = splitEdge[0];
736 v0 = addedPoints_[
mesh().
edges()[edgeI]];
743 label cut1 = splitEdge[1];
748 v1 = addedPoints_[
mesh().
edges()[edgeI]];
757 splitFace(newFace, v0, v1, f0, f1);
763 if (
mesh().isInternalFace(faceI))
771 <<
" own:" << own <<
" nei:" << nei
773 <<
" and f1:" << f1 <<
endl;
789 if (cellLoops[own].empty())
794 else if (isIn(splitEdge, cellLoops[own]))
798 if (uses(f0, anchorPts[own]))
800 f0Owner = addedCells_[own];
806 f1Owner = addedCells_[own];
813 if (uses(f, anchorPts[own]))
815 label newCellI = addedCells_[own];
827 label f0Neighbour = -1;
828 label f1Neighbour = -1;
832 if (cellLoops[nei].empty())
837 else if (isIn(splitEdge, cellLoops[nei]))
841 if (uses(f0, anchorPts[nei]))
843 f0Neighbour = addedCells_[nei];
849 f1Neighbour = addedCells_[nei];
856 if (uses(f, anchorPts[nei]))
858 label newCellI = addedCells_[nei];
859 f0Neighbour = newCellI;
860 f1Neighbour = newCellI;
871 addFace(meshMod, faceI, f0, f0Owner, f0Neighbour);
873 modFace(meshMod, faceI, f1, f1Owner, f1Neighbour);
875 faceUptodate[faceI] =
true;
888 if (edgeIsCut[edgeI])
894 label faceI = eFaces[i];
896 if (!faceUptodate[faceI])
899 face newFace(addEdgeCutsToFace(faceI));
903 Pout<<
"Added edge cuts to face " << faceI
905 <<
" newFace:" << newFace <<
endl;
910 faceCells(cuts, faceI, own, nei);
912 modFace(meshMod, faceI, newFace, own, nei);
914 faceUptodate[faceI] =
true;
927 if (cellLoops[cellI].size())
931 forAll(cllFaces, cllFaceI)
933 label faceI = cllFaces[cllFaceI];
935 if (!faceUptodate[faceI])
940 if (debug && (f != addEdgeCutsToFace(faceI)))
944 "meshCutter::setRefinement(const cellCuts&" 946 ) <<
"Problem: edges added to face which does " 947 <<
" not use a marked cut" <<
endl 948 <<
"faceI:" << faceI <<
endl 949 <<
"face:" << f <<
endl 950 <<
"newFace:" << addEdgeCutsToFace(faceI)
956 faceCells(cuts, faceI, own, nei);
967 faceUptodate[faceI] =
true;
975 Pout<<
"meshCutter:" <<
nl 976 <<
" cells split:" << addedCells_.
size() <<
nl 977 <<
" faces added:" << addedFaces_.
size() <<
nl 978 <<
" points added on edges:" << addedPoints_.size() <<
nl 995 label cellI = iter.key();
998 label addedCellI = iter();
1002 if (newCellI >= 0 && newAddedCellI >= 0)
1007 && (newCellI != cellI || newAddedCellI != addedCellI)
1010 Pout<<
"meshCutter::updateMesh :" 1011 <<
" updating addedCell for cell " << cellI
1012 <<
" from " << addedCellI
1013 <<
" to " << newAddedCellI <<
endl;
1015 newAddedCells.insert(newCellI, newAddedCellI);
1020 addedCells_.
transfer(newAddedCells);
1028 label cellI = iter.key();
1031 label addedFaceI = iter();
1035 if ((newCellI >= 0) && (newAddedFaceI >= 0))
1040 && (newCellI != cellI || newAddedFaceI != addedFaceI)
1043 Pout<<
"meshCutter::updateMesh :" 1044 <<
" updating addedFace for cell " << cellI
1045 <<
" from " << addedFaceI
1046 <<
" to " << newAddedFaceI
1049 newAddedFaces.insert(newCellI, newAddedFaceI);
1054 addedFaces_.
transfer(newAddedFaces);
1063 addedPoints_.begin();
1064 iter != addedPoints_.end();
1068 const edge& e = iter.key();
1074 label addedPointI = iter();
1078 if ((newStart >= 0) && (newEnd >= 0) && (newAddedPointI >= 0))
1080 edge newE =
edge(newStart, newEnd);
1085 && (e != newE || newAddedPointI != addedPointI)
1088 Pout<<
"meshCutter::updateMesh :" 1089 <<
" updating addedPoints for edge " << e
1090 <<
" from " << addedPointI
1091 <<
" to " << newAddedPointI
1095 newAddedPoints.insert(newE, newAddedPointI);
1100 addedPoints_.transfer(newAddedPoints);
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?
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 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.
const cellList & cells() const
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 updateMesh(const mapPolyMesh &)
Force recalculation of locally stored data on topological change.
const labelListList & cellAnchorPoints() const
For each cut cell the points on the 'anchor' side of the cell.
Class containing data for cell addition.
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.
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
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.
void setRefinement(const cellCuts &cuts, polyTopoChange &meshMod)
Do actual cutting with cut description. Inserts mesh changes.
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.