49 updateSets<pointSet>(map);
50 updateSets<faceSet>(map);
51 updateSets<cellSet>(map);
55 void Foam::polyMeshFilter::copySets
61 copySets<pointSet>(oldMesh, newMesh);
62 copySets<faceSet>(oldMesh, newMesh);
63 copySets<cellSet>(oldMesh, newMesh);
78 mesh.polyMesh::instance(),
91 meshCopy().updateMesh(map);
97 copySets(mesh, meshCopy());
105 Foam::label Foam::polyMeshFilter::filterFacesLoop(
const label nOriginalBadFaces)
108 label nOuterIterations = 0;
111 labelList pointErrorCount(mesh_.nPoints(), 0);
117 meshQualityCoeffDict(),
121 bool newBadFaces =
true;
131 nOuterIterations < maxIterations()
136 Info<<
nl <<
"Outer Iteration = " << nOuterIterations++ <<
nl 139 printScalarFieldStats(
"Edge Filter Factor", minEdgeLen_);
140 printScalarFieldStats(
"Face Filter Factor", faceFilterFactor_);
143 newMeshPtr_ = copyMesh(mesh_);
144 fvMesh& newMesh = newMeshPtr_();
146 scalarField newMeshFaceFilterFactor = faceFilterFactor_;
147 pointPriority_.reset(
new labelList(originalPointPriority_));
152 label nInnerIterations = 0;
160 << nInnerIterations++ <<
nl << incrIndent <<
endl;
162 label nLocalCollapse = filterFaces
165 newMeshFaceFilterFactor,
166 origToCurrentPointMap
172 nLocalCollapse >= nPrevLocalCollapse
173 || nLocalCollapse == 0
181 nPrevLocalCollapse = nLocalCollapse;
189 label nInnerIterations = 0;
197 << nInnerIterations++ <<
nl << incrIndent <<
endl;
199 label nLocalCollapse = filterEdges
203 origToCurrentPointMap
209 nLocalCollapse >= nPrevLocalCollapse
210 || nLocalCollapse == 0
218 nPrevLocalCollapse = nLocalCollapse;
229 if (controlMeshQuality())
235 meshQualityCoeffDict(),
239 Info<<
nl <<
" Number of bad faces : " << nBadFaces <<
nl 240 <<
" Number of marked points : " 244 updatePointErrorCount
247 origToCurrentPointMap,
251 checkMeshEdgesAndRelaxEdges
254 origToCurrentPointMap,
259 checkMeshFacesAndRelaxEdges
262 origToCurrentPointMap,
268 forAll(mesh_.points(), pI)
272 origToCurrentPointMap[pI] >= 0
273 && isErrorPoint[origToCurrentPointMap[pI]]
276 if (!newErrorPoint[pI])
312 labelPair nCollapsedPtEdge = collapser.markSmallSliverFaces
314 newMeshFaceFilterFactor,
317 collapsePointToLocation
320 label nCollapsed = 0;
321 forAll(nCollapsedPtEdge, collapseTypeI)
323 nCollapsed += nCollapsedPtEdge[collapseTypeI];
332 <<
"Collapsing " << nCollapsed <<
" faces " 333 <<
"(to point = " << nToPoint <<
", to edge = " << nToEdge <<
")" 347 collapser.consistentCollapse
351 collapsePointToLocation,
360 <<
" edges after synchronisation and PointEdgeWave" <<
endl;
362 if (nLocalCollapse == 0)
372 collapser.setRefinement(allPointInfo, newMeshMod);
392 updatePointPriorities(newMesh, newMap.
pointMap());
394 mapOldMeshFaceFieldToNewMesh
398 newMeshFaceFilterFactor
401 updateOldToNewPointMap
404 origToCurrentPointMap
408 return nLocalCollapse;
430 label nSmallCollapsed = collapser.markSmallEdges
435 collapsePointToLocation
439 Info<<
indent <<
"Collapsing " << nSmallCollapsed
440 <<
" small edges" <<
endl;
443 label nMerged = collapser.markMergeEdges
448 collapsePointToLocation
452 Info<<
indent <<
"Collapsing " << nMerged <<
" in line edges" 455 if (nMerged + nSmallCollapsed == 0)
465 collapser.consistentCollapse
469 collapsePointToLocation,
478 <<
" edges after synchronisation and PointEdgeWave" <<
endl;
480 if (nLocalCollapse == 0)
489 collapser.setRefinement(allPointInfo, newMeshMod);
510 mapOldMeshEdgeFieldToNewMesh
517 updateOldToNewPointMap
520 origToCurrentPointMap
523 updatePointPriorities(newMesh, newMap.
pointMap());
525 return nLocalCollapse;
529 void Foam::polyMeshFilter::updatePointErrorCount
536 forAll(mesh_.points(), pI)
538 if (isErrorPoint[oldToNewMesh[pI]])
540 pointErrorCount[pI]++;
546 void Foam::polyMeshFilter::checkMeshEdgesAndRelaxEdges
554 const edgeList& edges = mesh_.edges();
558 const edge&
e = edges[edgeI];
559 label newStart = oldToNewMesh[e[0]];
560 label newEnd = oldToNewMesh[e[1]];
564 pointErrorCount[e[0]] >= maxPointErrorCount()
565 || pointErrorCount[e[1]] >= maxPointErrorCount()
568 minEdgeLen_[edgeI] = -1;
573 (newStart >= 0 && isErrorPoint[newStart])
574 || (newEnd >= 0 && isErrorPoint[newEnd])
577 minEdgeLen_[edgeI] *= edgeReductionFactor();
583 for (
label smoothIter = 0; smoothIter < maxSmoothIters(); ++smoothIter)
586 forAll(mesh_.edges(), edgeI)
588 const edge&
e = mesh_.edges()[edgeI];
590 scalar sumMinEdgeLen = 0;
595 const labelList& pEdges = mesh_.pointEdges()[e[pointi]];
599 const label pEdge = pEdges[pEdgeI];
600 sumMinEdgeLen += minEdgeLen_[pEdge];
605 minEdgeLen_[edgeI] =
min 623 void Foam::polyMeshFilter::checkMeshFacesAndRelaxEdges
631 const faceList& faces = mesh_.faces();
635 const face&
f = faces[facei];
639 const label ptIndex = oldToNewMesh[f[fpI]];
641 if (pointErrorCount[f[fpI]] >= maxPointErrorCount())
643 faceFilterFactor_[facei] = -1;
646 if (isErrorPoint[ptIndex])
648 faceFilterFactor_[facei] *= faceReductionFactor();
657 for (
label smoothIter = 0; smoothIter < maxSmoothIters(); ++smoothIter)
662 const labelList& fEdges = mesh_.faceEdges()[facei];
664 scalar sumFaceFilterFactors = 0;
669 bool skipFace =
true;
673 const labelList& eFaces = mesh_.edgeFaces()[fEdges[fEdgeI]];
677 const label eFace = eFaces[eFacei];
679 const face&
f = faces[eFace];
683 const label ptIndex = oldToNewMesh[f[fpI]];
685 if (isErrorPoint[ptIndex])
694 sumFaceFilterFactors += faceFilterFactor_[eFace];
705 faceFilterFactor_[facei] =
min 707 faceFilterFactor_[facei],
708 sumFaceFilterFactors/nFaces
718 void Foam::polyMeshFilter::updatePointPriorities
725 const labelList& currPointPriority = pointPriority_();
727 forAll(newPointPriority, ptI)
729 const label newPointToOldPoint = pointMap[ptI];
730 const label origPointPriority = currPointPriority[newPointToOldPoint];
732 newPointPriority[ptI] =
max(origPointPriority, newPointPriority[ptI]);
743 pointPriority_.reset(
new labelList(newPointPriority));
747 void Foam::polyMeshFilter::printScalarFieldStats
754 scalar validElements = 0;
760 const scalar fldElement = fld[i];
766 if (fldElement < min)
771 if (fldElement > max)
788 <<
" av = " << sum/(validElements + SMALL)
789 <<
" max = " << max <<
nl 791 <<
" " << validElements <<
" / " << totFieldSize <<
" elements used" 796 void Foam::polyMeshFilter::mapOldMeshEdgeFieldToNewMesh
807 forAll(newEdges, newEdgeI)
809 const edge& newEdge = newEdges[newEdgeI];
815 newMeshMinEdgeLen[pointMap[pStart]],
816 newMeshMinEdgeLen[pointMap[pEnd]]
832 void Foam::polyMeshFilter::mapOldMeshFaceFieldToNewMesh
843 const label oldFacei = faceMap[newFacei];
845 tmp[newFacei] = newMeshFaceFilterFactor[oldFacei];
853 newMeshFaceFilterFactor,
859 void Foam::polyMeshFilter::updateOldToNewPointMap
865 forAll(origToCurrentPointMap, origPointi)
867 label oldPointi = origToCurrentPointMap[origPointi];
875 origToCurrentPointMap[origPointi] =
newPointi;
877 else if (newPointi == -1)
879 origToCurrentPointMap[origPointi] = -1;
883 origToCurrentPointMap[origPointi] = -newPointi-2;
892 Foam::polyMeshFilter::polyMeshFilter(
const fvMesh& mesh)
919 Foam::polyMeshFilter::polyMeshFilter
941 originalPointPriority_(pointPriority),
949 Foam::polyMeshFilter::polyMeshFilter
959 originalPointPriority_(pointPriority),
981 return filterFacesLoop(nOriginalBadFaces);
990 forAll(faceFilterFactor_, fI)
994 faceFilterFactor_[fI] = -1;
998 return filterFacesLoop(0);
1004 const label nOriginalBadFaces
1009 label nOuterIterations = 0;
1012 faceFilterFactor_.
resize(0);
1025 && nBadFaces > nOriginalBadFaces
1026 && nBadFaces < nPreviousBadFaces
1029 Info<<
nl <<
"Outer Iteration = " << nOuterIterations++ <<
nl 1032 printScalarFieldStats(
"Edge Filter Factor", minEdgeLen_);
1034 nPreviousBadFaces = nBadFaces;
1038 fvMesh& newMesh = newMeshPtr_();
1041 pointPriority_.reset(
new labelList(originalPointPriority_));
1047 label nInnerIterations = 0;
1053 <<
indent <<
"Inner iteration = " << nInnerIterations++ <<
nl 1054 << incrIndent <<
endl;
1056 label nLocalCollapse = filterEdges
1060 origToCurrentPointMap
1067 nLocalCollapse >= nPrevLocalCollapse
1068 || nLocalCollapse == 0
1076 nPrevLocalCollapse = nLocalCollapse;
1095 Info<<
nl <<
" Number of bad faces : " << nBadFaces <<
nl 1096 <<
" Number of marked points : " 1100 updatePointErrorCount
1103 origToCurrentPointMap,
1107 checkMeshEdgesAndRelaxEdges
1110 origToCurrentPointMap,
1134 return pointPriority_;
unsigned int count() const
Count number of bits set, O(log(n))
label end() const
Return end vertex label.
virtual tmp< scalarField > movePoints(const pointField &)
Move points, returns volumes swept by faces in motion.
#define forAll(list, i)
Loop across all elements in list.
label filter(const label nOriginalBadFaces)
Filter edges and faces.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Ostream & indent(Ostream &os)
Indent stream.
A face is a list of labels corresponding to mesh vertices.
const double e
Elementary charge.
A list of keyword definitions, which are a keyword followed by any number of values (e...
dimensioned< Type > max(const dimensioned< Type > &, const dimensioned< Type > &)
autoPtr< mapPolyMesh > makeMesh(autoPtr< fvMesh > &newMesh, const IOobject &io, const polyMesh &mesh, const bool syncParallel=true, const bool orderCells=false, const bool orderPoints=false)
Create new mesh with old mesh patches.
Unit conversion functions.
const edgeList & edges() const
Return mesh edges. Uses calcEdges.
void size(const label)
Override size to be inconsistent with allocated storage.
const autoPtr< labelList > & pointPriority() const
Return the new pointPriority list.
const Type & second() const
Return second.
polyMeshFilterSettings(const dictionary &dict)
Construct from dictionary.
Ostream & endl(Ostream &os)
Add newline and flush stream.
bool hasMotionPoints() const
Has valid preMotionPoints?
Does polyTopoChanges to remove edges. Can remove faces due to edge collapse but can not remove cells ...
const labelList & pointMap() const
Old point map.
label collapseEdge(triSurface &surf, const scalar minLen)
Keep collapsing all edges < minLen.
labelList identity(const label len)
Create identity map (map[i] == i) of given length.
const Type & first() const
Return first.
const Switch & controlMeshQuality() const
void resize(const label)
Alias for setSize(const label)
const autoPtr< fvMesh > & filteredMesh() const
Return reference to the filtered mesh. Does not check if the.
static autoPtr< fvMesh > copyMesh(const fvMesh &mesh)
Return a copy of an fvMesh.
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
dimensioned< Type > sum(const DimensionedField< Type, GeoMesh > &df)
IOdictionary is derived from dictionary and IOobject to give the dictionary automatic IO functionalit...
Calculates a unique integer (label so might not have enough room - 2G max) for processor + local inde...
An ordered pair of two objects of type <T> with first() and second() elements.
void writeSettings(Ostream &os) const
Write the settings to a stream.
const dictionary & meshQualityCoeffDict() const
An edge is a list of two point labels. The functionality it provides supports the discretisation on a...
virtual void updateMesh(const mapPolyMesh &mpm)
Update the mesh corresponding to given map.
const scalar & initialFaceLengthFactor() const
static const label labelMax
List< label > labelList
A List of labels.
bool found(const Key &) const
Return true if hashedEntry is found in table.
label start() const
Return start vertex label.
static label checkMeshQuality(const polyMesh &mesh, const dictionary &meshQualityDict, PackedBoolList &isErrorPoint)
Check mesh and mark points on faces in error.
const scalar & minLen() const
defineTypeNameAndDebug(combustionModel, 0)
Ostream & decrIndent(Ostream &os)
Decrement the indent level.
~polyMeshFilter()
Destructor.
dimensioned< Type > min(const dimensioned< Type > &, const dimensioned< Type > &)
void reduce(const List< UPstream::commsStruct > &comms, T &Value, const BinaryOp &bop, const int tag, const label comm)
Calculates points shared by more than two processor patches or cyclic patches.
Mesh data needed to do the Finite Volume discretisation.
Direct mesh changes based on v1.3 polyTopoChange syntax.
const label & maxIterations() const
const labelList & faceMap() const
Old face map.
const pointField & preMotionPoints() const
Pre-motion point positions.
T returnReduce(const T &Value, const BinaryOp &bop, const int tag=Pstream::msgType(), const label comm=UPstream::worldComm)
Mesh consisting of general polyhedral cells.
const word & system() const
Return system name.
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.
Class to store the settings for the polyMeshFilter class.
A class for managing temporary objects.
Ostream & incrIndent(Ostream &os)
Increment the indent level.
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
void transfer(List< T > &)
Transfer the contents of the argument List into this list.
const word & name() const
Return reference to name.
static const label labelMin
const Time & time() const
Return the top-level database.
int system(const std::string &command)
Execute the specified command.
const labelList & reversePointMap() const
Reverse point map.
A HashTable to objects of type <T> with a label key.