Go to the documentation of this file.
47 #ifndef meshRefinement_H
48 #define meshRefinement_H
71 class mapDistributePolyMesh;
72 class decompositionMethod;
73 class refinementSurfaces;
74 class refinementFeatures;
77 class fvMeshDistribute;
79 class localPointRegion;
160 const scalar mergeDistance_;
163 const bool overwrite_;
166 const word oldInstance_;
217 template<
class GeoField>
218 static void addPatchFields(
fvMesh&,
const word& patchFieldType);
221 template<
class GeoField>
237 void calcCellCellRays
256 const label exposedPatchi
265 static bool markForRefine
267 const label markValue,
268 const label nAllowRefine,
275 void markFeatureCellLevel
283 label markFeatureRefinement
286 const label nAllowRefine,
293 label markInternalDistanceToFeatureRefinement
295 const label nAllowRefine,
301 label markInternalRefinement
303 const label nAllowRefine,
310 label unmarkInternalRefinement
324 label markSurfaceRefinement
326 const label nAllowRefine,
335 void collectGapCandidates
348 const scalar planarCos,
361 const label nAllowRefine,
372 label markSurfaceGapRefinement
374 const scalar planarCos,
375 const label nAllowRefine,
386 const point& nearPoint,
401 const bool useSurfaceNormal,
403 const point& nearPoint,
422 void selectGapCandidates
446 label markInternalGapRefinement
448 const scalar planarCos,
449 const bool spreadGapSize,
450 const label nAllowRefine,
458 label markSmallFeatureRefinement
460 const scalar planarCos,
461 const label nAllowRefine,
474 const scalar tol = 1
e-6
480 label markSurfaceCurvatureRefinement
482 const scalar curvature,
483 const label nAllowRefine,
493 const scalar planarCos,
494 const label nAllowRefine,
496 const label surfaceLevel,
498 const vector& surfaceNormal,
511 label markProximityRefinement
513 const scalar curvature,
519 const label nAllowRefine,
527 void markMultiRegionCell
538 void detectMultiRegionCells
555 label markProximityRefinementWave
557 const scalar planarCos,
559 const label nAllowRefine,
573 const bool allowBoundary,
580 void getIntersections
593 void getIntersections
604 void getBafflePatches
606 const label nErodeCellZones,
619 const label nBufferLayers,
633 const label ownPatch,
634 const label neiPatch,
642 void markBoundaryFace
669 const scalar minFaceArea,
670 const scalar maxNonOrtho,
677 const scalar volFraction,
687 const bool removeEdgeConnectedCells,
703 const label defaultRegion
708 labelList markFacesOnProblemCellsGeometric
724 const scalar freeStandingAngle
734 void findCellZoneGeometric
745 void findCellZoneInsideWalk
755 void findCellZoneInsideWalk
764 bool calcRegionToZone
766 const label backgroundZoneID,
767 const label surfZoneI,
768 const label ownRegion,
769 const label neiRegion,
778 void findCellZoneTopo
780 const label backgroundZoneID,
792 const label nErodeCellZones,
793 const label backgroundZoneID,
803 const label nGrowCellZones,
804 const label backgroundZoneID,
813 void makeConsistentFaceIndex
823 const bool allowFreeStandingZoneFaces,
824 const label nErodeCellZones,
825 const label backgroundZoneID,
839 const bitSet& isMasterFace,
843 const bitSet& meshFlipMap,
848 void allocateInterRegionFaceZone
857 void handleSnapProblems
860 const bool useTopologicalSnapDetection,
861 const bool removeEdgeConnectedCells,
883 void calcPatchNumMasterFaces
885 const bitSet& isMasterFace,
900 void consistentOrientation
902 const bitSet& isMasterFace,
956 return mergeDistance_;
1010 return faceToCoupledPatch_;
1019 return userFaceData_;
1024 return userFaceData_;
1039 const bool keepZoneFaces,
1040 const bool keepBaffles,
1078 const bitSet& isMasterEdge,
1087 template<
class Type>
1091 const bitSet& isMasterEdge,
1115 const scalar planarCos,
1128 const scalar curvature,
1129 const scalar planarAngle,
1131 const bool featureRefinement,
1132 const bool featureDistanceRefinement,
1133 const bool internalRefinement,
1134 const bool surfaceRefinement,
1135 const bool curvatureRefinement,
1136 const bool smallFeatureRefinement,
1137 const bool gapRefinement,
1138 const bool bigGapRefinement,
1139 const bool spreadGapSize,
1140 const label maxGlobalCells,
1141 const label maxLocalCells
1160 const bitSet& isOutsideFace,
1168 const bitSet& isOutsideFace,
1176 const scalar planarAngle,
1179 const label growIter
1192 const scalar maxLoadUnbalance
1202 const scalar maxLoadUnbalance
1208 const label maxGlobalCells,
1209 const label maxLocalCells,
1228 const bool handleSnapProblems,
1232 const bool useTopologicalSnapDetection,
1233 const bool removeEdgeConnectedCells,
1235 const label nErodeCellZones,
1250 const bool useTopologicalSnapDetection,
1251 const bool removeEdgeConnectedCells,
1253 const scalar planarAngle,
1267 const label nBufferLayers,
1268 const label nErodeCellZones,
1281 const label nBufferLayers,
1282 const label nErodeCellZones,
1360 const bool doInternalZones,
1361 const bool doBaffleZones
1371 const bool allowFreeStandingZoneFaces,
1372 const label nErodeCellZones,
1385 const label insertPatchi,
1405 const word& masterPatch,
1406 const word& slavePatch,
1415 label& masterPatchID,
1416 label& slavePatchID,
1431 const vector& perturbVec,
1440 const vector& perturbVec,
1443 const bool exitIfLeakPath,
1445 const label nRegions,
1458 const bool exitIfLeakPath,
1540 const scalar minCos,
1541 const scalar concaveCos,
1542 const label mergeSize,
1551 const scalar minCos,
1552 const scalar concaveCos,
1593 const scalar minCos,
1685 const bitSet& isMasterElem,
1699 template<
class EnumContainer>
1702 const EnumContainer& namedEnum,
1707 template<
class Type>
1711 const word& keyword,
1714 const Type& deflt =
Zero
1721 const word& keyword,
1730 const word& keyword,
const shellSurfaces & shells() const
Reference to refinement shells (regions)
autoPtr< mapPolyMesh > mergePoints(const labelList &pointToDuplicate)
Merge duplicate points.
autoPtr< mapPolyMesh > removeGapCells(const scalar planarAngle, const labelList &minSurfaceLevel, const labelList &globalToMasterPatch, const label growIter)
Detect gapRefinement cells and remove them.
const List< Tuple2< mapType, labelList > > & userFaceData() const
Additional face data that is maintained across.
label mergePatchFacesUndo(const scalar minCos, const scalar concaveCos, const labelList &patchIDs, const dictionary &motionDict, const labelList &preserveFaces, const meshRefinement::FaceMergeType mergeType)
Merge coplanar faces. preserveFaces is != -1 for faces.
static Type get(const dictionary &dict, const word &keyword, const bool noExit, enum keyType::option matchOpt=keyType::REGEX, const Type &deflt=Zero)
Wrapper around dictionary::get which does not exit.
List< Tuple2< mapType, labelList > > & userFaceData()
static void weightedSum(const polyMesh &mesh, const bitSet &isMasterEdge, const labelList &meshPoints, const edgeList &edges, const scalarField &edgeWeights, const Field< Type > &data, Field< Type > &sum)
Helper: weighted sum (over all subset of mesh points) by.
labelList growFaceCellFace(const labelUList &set) const
Takes mesh with 'baffles' (= boundary faces sharing points). Determines for selected points on bounda...
void set(List< bool > &bools, const labelRange &range)
Set the specified range 'on' in a boolList.
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
static T gAverage(const bitSet &isMasterElem, const UList< T > &values)
Helper: calculate average.
faceZoneType
What to do with faceZone faces.
void dumpIntersections(const fileName &prefix) const
Debug: Write intersection information to OBJ format.
autoPtr< mapPolyMesh > createBaffles(const labelList &ownPatch, const labelList &neiPatch)
Create baffle for every internal face where ownPatch != -1.
bool isNormalGap(const scalar planarCos, const label level0, const vector &point0, const vector &normal0, const label level1, const vector &point1, const vector &normal1) const
Is local topology a small gap normal to the test vector.
A class for handling words, derived from Foam::string.
A class for handling file names.
A bitSet stores bits (elements with only two states) in packed internal format and supports a variety...
autoPtr< mapPolyMesh > splitMeshRegions(const labelList &globalToMasterPatch, const labelList &globalToSlavePatch, const pointField &locationsInMesh, const pointField &locationsOutsideMesh, const bool exitIfLeakPath, const writer< scalar > &leakPathFormatter)
Split mesh. Keep part containing point. Return empty map if.
static label findRegion(const polyMesh &, const labelList &cellRegion, const vector &perturbVec, const point &p)
Find region point is in. Uses optional perturbation to re-test.
Removes selected points from mesh and updates faces using these points.
A class for managing temporary objects.
labelList intersectedPoints() const
Get points on surfaces with intersection and boundary faces.
static ITstream & lookup(const dictionary &dict, const word &keyword, const bool noExit, enum keyType::option matchOpt=keyType::REGEX)
Wrapper around dictionary::lookup which does not exit.
static constexpr const zero Zero
Global zero (0)
Given list of cells to remove, insert all the topology changes.
List< T > values(const HashTable< T, Key, Hash > &tbl, const bool doSort=false)
List of values from HashTable, optionally sorted.
labelList collectFaces(const labelList &candidateFaces, const labelHashSet &set) const
static writeType writeLevel()
Get/set write level.
labelList intersectedFaces() const
Get faces with intersection.
void printMeshInfo(const bool, const string &) const
Print some mesh stats.
label addFaceZone(const word &fzName, const word &masterPatch, const word &slavePatch, const surfaceZonesInfo::faceZoneType &fzType)
Add/lookup faceZone and update information. Return index of.
label countFaceDirs(const bitSet &isOutsideFace, const label celli) const
Count number of faces on cell that are in set.
set value to -1 any face that was refined
labelList getZones(const List< surfaceZonesInfo::faceZoneType > &fzTypes) const
Get zones of given type.
Contains information about location on a triSurface.
Direct mesh changes based on v1.3 polyTopoChange syntax.
label countHits() const
Count number of intersections (local)
static const dictionary & subDict(const dictionary &dict, const word &keyword, const bool noExit, enum keyType::option matchOpt=keyType::REGEX)
Wrapper around dictionary::subDict which does not exit.
label splitFacesUndo(const labelList &splitFaces, const labelPairList &splits, const dictionary &motionDict, labelList &duplicateFace, List< labelPair > &baffles)
Split faces along diagonal. Maintain mesh quality. Return.
autoPtr< mapDistributePolyMesh > balanceAndRefine(const string &msg, decompositionMethod &decomposer, fvMeshDistribute &distributor, const labelList &cellsToRefine, const scalar maxLoadUnbalance)
Balance before refining some cells.
label mergePatchFaces(const scalar minCos, const scalar concaveCos, const label mergeSize, const labelList &patchIDs, const meshRefinement::FaceMergeType mergeType)
Merge coplanar faces if sets are of size mergeSize.
autoPtr< mapDistributePolyMesh > refineAndBalance(const string &msg, decompositionMethod &decomposer, fvMeshDistribute &distributor, const labelList &cellsToRefine, const scalar maxLoadUnbalance)
Refine some cells and rebalance.
const word & oldInstance() const
(points)instance of mesh upon construction
const fvMesh & mesh() const
Reference to mesh.
autoPtr< mapPolyMesh > removeLimitShells(const label nBufferLayers, const label nErodeCellZones, const labelList &globalToMasterPatch, const labelList &globalToSlavePatch, const pointField &locationsInMesh, const wordList ®ionsInMesh)
Remove cells from limitRegions if level -1.
static void removeFiles(const polyMesh &)
Helper: remove all relevant files from mesh instance.
static label addPatch(fvMesh &, const word &name, const dictionary &)
Helper:add patch to mesh. Update all registered fields.
void doSplitFaces(const labelList &splitFaces, const labelPairList &splits, polyTopoChange &meshMod) const
Split faces into two.
const labelIOList & zoneIDs
Mesh consisting of general polyhedral cells.
static void updateList(const labelList &newToOld, const T &nullValue, List< T > &elems)
Helper: reorder list according to map.
static List< labelPair > subsetBaffles(const polyMesh &mesh, const labelList &zoneIDs, const List< labelPair > &baffles)
Subset baffles according to zones.
FaceMergeType
Enumeration for what to do with co-planar patch faces on a single.
static bitSet getMasterEdges(const polyMesh &mesh, const labelList &meshEdges)
Determine master edge for subset of edges. If coupled.
labelList refineCandidates(const pointField &keepPoints, const scalar curvature, const scalar planarAngle, const bool featureRefinement, const bool featureDistanceRefinement, const bool internalRefinement, const bool surfaceRefinement, const bool curvatureRefinement, const bool smallFeatureRefinement, const bool gapRefinement, const bool bigGapRefinement, const bool spreadGapSize, const label maxGlobalCells, const label maxLocalCells) const
Calculate list of cells to refine.
void growSet(const labelList &neiLevel, const bitSet &isOutsideFace, labelList &refineCell, label &nRefine) const
Add one layer of cells to set.
autoPtr< mapPolyMesh > doRemoveCells(const labelList &cellsToRemove, const labelList &exposedFaces, const labelList &exposedPatchIDs, removeCells &cellRemover)
Remove cells. Put exposedFaces into exposedPatchIDs.
static void calculateEdgeWeights(const polyMesh &mesh, const bitSet &isMasterEdge, const labelList &meshPoints, const edgeList &edges, scalarField &edgeWeights, scalarField &invSumWeight)
Helper: calculate edge weights (1/length)
mode_t mode(const fileName &name, const bool followLink=true)
Return the file mode, normally following symbolic links.
Simple container to keep together snap specific information.
Encapsulates queries for volume refinement ('refine all cells within shell').
A HashTable to objects of type <T> with a labelPair key. The hashing is based on labelPair (FixedList...
An enumeration wrapper for classification of a location as being inside/outside of a volume.
static void checkCoupledFaceZones(const polyMesh &)
Helper function: check that face zones are synced.
An input stream of tokens.
static int readFlags(const EnumContainer &namedEnum, const wordList &words)
Helper: convert wordList into bit pattern using provided Enum.
autoPtr< mapPolyMesh > directionalRefine(const string &msg, const direction cmpt, const labelList &cellsToRefine)
Directionally refine in direction cmpt.
mapType
Enumeration for how userdata is to be mapped upon refinement.
word name(const complex &c)
Return string representation of complex.
const labelList & surfaceIndex() const
Per start-end edge the index of the surface hit.
static label appendPatch(fvMesh &, const label insertPatchi, const word &, const dictionary &)
Helper:append patch to end of mesh.
const Map< label > & faceToCoupledPatch() const
For faces originating from processor faces store the original.
static label findRegions(const polyMesh &, const vector &perturbVec, const pointField &locationsInMesh, const pointField &locationsOutsideMesh, const bool exitIfLeakPath, const writer< scalar > &leakPathFormatter, const label nRegions, labelList &cellRegion, const boolList &blockedFace)
Find regions points are in.
labelList meshedPatches() const
Get patchIDs for patches added in addMeshedPatch.
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)
autoPtr< mapPolyMesh > doRemovePoints(removePoints &pointRemover, const boolList &pointCanBeDeleted)
labelList directionalRefineCandidates(const label maxGlobalCells, const label maxLocalCells, const labelList ¤tLevel, const direction dir) const
Calculate list of cells to directionally refine.
ClassName("meshRefinement")
Runtime type information.
gmvFile<< "tracers "<< particles.size()<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().x()<< ' ';}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().y()<< ' ';}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().z()<< ' ';}gmvFile<< nl;for(const word &name :lagrangianScalarNames){ IOField< scalar > fld(IOobject(name, runTime.timeName(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
label mergeEdgesUndo(const scalar minCos, const dictionary &motionDict)
Merge edges, maintain mesh quality. Return global number.
void distribute(const mapDistributePolyMesh &)
Update local numbering for mesh redistribution.
static void collectAndPrint(const UList< point > &points, const UList< T > &data)
Print list according to (collected and) sorted coordinate.
static const Enum< writeType > writeTypeNames
autoPtr< mapPolyMesh > mergeZoneBaffles(const bool doInternalZones, const bool doBaffleZones)
Merge all baffles on faceZones.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
static autoPtr< indirectPrimitivePatch > makePatch(const polyMesh &, const labelList &)
Create patch from set of patches.
Abstract base class for domain decomposition.
constexpr auto end(C &c) -> decltype(c.end())
Return iterator to the end of the container c.
void testSyncBoundaryFaceList(const scalar mergeDistance, const string &, const UList< T > &, const UList< T > &) const
Compare two lists over all boundary faces.
Mesh data needed to do the Finite Volume discretisation.
scalar mergeDistance() const
Mesh representing a set of points created from polyMesh.
void updateMesh(const mapPolyMesh &, const labelList &changedFaces)
Update for external change to mesh. changedFaces are in new mesh.
autoPtr< mapDistributePolyMesh > balance(const bool keepZoneFaces, const bool keepBaffles, const scalarField &cellWeights, decompositionMethod &decomposer, fvMeshDistribute &distributor)
Redecompose according to cell count.
void getZoneFaces(const labelList &zoneIDs, labelList &faceZoneID, labelList &ownPatch, labelList &neiPatch, labelList &nBaffles) const
Get per-face information (faceZone, master/slave patch)
void setInstance(const fileName &)
Set instance of all local IOobjects.
A HashTable similar to std::unordered_map.
void selectSeparatedCoupledFaces(boolList &) const
Select coupled faces that are not collocated.
const refinementFeatures & features() const
Reference to feature edge mesh.
const hexRef8 & meshCutter() const
Reference to meshcutting engine.
bool isGap(const scalar, const vector &, const vector &, const vector &, const vector &) const
Is local topology a small gap?
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
void baffleAndSplitMesh(const bool handleSnapProblems, const snapParameters &snapParams, const bool useTopologicalSnapDetection, const bool removeEdgeConnectedCells, const scalarField &perpendicularAngle, const label nErodeCellZones, const dictionary &motionDict, Time &runTime, const labelList &globalToMasterPatch, const labelList &globalToSlavePatch, const pointField &locationsInMesh, const wordList ®ionsInMesh, const pointField &locationsOutsideMesh, const writer< scalar > &leakPathFormatter)
Split off unreachable areas of mesh.
autoPtr< mapPolyMesh > dupNonManifoldBoundaryPoints()
Find boundary points that are on faceZones of type boundary.
void mergeFreeStandingBaffles(const snapParameters &snapParams, const bool useTopologicalSnapDetection, const bool removeEdgeConnectedCells, const scalarField &perpendicularAngle, const scalar planarAngle, const dictionary &motionDict, Time &runTime, const labelList &globalToMasterPatch, const labelList &globalToSlavePatch, const pointField &locationsInMesh, const pointField &locationsOutsideMesh, const writer< scalar > &leakPathFormatter)
Merge free-standing baffles.
Container with cells to refine. Refinement given as single direction.
Refinement of (split) hexes using polyTopoChange.
autoPtr< mapPolyMesh > mergeBaffles(const List< labelPair > &, const Map< label > &faceToPatch)
Merge baffles. Gets pairs of faces and boundary faces to move.
Encapsulates queries for features.
const std::string patch
OpenFOAM patch number as a std::string.
writeType
Enumeration for what to write. Used as a bit-pattern.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Forwards and collection of common point field types.
void checkData()
Debugging: check that all faces still obey start()>end()
Helper class which maintains intersections of (changing) mesh with (static) surfaces.
autoPtr< mapPolyMesh > createZoneBaffles(const labelList &zoneIDs, List< labelPair > &baffles, labelList &originatingFaceZone)
Create baffles for faces on faceZones. Return created baffles.
const dimensionedScalar e
Elementary charge.
bool write() const
Write mesh and all data.
dimensioned< Type > sum(const DimensionedField< Type, GeoMesh > &df)
label addMeshedPatch(const word &name, const dictionary &)
Add patch originating from meshing. Update meshedPatches_.
void storeData(const labelList &pointsToStore, const labelList &facesToStore, const labelList &cellsToStore)
Signal points/face/cells for which to store data.
const shellSurfaces & limitShells() const
Reference to limit shells (regions)
static void testSyncPointList(const string &msg, const polyMesh &mesh, const List< scalar > &fld)
have slaves (upon refinement) from master
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
autoPtr< mapPolyMesh > doRestorePoints(removePoints &pointRemover, const labelList &facesToRestore)
autoPtr< mapPolyMesh > refine(const labelList &cellsToRefine)
Refine some cells.
void updateIntersections(const labelList &changedFaces)
Find any intersection of surface. Store in surfaceIndex_.
void markOutsideFaces(const labelList &cellLevel, const labelList &neiLevel, const labelList &refineCell, bitSet &isOutsideFace) const
Mark faces on interface between set and rest.
Class containing mesh-to-mesh mapping information after a mesh distribution where we send parts of me...
static const Enum< debugType > debugTypeNames
autoPtr< mapPolyMesh > dupNonManifoldPoints()
Find boundary points that connect to more than one cell.
Container for data on surfaces used for surface-driven refinement. Contains all the data about the le...
static tmp< pointVectorField > makeDisplacementField(const pointMesh &pMesh, const labelList &adaptPatchIDs)
Helper function to make a pointVectorField with correct.
Sends/receives parts of mesh+fvfields to neighbouring processors. Used in load balancing.
Database for solution data, solver performance and other reduced data.
static bitSet getMasterPoints(const polyMesh &mesh, const labelList &meshPoints)
Determine master point for subset of points. If coupled.
bool getFaceZoneInfo(const word &fzName, label &masterPatchID, label &slavePatchID, surfaceZonesInfo::faceZoneType &fzType) const
Lookup faceZone information. Return false if no information.
option
Enumeration for the data type and search/match modes (bitmask)
bool overwrite() const
Overwrite the mesh?
A list of faces which address into the list of points.
void dumpRefinementLevel() const
Write refinement level as volScalarFields for postprocessing.
const refinementSurfaces & surfaces() const
Reference to surface search engines.
debugType
Enumeration for what to debug. Used as a bit-pattern.