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;
161 const scalar mergeDistance_;
164 const bool overwrite_;
167 const word oldInstance_;
218 template<
class GeoField>
219 static void addPatchFields(
fvMesh&,
const word& patchFieldType);
222 template<
class GeoField>
238 void calcCellCellRays
266 const label exposedPatchi
275 static bool markForRefine
277 const label markValue,
278 const label nAllowRefine,
285 void markFeatureCellLevel
293 label markFeatureRefinement
296 const label nAllowRefine,
303 label markInternalDistanceToFeatureRefinement
305 const label nAllowRefine,
311 label markInternalRefinement
313 const label nAllowRefine,
320 label unmarkInternalRefinement
334 label markSurfaceRefinement
336 const label nAllowRefine,
345 void collectGapCandidates
358 const scalar planarCos,
371 const label nAllowRefine,
382 label markSurfaceGapRefinement
384 const scalar planarCos,
385 const label nAllowRefine,
396 const point& nearPoint,
411 const bool useSurfaceNormal,
413 const point& nearPoint,
432 void selectGapCandidates
455 label markInternalGapRefinement
457 const scalar planarCos,
458 const bool spreadGapSize,
459 const label nAllowRefine,
467 label markSmallFeatureRefinement
469 const scalar planarCos,
470 const label nAllowRefine,
483 const scalar tol = 1
e-6
489 label markSurfaceCurvatureRefinement
491 const scalar curvature,
492 const label nAllowRefine,
502 const scalar planarCos,
503 const label nAllowRefine,
505 const label surfaceLevel,
507 const vector& surfaceNormal,
520 label markProximityRefinement
522 const scalar curvature,
528 const label nAllowRefine,
536 void markMultiRegionCell
547 void detectMultiRegionCells
564 label markProximityRefinementWave
566 const scalar planarCos,
568 const label nAllowRefine,
582 const bool allowBoundary,
589 void getIntersections
601 void getIntersections
612 void getBafflePatches
614 const label nErodeCellZones,
627 const label nBufferLayers,
641 const label ownPatch,
642 const label neiPatch,
650 void markBoundaryFace
677 const scalar minFaceArea,
678 const scalar maxNonOrtho,
685 const scalar volFraction,
695 const bool removeEdgeConnectedCells,
711 const label defaultRegion
716 labelList markFacesOnProblemCellsGeometric
732 const scalar freeStandingAngle
742 void findCellZoneGeometric
753 void findCellZoneInsideWalk
763 void findCellZoneInsideWalk
772 bool calcRegionToZone
774 const label backgroundZoneID,
775 const label surfZoneI,
776 const label ownRegion,
777 const label neiRegion,
786 void findCellZoneTopo
788 const label backgroundZoneID,
800 const label nErodeCellZones,
801 const label backgroundZoneID,
809 void makeConsistentFaceIndex
819 const bool allowFreeStandingZoneFaces,
820 const label nErodeCellZones,
821 const label backgroundZoneID,
835 const bitSet& isMasterFace,
839 const bitSet& meshFlipMap,
844 void allocateInterRegionFaceZone
853 void handleSnapProblems
856 const bool useTopologicalSnapDetection,
857 const bool removeEdgeConnectedCells,
879 void calcPatchNumMasterFaces
881 const bitSet& isMasterFace,
896 void consistentOrientation
898 const bitSet& isMasterFace,
952 return mergeDistance_;
1006 return faceToCoupledPatch_;
1015 return userFaceData_;
1020 return userFaceData_;
1035 const bool keepZoneFaces,
1036 const bool keepBaffles,
1074 const bitSet& isMasterEdge,
1083 template<
class Type>
1087 const bitSet& isMasterEdge,
1111 const scalar planarCos,
1124 const scalar curvature,
1125 const scalar planarAngle,
1127 const bool featureRefinement,
1128 const bool featureDistanceRefinement,
1129 const bool internalRefinement,
1130 const bool surfaceRefinement,
1131 const bool curvatureRefinement,
1132 const bool smallFeatureRefinement,
1133 const bool gapRefinement,
1134 const bool bigGapRefinement,
1135 const bool spreadGapSize,
1136 const label maxGlobalCells,
1137 const label maxLocalCells
1156 const bitSet& isOutsideFace,
1164 const bitSet& isOutsideFace,
1172 const scalar planarAngle,
1175 const label growIter
1188 const scalar maxLoadUnbalance
1198 const scalar maxLoadUnbalance
1204 const label maxGlobalCells,
1205 const label maxLocalCells,
1224 const bool handleSnapProblems,
1228 const bool useTopologicalSnapDetection,
1229 const bool removeEdgeConnectedCells,
1231 const label nErodeCellZones,
1246 const bool useTopologicalSnapDetection,
1247 const bool removeEdgeConnectedCells,
1249 const scalar planarAngle,
1263 const label nBufferLayers,
1264 const label nErodeCellZones,
1277 const label nBufferLayers,
1278 const label nErodeCellZones,
1346 const bool doInternalZones,
1347 const bool doBaffleZones
1357 const bool allowFreeStandingZoneFaces,
1358 const label nErodeCellZones,
1371 const label insertPatchi,
1391 const word& masterPatch,
1392 const word& slavePatch,
1401 label& masterPatchID,
1402 label& slavePatchID,
1417 const vector& perturbVec,
1426 const vector& perturbVec,
1430 const label nRegions,
1515 const scalar minCos,
1516 const scalar concaveCos,
1517 const label mergeSize,
1526 const scalar minCos,
1527 const scalar concaveCos,
1568 const scalar minCos,
1660 const bitSet& isMasterElem,
1674 template<
class EnumContainer>
1677 const EnumContainer& namedEnum,
1682 template<
class Type>
1686 const word& keyword,
1689 const Type& defaultValue =
Zero
1696 const word& keyword,
1704 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.
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...
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...
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 constexpr const zero Zero
Global zero.
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)
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.
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.
static label findRegions(const polyMesh &, const vector &perturbVec, const pointField &locationsInMesh, const pointField &locationsOutsideMesh, const writer< scalar > &leakPathFormatter, const label nRegions, labelList &cellRegion, const boolList &blockedFace)
Find regions points are in.
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...
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
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.
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 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.
static ITstream & lookup(const dictionary &dict, const word &keyword, const bool noExit)
Wrapper around dictionary::lookup which does not exit.
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...
autoPtr< mapPolyMesh > splitMeshRegions(const labelList &globalToMasterPatch, const labelList &globalToSlavePatch, const pointField &locationsInMesh, const pointField &locationsOutsideMesh, const writer< scalar > &leakPathFormatter)
Split mesh. Keep part containing point. Return empty map if.
label ListType::const_reference const label start
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 const dictionary & subDict(const dictionary &dict, const word &keyword, const bool noExit)
Wrapper around dictionary::subDict which does not exit.
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.
static Type get(const dictionary &dict, const word &keyword, const bool noExit, enum keyType::option matchOpt=keyType::REGEX, const Type &defaultValue=Zero)
Wrapper around dictionary::get which does not exit.
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.