250 const scalar concaveCos,
278 if (preserveFaces[
set[j]] != -1)
289 allFaceSets[compactI] =
set;
295 allFaceSets.setSize(compactI);
299 Info<<
"Merging " << nFaceSets <<
" sets of faces." <<
nl <<
endl;
303 if (debug&meshRefinement::MESH)
305 faceSet allSets(mesh_,
"allFaceSets", allFaceSets.size());
308 forAll(allFaceSets[setI], i)
310 allSets.insert(allFaceSets[setI][i]);
313 Pout<<
"Writing all faces to be merged to set " 314 << allSets.objectPath() <<
endl;
318 const_cast<Time&
>(mesh_.time())++;
340 mesh_.updateMesh(map);
343 if (map().hasMotionPoints())
345 mesh_.movePoints(map().preMotionPoints());
365 label oldMasterI = allFaceSets[setI][0];
366 retestFaces.insert(map().reverseFaceMap()[oldMasterI]);
368 updateMesh(map, growFaceCellFace(retestFaces));
370 if (debug&meshRefinement::MESH)
373 Pout<<
"Checking sync after initial merging " << nFaceSets
374 <<
" faces." <<
endl;
377 Pout<<
"Writing initial merged-faces mesh to time " 382 for (
label iteration = 0; iteration < 100; iteration++)
385 <<
"Undo iteration " << iteration <<
nl 386 <<
"----------------" <<
endl;
396 mesh_.nFaces()-mesh_.nInternalFaces()
398 bool hasErrors = motionSmoother::checkMesh
437 if (debug&meshRefinement::MESH)
440 Pout<<
"Writing all faces in error to faceSet " 441 << errorFaces.objectPath() <<
nl <<
endl;
455 if (masterFacei != -1)
457 label masterCellII = mesh_.faceOwner()[masterFacei];
459 const cell& cFaces = mesh_.cells()[masterCellII];
463 if (errorFaces.found(cFaces[i]))
465 mastersToRestore.append(masterFacei);
471 mastersToRestore.shrink();
475 mastersToRestore.size(),
479 Info<<
"Masters that need to be restored:" 482 if (debug&meshRefinement::MESH)
484 faceSet restoreSet(mesh_,
"mastersToRestore", mastersToRestore);
486 Pout<<
"Writing all " << mastersToRestore.size()
487 <<
" masterfaces to be restored to set " 504 const_cast<Time&
>(mesh_.time())++;
529 mesh_.updateMesh(map);
532 if (map().hasMotionPoints())
534 mesh_.movePoints(map().preMotionPoints());
561 retestFaces.insert(iter.key());
568 growFaceCellFace(retestFaces),
574 if (debug&meshRefinement::MESH)
577 Pout<<
"Checking sync after restoring " << retestFaces.size()
578 <<
" faces." <<
endl;
581 Pout<<
"Writing merged-faces mesh to time " 591 Info<<
"No faces merged ..." <<
endl;
614 mesh_.updateMesh(map);
617 if (map().hasMotionPoints())
619 mesh_.movePoints(map().preMotionPoints());
640 retestFaces.insert(facei);
643 updateMesh(map, growFaceCellFace(retestFaces));
648 Pout<<
"Checking sync after removing points." <<
endl;
687 mesh_.updateMesh(map);
690 if (map().hasMotionPoints())
692 mesh_.movePoints(map().preMotionPoints());
708 label facei = map().reverseFaceMap()[facesToRestore[i]];
711 retestFaces.insert(facei);
714 updateMesh(map, growFaceCellFace(retestFaces));
719 Pout<<
"Checking sync after restoring points on " 720 << facesToRestore.
size() <<
" faces." <<
endl;
737 boolList selected(mesh_.nFaces(),
false);
741 label facei = candidateFaces[i];
743 if (
set.
found(facei))
745 selected[facei] =
true;
748 syncTools::syncFaceList
757 return selectedFaces;
767 boolList selected(mesh_.nFaces(),
false);
771 label facei = iter.key();
773 label own = mesh_.faceOwner()[facei];
775 const cell& ownFaces = mesh_.cells()[own];
776 forAll(ownFaces, ownFacei)
778 selected[ownFaces[ownFacei]] =
true;
781 if (mesh_.isInternalFace(facei))
783 label nbr = mesh_.faceNeighbour()[facei];
785 const cell& nbrFaces = mesh_.cells()[nbr];
786 forAll(nbrFaces, nbrFacei)
788 selected[nbrFaces[nbrFacei]] =
true;
792 syncTools::syncFaceList
811 <<
"Merging all points on surface that" <<
nl 812 <<
"- are used by only two boundary faces and" <<
nl 813 <<
"- make an angle with a cosine of more than " << minCos
825 Info<<
"Removing " << nRemove
826 <<
" straight edge points ..." <<
nl <<
endl;
831 doRemovePoints(pointRemover, pointCanBeDeleted);
834 for (
label iteration = 0; iteration < 100; iteration++)
837 <<
"Undo iteration " << iteration <<
nl 838 <<
"----------------" <<
endl;
848 mesh_.nFaces()-mesh_.nInternalFaces()
850 bool hasErrors = motionSmoother::checkMesh
883 if (debug&meshRefinement::MESH)
886 Pout<<
"**Writing all faces in error to faceSet " 887 << errorFaces.objectPath() <<
nl <<
endl;
902 Info<<
"Detected " << n
903 <<
" error faces on boundaries that have been merged." 904 <<
" These will be restored to their original faces." <<
nl 913 <<
" error faces in mesh." 914 <<
" Restoring neighbours of faces in error." <<
nl 925 doRestorePoints(pointRemover, expandedErrorFaces);
931 doRestorePoints(pointRemover, masterErrorFaces);
934 if (debug&meshRefinement::MESH)
936 const_cast<Time&
>(mesh_.time())++;
937 Pout<<
"Writing merged-edges mesh to time " 944 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...
label mergePatchFacesUndo(const scalar minCos, const scalar concaveCos, const labelHashSet &patchIDs, const dictionary &motionDict, const labelList &preserveFaces)
Merge coplanar faces. preserveFaces is != -1 for faces.
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
labelListList getMergeSets(const scalar featureCos, const scalar minConcaveCos, const labelHashSet &patchIDs, const labelHashSet &boundaryCells) const
Extract lists of all (non-coupled) boundary faces on selected.
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') ...
List< label > labelList
A List of labels.
autoPtr< mapPolyMesh > doRemovePoints(removePoints &pointRemover, const boolList &pointCanBeDeleted)
forAllConstIter(PtrDictionary< phaseModel >, mixture.phases(), phase)
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 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.
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.
virtual bool write(const bool write=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.