Go to the documentation of this file.
58 const label maxNumGlobalIterations,
59 const label maxNumIterations,
60 const label maxNumSurfaceIterations,
61 const bool relaxedCheck
64 Info <<
"Starting untangling the mesh" <<
endl;
70 Info <<
"Tet " << tetI <<
" is inverted!" <<
endl;
76 Info <<
"Point " << pI <<
" cannot be moved!" <<
endl;
83 if( tets[pTets(pointI, i)].whichPosition(pointI) < 0 )
92 if( neighbour[faceI] == -1 )
97 boundaryVertex[
f[pI]] =
true;
100 forAll(boundaryVertex, pI)
105 "void meshOptimizer::untangleMeshFV()"
110 label nBadFaces, nGlobalIter(0), nIter;
118 forAll(vertexLocation_, pointI)
120 if( vertexLocation_[pointI] & LOCKED )
121 lockedPoints.
append(pointI);
130 label minNumBadFaces(10 * faces.
size()), minIter(-1);
156 Info <<
"Iteration " << nIter
157 <<
". Number of bad faces is " << nBadFaces <<
endl;
163 if( nBadFaces < minNumBadFaces )
165 minNumBadFaces = nBadFaces;
175 (nGlobalIter / 2) + 1
191 }
while( (nIter < minIter+5) && (++nIter < maxNumIterations) );
193 if( (nBadFaces == 0) || (++nGlobalIter >= maxNumGlobalIterations) )
199 while( nIter++ < maxNumSurfaceIterations )
224 Info <<
"Iteration " << nIter
225 <<
". Number of bad faces is " << nBadFaces <<
endl;
232 else if( enforceConstraints_ )
234 const label subsetId =
235 mesh_.addPointSubset(badPointsSubsetName_);
239 const face&
f = faces[it.key()];
241 mesh_.addPointToSubset(subsetId,
f[pI]);
246 "void meshOptimizer::untangleMeshFV()"
247 ) <<
"Writing mesh with " << badPointsSubsetName_
248 <<
" subset. These points cannot be untangled"
249 <<
" without sacrificing geometry constraints. Exitting.."
253 throw std::logic_error
255 "void meshOptimizer::untangleMeshFV()"
256 "Cannot untangle mesh!!"
261 partTetMesh tetMesh(mesh_, lockedPoints, badFaces, 0);
266 if( nGlobalIter < 2 )
271 else if( nGlobalIter < 5 )
286 }
while( nBadFaces );
290 label subsetId = mesh_.faceSubsetIndex(
"badFaces");
292 mesh_.removeFaceSubset(subsetId);
293 subsetId = mesh_.addFaceSubset(
"badFaces");
296 mesh_.addFaceToSubset(subsetId, it.key());
299 Info <<
"Finished untangling the mesh" <<
endl;
309 bool smoothLayer(
false);
311 if( meshDict.
found(
"boundaryLayers") )
315 if( layersDict.
found(
"optimiseLayer") )
337 Info <<
"Starting optimising boundary layer" <<
endl;
360 bndLayerCells.
append(faceOwner[bfI]);
401 Info <<
"Finished optimising boundary layer" <<
endl;
407 bool untangleLayer(
true);
413 if( meshDict.
found(
"boundaryLayers") )
417 if( layersDict.
found(
"untangleLayers") )
430 const label nInvalidFaces =
433 if( nInvalidFaces != 0 )
438 const label badBlCellsId =
445 if( neighbour[it.key()] < 0 )
453 throw std::logic_error
455 "void meshOptimizer::untangleBoundaryLayer()"
456 "Found invalid faces in the boundary layer."
457 " Cannot untangle mesh!!"
471 label nBadFaces, nIter(0);
481 lockedPoints.
append(pointI);
498 changedFace[it.key()] =
true;
500 Info <<
"Iteration " << nIter
501 <<
". Number of bad faces is " << nBadFaces <<
endl;
518 }
while( ++nIter < maxNumIterations );
523 const label maxNumIterations,
524 const label numLayersOfCells
534 forAll(vertexLocation_, pointI)
536 if( vertexLocation_[pointI] & LOCKED )
537 lockedPoints.
append(pointI);
540 partTetMesh tetMesh(mesh_, lockedPoints, numLayersOfCells);
551 }
while( ++nIter < maxNumIterations );
558 const label numLaplaceIterations,
559 const label maxNumGlobalIterations,
560 const label maxNumIterations,
561 const label maxNumSurfaceIterations
564 Info <<
"Starting smoothing the mesh" <<
endl;
571 maxNumGlobalIterations,
573 maxNumSurfaceIterations
576 Info <<
"Finished smoothing the mesh" <<
endl;
581 const label maxNumIterations,
582 const scalar threshold
585 label nBadFaces, nIter(0);
593 forAll(vertexLocation_, pointI)
595 if( vertexLocation_[pointI] & LOCKED )
596 lockedPoints.
append(pointI);
615 changedFace[it.key()] =
true;
617 Info <<
"Iteration " << nIter
618 <<
". Number of worst quality faces is " << nBadFaces <<
endl;
624 if( nBadFaces < minNumBadFaces )
626 minNumBadFaces = nBadFaces;
632 partTetMesh tetMesh(mesh_, lockedPoints, lowQualityFaces, 2);
643 }
while( (nIter < minIter+5) && (++nIter < maxNumIterations) );
void optimizeMeshFV(const label numLaplaceIterations=5, const label maxNumGlobalIterations=10, const label maxNumIterations=50, const label maxNumSurfaceIterations=2)
final optimisation
const labelList & neighbour() const
IOdictionary is derived from dictionary and IOobject to give the dictionary automatic IO functionalit...
const labelList & owner() const
owner and neighbour cells for faces
void optimiseUsingKnuppMetric(const label nInterations=5)
untangle mesh by using Patrik Knupp's simple metric
void refineLayers()
performs refinement based on the given settings
void lockCells(const labelListType &)
lock the cells which shall not be modified
void append(const T &e)
Append an element at the end of the list.
label findBadFaces(const polyMeshGen &, labelHashSet &badFaces, const bool report=false, const boolList *activeFacePtr=NULL)
void optimizeLowQualityFaces(const label maxNumIterations=10)
void optimizeMeshNearBoundaries(const label maxNumIterations=10, const label numLayersOfCells=2)
T returnReduce(const T &Value, const BinaryOp &bop, const int tag=Pstream::msgType(), const label comm=UPstream::worldComm)
void createPolyMesh(polyMeshGen &pmg) const
creates polyMeshGen from this partTetMesh
#define forAll(list, i)
Loop across all elements in list.
void optimiseBoundaryVolumeOptimizer(const label nIterations=3, const bool nonShrinking=false)
smooth boundary using the volume optimizer
void untangleBoundaryLayer()
Template functions to aid in the implementation of demand driven data.
List< direction > vertexLocation_
location of vertex (internal, boundary, edge, corner)
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.
Ostream & endl(Ostream &os)
Add newline and flush stream.
const pointFieldPMG & points() const
access to points
void optimiseUsingMeshUntangler(const label nIerations=5)
smooth using mesh untangler
void activateSpecialMode()
dimensioned< scalar > mag(const dimensioned< Type > &)
const VRWGraph & pointTets() const
const faceListPMG & faces() const
access to faces
forAllConstIter(PtrDictionary< phaseModel >, mixture.phases(), phase)
Ostream & flush(Ostream &os)
Flush stream.
void addCellToSubset(const label, const label)
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
bool found(const word &, bool recursive=false, bool patternMatch=true) const
Search dictionary for given keyword.
Pre-declare SubField and related Field type.
void optimizeLaplacianPC(const label nIterations=1)
void optimiseBoundarySurfaceLaplace(const label nIterations=3)
smooth boundary using shrinking surface laplace
void clearAddressingData() const
clear addressing data
label addCellSubset(const word &)
void updateOrigMesh(boolList *changedFacePtr=NULL)
updates the vertices of the original polyMeshGen
const LongList< partTet > & tets() const
label findBadFacesRelaxed(const polyMeshGen &, labelHashSet &badFaces, const bool report=false, const boolList *activeFacePtr=NULL)
#define forAllRow(graph, rowI, index)
const boolList & isBaseFace() const
label size() const
return the number of used elements
void removeUnusedVertices()
remove unused vertices
void optimiseLayer()
performs boundary layer optimisation
label findLowQualityFaces(const polyMeshGen &mesh, labelHashSet &badFaces, const bool report=false, const boolList *activeFacePtr=NULL)
A list of keyword definitions, which are a keyword followed by any number of values (e....
label size() const
Return number of elements in table.
errorManip< error > abort(error &err)
polyMeshGen & mesh_
reference to the mesh
const Time & returnTime() const
access to Time
bool checkFacePyramids(const polyMeshGen &, const bool report=false, const scalar minPyrVol=-SMALL, labelHashSet *setPtr=NULL, const boolList *changedFacePtr=NULL)
Check face pyramid volume.
bool foundObject(const word &name) const
Is the named Type found?
void untangleMeshFV(const label maxNumGlobalIterations=10, const label maxNumIterations=50, const label maxNumSurfaceIterations=2, const bool relaxedCheck=false)
label size() const
return the number of used elements
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
void calculatePointLocations()
mark point locations
void optimizeBoundaryLayer(const bool addBufferLayer=true)
static void readSettings(const dictionary &, boundaryLayerOptimisation &)
read the settings from dictionary
void optimiseUsingVolumeOptimizer(const label nIterations=10)
smooth using volume optimizer
#define FatalErrorIn(functionName)
Report an error message using Foam::FatalError.
A face is a list of labels corresponding to mesh vertices.
#define WarningIn(functionName)
Report a warning using Foam::Warning.
const Type & lookupObject(const word &name) const
Lookup and return the object of the given Type.
const LongList< point > & points() const
access to points, tets and other data
static void readSettings(const dictionary &, refineBoundaryLayers &)
read the settings from dictionary
const meshSurfaceEngine & meshSurface() const
return mesh surface
const dictionary & subDict(const word &) const
Find and return a sub-dictionary.
void removeUserConstraints()
reset to default constraints
const LongList< direction > & smoothVertex() const
label findWorstQualityFaces(const polyMeshGen &mesh, labelHashSet &badFaces, const bool report=false, const boolList *activeFacePtr=NULL, const scalar relativeThreshold=0.1)
checks the mesh and selects the faces with worst quality
void optimizeMeshFVBestQuality(const label maxNumIterations=50, const scalar threshold=0.1)
greedy optimisation until the mesh can be improved
const labelList & faceOwners() const