Go to the documentation of this file.
44 const scalar concaveCos,
45 const label mergeSize,
58 for (
const label patchi : patchIDs)
66 boundaryCells.insert(mesh_.faceOwner()[
patch.start()+i]);
79 (mergeType == FaceMergeType::IGNOREPATCH)
89 if (mergeSets[setI].size() == mergeSize && compactI != setI)
91 mergeSets[compactI++] = mergeSets[setI];
94 mergeSets.setSize(compactI);
100 Info<<
"Merging " << nFaceSets <<
" sets of faces." <<
nl <<
endl;
116 mesh_.updateMesh(map);
141 label oldMasterI = mergeSets[setI][0];
144 updateMesh(map, growFaceCellFace(retestFaces));
252 const scalar concaveCos,
268 for (
const label patchi : patchIDs)
272 if (!
patch.coupled())
276 boundaryCells.insert(mesh_.faceOwner()[
patch.start()+i]);
294 (mergeType == FaceMergeType::IGNOREPATCH)
307 if (preserveFaces[
set[j]] != -1)
318 allFaceSets[compactI] =
set;
324 allFaceSets.setSize(compactI);
328 Info<<
"Merging " << nFaceSets <<
" sets of faces." <<
nl <<
endl;
332 if (
debug&meshRefinement::MESH)
334 faceSet allSets(mesh_,
"allFaceSets", allFaceSets.size());
337 allSets.insert(allFaceSets[setI]);
339 Pout<<
"Writing all faces to be merged to set "
340 << allSets.objectPath() <<
endl;
344 const_cast<Time&
>(mesh_.time())++;
366 mesh_.updateMesh(map());
369 if (map().hasMotionPoints())
371 mesh_.movePoints(map().preMotionPoints());
391 label oldMasterI = allFaceSets[setI][0];
392 retestFaces.insert(map().reverseFaceMap()[oldMasterI]);
394 updateMesh(map(), growFaceCellFace(retestFaces));
396 if (
debug&meshRefinement::MESH)
399 Pout<<
"Checking sync after initial merging " << nFaceSets
400 <<
" faces." <<
endl;
403 Pout<<
"Writing initial merged-faces mesh to time "
408 for (label iteration = 0; iteration < 100; iteration++)
411 <<
"Undo iteration " << iteration <<
nl
412 <<
"----------------" <<
endl;
418 faceSet errorFaces(mesh_,
"errorFaces", mesh_.nBoundaryFaces());
419 bool hasErrors = motionSmoother::checkMesh
459 if (
debug&meshRefinement::MESH)
462 Pout<<
"Writing all faces in error to faceSet "
463 << errorFaces.objectPath() <<
nl <<
endl;
475 label masterFaceI = faceCombiner.
masterFace()[setI];
477 if (masterFaceI != -1)
479 label masterCellII = mesh_.faceOwner()[masterFaceI];
481 const cell& cFaces = mesh_.cells()[masterCellII];
485 if (errorFaces.found(cFaces[i]))
487 mastersToRestore.append(masterFaceI);
493 mastersToRestore.shrink();
497 mastersToRestore.size(),
501 Info<<
"Masters that need to be restored:"
504 if (
debug&meshRefinement::MESH)
506 faceSet restoreSet(mesh_,
"mastersToRestore", mastersToRestore);
508 Pout<<
"Writing all " << mastersToRestore.size()
509 <<
" masterfaces to be restored to set "
526 const_cast<Time&
>(mesh_.time())++;
551 mesh_.updateMesh(map());
554 if (map().hasMotionPoints())
556 mesh_.movePoints(map().preMotionPoints());
583 retestFaces.insert(iter.key());
590 growFaceCellFace(retestFaces),
596 if (
debug&meshRefinement::MESH)
599 Pout<<
"Checking sync after restoring " << retestFaces.size()
600 <<
" faces." <<
endl;
603 Pout<<
"Writing merged-faces mesh to time "
613 Info<<
"No faces merged ..." <<
endl;
637 mesh_.updateMesh(map);
662 retestFaces.
insert(facei);
665 updateMesh(map, growFaceCellFace(retestFaces));
670 Pout<<
"Checking sync after removing points." <<
endl;
710 mesh_.updateMesh(map);
734 retestFaces.insert(faceI);
737 updateMesh(map, growFaceCellFace(retestFaces));
742 Pout<<
"Checking sync after restoring points on "
743 << facesToRestore.size() <<
" faces." <<
endl;
760 boolList selected(mesh_.nFaces(),
false);
762 for (
const label facei : candidateFaces)
764 if (
set.found(facei))
766 selected[facei] =
true;
769 syncTools::syncFaceList
778 return selectedFaces;
793 const label own = pMesh.
faceOwner()[faceI];
795 const cell& ownFaces = pMesh.
cells()[own];
796 for (
const label facei : ownFaces)
798 selected[facei] =
true;
805 const cell& nbrFaces = pMesh.
cells()[nbr];
806 forAll(nbrFaces, nbrFaceI)
808 selected[nbrFaces[nbrFaceI]] =
true;
821 boolList selected(mesh_.nFaces(),
false);
823 for (
const label facei :
set)
828 syncTools::syncFaceList
844 boolList selected(mesh_.nFaces(),
false);
846 for (
const label facei :
set)
851 syncTools::syncFaceList
870 <<
"Merging all points on surface that" <<
nl
871 <<
"- are used by only two boundary faces and" <<
nl
872 <<
"- make an angle with a cosine of more than " << minCos
880 label nRemove = pointRemover.
countPointUsage(minCos, pointCanBeDeleted);
884 Info<<
"Removing " << nRemove
885 <<
" straight edge points ..." <<
nl <<
endl;
890 doRemovePoints(pointRemover, pointCanBeDeleted);
893 for (label iteration = 0; iteration < 100; iteration++)
896 <<
"Undo iteration " << iteration <<
nl
897 <<
"----------------" <<
endl;
903 faceSet errorFaces(mesh_,
"errorFaces", mesh_.nBoundaryFaces());
904 bool hasErrors = motionSmoother::checkMesh
938 if (
debug&meshRefinement::MESH)
941 Pout<<
"**Writing all faces in error to faceSet "
942 << errorFaces.objectPath() <<
nl <<
endl;
957 Info<<
"Detected " <<
n
958 <<
" error faces on boundaries that have been merged."
959 <<
" These will be restored to their original faces." <<
nl
968 <<
" error faces in mesh."
969 <<
" Restoring neighbours of faces in error." <<
nl
980 doRestorePoints(pointRemover, expandedErrorFaces);
986 doRestorePoints(pointRemover, masterErrorFaces);
989 if (
debug&meshRefinement::MESH)
991 const_cast<Time&
>(mesh_.time())++;
992 Pout<<
"Writing merged-edges mesh to time "
999 Info<<
"No straight edges simplified and no points removed ..." <<
endl;
int debug
Static debugging option.
List< label > labelList
A List of labels.
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.
labelList growFaceCellFace(const labelUList &set) const
void set(List< bool > &bools, const labelRange &range)
Set the specified range 'on' in a boolList.
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Combines boundary faces into single face. The faces get the patch of the first face ('the master')
T returnReduce(const T &Value, const BinaryOp &bop, const int tag=Pstream::msgType(), const label comm=UPstream::worldComm)
A polyBoundaryMesh is a polyPatch list with additional search methods and registered IO.
const labelList & savedPointLabels() const
If undoable: set of original point labels of stored points.
const fileName & instance() const noexcept
Removes selected points from mesh and updates faces using these points.
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.
label checkData(const fvMesh &mesh, const instantList &timeDirs, wordList &objectNames)
Check if fields are good to use (available at all times)
labelList collectFaces(const labelList &candidateFaces, const labelHashSet &set) const
const cellList & cells() const
Direct mesh changes based on v1.3 polyTopoChange syntax.
void getUnrefimentSet(const labelList &undoFaces, labelList &localFaces, labelList &localPoints) const
Given set of faces to restore calculates a consistent set of.
Ostream & endl(Ostream &os)
Add newline and flush stream.
const pointField & preMotionPoints() const
Pre-motion point positions.
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.
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.
Mesh consisting of general polyhedral cells.
#define forAll(list, i)
Loop across all elements in list.
FaceMergeType
Enumeration for what to do with co-planar patch faces on a single.
void inplaceMapKey(const labelUList &oldToNew, Container &input)
Rewrite with mapped keys. Ignore elements with negative key.
virtual bool write(const bool valid=true) const
Write using setting from DB.
static void markGrowFaceCellFace(const polyMesh &pMesh, const label faceI, boolList &selected)
messageStream Info
Information stream (stdout output on master, null elsewhere)
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.
virtual const labelList & faceOwner() const
Return face owner.
autoPtr< mapPolyMesh > doRemovePoints(removePoints &pointRemover, const boolList &pointCanBeDeleted)
const labelList & savedFaceLabels() const
label mergeEdgesUndo(const scalar minCos, const dictionary &motionDict)
Merge edges, maintain mesh quality. Return global number.
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.
void setUnrefinement(const labelList &localFaces, const labelList &localPoints, polyTopoChange &)
Restore selected faces and vertices.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
virtual bool write(const token &tok)=0
Write token to stream or otherwise handle it.
const labelList & masterFace() const
If undoable: masterface for every set.
const labelList & reverseFaceMap() const
Reverse face map.
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
bool isInternalFace(const label faceIndex) const noexcept
Return true if given face label is internal to the mesh.
forAllConstIters(mixture.phases(), phase)
const std::string patch
OpenFOAM patch number as a std::string.
bool insert(const Key &key)
Insert a new entry, not overwriting existing entries.
const polyBoundaryMesh & patches
void write(vtk::formatter &fmt, const Type &val, const label n=1)
Component-wise write of a value (N times)
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
bool hasMotionPoints() const
Has valid preMotionPoints?
labelList findIndices(const ListType &input, typename ListType::const_reference val, label start=0)
Linear search to find all occurrences of given element.
void setRefinement(const labelListList &, polyTopoChange &)
Play commands into polyTopoChange to combine faces. Gets.
autoPtr< mapPolyMesh > doRestorePoints(removePoints &pointRemover, const labelList &facesToRestore)
fileName objectPath() const
The complete path + object name.
void updateMesh(const mapPolyMesh &)
Force recalculation of locally stored data on topological change.
void setRefinement(const boolList &, polyTopoChange &)
Play commands into polyTopoChange to remove points. Gets.
A cell is defined as a list of faces with extra functionality.
label countPointUsage(const scalar minCos, boolList &pointCanBeDeleted) const
Mark in pointCanBeDeleted the points that can be deleted.
virtual const labelList & faceNeighbour() const
Return face neighbour.