63 meshRefiner_(meshRefiner),
64 decomposer_(decomposer),
65 distributor_(distributor),
66 globalToMasterPatch_(globalToMasterPatch),
67 globalToSlavePatch_(globalToSlavePatch)
73 Foam::label Foam::snappyRefineDriver::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::snappyRefineDriver::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),
300 Foam::label Foam::snappyRefineDriver::gapOnlyRefine
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::snappyRefineDriver::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::snappyRefineDriver::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::snappyRefineDriver::baffleAndSplitMesh
892 const bool handleSnapProblems,
897 <<
"Splitting mesh at surface intersections" <<
nl 898 <<
"---------------------------------------" <<
nl 906 meshRefiner_.baffleAndSplitMesh
922 globalToMasterPatch_,
929 void Foam::snappyRefineDriver::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::snappyRefineDriver::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::snappyRefineDriver::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();
const polyBoundaryMesh & boundaryMesh() const
Return boundary mesh.
#define forAll(list, i)
Loop across all elements in list.
virtual Ostream & write(const char)=0
Write character.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
A list of keyword definitions, which are a keyword followed by any number of values (e...
dimensioned< Type > max(const dimensioned< Type > &, const dimensioned< Type > &)
label nInternalFaces() const
virtual const labelList & faceNeighbour() const
Return face neighbour.
Unit conversion functions.
void size(const label)
Override size to be inconsistent with allocated storage.
Ostream & endl(Ostream &os)
Add newline and flush stream.
const labelList & patchID() const
Per boundary face label the patch index.
label nTotalCells() const
Return total number of cells in decomposed mesh.
const pointField & keepPoints() const
Areas to keep.
static writeType writeLevel()
Get/set write level.
const cellList & cells() const
set value to -1 any face that was refined
const Time & time() const
Return the top-level database.
labelList findIndices(const ListType &, typename ListType::const_reference, const label start=0)
Find all occurrences of given element. Linear search.
Simple container to keep together refinement specific information.
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
const dimensionedScalar c
Speed of light in a vacuum.
scalar degToRad(const scalar deg)
Conversion from degrees to radians.
static labelPairList findDuplicateFacePairs(const polyMesh &)
Helper routine to find all baffles (two boundary faces.
labelList findCells(const polyMesh &) const
Checks that cells are in mesh. Returns cells they are in.
label minRefineCells() const
When to stop refining.
Sends/receives parts of mesh+fvfields to neighbouring processors. Used in load balancing.
dimensionedScalar cos(const dimensionedScalar &ds)
bool allowFreeStandingZoneFaces() const
Are zone faces allowed only in between different cell zones.
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
Simple container to keep together snap specific information.
double cpuTimeIncrement() const
Return CPU time (in seconds) since last call to cpuTimeIncrement()
void doRefine(const dictionary &refineDict, const refinementParameters &refineParams, const snapParameters &snapParams, const bool prepareForSnapping, const dictionary &motionDict)
Do all the refinement.
bool useTopologicalSnapDetection() const
Use old topology based problem-cell removal.
label maxGlobalCells() const
Total number of cells.
scalar maxLoadUnbalance() const
Allowed load unbalance.
static void checkCoupledFaceZones(const polyMesh &)
Helper function: check that face zones are synced.
virtual const labelList & faceOwner() const
Return face owner.
const globalMeshData & globalData() const
Return parallel info.
List< label > labelList
A List of labels.
Abstract base class for decomposition.
defineTypeNameAndDebug(combustionModel, 0)
void reduce(const List< UPstream::commsStruct > &comms, T &Value, const BinaryOp &bop, const int tag, const label comm)
word name(const complex &)
Return a string representation of a complex.
Helper class which maintains intersections of (changing) mesh with (static) surfaces.
scalar planarAngle() const
Angle when two intersections are considered to be planar.
snappyRefineDriver(meshRefinement &meshRefiner, decompositionMethod &decomposer, fvMeshDistribute &distributor, const labelList &globalToMasterPatch, const labelList &globalToSlavePatch)
Construct from components.
void setSize(const label)
Reset size of List.
static bool & parRun()
Is this a parallel run?
const fileName & instance() const
A cell is defined as a list of faces with extra functionality.
A collection of cell labels.
prefixOSstream Pout(cout, "Pout")
Mesh data needed to do the Finite Volume discretisation.
void clear()
Remove all regIOobject owned by the registry.
static labelList getNamedSurfaces(const PtrList< surfaceZonesInfo > &surfList)
Get indices of named surfaces (surfaces with faceZoneName)
T returnReduce(const T &Value, const BinaryOp &bop, const int tag=Pstream::msgType(), const label comm=UPstream::worldComm)
virtual bool write(const bool write=true) const
Write using setting from DB.
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.
scalar curvature() const
Curvature.
label maxLocalCells() const
Per processor max number of cells.
label nBufferLayers() const
Number of layers between different refinement levels.