54 Foam::autoRefineDriver::autoRefineDriver
63 meshRefiner_(meshRefiner),
64 decomposer_(decomposer),
65 distributor_(distributor),
66 globalToMasterPatch_(globalToMasterPatch),
67 globalToSlavePatch_(globalToSlavePatch)
73 Foam::label Foam::autoRefineDriver::featureEdgeRefine
84 if (meshRefiner_.features().size() && maxIter > 0)
86 for (; iter < maxIter; iter++)
89 <<
"Feature refinement iteration " << iter <<
nl 90 <<
"------------------------------" <<
nl 95 meshRefiner_.refineCandidates
113 meshRefiner_.meshCutter().consistentRefinement
119 Info<<
"Determined cells to refine in = " 124 label nCellsToRefine = cellsToRefine.size();
127 Info<<
"Selected for feature refinement : " << nCellsToRefine
131 if (nCellsToRefine <= minRefine)
133 Info<<
"Stopping refining since too few cells selected." 154 meshRefiner_.balanceAndRefine
156 "feature refinement iteration " +
name(iter),
165 meshRefiner_.refineAndBalance
167 "feature refinement iteration " +
name(iter),
180 Foam::label Foam::autoRefineDriver::surfaceOnlyRefine
190 label overallMaxLevel =
max(meshRefiner_.surfaces().maxLevel());
193 for (iter = 0; iter < maxIter; iter++)
196 <<
"Surface refinement iteration " << iter <<
nl 197 <<
"------------------------------" <<
nl 208 meshRefiner_.refineCandidates
226 meshRefiner_.meshCutter().consistentRefinement
232 Info<<
"Determined cells to refine in = " 236 label nCellsToRefine = cellsToRefine.size();
239 Info<<
"Selected for refinement : " << nCellsToRefine
249 iter >= overallMaxLevel
254 Info<<
"Stopping refining since too few cells selected." 275 meshRefiner_.balanceAndRefine
277 "surface refinement iteration " +
name(iter),
286 meshRefiner_.refineAndBalance
288 "surface refinement iteration " +
name(iter),
311 label maxIncrement = 0;
312 const labelList& maxLevel = meshRefiner_.surfaces().maxLevel();
313 const labelList& gapLevel = meshRefiner_.surfaces().gapLevel();
317 maxIncrement =
max(maxIncrement, gapLevel[i]-maxLevel[i]);
322 if (maxIncrement == 0)
327 for (iter = 0; iter < maxIter; iter++)
330 <<
"Gap refinement iteration " << iter <<
nl 331 <<
"--------------------------" <<
nl 342 meshRefiner_.refineCandidates
361 Pout<<
"Dumping " << candidateCells.
size()
362 <<
" cells to cellSet candidateCellsFromGap." <<
endl;
363 cellSet c(mesh,
"candidateCellsFromGap", candidateCells);
364 c.
instance() = meshRefiner_.timeName();
373 isCandidateCell[candidateCells[i]] =
true;
376 for (
label i=0; i<1; i++)
378 boolList newIsCandidateCell(isCandidateCell);
386 if (isCandidateCell[own] != isCandidateCell[nei])
388 newIsCandidateCell[own] =
true;
389 newIsCandidateCell[nei] =
true;
413 if (isCandidateCell[own] != neiIsCandidateCell[bFaceI])
415 newIsCandidateCell[own] =
true;
419 isCandidateCell.
transfer(newIsCandidateCell);
423 forAll(isCandidateCell, cellI)
425 if (isCandidateCell[cellI])
432 forAll(isCandidateCell, cellI)
434 if (isCandidateCell[cellI])
436 candidateCells[n++] = cellI;
442 if (debug&meshRefinement::MESH)
444 Pout<<
"Dumping " << candidateCells.
size()
445 <<
" cells to cellSet candidateCellsFromGapPlusBuffer." <<
endl;
446 cellSet c(mesh,
"candidateCellsFromGapPlusBuffer", candidateCells);
447 c.
instance() = meshRefiner_.timeName();
454 meshRefiner_.meshCutter().consistentRefinement
460 Info<<
"Determined cells to refine in = " 464 label nCellsToRefine = cellsToRefine.size();
467 Info<<
"Selected for refinement : " << nCellsToRefine
482 Info<<
"Stopping refining since too few cells selected." 503 meshRefiner_.balanceAndRefine
505 "gap refinement iteration " +
name(iter),
514 meshRefiner_.refineAndBalance
516 "gap refinement iteration " +
name(iter),
528 Foam::label Foam::autoRefineDriver::danglingCellRefine
538 for (iter = 0; iter < maxIter; iter++)
541 <<
"Dangling coarse cells refinement iteration " << iter <<
nl 542 <<
"--------------------------------------------" <<
nl 554 cellSet candidateCellSet(mesh,
"candidateCells", cells.
size()/1000);
558 const cell& cFaces = cells[cellI];
571 if (pbm[patchI].coupled())
578 if (nIntFaces == nFaces)
580 candidateCellSet.insert(cellI);
586 Pout<<
"Dumping " << candidateCellSet.size()
587 <<
" cells to cellSet candidateCellSet." <<
endl;
588 candidateCellSet.instance() = meshRefiner_.timeName();
589 candidateCellSet.
write();
591 candidateCells = candidateCellSet.toc();
598 meshRefiner_.meshCutter().consistentRefinement
604 Info<<
"Determined cells to refine in = " 608 label nCellsToRefine = cellsToRefine.size();
611 Info<<
"Selected for refinement : " << nCellsToRefine
626 Info<<
"Stopping refining since too few cells selected." 647 meshRefiner_.balanceAndRefine
649 "coarse cell refinement iteration " +
name(iter),
658 meshRefiner_.refineAndBalance
660 "coarse cell refinement iteration " +
name(iter),
672 void Foam::autoRefineDriver::removeInsideCells
675 const label nBufferLayers
679 <<
"Removing mesh beyond surface intersections" <<
nl 680 <<
"------------------------------------------" <<
nl 690 meshRefiner_.splitMesh
693 globalToMasterPatch_,
700 Pout<<
"Writing subsetted mesh to time " 701 << meshRefiner_.timeName() <<
'.' <<
endl;
710 mesh.
time().
path()/meshRefiner_.timeName()
712 Pout<<
"Dumped mesh in = " 727 meshRefiner_.userFaceData().setSize(1);
731 meshRefiner_.userFaceData()[0].second() = createWithValues<labelList>
735 meshRefiner_.intersectedFaces(),
742 label overallMaxShellLevel = meshRefiner_.shells().maxLevel();
745 for (iter = 0; iter < maxIter; iter++)
748 <<
"Shell refinement iteration " << iter <<
nl 749 <<
"----------------------------" <<
nl 754 meshRefiner_.refineCandidates
773 Pout<<
"Dumping " << candidateCells.
size()
774 <<
" cells to cellSet candidateCellsFromShells." <<
endl;
776 cellSet c(mesh,
"candidateCellsFromShells", candidateCells);
777 c.
instance() = meshRefiner_.timeName();
790 findIndices(meshRefiner_.userFaceData()[0].second(), 0)
800 cellsToRefine = meshRefiner_.meshCutter().consistentSlowRefinement
806 meshRefiner_.intersectedPoints()
811 cellsToRefine = meshRefiner_.meshCutter().consistentSlowRefinement2
819 Info<<
"Determined cells to refine in = " 823 label nCellsToRefine = cellsToRefine.
size();
826 Info<<
"Selected for internal refinement : " << nCellsToRefine
836 iter >= overallMaxShellLevel
841 Info<<
"Stopping refining since too few cells selected." 861 meshRefiner_.balanceAndRefine
863 "shell refinement iteration " +
name(iter),
872 meshRefiner_.refineAndBalance
874 "shell refinement iteration " +
name(iter),
882 meshRefiner_.userFaceData().
clear();
888 void Foam::autoRefineDriver::baffleAndSplitMesh
892 const bool handleSnapProblems,
897 <<
"Splitting mesh at surface intersections" <<
nl 898 <<
"---------------------------------------" <<
nl 906 meshRefiner_.baffleAndSplitMesh
922 globalToMasterPatch_,
929 void Foam::autoRefineDriver::zonify
943 if (namedSurfaces.
size())
946 <<
"Introducing zones for interfaces" <<
nl 947 <<
"--------------------------------" <<
nl 965 Pout<<
"Writing zoned mesh to time " 966 << meshRefiner_.timeName() <<
'.' <<
endl;
975 mesh.
time().
path()/meshRefiner_.timeName()
985 void Foam::autoRefineDriver::splitAndMergeBaffles
989 const bool handleSnapProblems,
994 <<
"Handling cells with snap problems" <<
nl 995 <<
"---------------------------------" <<
nl 1006 const scalarField& perpAngle = meshRefiner_.surfaces().perpendicularAngle();
1008 meshRefiner_.baffleAndSplitMesh
1024 globalToMasterPatch_,
1025 globalToSlavePatch_,
1036 meshRefiner_.dupNonManifoldPoints();
1044 Info<<
"Detected unsplittable baffles : " << nCouples <<
endl;
1051 meshRefiner_.mergeBaffles(couples);
1056 meshRefiner_.checkData();
1060 meshRefiner_.splitMeshRegions
1062 globalToMasterPatch_,
1063 globalToSlavePatch_,
1070 meshRefiner_.checkData();
1073 Info<<
"Merged free-standing baffles in = " 1079 Pout<<
"Writing handleProblemCells mesh to time " 1080 << meshRefiner_.timeName() <<
'.' <<
endl;
1089 mesh.
time().
path()/meshRefiner_.timeName()
1095 void Foam::autoRefineDriver::mergePatchFaces
1102 <<
"Merge refined boundary faces" <<
nl 1103 <<
"----------------------------" <<
nl 1108 meshRefiner_.mergePatchFacesUndo
1112 meshRefiner_.meshedPatches(),
1119 meshRefiner_.checkData();
1126 meshRefiner_.checkData();
1136 const bool prepareForSnapping,
1141 <<
"Refinement phase" <<
nl 1142 <<
"----------------" <<
nl 1210 zonify(refineParams);
1213 splitAndMergeBaffles
1222 if (prepareForSnapping)
1224 mergePatchFaces(refineParams, motionDict);
1231 <<
"Doing final balancing" <<
nl 1232 <<
"---------------------" <<
nl 1243 meshRefiner_.balance
1255 meshRefiner_.checkZoneFaces();
void reduce(const List< UPstream::commsStruct > &comms, T &Value, const BinaryOp &bop, const int tag, const label comm)
double cpuTimeIncrement() const
Return CPU time (in seconds) since last call to cpuTimeIncrement()
static bool & parRun()
Is this a parallel run?
Mesh data needed to do the Finite Volume discretisation.
T returnReduce(const T &Value, const BinaryOp &bop, const int tag=Pstream::msgType(), const label comm=UPstream::worldComm)
T * first()
Return the first entry.
fileName path() const
Return path.
void transfer(List< T > &)
Transfer the contents of the argument List into this list.
word name(const complex &)
Return a string representation of a complex.
A cell is defined as a list of faces with extra functionality.
label nBufferLayers() const
Number of layers between different refinement levels.
label maxGlobalCells() const
Total number of cells.
scalar maxLoadUnbalance() const
Allowed load unbalance.
A collection of cell labels.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
void size(const label)
Override size to be inconsistent with allocated storage.
const fileName & instance() const
static labelList getNamedSurfaces(const PtrList< surfaceZonesInfo > &surfList)
Get indices of named surfaces (surfaces with faceZoneName)
const cellList & cells() const
Simple container to keep together refinement specific information.
A list of keyword definitions, which are a keyword followed by any number of values (e...
Simple container to keep together snap specific information.
Sends/receives parts of mesh+fvfields to neighbouring processors. Used in load balancing.
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
static labelPairList findDuplicateFacePairs(const polyMesh &)
Helper routine to find all baffles (two boundary faces.
const Time & time() const
Return the top-level database.
virtual bool write() const
Write using setting from DB.
static void checkCoupledFaceZones(const polyMesh &)
Helper function: check that face zones are synced.
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
void setSize(const label)
Reset size of List.
Ostream & endl(Ostream &os)
Add newline and flush stream.
const pointField & keepPoints() const
Areas to keep.
void clear()
Clear all entries from table.
Abstract base class for decomposition.
dimensioned< Type > max(const dimensioned< Type > &, const dimensioned< Type > &)
virtual Ostream & write(const token &)=0
Write next token to stream.
dimensionedScalar cos(const dimensionedScalar &ds)
label nTotalCells() const
Return total number of cells in decomposed mesh.
Unit conversion functions.
virtual const labelList & faceOwner() const
Return face owner.
const polyBoundaryMesh & boundaryMesh() const
Return boundary mesh.
const cellShapeList & cells
static writeType writeLevel()
Get/set write level.
label nInternalFaces() const
const labelList & patchID() const
Per boundary face label the patch index.
List< label > labelList
A List of labels.
scalar degToRad(const scalar deg)
Conversion from degrees to radians.
labelList findCells(const polyMesh &) const
Checks that cells are in mesh. Returns cells they are in.
scalar planarAngle() const
Angle when two intersections are considered to be planar.
const dimensionedScalar c
Speed of light in a vacuum.
label maxLocalCells() const
Per processor max number of cells.
static void swapBoundaryCellList(const polyMesh &mesh, const UList< T > &cellData, List< T > &neighbourCellData)
Swap to obtain neighbour cell values for all boundary faces.
virtual const labelList & faceNeighbour() const
Return face neighbour.
Helper class which maintains intersections of (changing) mesh with (static) surfaces.
scalar curvature() const
Curvature.
void doRefine(const dictionary &refineDict, const refinementParameters &refineParams, const snapParameters &snapParams, const bool prepareForSnapping, const dictionary &motionDict)
Do all the refinement.
labelList findIndices(const ListType &, typename ListType::const_reference, const label start=0)
Find all occurences of given element. Linear search.
label minRefineCells() const
When to stop refining.
const globalMeshData & globalData() const
Return parallel info.
bool useTopologicalSnapDetection() const
Use old topology based problem-cell removal.
defineTypeNameAndDebug(combustionModel, 0)
prefixOSstream Pout(cout,"Pout")
bool allowFreeStandingZoneFaces() const
Are zone faces allowed only inbetween different cell zones.