50 void Foam::boundaryCutter::getFaceInfo
71 const faceZone& fZone = mesh_.
faceZones()[zoneID];
73 zoneFlip = fZone.flipMap()[fZone.whichFace(facei)];
80 Foam::face Foam::boundaryCutter::addEdgeCutsToFace
83 const Map<labelList>& edgeToAddedPoints
86 const edgeList& edges = mesh_.edges();
87 const face&
f = mesh_.faces()[facei];
88 const labelList& fEdges = mesh_.faceEdges()[facei];
91 DynamicList<label> newFace(2 *
f.
size());
96 newFace.append(
f[fp]);
99 label v1 =
f.nextLabel(fp);
103 const auto fnd = edgeToAddedPoints.cfind(edgeI);
110 if (edges[edgeI].start() ==
f[fp])
115 newFace.append(addedPoints[i]);
123 newFace.append(addedPoints[i]);
130 returnFace.transfer(newFace);
134 Pout<<
"addEdgeCutsToFace:" <<
nl 135 <<
" from : " <<
f <<
nl 136 <<
" to : " << returnFace <<
endl;
143 void Foam::boundaryCutter::addFace
149 polyTopoChange& meshMod
153 label
patchID, zoneID, zoneFlip;
154 getFaceInfo(facei,
patchID, zoneID, zoneFlip);
155 label own = mesh_.faceOwner()[facei];
156 label masterPoint = mesh_.faces()[facei][0];
202 bool Foam::boundaryCutter::splitFace
205 const Map<point>& pointToPos,
206 const Map<labelList>& edgeToAddedPoints,
207 polyTopoChange& meshMod
210 const edgeList& edges = mesh_.edges();
211 const face&
f = mesh_.faces()[facei];
212 const labelList& fEdges = mesh_.faceEdges()[facei];
215 label nSplitEdges = 0;
216 label nModPoints = 0;
217 label nTotalSplits = 0;
221 if (pointToPos.found(
f[fp]))
228 label nextV =
f.nextLabel(fp);
232 const auto fnd = edgeToAddedPoints.cfind(edgeI);
237 nTotalSplits += fnd().size();
243 Pout<<
"Face:" << facei
244 <<
" nModPoints:" << nModPoints
245 <<
" nSplitEdges:" << nSplitEdges
246 <<
" nTotalSplits:" << nTotalSplits <<
endl;
249 if (nSplitEdges == 0 && nModPoints == 0)
252 <<
" nSplitEdges:" << nSplitEdges
253 <<
" nTotalSplits:" << nTotalSplits
257 else if (nSplitEdges + nModPoints == 1)
261 Warning <<
"Face " << facei <<
" has only one edge cut " <<
endl;
272 label
patchID, zoneID, zoneFlip;
273 getFaceInfo(facei,
patchID, zoneID, zoneFlip);
276 face extendedFace(addEdgeCutsToFace(facei, edgeToAddedPoints));
283 if (extendedFace[fp] >= mesh_.nPoints())
295 if (pointToPos.found(extendedFace[fp]))
311 bool modifiedFace =
false;
335 DynamicList<label> newFace(extendedFace.size());
341 label pointi = extendedFace[fp];
343 newFace.append(pointi);
349 pointi >= mesh_.nPoints()
350 || pointToPos.found(pointi)
356 tmpFace.transfer(newFace);
359 addFace(facei, tmpFace, modifiedFace, meshMod);
362 newFace.append(extendedFace[startFp]);
363 newFace.append(extendedFace[fp]);
366 fp = (fp+1) % extendedFace.size();
370 if (newFace.size() > 2)
374 tmpFace.transfer(newFace);
377 addFace(facei, tmpFace, modifiedFace, meshMod);
388 Foam::boundaryCutter::boundaryCutter(
const polyMesh&
mesh)
408 edgeAddedPoints_.clear();
410 faceAddedPoint_.clear();
411 faceAddedPoint_.reserve(faceToFeaturePoint.
size());
440 Map<labelList> edgeToAddedPoints(edgeToCuts.size());
444 const label edgeI = iter.key();
445 const List<point>& cuts = iter.val();
447 const edge&
e = mesh_.edges()[edgeI];
454 const point& featurePoint = cuts[cutI];
468 auto fnd = edgeToAddedPoints.find(edgeI);
474 label sz = addedPoints.size();
475 addedPoints.setSize(sz+1);
476 addedPoints[sz] = addedPointi;
480 edgeToAddedPoints.insert(edgeI,
labelList(1, addedPointi));
485 Pout<<
"Added point " << addedPointi <<
" for edge " << edgeI
486 <<
" with cuts:" << edgeToAddedPoints[edgeI] <<
endl;
498 const label facei = iter.key();
500 const face&
f = mesh_.faces()[facei];
502 if (faceToSplit.
found(facei))
505 <<
"Face " << facei <<
" vertices " <<
f 506 <<
" is both marked for face-centre decomposition and" 507 <<
" diagonal splitting." 511 if (mesh_.isInternalFace(facei))
514 <<
"Face " << facei <<
" vertices " <<
f 515 <<
" is not an external face. Cannot split it" 531 faceAddedPoint_.insert(facei, addedPointi);
535 Pout<<
"Added point " << addedPointi <<
" for feature point " 536 << iter.val() <<
" on face " << facei <<
" with centre " 537 << mesh_.faceCentres()[facei] <<
endl;
549 boolList faceUptodate(mesh_.nFaces(),
false);
555 const label facei = iter.key();
556 const label addedPointi = iter.val();
559 face newFace(addEdgeCutsToFace(facei, edgeToAddedPoints));
562 label
patchID, zoneID, zoneFlip;
563 getFaceInfo(facei,
patchID, zoneID, zoneFlip);
564 label own = mesh_.faceOwner()[facei];
565 label masterPoint = mesh_.faces()[facei][0];
573 label nextV = newFace.nextLabel(fp);
575 tri[0] = newFace[fp];
577 tri[2] = addedPointi;
620 faceUptodate[facei] =
true;
627 const label facei = iter.key();
629 const face&
f = mesh_.faces()[facei];
631 if (faceAddedPoint_.found(facei))
634 <<
"Face " << facei <<
" vertices " <<
f 635 <<
" is both marked for face-centre decomposition and" 636 <<
" diagonal splitting." 642 face newFace(addEdgeCutsToFace(facei, edgeToAddedPoints));
645 label
patchID, zoneID, zoneFlip;
646 getFaceInfo(facei,
patchID, zoneID, zoneFlip);
647 label own = mesh_.faceOwner()[facei];
648 label masterPoint = mesh_.faces()[facei][0];
653 label fp0 = newFace.find(
f[
diag[0]]);
654 label fp1 = newFace.find(
f[
diag[1]]);
656 if (fp0 == -1 || fp1 == -1 || fp0 == fp1)
659 <<
"Problem : Face " << facei <<
" vertices " <<
f 660 <<
" newFace:" << newFace <<
" diagonal:" <<
f[
diag[0]]
668 DynamicList<label> newVerts(newFace.size());
675 newVerts.append(newFace[fp]);
677 fp = (fp == newFace.size()-1 ? 0 : fp+1);
681 newVerts.append(newFace[fp1]);
689 face(newVerts.shrink()),
708 newVerts.append(newFace[fp]);
710 fp = (fp == newFace.size()-1 ? 0 : fp+1);
714 newVerts.append(newFace[fp0]);
721 face(newVerts.shrink()),
734 faceUptodate[facei] =
true;
742 const label edgeI = iter.key();
744 const labelList& eFaces = mesh_.edgeFaces()[edgeI];
748 label facei = eFaces[i];
750 if (!faceUptodate[facei] && !mesh_.isInternalFace(facei))
753 if (splitFace(facei, pointToPos, edgeToAddedPoints, meshMod))
756 faceUptodate[facei] =
true;
768 const label edgeI = iter.key();
770 const labelList& eFaces = mesh_.edgeFaces()[edgeI];
774 label facei = eFaces[i];
776 if (!faceUptodate[facei])
779 face newFace(addEdgeCutsToFace(facei, edgeToAddedPoints));
781 const label own = mesh_.faceOwner()[facei];
785 if (mesh_.isInternalFace(facei))
787 nei = mesh_.faceNeighbour()[facei];
790 label
patchID, zoneID, zoneFlip;
791 getFaceInfo(facei,
patchID, zoneID, zoneFlip);
809 faceUptodate[facei] =
true;
816 edgeAddedPoints_.reserve(edgeToAddedPoints.size());
820 edgeAddedPoints_.insert(mesh_.edges()[iter.key()], iter.val());
835 Map<label> newAddedPoints(faceAddedPoint_.capacity());
839 const label oldFacei = iter.key();
840 const label oldPointi = iter.val();
842 const label newFacei = morphMap.reverseFaceMap()[oldFacei];
843 const label
newPointi = morphMap.reversePointMap()[oldPointi];
847 newAddedPoints.insert(newFacei,
newPointi);
852 faceAddedPoint_.transfer(newAddedPoints);
863 EdgeMap<labelList> newEdgeAddedPoints(edgeAddedPoints_.capacity());
867 const edge&
e = iter.key();
868 const labelList& addedPoints = iter.val();
870 const label newStart = morphMap.reversePointMap()[
e.start()];
871 const label newEnd = morphMap.reversePointMap()[
e.end()];
873 if (newStart >= 0 && newEnd >= 0)
875 labelList newAddedPoints(addedPoints.size());
880 label newAddedPointi =
881 morphMap.reversePointMap()[addedPoints[i]];
883 if (newAddedPointi >= 0)
885 newAddedPoints[newI++] = newAddedPointi;
890 newAddedPoints.setSize(newI);
892 edge newE = edge(newStart, newEnd);
894 newEdgeAddedPoints.insert(newE, newAddedPoints);
900 edgeAddedPoints_.transfer(newEdgeAddedPoints);
void size(const label n)
Older name for setAddressableSize.
A face is a list of labels corresponding to mesh vertices.
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
bool found(const label &key) const
Same as contains()
List< edge > edgeList
List of edge.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
constexpr char nl
The newline '\n' character (0x0a)
Ostream & endl(Ostream &os)
Add newline and flush stream.
bool isInternalFace(const label faceIndex) const noexcept
Return true if given face label is internal to the mesh.
void setRefinement(const Map< point > &pointToPos, const Map< List< point >> &edgeToCuts, const Map< labelPair > &faceToSplit, const Map< point > &faceToFeaturePoint, polyTopoChange &meshMod)
Do actual cutting with cut description. Inserts mesh changes.
#define forAll(list, i)
Loop across all elements in list.
label size() const noexcept
The number of elements in table.
void diag(pointPatchField< vector > &, const pointPatchField< tensor > &)
const dimensionedScalar e
Elementary charge.
const polyBoundaryMesh & boundaryMesh() const noexcept
Return boundary mesh.
label whichPatch(const label meshFacei) const
Return patch index for a given mesh face index. Uses binary search.
errorManip< error > abort(error &err)
Class describing modification of a point.
int debug
Static debugging option.
Pair< label > labelPair
A pair of labels.
const faceZoneMesh & faceZones() const noexcept
Return face zone mesh.
defineTypeNameAndDebug(combustionModel, 0)
messageStream Warning
Warning stream (stdout output on master, null elsewhere), with additional 'FOAM Warning' header text...
label whichZone(const label objectIndex) const
Given a global object index, return the zone it is in.
vector point
Point is a vector.
Direct mesh changes based on v1.3 polyTopoChange syntax.
#define forAllReverse(list, i)
Reverse loop across all elements in list.
List< label > labelList
A List of labels.
List< bool > boolList
A List of bools.
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.
void updateMesh(const mapPolyMesh &)
Force recalculation of locally stored data on topological change.
forAllConstIters(mixture.phases(), phase)
A HashTable to objects of type <T> with a label key.
label setAction(const topoAction &action)
For compatibility with polyTopoChange: set topological action.