Go to the documentation of this file.
51 if (
findIndex(elems2, elems1[elemI]) != -1)
75 cuts[cuts.fcIndex(index)] == twoCuts[1]
76 || cuts[cuts.rcIndex(index)] == twoCuts[1]
117 if (
mesh().isInternalFace(faceI))
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];
178 if (!
mesh().isInternalFace(faceI))
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
246 <<
" with new owner:" << nei
247 <<
" with new neighbour:" << own
248 <<
" patchID:" << patchID
249 <<
" zoneID:" << zoneID
250 <<
" zoneFlip:" << zoneFlip
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))
363 newFace[newFp++] =
f[fp];
365 fp = (fp + 1) %
f.
size();
367 newFace[newFp] =
f[fp];
387 <<
"Cannot find vertex (new numbering) " << v0
397 <<
"Cannot find vertex (new numbering) " << v1
406 copyFace(
f, startFp, endFp, f0);
407 copyFace(
f, endFp, startFp,
f1);
422 newFace[newFp++] =
f[fp];
425 label fp1 =
f.fcIndex(fp);
430 if (fnd != addedPoints_.end())
433 newFace[newFp++] = fnd();
463 label vertI = addedPoints_[
e];
465 newFace[newFaceI++] = vertI;
472 newFace[newFaceI++] = vertI;
474 label nextCut = loop[loop.fcIndex(fp)];
476 if (!isEdge(nextCut))
479 label nextVertI = getVertex(nextCut);
487 addedPoints_.
find(
mesh().edges()[edgeI]);
489 if (fnd != addedPoints_.end())
491 newFace[newFaceI++] = fnd();
531 addedCells_.resize(cuts.
nLoops());
534 addedFaces_.resize(cuts.
nLoops());
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
567 label masterPointI =
e.start();
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]
693 writeCuts(
Pout, loop, weights);
713 label faceI = iter.key();
716 face newFace(addEdgeCutsToFace(faceI));
719 const edge& splitEdge = iter();
721 label cut0 = splitEdge[0];
726 label edgeI = getEdge(cut0);
727 v0 = addedPoints_[
mesh().
edges()[edgeI]];
731 v0 = getVertex(cut0);
734 label cut1 = splitEdge[1];
738 label edgeI = getEdge(cut1);
739 v1 = addedPoints_[
mesh().
edges()[edgeI]];
743 v1 = getVertex(cut1);
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);
1012 Map<label> newAddedFaces(addedFaces_.size());
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);
virtual const pointField & points() const
Return raw points.
face reverseFace() const
Return face with reverse direction.
meshCutter(const meshCutter &)
Disallow default bitwise copy construct.
label nLoops() const
Number of valid cell loops.
void getFaceInfo(const label faceI, label &patchID, label &zoneID, label &zoneFlip) const
Get patch information for face.
const Map< edge > & faceSplitCut() const
Gives for split face the two cuts that split the face into two.
label findInternalFacePoint(const labelList &pointLabels) const
Returns first pointI in pointLabels that uses an internal.
#define forAll(list, i)
Loop across all elements in list.
static bool isIn(const edge &, const labelList &)
Do the elements of edge appear in consecutive order in the list.
label findIndex(const ListType &, typename ListType::const_reference, const label start=0)
Find first occurence of given element and return index,.
const labelListList & edgeFaces() const
const labelListList & pointFaces() const
const cellList & cells() const
Direct mesh changes based on v1.3 polyTopoChange syntax.
An edge is a list of two point labels. The functionality it provides supports the discretisation on a...
Combines edge or vertex in single label. Used to specify cuts across cell circumference.
bool insert(const Key &, const T &newElmt)
Insert a new hashedEntry.
A HashTable to objects of type <T> with a label key.
Class describing modification of a face.
const polyBoundaryMesh & boundaryMesh() const
Return boundary mesh.
Ostream & endl(Ostream &os)
Add newline and flush stream.
const labelListList & cellAnchorPoints() const
For each cut cell the points on the 'anchor' side of the cell.
const edgeList & edges() const
Return mesh edges. Uses calcEdges.
void updateMesh(const mapPolyMesh &)
Force recalculation of locally stored data on topological change.
Mesh consisting of general polyhedral cells.
forAllConstIter(PtrDictionary< phaseModel >, mixture.phases(), phase)
const faceZoneMesh & faceZones() const
Return face zone mesh.
Info<< "Finished reading KIVA file"<< endl;cellShapeList cellShapes(nPoints);labelList cellZoning(nPoints, -1);const cellModel &hex=*(cellModeller::lookup("hex"));labelList hexLabels(8);label activeCells=0;labelList pointMap(nPoints);forAll(pointMap, i){ pointMap[i]=i;}for(label i=0;i< nPoints;i++){ if(f[i] > 0.0) { hexLabels[0]=i;hexLabels[1]=i1tab[i];hexLabels[2]=i3tab[i1tab[i]];hexLabels[3]=i3tab[i];hexLabels[4]=i8tab[i];hexLabels[5]=i1tab[i8tab[i]];hexLabels[6]=i3tab[i1tab[i8tab[i]]];hexLabels[7]=i3tab[i8tab[i]];cellShapes[activeCells]=cellShape(hex, hexLabels);edgeList edges=cellShapes[activeCells].edges();forAll(edges, ei) { if(edges[ei].mag(points)< SMALL) { label start=pointMap[edges[ei].start()];while(start !=pointMap[start]) { start=pointMap[start];} label end=pointMap[edges[ei].end()];while(end !=pointMap[end]) { end=pointMap[end];} label minLabel=min(start, end);pointMap[start]=pointMap[end]=minLabel;} } cellZoning[activeCells]=idreg[i];activeCells++;}}cellShapes.setSize(activeCells);cellZoning.setSize(activeCells);forAll(cellShapes, celli){ cellShape &cs=cellShapes[celli];forAll(cs, i) { cs[i]=pointMap[cs[i]];} cs.collapse();}label bcIDs[11]={-1, 0, 2, 4, -1, 5, -1, 6, 7, 8, 9};const label nBCs=12;const word *kivaPatchTypes[nBCs]={ &wallPolyPatch::typeName, &wallPolyPatch::typeName, &wallPolyPatch::typeName, &wallPolyPatch::typeName, &symmetryPolyPatch::typeName, &wedgePolyPatch::typeName, &polyPatch::typeName, &polyPatch::typeName, &polyPatch::typeName, &polyPatch::typeName, &symmetryPolyPatch::typeName, &oldCyclicPolyPatch::typeName};enum patchTypeNames{ PISTON, VALVE, LINER, CYLINDERHEAD, AXIS, WEDGE, INFLOW, OUTFLOW, PRESIN, PRESOUT, SYMMETRYPLANE, CYCLIC};const char *kivaPatchNames[nBCs]={ "piston", "valve", "liner", "cylinderHead", "axis", "wedge", "inflow", "outflow", "presin", "presout", "symmetryPlane", "cyclic"};List< SLList< face > > pFaces[nBCs]
const scalarField & edgeWeight() const
If edge is cut gives weight (ratio between start() and end())
void addFace(polyTopoChange &meshMod, const label faceI, const face &newFace, const label owner, const label neighbour)
Adds a face on top of existing faceI. Flips face.
Hash function class for primitives. All non-primitives used to hash entries on hash tables likely nee...
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Pre-declare SubField and related Field type.
A subset of mesh faces organised as a primitive patch.
virtual const labelList & faceOwner() const
Return face owner.
const labelListList & cellLoops() const
For each cut cell the cut along the circumference.
label whichPatch(const label faceIndex) const
Return patch index for a given face label.
static bool uses(const labelList &elems1, const labelList &elems2)
Do list 1 and 2 share elements?
Patchify triangles based on orientation w.r.t other (triangulated or triangulatable) surfaces.
label whichZone(const label objectIndex) const
Given a global object index, return the zone it is in.
face loopToFace(const label cellI, const labelList &loop) const
Convert loop of cuts into face.
label whichFace(const label globalCellID) const
Helper function to re-direct to zone::localID(...)
errorManip< error > abort(error &err)
const double e
Elementary charge.
Class containing data for cell addition.
iterator find(const Key &)
Find and return an iterator set at the hashedEntry.
void faceCells(const cellCuts &cuts, const label faceI, label &own, label &nei) const
Get new owner and neighbour of face. Checks anchor points to see if.
An STL-conforming hash table.
const labelList & reverseFaceMap() const
Reverse face map.
void setSize(const label)
Reset size of List.
const labelList & reverseCellMap() const
Reverse cell map.
virtual const faceList & faces() const
Return raw faces.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
label setAction(const topoAction &action)
For compatibility with polyTopoChange: set topological action.
prefixOSstream Pout(cout, "Pout")
const labelList & reversePointMap() const
Reverse point map.
void setRefinement(const cellCuts &cuts, polyTopoChange &meshMod)
Do actual cutting with cut description. Inserts mesh changes.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
const boolList & edgeIsCut() const
Is edge cut.
void copyFace(const face &f, const label startFp, const label endFp, face &newFace) const
Class containing data for point addition.
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...
label findCutCell(const cellCuts &, const labelList &) const
Returns -1 or the cell in cellLabels that is cut.
A face is a list of labels corresponding to mesh vertices.
face addEdgeCutsToFace(const label faceI) const
Add cuts of edges to face.
void size(const label)
Override size to be inconsistent with allocated storage.
void splitFace(const face &f, const label v0, const label v1, face &f0, face &f1) const
Split face along cut into two faces. Faces are in same point.
void modFace(polyTopoChange &meshMod, const label faceI, const face &newFace, const label owner, const label neighbour)
Modifies existing faceI for either new owner/neighbour or.
const boolList & flipMap() const
Return face flip map.
defineTypeNameAndDebug(combustionModel, 0)
labelList pointLabels(nPoints, -1)
virtual const labelList & faceNeighbour() const
Return face neighbour.
Description of cuts across cells.
static const labelSphericalTensor labelI(1)
Identity labelTensor.