251 const scalar concaveCos,
279 if (preserveFaces[
set[j]] != -1)
290 allFaceSets[compactI] =
set;
296 allFaceSets.setSize(compactI);
300 Info<<
"Merging " << nFaceSets <<
" sets of faces." <<
nl <<
endl;
304 if (debug&meshRefinement::MESH)
306 faceSet allSets(mesh_,
"allFaceSets", allFaceSets.size());
309 forAll(allFaceSets[seti], i)
311 allSets.insert(allFaceSets[seti][i]);
314 Pout<<
"Writing all faces to be merged to set " 315 << allSets.objectPath() <<
endl;
319 const_cast<Time&
>(mesh_.time())++;
341 mesh_.topoChange(map);
344 if (map().hasMotionPoints())
346 mesh_.movePoints(map().preMotionPoints());
366 const label oldMasterI = allFaceSets[seti][0];
367 retestFaces.insert(map().reverseFaceMap()[oldMasterI]);
369 topoChange(map, growFaceCellFace(retestFaces));
371 if (debug&meshRefinement::MESH)
374 Pout<<
"Checking sync after initial merging " << nFaceSets
375 <<
" faces." <<
endl;
378 Pout<<
"Writing initial merged-faces mesh to time " 383 for (
label iteration = 0; iteration < 100; iteration++)
386 <<
"Undo iteration " << iteration <<
nl 387 <<
"----------------" <<
endl;
397 mesh_.nFaces()-mesh_.nInternalFaces()
399 bool hasErrors = motionSmoother::checkMesh
438 if (debug&meshRefinement::MESH)
441 Pout<<
"Writing all faces in error to faceSet " 442 << errorFaces.objectPath() <<
nl <<
endl;
456 if (masterFacei != -1)
458 const label masterCellII = mesh_.faceOwner()[masterFacei];
460 const cell& cFaces = mesh_.cells()[masterCellII];
464 if (errorFaces.found(cFaces[i]))
466 mastersToRestore.append(masterFacei);
472 mastersToRestore.shrink();
476 mastersToRestore.size(),
480 Info<<
"Masters that need to be restored:" 483 if (debug&meshRefinement::MESH)
485 faceSet restoreSet(mesh_,
"mastersToRestore", mastersToRestore);
487 Pout<<
"Writing all " << mastersToRestore.size()
488 <<
" masterfaces to be restored to set " 505 const_cast<Time&
>(mesh_.time())++;
531 mesh_.topoChange(map);
534 if (map().hasMotionPoints())
536 mesh_.movePoints(map().preMotionPoints());
563 retestFaces.insert(iter.key());
570 growFaceCellFace(retestFaces),
576 if (debug&meshRefinement::MESH)
579 Pout<<
"Checking sync after restoring " << retestFaces.size()
580 <<
" faces." <<
endl;
583 Pout<<
"Writing merged-faces mesh to time " 593 Info<<
"No faces merged ..." <<
endl;
616 mesh_.topoChange(map);
619 if (map().hasMotionPoints())
621 mesh_.movePoints(map().preMotionPoints());
642 retestFaces.insert(facei);
645 topoChange(map, growFaceCellFace(retestFaces));
650 Pout<<
"Checking sync after removing points." <<
endl;
688 mesh_.topoChange(map);
691 if (map().hasMotionPoints())
693 mesh_.movePoints(map().preMotionPoints());
709 const label facei = map().reverseFaceMap()[facesToRestore[i]];
712 retestFaces.insert(facei);
715 topoChange(map, growFaceCellFace(retestFaces));
720 Pout<<
"Checking sync after restoring points on " 721 << facesToRestore.
size() <<
" faces." <<
endl;
738 boolList selected(mesh_.nFaces(),
false);
742 const label facei = candidateFaces[i];
744 if (
set.
found(facei))
746 selected[facei] =
true;
749 syncTools::syncFaceList
758 return selectedFaces;
768 boolList selected(mesh_.nFaces(),
false);
772 const label facei = iter.key();
773 const 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 const 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 masterErrorFaces.
size(),
906 Info<<
"Detected " << n
907 <<
" error faces on boundaries that have been merged." 908 <<
" These will be restored to their original faces." <<
nl 917 <<
" error faces in mesh." 918 <<
" Restoring neighbours of faces in error." <<
nl 929 doRestorePoints(pointRemover, expandedErrorFaces);
935 doRestorePoints(pointRemover, masterErrorFaces);
938 if (debug&meshRefinement::MESH)
940 const_cast<Time&
>(mesh_.time())++;
941 Pout<<
"Writing merged-edges mesh to time " 948 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.
autoPtr< polyTopoChangeMap > 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 Ostream & write(const char)=0
Write character.
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...
#define forAllConstIter(Container, container, iter)
Iterate across all elements in the container object of type.
void topoChange(const polyTopoChangeMap &)
Force recalculation of locally stored data on topological change.
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.
fileName objectPath() const
Return complete path + object name.
Holds information (coordinate and normal) regarding nearest wall point.
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') ...
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects...
void write(std::ostream &os, const bool binary, List< floatScalar > &fField)
Write floats ascii or binary.
List< label > labelList
A List of labels.
autoPtr< polyTopoChangeMap > doRemovePoints(removePoints &pointRemover, const boolList &pointCanBeDeleted)
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.
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.
void topoChange(const polyTopoChangeMap &)
Force recalculation of locally stored data on topological change.
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.
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...
Removes selected points from mesh and updates faces using these points.
fileName & instance() const
Return the instance directory, constant, system, <time> etc.
virtual bool write(const bool write=true) const
Write using setting from DB.
autoPtr< polyTopoChangeMap > doRestorePoints(removePoints &pointRemover, const labelList &facesToRestore)