44 const scalar concaveCos,
45 const label mergeSize,
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;
145 label oldMasterI = mergeSets[setI][0];
260 const scalar concaveCos,
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;
332 allFaceSets.setSize(compactI);
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 " 348 << allSets.objectPath() <<
endl;
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 " 475 << errorFaces.objectPath() <<
nl <<
endl;
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 " 966 << errorFaces.objectPath() <<
nl <<
endl;
979 label
n =
returnReduce(masterErrorFaces.size(), sumOp<label>());
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;
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.
const labelList patchIDs(pbm.indices(polyPatchNames, true))
void clearOut()
Clear all geometry and addressing.
void size(const label n)
Older name for setAddressableSize.
void setUnrefinement(const labelList &localFaces, const labelList &localPoints, polyTopoChange &)
Restore selected faces and vertices.
void setUnrefinement(const labelList &masterFaces, polyTopoChange &meshMod, Map< label > &restoredPoints, Map< label > &restoredFaces, Map< label > &restoredCells)
Play commands into polyTopoChange to reinsert original faces.
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.
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.
A list of keyword definitions, which are a keyword followed by a number of values (eg...
labelList growFaceCellFace(const labelUList &set) const
virtual const labelList & faceNeighbour() const
Return face neighbour.
constexpr char nl
The newline '\n' character (0x0a)
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.
virtual void movePoints(const pointField &)
Move points, returns volumes swept by faces in motion.
const labelList & savedFaceLabels() const
If undoable: affected face labels. Already restored faces will be -1.
labelList findIndices(const ListType &input, typename ListType::const_reference val, label start=0)
Linear search to find all occurrences of given element.
const cellList & cells() const
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 insert(const Key &key)
Insert a new entry, not overwriting existing entries.
T returnReduce(const T &value, const BinaryOp &bop, const int tag=UPstream::msgType(), const label comm=UPstream::worldComm)
Perform reduction on a copy, using specified binary operation.
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
bool hasMotionPoints() const
Has valid preMotionPoints?
fileName objectPath() const
The complete path + object name.
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
bool isInternalFace(const label faceIndex) const noexcept
Return true if given face label is internal to the mesh.
UList< label > labelUList
A UList of labels.
labelList collectFaces(const labelList &candidateFaces, const labelHashSet &set) const
#define forAll(list, i)
Loop across all elements in list.
label mergeEdgesUndo(const scalar minCos, const dictionary &motionDict)
Merge edges, maintain mesh quality. Return global number.
HashSet< label, Hash< label > > labelHashSet
A HashSet of labels, uses label hasher.
label size() const noexcept
The number of elements in table.
void write(vtk::formatter &fmt, const Type &val, const label n=1)
Component-wise write of a value (N times)
Combines boundary faces into single face. The faces get the patch of the first face ('the master') ...
virtual void updateMesh(const mapPolyMesh &mpm)
Update mesh corresponding to the given map.
FaceMergeType
Enumeration for what to do with co-planar patch faces on a single.
label checkData(const fvMesh &mesh, const instantList &timeDirs, wordList &objectNames)
Check if fields are good to use (available at all times)
const polyBoundaryMesh & boundaryMesh() const noexcept
Return boundary mesh.
virtual const labelList & faceOwner() const
Return face owner.
virtual bool write(const bool writeOnProc=true) const
Write using setting from DB.
virtual bool write(const token &tok)=0
Write token to stream or otherwise handle it.
autoPtr< mapPolyMesh > doRemovePoints(removePoints &pointRemover, const boolList &pointCanBeDeleted)
word timeName() const
Replacement for Time::timeName() that returns oldInstance (if overwrite_)
A polyBoundaryMesh is a polyPatch list with additional search methods and registered IO...
void setRefinement(const labelListList &, polyTopoChange &)
Play commands into polyTopoChange to combine faces. Gets.
int debug
Static debugging option.
void setRefinement(const boolList &, polyTopoChange &)
Play commands into polyTopoChange to remove points. Gets.
void inplaceMapKey(const labelUList &oldToNew, Container &input)
Rewrite with mapped keys. Ignore elements with negative key.
autoPtr< mapPolyMesh > doRestorePoints(removePoints &pointRemover, const labelList &facesToRestore)
const labelList & masterFace() const
If undoable: masterface for every set.
static void markGrowFaceCellFace(const polyMesh &pMesh, const label faceI, boolList &selected)
void updateMesh(const mapPolyMesh &, const labelList &changedFaces)
Update for external change to mesh. changedFaces are in new mesh.
const fileName & instance() const noexcept
Read access to instance path component.
bool moving() const noexcept
Is mesh moving.
label countPointUsage(const scalar minCos, boolList &pointCanBeDeleted) const
Mark in pointCanBeDeleted the points that can be deleted.
const labelList & savedPointLabels() const
If undoable: set of original point labels of stored points.
void setInstance(const fileName &instance, const IOobjectOption::writeOption wOpt=IOobject::AUTO_WRITE)
Set the instance for mesh files.
A cell is defined as a list of faces with extra functionality.
Direct mesh changes based on v1.3 polyTopoChange syntax.
const polyBoundaryMesh & patches
const std::string patch
OpenFOAM patch number as a std::string.
void updateMesh(const mapPolyMesh &)
Force recalculation of locally stored data on topological change.
messageStream Info
Information stream (stdout output on master, null elsewhere)
Pointer management similar to std::unique_ptr, with some additional methods and type checking...
Removes selected points from mesh and updates faces using these points.
Mesh consisting of general polyhedral cells.
List< label > labelList
A List of labels.
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.
label nBoundaryFaces() const noexcept
Number of boundary faces (== nFaces - nInternalFaces)
List< bool > boolList
A List of bools.
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.
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.
const labelList & reverseFaceMap() const
Reverse face map.
const pointField & preMotionPoints() const
Pre-motion point positions.
forAllConstIters(mixture.phases(), phase)