Go to the documentation of this file.
53 const scalar minConcaveCos,
64 scalar magEPrev =
mag(ePrev);
65 ePrev /= magEPrev + VSMALL;
70 label fp1 =
f.fcIndex(fp0);
74 scalar magE10 =
mag(e10);
75 e10 /= magE10 + VSMALL;
77 if (magEPrev > SMALL && magE10 > SMALL)
79 vector edgeNormal = ePrev ^ e10;
81 if ((edgeNormal &
n) < 0)
84 if ((ePrev & e10) < minConcaveCos)
103 const scalar minConcaveCos,
110 if (edgeLoops.
size() > 1)
122 face f(getOutsideFace(bigFace));
124 return convexFace(minConcaveCos, bigFace.
points(),
f);
140 label edgeI = cEdges[i];
151 if (p0 != -1 && p0 == p1 && !
patches[p0].coupled())
153 vector f0Normal = mesh_.faceAreas()[f0];
154 f0Normal /=
mag(f0Normal);
155 vector f1Normal = mesh_.faceAreas()[
f1];
156 f1Normal /=
mag(f1Normal);
158 if ((f0Normal&f1Normal) > minCos)
163 if (f0Fnd != faceRegion.end())
171 if (f1Fnd != faceRegion.end())
180 label useRegion = faceRegion.size();
181 faceRegion.insert(f0, useRegion);
182 faceRegion.insert(
f1, useRegion);
186 faceRegion.insert(f0, region1);
193 faceRegion.insert(
f1, region0);
195 else if (region0 != region1)
198 label useRegion =
min(region0, region1);
199 label freeRegion =
max(region0, region1);
203 if (iter() == freeRegion)
222 if (faceRegion.size() <= 1)
227 const cell& cFaces = mesh_.cells()[cellI];
234 label faceI = cFaces[cFaceI];
236 if (!faceRegion.found(faceI))
238 const labelList& fEdges = mesh_.faceEdges(faceI, storage);
250 label edgeI = fEdges[i];
255 if (iter == faceRegion.end())
257 if (
findIndex(neighbourFaces, nbrI) == -1)
259 neighbourFaces.
append(nbrI);
264 neighbourRegions.
insert(iter());
268 if ((neighbourFaces.size()+neighbourRegions.
size()) < 3)
290 faceSetsVertices_(0),
291 savedPointLabels_(0),
300 const scalar featureCos,
301 const scalar minConcaveCos,
313 label cellI = iter.key();
315 const cell& cFaces = mesh_.cells()[cellI];
317 const labelList& cEdges = mesh_.cellEdges(cellI, storage);
321 regioniseFaces(featureCos, cellI, cEdges, faceRegion);
329 if (faceNeighboursValid(cellI, faceRegion))
336 label faceI = iter.key();
337 label region = iter();
341 if (regionFnd != regionToFaces.end())
346 setFaces[sz] = faceI;
350 regionToFaces.insert(region,
labelList(1, faceI));
370 if (validFace(minConcaveCos, bigFace))
372 allFaceSets.
append(iter());
378 return allFaceSets.
shrink();
384 const scalar featureCos,
385 const scalar minConcaveCos
391 labelHashSet boundaryCells(mesh_.nFaces()-mesh_.nInternalFaces());
401 boundaryCells.
insert(mesh_.faceOwner()[patch.
start()+i]);
406 return getMergeSets(featureCos, minConcaveCos, boundaryCells);
421 <<
"Multiple outside loops:" << fp.
edgeLoops()
433 if (eFaces.
size() != 1)
436 <<
"boundary edge:" << bEdgeI
439 <<
" on indirectPrimitivePatch has " << eFaces.
size()
453 bool edgeLoopConsistent =
false;
459 if (index0 == -1 || index1 == -1)
462 <<
"Cannot find boundary edge:" <<
e
467 else if (index1 == outsideLoop.fcIndex(index0))
469 edgeLoopConsistent =
true;
471 else if (index0 == outsideLoop.fcIndex(index1))
473 edgeLoopConsistent =
false;
478 <<
"Cannot find boundary edge:" <<
e
481 <<
" on consecutive points in edgeLoop:"
495 bool faceEdgeConsistent =
false;
504 <<
"Cannot find boundary edge:" <<
e
507 <<
" in face:" << eFaces[0]
508 <<
" edges:" << fp.
faceEdges()[eFaces[0]]
511 else if (localF[index] ==
e[0] && localF.
nextLabel(index) ==
e[1])
513 faceEdgeConsistent =
true;
515 else if (localF[index] ==
e[1] && localF.
nextLabel(index) ==
e[0])
517 faceEdgeConsistent =
false;
522 <<
"Cannot find boundary edge:" <<
e
525 <<
" in face:" << eFaces[0] <<
" verts:" << localF
533 if (faceEdgeConsistent != edgeLoopConsistent)
549 masterFace_.setSize(
faceSets.size());
550 faceSetsVertices_.setSize(
faceSets.size());
555 masterFace_[setI] = setFaces[0];
565 labelList nPointFaces(mesh_.nPoints(), 0);
569 forAll(pointFaces, pointI)
571 nPointFaces[pointI] = pointFaces[pointI].
size();
587 if (patchI == -1 ||
patches[patchI].coupled())
590 <<
"Can only merge non-coupled boundary faces"
591 <<
" but found internal or coupled face:"
592 << setFaces[i] <<
" in set " << setI
612 if (edgeLoops.
size() != 1)
615 <<
"Faces to-be-merged " << setFaces
616 <<
" do not form a single big face." <<
nl
626 label masterFaceI = setFaces[0];
629 face outsideFace(getOutsideFace(bigFace));
631 label zoneID = mesh_.faceZones().whichZone(masterFaceI);
633 bool zoneFlip =
false;
637 const faceZone& fZone = mesh_.faceZones()[zoneID];
642 label patchI = mesh_.boundaryMesh().whichPatch(masterFaceI);
650 mesh_.faceOwner()[masterFaceI],
664 for (
label i = 1; i < setFaces.
size(); i++)
676 const face&
f = mesh_.faces()[setFaces[i]];
680 nPointFaces[
f[fp]]--;
686 nPointFaces[outsideFace[fp]]++;
692 syncTools::syncPointList
703 forAll(nPointFaces, pointI)
705 if (nPointFaces[pointI] == 0)
715 forAll(nPointFaces, pointI)
717 if (nPointFaces[pointI] == 0)
723 savedPointLabels_.setSize(
n);
724 savedPoints_.setSize(
n);
729 forAll(nPointFaces, pointI)
731 if (nPointFaces[pointI] == 0)
735 savedPointLabels_[
n] = pointI;
736 savedPoints_[
n] = mesh_.points()[pointI];
738 meshToSaved.insert(pointI,
n);
744 forAll(faceSetsVertices_, setI)
746 faceList& setFaces = faceSetsVertices_[setI];
750 face&
f = setFaces[i];
756 if (nPointFaces[pointI] == 0)
758 f[fp] = -meshToSaved[pointI]-1;
796 <<
"In set " << setI <<
" at position " << i
797 <<
" with master face "
799 <<
"the points of the slave face " << faces[i]
800 <<
" don't exist anymore."
827 <<
"Can only call setUnrefinement if constructed with"
833 labelList addedPoints(savedPoints_.size(), -1);
840 if (masterFace_[setI] >= 0)
842 masterToSet.insert(masterFace_[setI], setI);
848 label masterFaceI = masterFaces[i];
852 if (iter == masterToSet.end())
855 <<
"Master face " << masterFaceI
856 <<
" is not the master of one of the merge sets"
857 <<
" or has already been merged"
867 faceList& faces = faceSetsVertices_[setI];
872 <<
"Set " << setI <<
" with master face " << masterFaceI
886 label localI = -pointI-1;
888 if (addedPoints[localI] == -1)
895 savedPoints_[localI],
901 restoredPoints.insert
904 savedPointLabels_[localI]
908 f[fp] = addedPoints[localI];
917 label own = mesh_.faceOwner()[masterFaceI];
918 label zoneID = mesh_.faceZones().whichZone(masterFaceI);
919 bool zoneFlip =
false;
922 const faceZone& fZone = mesh_.faceZones()[zoneID];
925 label patchI = mesh_.boundaryMesh().whichPatch(masterFaceI);
927 if (mesh_.boundaryMesh()[patchI].coupled())
930 <<
"Master face " << masterFaceI <<
" is on coupled patch "
931 << mesh_.boundaryMesh()[patchI].name()
954 restoredFaces.insert(masterFaceI, masterFaceI);
978 restoredFaces.insert(faceI, masterFaceI);
982 faceSetsVertices_[setI].clear();
983 masterFace_[setI] = -1;
static face getOutsideFace(const indirectPrimitivePatch &)
Gets outside of patch as a face (in mesh point labels)
const Field< PointType > & points() const
Return reference to global points.
const labelListList & edgeFaces() const
Return edge-face addressing.
#define forAllIter(Container, container, iter)
Iterate across all elements in the container object of type.
List< label > labelList
A List of labels.
An STL-conforming iterator.
const edgeList & edges() const
Return list of edges, address into LOCAL point list.
Class containing data for point removal.
#define forAll(list, i)
Loop across all elements in list.
label findIndex(const ListType &, typename ListType::const_reference, const label start=0)
Find first occurence of given element and return index,.
virtual bool coupled() const
Return true if this patch is geometrically coupled (i.e. faces and.
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...
labelListList getMergeSets(const scalar featureCos, const scalar minConcaveCos, const labelHashSet &boundaryCells) const
Extract lists of all (non-coupled) boundary faces on selected.
Class describing modification of a face.
const labelListList & faceEdges() const
Return face-edge addressing.
dimensioned< scalar > mag(const dimensioned< Type > &)
Mesh consisting of general polyhedral cells.
combineFaces(const combineFaces &)
Disallow default bitwise copy construct.
forAllConstIter(PtrDictionary< phaseModel >, mixture.phases(), phase)
void inplaceRenumber(const labelUList &oldToNew, ListType &)
Inplace renumber the values of a list.
List< faceList > faceSetsVertices_
If undoable: per set the vertices of all the faces in the set.
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.
A patch is a list of labels that address the faces in the global face list.
void updateMesh(const mapPolyMesh &)
Force recalculation of locally stored data on topological change.
void setUnrefinement(const labelList &masterFaces, polyTopoChange &meshMod, Map< label > &restoredPoints, Map< label > &restoredFaces, Map< label > &restoredCells)
Play commands into polyTopoChange to reinsert original faces.
A List with indirect addressing.
DynamicList< T, SizeInc, SizeMult, SizeDiv > & shrink()
Shrink the allocated space to the number of elements used.
bool faceNeighboursValid(const label cellI, const Map< label > &faceRegion) const
Does merging faces invalidate (unmerged) neighbouring faces?
label size() const
Return number of elements in table.
labelList masterFace_
If undoable: masterface for every set.
label whichFace(const label globalCellID) const
Helper function to re-direct to zone::localID(...)
errorManip< error > abort(error &err)
label start() const
Return start label of this patch in the polyMesh face list.
DynamicList< T, SizeInc, SizeMult, SizeDiv > & append(const T &)
Append an element at the end of the list.
errorManipArg< error, int > exit(error &err, const int errNo=1)
const labelList & reverseFaceMap() const
Reverse face map.
label nInternalEdges() const
Number of internal edges.
dimensioned< Type > max(const dimensioned< Type > &, const dimensioned< Type > &)
void setSize(const label)
Reset size of List.
const bool undoable_
Whether undoable.
label nextLabel(const label i) const
Next vertex on face.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
label setAction(const topoAction &action)
For compatibility with polyTopoChange: set topological action.
static bool convexFace(const scalar minConcaveCos, const pointField &, const face &)
Test if face is convex. Allow slight concavity through.
const labelList & reversePointMap() const
Reverse point map.
Class containing data for face removal.
void regioniseFaces(const scalar minCos, const label cellI, const labelList &cEdges, Map< label > &faceRegion) const
Create cell-local map from face to region (formed by merging faces.
const labelListList & edgeLoops() const
Return list of closed loops of boundary vertices.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
const dimensionedScalar e
Elementary charge.
bool insert(const Key &key)
Insert a new entry.
static bool validFace(const scalar minConcaveCos, const indirectPrimitivePatch &)
Test if set of faces (in primitivePatch) can be combined into.
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...
const List< Face > & localFaces() const
Return patch faces addressing into local point list.
A List with indirect addressing.
void setRefinement(const labelListList &, polyTopoChange &)
Play commands into polyTopoChange to combine faces. Gets.
A face is a list of labels corresponding to mesh vertices.
void size(const label)
Override size to be inconsistent with allocated storage.
const labelList & meshPoints() const
Return labelList of mesh points in patch.
bool checkPointManifold(const bool report=false, labelHashSet *setPtr=NULL) const
Checks primitivePatch for faces sharing point but not edge.
const boolList & flipMap() const
Return face flip map.
defineTypeNameAndDebug(combustionModel, 0)
dimensioned< Type > min(const dimensioned< Type > &, const dimensioned< Type > &)
A cell is defined as a list of faces with extra functionality.
static void renumber(const labelList &map, labelList &elems)
A list of faces which address into the list of points.
void reverse(UList< T > &, const label n)