44 const scalar concaveCos,
45 const label mergeSize,
66 boundaryCells.
insert(mesh_.faceOwner()[patch.start()+i]);
89 if (mergeSets[setI].size() == mergeSize && compactI != setI)
91 mergeSets[compactI++] = mergeSets[setI];
100 Info<<
"Merging " << nFaceSets <<
" sets of faces." <<
nl <<
endl;
120 mesh_.updateMesh(map);
145 label oldMasterI = mergeSets[setI][0];
260 const scalar concaveCos,
280 if (!patch.coupled())
284 boundaryCells.
insert(mesh_.faceOwner()[patch.start()+i]);
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]);
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());
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;
639 removePoints& pointRemover,
644 polyTopoChange meshMod(mesh_);
646 pointRemover.setRefinement(pointCanBeDeleted, meshMod);
653 autoPtr<mapPolyMesh> mapPtr = meshMod.changeMesh(mesh_,
false,
true);
654 mapPolyMesh& map = *mapPtr;
657 mesh_.updateMesh(map);
660 if (map.hasMotionPoints())
662 mesh_.movePoints(map.preMotionPoints());
673 pointRemover.updateMesh(map);
677 labelHashSet retestFaces(pointRemover.savedFaceLabels().size());
678 for (
const label facei : pointRemover.savedFaceLabels())
682 retestFaces.insert(facei);
685 updateMesh(map, growFaceCellFace(retestFaces));
690 Pout<<
"Checking sync after removing points." <<
endl;
701 removePoints& pointRemover,
706 polyTopoChange meshMod(mesh_);
710 pointRemover.getUnrefimentSet
718 pointRemover.setUnrefinement
730 autoPtr<mapPolyMesh> mapPtr = meshMod.changeMesh(mesh_,
false,
true);
731 mapPolyMesh& map = *mapPtr;
734 mesh_.updateMesh(map);
737 if (map.hasMotionPoints())
739 mesh_.movePoints(map.preMotionPoints());
750 pointRemover.updateMesh(map);
755 label faceI = map.reverseFaceMap()[facesToRestore[i]];
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;
812 const polyMesh& pMesh,
817 const label own = pMesh.faceOwner()[faceI];
819 const cell& ownFaces = pMesh.cells()[own];
820 for (
const label facei : ownFaces)
822 selected[facei] =
true;
825 if (pMesh.isInternalFace(faceI))
827 const label nbr = pMesh.faceNeighbour()[faceI];
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 "
966 << errorFaces.objectPath() <<
nl <<
endl;
974 pointRemover.savedFaceLabels(),
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.
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.
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(label n)
Alias for resize().
A HashTable to objects of type <T> with a label key.
virtual bool write(const token &tok)=0
Write token to stream or otherwise handle it.
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,...
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
const pointField & preMotionPoints() const noexcept
Pre-motion point positions.
const labelList & reverseFaceMap() const noexcept
Reverse face map.
bool hasMotionPoints() const noexcept
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.
word timeName() const
Replacement for Time::timeName() that returns oldInstance (if overwrite_).
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.
void storeData(const labelList &pointsToStore, const labelList &facesToStore, const labelList &cellsToStore)
Signal points/face/cells for which to store data.
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.
static bool checkMesh(const bool report, const polyMesh &mesh, const dictionary &dict, labelHashSet &wrongFaces, const bool dryRun=false)
Check mesh with mesh settings in dict. Collects incorrect faces.
A polyBoundaryMesh is a polyPatch list with registered IO, a reference to the associated polyMesh,...
Mesh consisting of general polyhedral cells.
virtual const labelList & faceOwner() const
Return face owner.
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.
const cellList & cells() const
virtual bool write(const bool writeOnProc=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
If undoable: affected face labels. Already restored faces will be -1.
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
void set(List< bool > &bools, const labelUList &locations)
Set the listed locations (assign 'true').
Namespace for handling debugging switches.
List< labelList > labelListList
List of labelList.
List< label > labelList
A List of labels.
HashSet< label, Hash< label > > labelHashSet
A HashSet of labels, uses label hasher.
messageStream Info
Information stream (stdout output on master, null elsewhere).
label checkData(const objectRegistry &obr, const instantList &timeDirs, wordList &objectNames, const fileName &local=fileName::null)
Check if fields are good to use (available at all times).
T returnReduce(const T &value, BinaryOp bop, const int tag=UPstream::msgType(), const int communicator=UPstream::worldComm)
Perform reduction on a copy, using specified binary operation.
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.
List< bool > boolList
A List of bools.
static void markGrowFaceCellFace(const polyMesh &pMesh, const label faceI, boolList &selected)
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.
UList< label > labelUList
A UList of labels.
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.