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
265 const label exposedPatchi
274 static bool markForRefine
276 const label markValue,
277 const label nAllowRefine,
284 void markFeatureCellLevel
292 label markFeatureRefinement
295 const label nAllowRefine,
302 label markInternalDistanceToFeatureRefinement
304 const label nAllowRefine,
310 label markInternalRefinement
312 const label nAllowRefine,
319 label unmarkInternalRefinement
333 label markSurfaceRefinement
335 const label nAllowRefine,
344 void collectGapCandidates
357 const scalar planarCos,
370 const label nAllowRefine,
381 label markSurfaceGapRefinement
383 const scalar planarCos,
384 const label nAllowRefine,
395 const point& nearPoint,
410 const bool useSurfaceNormal,
412 const point& nearPoint,
431 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
602 void getIntersections
613 void getBafflePatches
615 const label nErodeCellZones,
628 const label nBufferLayers,
642 const label ownPatch,
643 const label neiPatch,
651 void markBoundaryFace
678 const scalar minFaceArea,
679 const scalar maxNonOrtho,
686 const scalar volFraction,
696 const bool removeEdgeConnectedCells,
712 const label defaultRegion
717 labelList markFacesOnProblemCellsGeometric
733 const scalar freeStandingAngle
743 void findCellZoneGeometric
754 void findCellZoneInsideWalk
764 void findCellZoneInsideWalk
773 bool calcRegionToZone
775 const label backgroundZoneID,
776 const label surfZoneI,
777 const label ownRegion,
778 const label neiRegion,
787 void findCellZoneTopo
789 const label backgroundZoneID,
801 const label nErodeCellZones,
802 const label backgroundZoneID,
812 const label nGrowCellZones,
813 const label backgroundZoneID,
822 void makeConsistentFaceIndex
832 const bool allowFreeStandingZoneFaces,
833 const label nErodeCellZones,
834 const label backgroundZoneID,
848 const bitSet& isMasterFace,
852 const bitSet& meshFlipMap,
857 void allocateInterRegionFaceZone
866 void handleSnapProblems
869 const bool useTopologicalSnapDetection,
870 const bool removeEdgeConnectedCells,
892 void calcPatchNumMasterFaces
894 const bitSet& isMasterFace,
909 void consistentOrientation
911 const bitSet& isMasterFace,
965 return mergeDistance_;
1001 return limitShells_;
1019 return faceToCoupledPatch_;
1028 return userFaceData_;
1033 return userFaceData_;
1048 const bool keepZoneFaces,
1049 const bool keepBaffles,
1087 const bitSet& isMasterEdge,
1096 template<
class Type>
1100 const bitSet& isMasterEdge,
1124 const scalar planarCos,
1137 const scalar curvature,
1138 const scalar planarAngle,
1140 const bool featureRefinement,
1141 const bool featureDistanceRefinement,
1142 const bool internalRefinement,
1143 const bool surfaceRefinement,
1144 const bool curvatureRefinement,
1145 const bool smallFeatureRefinement,
1146 const bool gapRefinement,
1147 const bool bigGapRefinement,
1148 const bool spreadGapSize,
1149 const label maxGlobalCells,
1150 const label maxLocalCells
1169 const bitSet& isOutsideFace,
1177 const bitSet& isOutsideFace,
1185 const scalar planarAngle,
1188 const label growIter
1201 const scalar maxLoadUnbalance
1211 const scalar maxLoadUnbalance
1217 const label maxGlobalCells,
1218 const label maxLocalCells,
1237 const bool handleSnapProblems,
1241 const bool useTopologicalSnapDetection,
1242 const bool removeEdgeConnectedCells,
1244 const label nErodeCellZones,
1259 const bool useTopologicalSnapDetection,
1260 const bool removeEdgeConnectedCells,
1262 const scalar planarAngle,
1276 const label nBufferLayers,
1277 const label nErodeCellZones,
1290 const label nBufferLayers,
1291 const label nErodeCellZones,
1359 const bool doInternalZones,
1360 const bool doBaffleZones
1370 const bool allowFreeStandingZoneFaces,
1371 const label nErodeCellZones,
1384 const label insertPatchi,
1404 const word& masterPatch,
1405 const word& slavePatch,
1414 label& masterPatchID,
1415 label& slavePatchID,
1430 const vector& perturbVec,
1439 const vector& perturbVec,
1442 const bool exitIfLeakPath,
1444 const label nRegions,
1457 const bool exitIfLeakPath,
1530 const scalar minCos,
1531 const scalar concaveCos,
1532 const label mergeSize,
1541 const scalar minCos,
1542 const scalar concaveCos,
1583 const scalar minCos,
1675 const bitSet& isMasterElem,
1689 template<
class EnumContainer>
1692 const EnumContainer& namedEnum,
1697 template<
class Type>
1701 const word& keyword,
1704 const Type& deflt =
Zero
1711 const word& keyword,
1720 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...
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.
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 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.