50void Foam::boundaryCutter::getFaceInfo
65 zoneID = mesh_.faceZones().whichZone(facei);
71 const faceZone& fZone = mesh_.faceZones()[zoneID];
73 zoneFlip = fZone.flipMap()[fZone.whichFace(facei)];
80Foam::face Foam::boundaryCutter::addEdgeCutsToFace
86 const edgeList& edges = mesh_.edges();
87 const face&
f = mesh_.faces()[facei];
88 const labelList& fEdges = mesh_.faceEdges()[facei];
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]);
134 Pout<<
"addEdgeCutsToFace:" <<
nl
135 <<
" from : " <<
f <<
nl
136 <<
" to : " << returnFace <<
endl;
143void Foam::boundaryCutter::addFace
153 label
patchID, zoneID, zoneFlip;
154 getFaceInfo(facei,
patchID, zoneID, zoneFlip);
155 label own = mesh_.faceOwner()[facei];
156 label masterPoint = mesh_.faces()[facei][0];
202bool Foam::boundaryCutter::splitFace
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;
341 label pointi = extendedFace[fp];
343 newFace.append(pointi);
349 pointi >= mesh_.nPoints()
350 || pointToPos.found(pointi)
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)
377 addFace(facei, tmpFace, modifiedFace, meshMod);
388Foam::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]]
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);
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);
894 newEdgeAddedPoints.insert(newE, newAddedPoints);
900 edgeAddedPoints_.transfer(newEdgeAddedPoints);
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects.
void clear() noexcept
Clear the addressed list, i.e. set the size to zero.
void append(const T &val)
Copy append an element to the end of this list.
DynamicList< T, SizeMin > & shrink()
Calls shrink_to_fit() and returns a reference to the DynamicList.
Map from edge (expressed as its endpoints) to value. Hashing (and ==) on an edge is symmetric.
bool found(const Key &key) const
Same as contains().
bool insert(const Key &key, const T &obj)
Copy insert a new entry, not overwriting existing entries.
iterator find(const Key &key)
Find and return an iterator set at the hashed entry.
label size() const noexcept
The number of elements in table.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
void transfer(List< T > &list)
Transfer the contents of the argument List into this list and annul the argument list.
void setSize(label n)
Alias for resize().
A HashTable to objects of type <T> with a label key.
iterator end() noexcept
Return an iterator to end traversing the UList.
void size(const label n)
Older name for setAddressableSize.
Does modifications to boundary faces.
void updateMesh(const mapPolyMesh &)
Force recalculation of locally stored data on topological change.
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.
An edge is a list of two vertex labels. This can correspond to a directed graph edge or an edge on a ...
A face is a list of labels corresponding to mesh vertices.
label find(const Foam::edge &e) const
Find the edge within the face.
label nextLabel(const label i) const
Next vertex on face.
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
const labelList & reverseFaceMap() const noexcept
Reverse face map.
const labelList & reversePointMap() const noexcept
Reverse point map.
A face addition data class. A face can be inflated either from a point or from another face and can e...
Class containing data for point addition.
label whichPatch(const label meshFacei) const
Return patch index for a given mesh face index. Uses binary search.
Mesh consisting of general polyhedral cells.
const polyBoundaryMesh & boundaryMesh() const noexcept
Return boundary mesh.
Class describing modification of a face.
Class describing modification of a point.
Direct mesh changes based on v1.3 polyTopoChange syntax.
label setAction(const topoAction &action)
For compatibility with polyTopoChange: set topological action.
bool isInternalFace(const label faceIndex) const noexcept
Return true if given face label is internal to the mesh.
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Namespace for handling debugging switches.
List< edge > edgeList
List of edge.
Pair< label > labelPair
A pair of labels.
List< label > labelList
A List of labels.
Ostream & endl(Ostream &os)
Add newline and flush stream.
errorManip< error > abort(error &err)
vector point
Point is a vector.
List< bool > boolList
A List of bools.
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.
void diag(pointPatchField< vector > &, const pointPatchField< tensor > &)
messageStream Warning
Warning stream (stdout output on master, null elsewhere), with additional 'FOAM Warning' header text.
constexpr char nl
The newline '\n' character (0x0a).
#define forAll(list, i)
Loop across all elements in list.
#define forAllReverse(list, i)
Reverse loop across all elements in list.
#define forAllConstIters(container, iter)
Iterate across all elements of the container object with const access.