Go to the documentation of this file.
49 updateSets<pointSet>(map);
50 updateSets<faceSet>(map);
51 updateSets<cellSet>(map);
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());
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;
162 label nLocalCollapse = filterFaces
165 newMeshFaceFilterFactor,
166 origToCurrentPointMap
172 nLocalCollapse >= nPrevLocalCollapse
173 || nLocalCollapse == 0
181 nPrevLocalCollapse = nLocalCollapse;
189 label nInnerIterations = 0;
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])
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 <<
")"
351 collapsePointToLocation,
360 <<
" edges after synchronisation and PointEdgeWave" <<
endl;
362 if (nLocalCollapse == 0)
392 updatePointPriorities(newMesh, newMap.
pointMap());
394 mapOldMeshFaceFieldToNewMesh
398 newMeshFaceFilterFactor
401 updateOldToNewPointMap
404 origToCurrentPointMap
408 return nLocalCollapse;
435 collapsePointToLocation
439 Info<<
indent <<
"Collapsing " << nSmallCollapsed
440 <<
" small edges" <<
endl;
448 collapsePointToLocation
452 Info<<
indent <<
"Collapsing " << nMerged <<
" in line edges"
455 if (nMerged + nSmallCollapsed == 0)
469 collapsePointToLocation,
478 <<
" edges after synchronisation and PointEdgeWave" <<
endl;
480 if (nLocalCollapse == 0)
510 mapOldMeshEdgeFieldToNewMesh
517 updateOldToNewPointMap
520 origToCurrentPointMap
523 updatePointPriorities(newMesh, newMap.
pointMap());
525 return nLocalCollapse;
536 forAll(mesh_.points(), pI)
538 if (isErrorPoint[oldToNewMesh[pI]])
540 pointErrorCount[pI]++;
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
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
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));
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"
807 forAll(newEdges, newEdgeI)
809 const edge& newEdge = newEdges[newEdgeI];
815 newMeshMinEdgeLen[pointMap[pStart]],
816 newMeshMinEdgeLen[pointMap[pEnd]]
820 newMeshMinEdgeLen.transfer(
tmp);
845 tmp[newFaceI] = newMeshFaceFilterFactor[oldFaceI];
848 newMeshFaceFilterFactor.transfer(
tmp);
853 newMeshFaceFilterFactor,
865 forAll(origToCurrentPointMap, origPointI)
867 label oldPointI = origToCurrentPointMap[origPointI];
871 label newPointI = currToNew[oldPointI];
875 origToCurrentPointMap[origPointI] = newPointI;
877 else if (newPointI == -1)
879 origToCurrentPointMap[origPointI] = -1;
883 origToCurrentPointMap[origPointI] = -newPointI-2;
941 originalPointPriority_(pointPriority),
960 minEdgeLen_.resize(mesh_.nEdges(), minLen());
961 faceFilterFactor_.resize(mesh_.nFaces(), initialFaceLengthFactor());
963 return filterFacesLoop(nOriginalBadFaces);
969 minEdgeLen_.resize(mesh_.nEdges(), minLen());
970 faceFilterFactor_.resize(mesh_.nFaces(), initialFaceLengthFactor());
972 forAll(faceFilterFactor_, fI)
976 faceFilterFactor_[fI] = -1;
980 return filterFacesLoop(0);
986 const label nOriginalBadFaces
991 label nOuterIterations = 0;
993 minEdgeLen_.resize(mesh_.nEdges(), minLen());
994 faceFilterFactor_.resize(0);
996 labelList pointErrorCount(mesh_.nPoints(), 0);
1006 nOuterIterations < maxIterations()
1007 && nBadFaces > nOriginalBadFaces
1008 && nBadFaces < nPreviousBadFaces
1011 Info<<
nl <<
"Outer Iteration = " << nOuterIterations++ <<
nl
1014 printScalarFieldStats(
"Edge Filter Factor", minEdgeLen_);
1016 nPreviousBadFaces = nBadFaces;
1019 newMeshPtr_ = copyMesh(mesh_);
1020 fvMesh& newMesh = newMeshPtr_();
1023 pointPriority_.reset(
new labelList(originalPointPriority_));
1029 label nInnerIterations = 0;
1035 <<
indent <<
"Inner iteration = " << nInnerIterations++ <<
nl
1038 label nLocalCollapse = filterEdges
1042 origToCurrentPointMap
1049 nLocalCollapse >= nPrevLocalCollapse
1050 || nLocalCollapse == 0
1058 nPrevLocalCollapse = nLocalCollapse;
1067 if (controlMeshQuality())
1073 meshQualityCoeffDict(),
1077 Info<<
nl <<
" Number of bad faces : " << nBadFaces <<
nl
1078 <<
" Number of marked points : "
1082 updatePointErrorCount
1085 origToCurrentPointMap,
1089 checkMeshEdgesAndRelaxEdges
1092 origToCurrentPointMap,
1116 return pointPriority_;
void checkMeshFacesAndRelaxEdges(const polyMesh &newMesh, const labelList &oldToNewMesh, const PackedBoolList &isErrorPoint, const labelList &pointErrorCount)
Given the new points that are part of bad faces, and a map from the.
IOdictionary is derived from dictionary and IOobject to give the dictionary automatic IO functionalit...
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Calculates points shared by more than two processor patches or cyclic patches.
Pair< int > faceMap(const label facePi, const face &faceP, const label faceNi, const face &faceN)
void writeSettings(Ostream &os) const
Write the settings to a stream.
label markMergeEdges(const scalar maxCos, const labelList &pointPriority, PackedBoolList &collapseEdge, Map< point > &collapsePointToLocation) const
Mark (in collapseEdge) any edges to merge.
List< label > labelList
A List of labels.
T returnReduce(const T &Value, const BinaryOp &bop, const int tag=Pstream::msgType(), const label comm=UPstream::worldComm)
void checkMeshEdgesAndRelaxEdges(const polyMesh &newMesh, const labelList &oldToNewMesh, const PackedBoolList &isErrorPoint, const labelList &pointErrorCount)
Given the new points that are part of bad faces, and a map from the.
#define forAll(list, i)
Loop across all elements in list.
A class for managing temporary objects.
void updateOldToNewPointMap(const labelList &currToNew, labelList &origToCurrentPointMap) const
Maintain a map of the original mesh points to the latest version of.
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 tmp< scalarField > movePoints(const pointField &)
Move points, returns volumes swept by faces in motion.
static const label labelMax
Direct mesh changes based on v1.3 polyTopoChange syntax.
An edge is a list of two point labels. The functionality it provides supports the discretisation on a...
const Type & first() const
Return first.
A HashTable to objects of type <T> with a label key.
Unit conversion functions.
void mapOldMeshFaceFieldToNewMesh(const polyMesh &newMesh, const labelList &faceMap, scalarField &newMeshFaceFilterFactor) const
Update faceFilterFactor_ for the new mesh based upon the movement.
Ostream & endl(Ostream &os)
Add newline and flush stream.
const pointField & preMotionPoints() const
Pre-motion point positions.
~polyMeshFilter()
Destructor.
const edgeList & edges() const
Return mesh edges. Uses calcEdges.
label markSmallEdges(const scalarField &minEdgeLen, const labelList &pointPriority, PackedBoolList &collapseEdge, Map< point > &collapsePointToLocation) const
Mark (in collapseEdge) any edges to collapse.
Ostream & incrIndent(Ostream &os)
Increment the indent level.
Mesh consisting of general polyhedral cells.
label filterFacesLoop(const label nOriginalBadFaces)
Does polyTopoChanges to remove edges. Can remove faces due to edge collapse but can not remove cells ...
label end() const
Return end vertex label.
label filterEdges(polyMesh &newMesh, scalarField &newMeshMinEdgeLen, labelList &origToCurrentPointMap)
void reduce(const List< UPstream::commsStruct > &comms, T &Value, const BinaryOp &bop, const int tag, const label comm)
static const label labelMin
void printScalarFieldStats(const string desc, const scalarField &fld) const
Print min/mean/max data for a field.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
polyMeshFilter(const polyMeshFilter &)
Disallow default bitwise copy construct.
Pre-declare SubField and related Field type.
void updatePointErrorCount(const PackedBoolList &isErrorPoint, const labelList &oldToNewMesh, labelList &pointErrorCount) const
Increment pointErrorCount for points attached to a bad face.
const word & system() const
Return system name.
const autoPtr< fvMesh > & filteredMesh() const
Return reference to the filtered mesh. Does not check if the.
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.
virtual void updateMesh(const mapPolyMesh &mpm)
Update the mesh corresponding to given map.
label filter(const label nOriginalBadFaces)
Filter edges and faces.
static void updateSets(const mapPolyMesh &map)
const Type & second() const
Return second.
unsigned int count() const
Count number of bits set, O(log(n))
void consistentCollapse(const globalIndex &globalPoints, const labelList &pointPriority, const Map< point > &collapsePointToLocation, PackedBoolList &collapseEdge, List< pointEdgeCollapse > &allPointInfo, const bool allowCellCollapse=false) const
Ensure that the collapse is parallel consistent and update.
labelList identity(const label len)
Create identity map (map[i] == i) of given length.
labelPair markSmallSliverFaces(const scalarField &faceFilterFactor, const labelList &pointPriority, PackedBoolList &collapseEdge, Map< point > &collapsePointToLocation) const
Find small faces and sliver faces in the mesh and mark the.
Class to store the settings for the polyMeshFilter class.
gmvFile<< "tracers "<< particles.size()<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().x()<< ' ';}gmvFile<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().y()<< ' ';}gmvFile<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().z()<< ' ';}gmvFile<< nl;forAll(lagrangianScalarNames, i){ const word &name=lagrangianScalarNames[i];IOField< scalar > fld(IOobject(name, runTime.timeName(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
bool found(const Key &) const
Return true if hashedEntry is found in table.
Mesh data needed to do the Finite Volume discretisation.
bool setRefinement(const List< pointEdgeCollapse > &allPointInfo, polyTopoChange &meshMod) const
Play commands into polyTopoChange to create mesh.
const autoPtr< labelList > & pointPriority() const
Return the new pointPriority list.
Ostream & decrIndent(Ostream &os)
Decrement the indent level.
Calculates a unique integer (label so might not have enough room - 2G max) for processor + local inde...
const double e
Elementary charge.
Ostream & indent(Ostream &os)
Indent stream.
void mapOldMeshEdgeFieldToNewMesh(const polyMesh &newMesh, const labelList &pointMap, scalarField &newMeshMinEdgeLen) const
Update minEdgeLen_ for the new mesh based upon the movement of the.
dimensioned< Type > max(const dimensioned< Type > &, const dimensioned< Type > &)
label start() const
Return start vertex label.
An ordered pair of two objects of type <T> with first() and second() elements.
const labelList & reversePointMap() const
Reverse point map.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
const labelList & pointMap() const
Old point map.
dimensioned< Type > sum(const DimensionedField< Type, GeoMesh > &df)
static void copySets(const polyMesh &oldMesh, const polyMesh &newMesh)
const labelList & faceMap() const
Old face map.
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
bool hasMotionPoints() const
Has valid preMotionPoints?
static label checkMeshQuality(const polyMesh &mesh, const dictionary &meshQualityDict, PackedBoolList &isErrorPoint)
Check mesh and mark points on faces in error.
const Time & time() const
Return the top-level database.
static autoPtr< fvMesh > copyMesh(const fvMesh &mesh)
Return a copy of an fvMesh.
void updatePointPriorities(const polyMesh &newMesh, const labelList &pointMap)
A face is a list of labels corresponding to mesh vertices.
label collapseEdge(triSurface &surf, const scalar minLen)
Keep collapsing all edges < minLen.
defineTypeNameAndDebug(combustionModel, 0)
dimensioned< Type > min(const dimensioned< Type > &, const dimensioned< Type > &)
int system(const std::string &command)
Execute the specified command.
const word & name() const
Return reference to name.
label filterFaces(polyMesh &newMesh, scalarField &newMeshFaceFilterFactor, labelList &origToCurrentPointMap)