250 const scalar concaveCos,
260 labelHashSet boundaryCells(mesh_.nFaces()-mesh_.nInternalFaces());
275 boundaryCells.insert(mesh_.faceOwner()[patch.
start()+i]);
305 if (preserveFaces[
set[j]] != -1)
316 allFaceSets[compactI] =
set;
322 allFaceSets.setSize(compactI);
326 Info<<
"Merging " << nFaceSets <<
" sets of faces." <<
nl <<
endl;
330 if (debug&meshRefinement::MESH)
332 faceSet allSets(mesh_,
"allFaceSets", allFaceSets.size());
335 forAll(allFaceSets[setI], i)
337 allSets.insert(allFaceSets[setI][i]);
340 Pout<<
"Writing all faces to be merged to set " 341 << allSets.objectPath() <<
endl;
345 const_cast<Time&
>(mesh_.time())++;
367 mesh_.updateMesh(map);
370 if (map().hasMotionPoints())
372 mesh_.movePoints(map().preMotionPoints());
392 label oldMasterI = allFaceSets[setI][0];
393 retestFaces.insert(map().reverseFaceMap()[oldMasterI]);
395 updateMesh(map, growFaceCellFace(retestFaces));
397 if (debug&meshRefinement::MESH)
400 Pout<<
"Checking sync after initial merging " << nFaceSets
401 <<
" faces." <<
endl;
404 Pout<<
"Writing initial merged-faces mesh to time " 409 for (
label iteration = 0; iteration < 100; iteration++)
412 <<
"Undo iteration " << iteration <<
nl 413 <<
"----------------" <<
endl;
423 mesh_.nFaces()-mesh_.nInternalFaces()
425 bool hasErrors = motionSmoother::checkMesh
464 if (debug&meshRefinement::MESH)
467 Pout<<
"Writing all faces in error to faceSet " 468 << errorFaces.objectPath() <<
nl <<
endl;
482 if (masterFacei != -1)
484 label masterCellII = mesh_.faceOwner()[masterFacei];
486 const cell& cFaces = mesh_.cells()[masterCellII];
490 if (errorFaces.found(cFaces[i]))
492 mastersToRestore.append(masterFacei);
498 mastersToRestore.shrink();
502 mastersToRestore.size(),
506 Info<<
"Masters that need to be restored:" 509 if (debug&meshRefinement::MESH)
511 faceSet restoreSet(mesh_,
"mastersToRestore", mastersToRestore);
513 Pout<<
"Writing all " << mastersToRestore.size()
514 <<
" masterfaces to be restored to set " 531 const_cast<Time&
>(mesh_.time())++;
556 mesh_.updateMesh(map);
559 if (map().hasMotionPoints())
561 mesh_.movePoints(map().preMotionPoints());
588 retestFaces.insert(iter.key());
595 growFaceCellFace(retestFaces),
601 if (debug&meshRefinement::MESH)
604 Pout<<
"Checking sync after restoring " << retestFaces.size()
605 <<
" faces." <<
endl;
608 Pout<<
"Writing merged-faces mesh to time " 618 Info<<
"No faces merged ..." <<
endl;
641 mesh_.updateMesh(map);
644 if (map().hasMotionPoints())
646 mesh_.movePoints(map().preMotionPoints());
667 retestFaces.insert(facei);
670 updateMesh(map, growFaceCellFace(retestFaces));
675 Pout<<
"Checking sync after removing points." <<
endl;
714 mesh_.updateMesh(map);
717 if (map().hasMotionPoints())
719 mesh_.movePoints(map().preMotionPoints());
735 label facei = map().reverseFaceMap()[facesToRestore[i]];
738 retestFaces.insert(facei);
741 updateMesh(map, growFaceCellFace(retestFaces));
746 Pout<<
"Checking sync after restoring points on " 747 << facesToRestore.
size() <<
" faces." <<
endl;
764 boolList selected(mesh_.nFaces(),
false);
768 label facei = candidateFaces[i];
770 if (
set.
found(facei))
772 selected[facei] =
true;
775 syncTools::syncFaceList
784 return selectedFaces;
794 boolList selected(mesh_.nFaces(),
false);
798 label facei = iter.key();
800 label own = mesh_.faceOwner()[facei];
802 const cell& ownFaces = mesh_.cells()[own];
803 forAll(ownFaces, ownFacei)
805 selected[ownFaces[ownFacei]] =
true;
808 if (mesh_.isInternalFace(facei))
810 label nbr = mesh_.faceNeighbour()[facei];
812 const cell& nbrFaces = mesh_.cells()[nbr];
813 forAll(nbrFaces, nbrFacei)
815 selected[nbrFaces[nbrFacei]] =
true;
819 syncTools::syncFaceList
838 <<
"Merging all points on surface that" <<
nl 839 <<
"- are used by only two boundary faces and" <<
nl 840 <<
"- make an angle with a cosine of more than " << minCos
852 Info<<
"Removing " << nRemove
853 <<
" straight edge points ..." <<
nl <<
endl;
858 doRemovePoints(pointRemover, pointCanBeDeleted);
861 for (
label iteration = 0; iteration < 100; iteration++)
864 <<
"Undo iteration " << iteration <<
nl 865 <<
"----------------" <<
endl;
875 mesh_.nFaces()-mesh_.nInternalFaces()
877 bool hasErrors = motionSmoother::checkMesh
910 if (debug&meshRefinement::MESH)
913 Pout<<
"**Writing all faces in error to faceSet " 914 << errorFaces.objectPath() <<
nl <<
endl;
929 Info<<
"Detected " << n
930 <<
" error faces on boundaries that have been merged." 931 <<
" These will be restored to their original faces." <<
nl 940 <<
" error faces in mesh." 941 <<
" Restoring neighbours of faces in error." <<
nl 952 doRestorePoints(pointRemover, expandedErrorFaces);
958 doRestorePoints(pointRemover, masterErrorFaces);
961 if (debug&meshRefinement::MESH)
963 const_cast<Time&
>(mesh_.time())++;
964 Pout<<
"Writing merged-edges mesh to time " 971 Info<<
"No straight edges simplified and no points removed ..." <<
endl;
void inplaceMapKey(const labelUList &oldToNew, Container &)
Recreate with mapped keys. Do not map elements with negative key.
void setUnrefinement(const labelList &localFaces, const labelList &localPoints, polyTopoChange &)
Restore selected faces and vertices.
#define forAll(list, i)
Loop across all elements in list.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
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 of keyword definitions, which are a keyword followed by any number of values (e...
void size(const label)
Override size to be inconsistent with allocated storage.
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 labelList & savedFaceLabels() const
If undoable: affected face labels. Already restored faces.
labelList findIndices(const ListType &, typename ListType::const_reference, const label start=0)
Find all occurrences of given element. Linear search.
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
label size() const
Return number of elements in table.
labelList collectFaces(const labelList &candidateFaces, const labelHashSet &set) const
label mergeEdgesUndo(const scalar minCos, const dictionary &motionDict)
Merge edges, maintain mesh quality. Return global number.
Combines boundary faces into single face. The faces get the patch of the first face ('the master') ...
virtual bool coupled() const
Return true if this patch is geometrically coupled (i.e. faces and.
List< label > labelList
A List of labels.
autoPtr< mapPolyMesh > doRemovePoints(removePoints &pointRemover, const boolList &pointCanBeDeleted)
forAllConstIter(PtrDictionary< phaseModel >, mixture.phases(), phase)
labelListList getMergeSets(const scalar featureCos, const scalar minConcaveCos, const labelHashSet &boundaryCells) const
Extract lists of all (non-coupled) boundary faces on selected.
void setRefinement(const labelListList &, polyTopoChange &)
Play commands into polyTopoChange to combine faces. Gets.
void setRefinement(const boolList &, polyTopoChange &)
Play commands into polyTopoChange to remove points. Gets.
autoPtr< mapPolyMesh > doRestorePoints(removePoints &pointRemover, const labelList &facesToRestore)
const labelList & masterFace() const
If undoable: masterface for every set.
label mergePatchFacesUndo(const scalar minCos, const scalar concaveCos, const labelList &patchIDs, const dictionary &motionDict, const labelList &preserveFaces)
Merge coplanar faces. preserveFaces is != -1 for faces.
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.
const fileName & instance() const
labelList growFaceCellFace(const labelHashSet &set) const
A cell is defined as a list of faces with extra functionality.
prefixOSstream Pout(cout, "Pout")
Direct mesh changes based on v1.3 polyTopoChange syntax.
label start() const
Return start label of this patch in the polyMesh face list.
void updateMesh(const mapPolyMesh &)
Force recalculation of locally stored data on topological change.
T returnReduce(const T &Value, const BinaryOp &bop, const int tag=Pstream::msgType(), const label comm=UPstream::worldComm)
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
virtual Ostream & write(const token &)=0
Write next token to stream.
Removes selected points from mesh and updates faces using these points.
autoPtr< mapPolyMesh > changeMesh(polyMesh &mesh, const bool inflate, const bool syncParallel=true, const bool orderCells=false, const bool orderPoints=false)
Inplace changes mesh without change of patches.
A patch is a list of labels that address the faces in the global face list.
virtual bool write(const bool valid=true) const
Write using setting from DB.
void updateMesh(const mapPolyMesh &)
Force recalculation of locally stored data on topological change.
fileName objectPath() const
Return complete path + object name.