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())
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
387 <<
"Cannot find vertex (new numbering) " << v0
397 <<
"Cannot find vertex (new numbering) " << v1
403 f0.setSize((endFp + 1 + f.size() - startFp) % f.size());
404 f1.setSize(f.size() - f0.size() + 2);
406 copyFace(f, startFp, endFp, f0);
407 copyFace(f, endFp, startFp, f1);
411 Foam::face Foam::meshCutter::addEdgeCutsToFace(
const label facei)
const 415 face newFace(2 * f.size());
422 newFace[newFp++] = f[fp];
425 label fp1 = f.fcIndex(fp);
427 HashTable<label, edge, Hash<edge>>::const_iterator fnd =
428 addedPoints_.find(edge(f[fp], f[fp1]));
430 if (fnd != addedPoints_.end())
433 newFace[newFp++] = fnd();
437 newFace.setSize(newFp);
449 face newFace(2*loop.size());
455 label cut = loop[fp];
459 label edgeI = getEdge(cut);
463 label vertI = addedPoints_[
e];
465 newFace[newFacei++] = vertI;
470 label vertI = getVertex(cut);
472 newFace[newFacei++] = vertI;
474 label nextCut = loop[loop.fcIndex(fp)];
476 if (!isEdge(nextCut))
479 label nextVertI = getVertex(nextCut);
486 HashTable<label, edge, Hash<edge>>::const_iterator fnd =
487 addedPoints_.find(
mesh().edges()[edgeI]);
489 if (fnd != addedPoints_.end())
491 newFace[newFacei++] = fnd();
497 newFace.setSize(newFacei);
536 addedPoints_.clear();
537 addedPoints_.resize(cuts.
nLoops());
558 if (debug && findCutCell(cuts,
mesh().edgeCells()[edgeI]) == -1)
561 <<
"Problem: cut edge but none of the cells using it is\n" 562 <<
"edge:" << edgeI <<
" verts:" << e
574 point newPt = weight*v1 + (1.0-weight)*v0;
589 addedPoints_.insert(e, addedPointi);
593 Pout<<
"Added point " << addedPointi
595 << masterPointi <<
" of edge " << edgeI
596 <<
" vertices " << e <<
endl;
607 if (cellLoops[celli].size())
619 mesh().cellZones().whichZone(celli)
623 addedCells_.
insert(celli, addedCelli);
627 Pout<<
"Added cell " << addedCells_[celli] <<
" to cell " 640 const labelList& loop = cellLoops[celli];
647 face newFace(loopToFace(celli, loop));
650 label masterPointi = findInternalFacePoint(anchorPts[celli]);
670 addedFaces_.
insert(celli, addedFacei);
688 Pout<<
"Added splitting face " << newFace <<
" index:" 690 <<
" to owner " << celli
691 <<
" neighbour " << addedCells_[celli]
713 label facei = iter.key();
716 face newFace(addEdgeCutsToFace(facei));
719 const edge& splitEdge = iter();
721 label cut0 = splitEdge[0];
727 v0 = addedPoints_[
mesh().
edges()[edgeI]];
734 label cut1 = splitEdge[1];
739 v1 = addedPoints_[
mesh().
edges()[edgeI]];
748 splitFace(newFace, v0, v1, f0, f1);
754 if (
mesh().isInternalFace(facei))
762 <<
" own:" << own <<
" nei:" << nei
764 <<
" and f1:" << f1 <<
endl;
780 if (cellLoops[own].empty())
785 else if (isIn(splitEdge, cellLoops[own]))
789 if (uses(f0, anchorPts[own]))
791 f0Owner = addedCells_[own];
797 f1Owner = addedCells_[own];
804 if (uses(f, anchorPts[own]))
806 label newCelli = addedCells_[own];
818 label f0Neighbour = -1;
819 label f1Neighbour = -1;
823 if (cellLoops[nei].empty())
828 else if (isIn(splitEdge, cellLoops[nei]))
832 if (uses(f0, anchorPts[nei]))
834 f0Neighbour = addedCells_[nei];
840 f1Neighbour = addedCells_[nei];
847 if (uses(f, anchorPts[nei]))
849 label newCelli = addedCells_[nei];
850 f0Neighbour = newCelli;
851 f1Neighbour = newCelli;
862 addFace(meshMod, facei, f0, f0Owner, f0Neighbour);
864 modFace(meshMod, facei, f1, f1Owner, f1Neighbour);
866 faceUptodate[facei] =
true;
879 if (edgeIsCut[edgeI])
885 label facei = eFaces[i];
887 if (!faceUptodate[facei])
890 face newFace(addEdgeCutsToFace(facei));
894 Pout<<
"Added edge cuts to face " << facei
896 <<
" newFace:" << newFace <<
endl;
901 faceCells(cuts, facei, own, nei);
903 modFace(meshMod, facei, newFace, own, nei);
905 faceUptodate[facei] =
true;
918 if (cellLoops[celli].size())
922 forAll(cllFaces, cllFacei)
924 label facei = cllFaces[cllFacei];
926 if (!faceUptodate[facei])
931 if (debug && (f != addEdgeCutsToFace(facei)))
934 <<
"Problem: edges added to face which does " 935 <<
" not use a marked cut" <<
endl 936 <<
"facei:" << facei <<
endl 937 <<
"face:" << f <<
endl 938 <<
"newFace:" << addEdgeCutsToFace(facei)
944 faceCells(cuts, facei, own, nei);
955 faceUptodate[facei] =
true;
963 Pout<<
"meshCutter:" <<
nl 964 <<
" cells split:" << addedCells_.
size() <<
nl 965 <<
" faces added:" << addedFaces_.
size() <<
nl 966 <<
" points added on edges:" << addedPoints_.size() <<
nl 983 label celli = iter.key();
986 label addedCelli = iter();
990 if (newCelli >= 0 && newAddedCelli >= 0)
995 && (newCelli != celli || newAddedCelli != addedCelli)
998 Pout<<
"meshCutter::updateMesh :" 999 <<
" updating addedCell for cell " << celli
1000 <<
" from " << addedCelli
1001 <<
" to " << newAddedCelli <<
endl;
1003 newAddedCells.insert(newCelli, newAddedCelli);
1008 addedCells_.
transfer(newAddedCells);
1016 label celli = iter.key();
1019 label addedFacei = iter();
1023 if ((newCelli >= 0) && (newAddedFacei >= 0))
1028 && (newCelli != celli || newAddedFacei != addedFacei)
1031 Pout<<
"meshCutter::updateMesh :" 1032 <<
" updating addedFace for cell " << celli
1033 <<
" from " << addedFacei
1034 <<
" to " << newAddedFacei
1037 newAddedFaces.insert(newCelli, newAddedFacei);
1042 addedFaces_.
transfer(newAddedFaces);
1051 addedPoints_.begin();
1052 iter != addedPoints_.end();
1056 const edge& e = iter.key();
1062 label addedPointi = iter();
1066 if ((newStart >= 0) && (newEnd >= 0) && (newAddedPointi >= 0))
1068 edge newE =
edge(newStart, newEnd);
1073 && (e != newE || newAddedPointi != addedPointi)
1076 Pout<<
"meshCutter::updateMesh :" 1077 <<
" updating addedPoints for edge " << e
1078 <<
" from " << addedPointi
1079 <<
" to " << newAddedPointi
1083 newAddedPoints.insert(newE, newAddedPointi);
1088 addedPoints_.transfer(newAddedPoints);
const labelListList & pointFaces() const
label end() const
Return end vertex label.
List< labelList > labelListList
A List of labelList.
const boolList & edgeIsCut() const
Is edge cut.
#define forAll(list, i)
Loop across all elements in list.
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.
const double e
Elementary charge.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
const edgeList & edges() const
Return mesh edges. Uses calcEdges.
void size(const label)
Override size to be inconsistent with allocated storage.
Ostream & endl(Ostream &os)
Add newline and flush stream.
Class containing data for point addition.
label size() const
Return number of elements in table.
void transfer(HashTable< T, Key, Hash > &)
Transfer the contents of the argument table into this table.
label nLoops() const
Number of valid cell loops.
Description of cuts across cells.
const cellList & cells() const
const polyBoundaryMesh & boundaryMesh() const
Return boundary mesh.
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...
const labelListList & edgeFaces() const
virtual const pointField & points() const
Return raw points.
bool insert(const Key &, const T &newElmt)
Insert a new hashedEntry.
void updateMesh(const mapPolyMesh &)
Force recalculation of locally stored data on topological change.
Class containing data for cell addition.
const polyMesh & mesh() const
static const labelSphericalTensor labelI(1)
Identity labelTensor.
const labelList & reverseFaceMap() const
Reverse face map.
An edge is a list of two point labels. The functionality it provides supports the discretisation on a...
const scalarField & edgeWeight() const
If edge is cut gives weight (ratio between start() and end())
void clear()
Clear all entries from table.
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.
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)
void setRefinement(const cellCuts &cuts, polyTopoChange &meshMod)
Do actual cutting with cut description. Inserts mesh changes.
const labelListList & cellLoops() const
For each cut cell the cut along the circumference.
prefixOSstream Pout(cout,"Pout")
label start() const
Return start vertex label.
defineTypeNameAndDebug(combustionModel, 0)
label findIndex(const ListType &, typename ListType::const_reference, const label start=0)
Find first occurence of given element and return index,.
static bool isEdge(const primitiveMesh &mesh, const label eVert)
Is eVert an edge?
const Map< edge > & faceSplitCut() const
Gives for split face the two cuts that split the face into two.
const labelListList & cellAnchorPoints() const
For each cut cell the points on the 'anchor' side of the cell.
virtual const labelList & faceNeighbour() const
Return face neighbour.
label whichPatch(const label faceIndex) const
Return patch index for a given face label.
label whichZone(const label objectIndex) const
Given a global object index, return the zone it is in.
Direct mesh changes based on v1.3 polyTopoChange syntax.
const labelList & reverseCellMap() const
Reverse cell map.
Hash function class for primitives. All non-primitives used to hash entries on hash tables likely nee...
void resize(const label newSize)
Resize the hash table for efficiency.
const faceZoneMesh & faceZones() const
Return face zone mesh.
Mesh consisting of general polyhedral cells.
virtual const labelList & faceOwner() const
Return face owner.
virtual const faceList & faces() const
Return raw faces.
Ostream & writeCuts(Ostream &os, const labelList &, const scalarField &) const
Write cut descriptions to Ostream.
const labelList & reversePointMap() const
Reverse point map.
A HashTable to objects of type <T> with a label key.
label setAction(const topoAction &action)
For compatibility with polyTopoChange: set topological action.