44 const scalar concaveCos,
45 const label mergeSize,
58 for (
const label patchi : patchIDs)
89 if (mergeSets[setI].size() == mergeSize && compactI != setI)
91 mergeSets[compactI++] = mergeSets[setI];
100 Info<<
"Merging " << nFaceSets <<
" sets of faces." <<
nl <<
endl;
145 label oldMasterI = mergeSets[setI][0];
260 const scalar concaveCos,
276 for (
const label patchi : patchIDs)
280 if (!patch.coupled())
284 boundaryCells.
insert(mesh_.faceOwner()[patch.start()+i]);
302 (mergeType == FaceMergeType::IGNOREPATCH)
315 if (preserveFaces[set[j]] != -1)
326 allFaceSets[compactI] = set;
336 Info<<
"Merging " << nFaceSets <<
" sets of faces." <<
nl <<
endl;
342 faceSet allSets(mesh_,
"allFaceSets", allFaceSets.
size());
345 allSets.
insert(allFaceSets[setI]);
347 Pout<<
"Writing all faces to be merged to set "
352 const_cast<Time&
>(mesh_.time())++;
378 mesh_.updateMesh(map());
381 if (map().hasMotionPoints())
383 mesh_.movePoints(map().preMotionPoints());
403 label oldMasterI = allFaceSets[setI][0];
404 retestFaces.
insert(map().reverseFaceMap()[oldMasterI]);
406 updateMesh(map(), growFaceCellFace(retestFaces));
411 Pout<<
"Checking sync after initial merging " << nFaceSets
412 <<
" faces." <<
endl;
415 Pout<<
"Writing initial merged-faces mesh to time "
420 for (label iteration = 0; iteration < 100; iteration++)
423 <<
"Undo iteration " << iteration <<
nl
424 <<
"----------------" <<
endl;
430 faceSet errorFaces(mesh_,
"errorFaces", mesh_.nBoundaryFaces());
474 Pout<<
"Writing all faces in error to faceSet "
487 label masterFaceI = faceCombiner.
masterFace()[setI];
489 if (masterFaceI != -1)
491 label masterCellII = mesh_.faceOwner()[masterFaceI];
493 const cell& cFaces = mesh_.cells()[masterCellII];
497 if (errorFaces.
found(cFaces[i]))
499 mastersToRestore.
append(masterFaceI);
505 mastersToRestore.
shrink();
509 mastersToRestore.
size(),
513 Info<<
"Masters that need to be restored:"
518 faceSet restoreSet(mesh_,
"mastersToRestore", mastersToRestore);
520 Pout<<
"Writing all " << mastersToRestore.
size()
521 <<
" masterfaces to be restored to set "
538 const_cast<Time&
>(mesh_.time())++;
567 mesh_.updateMesh(map());
570 if (map().hasMotionPoints())
572 mesh_.movePoints(map().preMotionPoints());
599 retestFaces.
insert(iter.key());
606 growFaceCellFace(retestFaces),
615 Pout<<
"Checking sync after restoring " << retestFaces.
size()
616 <<
" faces." <<
endl;
619 Pout<<
"Writing merged-faces mesh to time "
629 Info<<
"No faces merged ..." <<
endl;
657 mesh_.updateMesh(map);
682 retestFaces.
insert(facei);
685 updateMesh(map, growFaceCellFace(retestFaces));
690 Pout<<
"Checking sync after removing points." <<
endl;
734 mesh_.updateMesh(map);
758 retestFaces.
insert(faceI);
761 updateMesh(map, growFaceCellFace(retestFaces));
766 Pout<<
"Checking sync after restoring points on "
767 << facesToRestore.
size() <<
" faces." <<
endl;
784 boolList selected(mesh_.nFaces(),
false);
786 for (
const label facei : candidateFaces)
788 if (set.found(facei))
790 selected[facei] =
true;
802 return selectedFaces;
817 const label own = pMesh.
faceOwner()[faceI];
819 const cell& ownFaces = pMesh.
cells()[own];
820 for (
const label facei : ownFaces)
822 selected[facei] =
true;
829 const cell& nbrFaces = pMesh.
cells()[nbr];
830 forAll(nbrFaces, nbrFaceI)
832 selected[nbrFaces[nbrFaceI]] =
true;
845 boolList selected(mesh_.nFaces(),
false);
847 for (
const label facei : set)
868 boolList selected(mesh_.nFaces(),
false);
870 for (
const label facei : set)
894 <<
"Merging all points on surface that" <<
nl
895 <<
"- are used by only two boundary faces and" <<
nl
896 <<
"- make an angle with a cosine of more than " << minCos
904 label nRemove = pointRemover.
countPointUsage(minCos, pointCanBeDeleted);
908 Info<<
"Removing " << nRemove
909 <<
" straight edge points ..." <<
nl <<
endl;
914 doRemovePoints(pointRemover, pointCanBeDeleted);
917 for (label iteration = 0; iteration < 100; iteration++)
920 <<
"Undo iteration " << iteration <<
nl
921 <<
"----------------" <<
endl;
927 faceSet errorFaces(mesh_,
"errorFaces", mesh_.nBoundaryFaces());
965 Pout<<
"**Writing all faces in error to faceSet "
981 Info<<
"Detected " <<
n
982 <<
" error faces on boundaries that have been merged."
983 <<
" These will be restored to their original faces." <<
nl
992 <<
" error faces in mesh."
993 <<
" Restoring neighbours of faces in error." <<
nl
1004 doRestorePoints(pointRemover, expandedErrorFaces);
1010 doRestorePoints(pointRemover, masterErrorFaces);
1015 const_cast<Time&
>(mesh_.time())++;
1016 Pout<<
"Writing merged-edges mesh to time "
1023 Info<<
"No straight edges simplified and no points removed ..." <<
endl;
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects.
DynamicList< T, SizeMin > & shrink()
Shrink the allocated space to the number of elements used.
void append(const T &val)
Copy append an element to the end of this list.
bool insert(const Key &key)
Insert a new entry, not overwriting existing entries.
label size() const noexcept
The number of elements in table.
const fileName & instance() const noexcept
Read access to instance path component.
fileName objectPath() const
The complete path + object name.
void setSize(const label n)
Alias for resize()
A HashTable to objects of type <T> with a label key.
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
void size(const label n)
Older name for setAddressableSize.
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
A cell is defined as a list of faces with extra functionality.
Combines boundary faces into single face. The faces get the patch of the first face ('the master')
labelListList getMergeSets(const scalar featureCos, const scalar minConcaveCos, const labelHashSet &boundaryCells, const bool mergeAcrossPatches=false) const
Extract lists of all (non-coupled) boundary faces on selected.
void setUnrefinement(const labelList &masterFaces, polyTopoChange &meshMod, Map< label > &restoredPoints, Map< label > &restoredFaces, Map< label > &restoredCells)
Play commands into polyTopoChange to reinsert original faces.
void setRefinement(const labelListList &, polyTopoChange &)
Play commands into polyTopoChange to combine faces. Gets.
const labelList & masterFace() const
If undoable: masterface for every set.
const labelList & savedPointLabels() const
If undoable: set of original point labels of stored points.
void updateMesh(const mapPolyMesh &)
Force recalculation of locally stored data on topological change.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
virtual void updateMesh(const mapPolyMesh &mpm)
Update mesh corresponding to the given map.
virtual void movePoints(const pointField &)
Move points, returns volumes swept by faces in motion.
void clearOut()
Clear all geometry and addressing.
void checkMesh() const
Debug: Check coupled mesh for correctness.
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
const pointField & preMotionPoints() const
Pre-motion point positions.
const labelList & reverseFaceMap() const
Reverse face map.
bool hasMotionPoints() const
Has valid preMotionPoints?
label mergeEdgesUndo(const scalar minCos, const dictionary &motionDict)
Merge edges, maintain mesh quality. Return global number.
void updateMesh(const mapPolyMesh &, const labelList &changedFaces)
Update for external change to mesh. changedFaces are in new mesh.
autoPtr< mapPolyMesh > doRestorePoints(removePoints &pointRemover, const labelList &facesToRestore)
labelList growFaceCellFace(const labelUList &set) const
label mergePatchFaces(const scalar minCos, const scalar concaveCos, const label mergeSize, const labelList &patchIDs, const meshRefinement::FaceMergeType mergeType)
Merge coplanar faces if sets are of size mergeSize.
labelList collectFaces(const labelList &candidateFaces, const labelHashSet &set) const
autoPtr< mapPolyMesh > doRemovePoints(removePoints &pointRemover, const boolList &pointCanBeDeleted)
FaceMergeType
Enumeration for what to do with co-planar patch faces on a single.
label mergePatchFacesUndo(const scalar minCos, const scalar concaveCos, const labelList &patchIDs, const dictionary &motionDict, const labelList &preserveFaces, const meshRefinement::FaceMergeType mergeType)
Merge coplanar faces. preserveFaces is != -1 for faces.
A polyBoundaryMesh is a polyPatch list with additional search methods and registered IO.
Mesh consisting of general polyhedral cells.
void setInstance(const fileName &instance, const IOobject::writeOption wOpt=IOobject::AUTO_WRITE)
Set the instance for mesh files.
bool moving() const noexcept
Is mesh moving.
virtual const labelList & faceOwner() const
Return face owner.
const polyBoundaryMesh & boundaryMesh() const
Return boundary mesh.
virtual const labelList & faceNeighbour() const
Return face neighbour.
A patch is a list of labels that address the faces in the global face list.
Direct mesh changes based on v1.3 polyTopoChange syntax.
autoPtr< mapPolyMesh > changeMesh(polyMesh &mesh, const labelUList &patchMap, const bool inflate, const bool syncParallel=true, const bool orderCells=false, const bool orderPoints=false)
Inplace changes mesh without change of patches.
bool isInternalFace(const label faceIndex) const noexcept
Return true if given face label is internal to the mesh.
label nBoundaryFaces() const noexcept
Number of boundary faces (== nFaces - nInternalFaces)
const cellList & cells() const
virtual bool write(const bool valid=true) const
Write using setting from DB.
Removes selected points from mesh and updates faces using these points.
label countPointUsage(const scalar minCos, boolList &pointCanBeDeleted) const
Mark in pointCanBeDeleted the points that can be deleted.
void setUnrefinement(const labelList &localFaces, const labelList &localPoints, polyTopoChange &)
Restore selected faces and vertices.
const labelList & savedFaceLabels() const
void setRefinement(const boolList &, polyTopoChange &)
Play commands into polyTopoChange to remove points. Gets.
void updateMesh(const mapPolyMesh &)
Force recalculation of locally stored data on topological change.
void getUnrefimentSet(const labelList &undoFaces, labelList &localFaces, labelList &localPoints) const
Given set of faces to restore calculates a consistent set of.
virtual bool found(const label id) const
Has the given index?
const polyBoundaryMesh & patches
List< label > labelList
A List of labels.
messageStream Info
Information stream (stdout output on master, null elsewhere)
Ostream & endl(Ostream &os)
Add newline and flush stream.
void inplaceMapKey(const labelUList &oldToNew, Container &input)
Rewrite with mapped keys. Ignore elements with negative key.
static void markGrowFaceCellFace(const polyMesh &pMesh, const label faceI, boolList &selected)
label checkData(const fvMesh &mesh, const instantList &timeDirs, wordList &objectNames)
Check if fields are good to use (available at all times)
T returnReduce(const T &value, const BinaryOp &bop, const int tag=UPstream::msgType(), const label comm=UPstream::worldComm)
Reduce (copy) and return value.
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.
labelList findIndices(const ListType &input, typename ListType::const_reference val, label start=0)
Linear search to find all occurrences of given element.
constexpr char nl
The newline '\n' character (0x0a)
#define forAll(list, i)
Loop across all elements in list.
#define forAllConstIters(container, iter)
Iterate across all elements of the container object with const access.