65 meshRefiner_(meshRefiner),
66 decomposer_(decomposer),
67 distributor_(distributor),
68 globalToMasterPatch_(globalToMasterPatch),
69 globalToSlavePatch_(globalToSlavePatch)
86 if (meshRefiner_.features().size() && maxIter > 0)
88 for (; iter < maxIter; iter++)
91 <<
"Feature refinement iteration " << iter <<
nl
92 <<
"------------------------------" <<
nl
97 meshRefiner_.refineCandidates
118 meshRefiner_.meshCutter().consistentRefinement
124 Info<<
"Determined cells to refine in = "
125 <<
mesh.time().cpuTimeIncrement() <<
" s" <<
endl;
129 label nCellsToRefine = cellsToRefine.
size();
132 Info<<
"Selected for feature refinement : " << nCellsToRefine
133 <<
" cells (out of " <<
mesh.globalData().nTotalCells()
136 if (nCellsToRefine <= minRefine)
138 Info<<
"Stopping refining since too few cells selected."
159 meshRefiner_.balanceAndRefine
161 "feature refinement iteration " +
name(iter),
170 meshRefiner_.refineAndBalance
172 "feature refinement iteration " +
name(iter),
197 labelList surfaceMaxLevel(meshRefiner_.surfaces().maxGapLevel());
198 labelList shellMaxLevel(meshRefiner_.shells().maxGapLevel());
200 if (
max(surfaceMaxLevel) == 0 &&
max(shellMaxLevel) == 0)
205 for (; iter < maxIter; iter++)
208 <<
"Small surface feature refinement iteration " << iter <<
nl
209 <<
"--------------------------------------------" <<
nl
218 meshRefiner_.refineCandidates
240 meshRefiner_.meshCutter().consistentRefinement
246 Info<<
"Determined cells to refine in = "
247 <<
mesh.time().cpuTimeIncrement() <<
" s" <<
endl;
250 label nCellsToRefine = cellsToRefine.
size();
253 Info<<
"Selected for refinement : " << nCellsToRefine
254 <<
" cells (out of " <<
mesh.globalData().nTotalCells()
259 if (nCellsToRefine == 0)
261 Info<<
"Stopping refining since too few cells selected."
282 meshRefiner_.balanceAndRefine
284 "small feature refinement iteration " +
name(iter),
293 meshRefiner_.refineAndBalance
295 "small feature refinement iteration " +
name(iter),
317 label overallMaxLevel =
max(meshRefiner_.surfaces().maxLevel());
320 for (iter = 0; iter < maxIter; iter++)
323 <<
"Surface refinement iteration " << iter <<
nl
324 <<
"------------------------------" <<
nl
335 meshRefiner_.refineCandidates
356 meshRefiner_.meshCutter().consistentRefinement
362 Info<<
"Determined cells to refine in = "
363 <<
mesh.time().cpuTimeIncrement() <<
" s" <<
endl;
366 label nCellsToRefine = cellsToRefine.
size();
369 Info<<
"Selected for refinement : " << nCellsToRefine
370 <<
" cells (out of " <<
mesh.globalData().nTotalCells()
379 iter >= overallMaxLevel
384 Info<<
"Stopping refining since too few cells selected."
405 meshRefiner_.balanceAndRefine
407 "surface refinement iteration " +
name(iter),
416 meshRefiner_.refineAndBalance
418 "surface refinement iteration " +
name(iter),
441 label maxIncrement = 0;
442 const labelList& maxLevel = meshRefiner_.surfaces().maxLevel();
443 const labelList& gapLevel = meshRefiner_.surfaces().gapLevel();
447 maxIncrement =
max(maxIncrement, gapLevel[i]-maxLevel[i]);
452 if (maxIncrement == 0)
457 for (iter = 0; iter < maxIter; iter++)
460 <<
"Gap refinement iteration " << iter <<
nl
461 <<
"--------------------------" <<
nl
472 meshRefiner_.refineCandidates
494 Pout<<
"Dumping " << candidateCells.
size()
495 <<
" cells to cellSet candidateCellsFromGap." <<
endl;
496 cellSet c(
mesh,
"candidateCellsFromGap", candidateCells);
497 c.instance() = meshRefiner_.timeName();
506 isCandidateCell[candidateCells[i]] =
true;
509 for (
label i=0; i<1; i++)
511 boolList newIsCandidateCell(isCandidateCell);
514 for (
label faceI = 0; faceI <
mesh.nInternalFaces(); faceI++)
519 if (isCandidateCell[own] != isCandidateCell[nei])
521 newIsCandidateCell[own] =
true;
522 newIsCandidateCell[nei] =
true;
528 syncTools::swapBoundaryCellList
539 faceI <
mesh.nFaces();
544 label bFaceI = faceI-
mesh.nInternalFaces();
546 if (isCandidateCell[own] != neiIsCandidateCell[bFaceI])
548 newIsCandidateCell[own] =
true;
552 isCandidateCell.
transfer(newIsCandidateCell);
556 forAll(isCandidateCell, cellI)
558 if (isCandidateCell[cellI])
565 forAll(isCandidateCell, cellI)
567 if (isCandidateCell[cellI])
569 candidateCells[
n++] = cellI;
577 Pout<<
"Dumping " << candidateCells.
size()
578 <<
" cells to cellSet candidateCellsFromGapPlusBuffer." <<
endl;
579 cellSet c(
mesh,
"candidateCellsFromGapPlusBuffer", candidateCells);
580 c.instance() = meshRefiner_.timeName();
587 meshRefiner_.meshCutter().consistentRefinement
593 Info<<
"Determined cells to refine in = "
594 <<
mesh.time().cpuTimeIncrement() <<
" s" <<
endl;
597 label nCellsToRefine = cellsToRefine.
size();
600 Info<<
"Selected for refinement : " << nCellsToRefine
601 <<
" cells (out of " <<
mesh.globalData().nTotalCells()
615 Info<<
"Stopping refining since too few cells selected."
636 meshRefiner_.balanceAndRefine
638 "gap refinement iteration " +
name(iter),
647 meshRefiner_.refineAndBalance
649 "gap refinement iteration " +
name(iter),
664 const bool spreadGapSize,
673 labelList surfaceMaxLevel(meshRefiner_.surfaces().maxGapLevel());
674 labelList shellMaxLevel(meshRefiner_.shells().maxGapLevel());
676 label overallMaxLevel(
max(
max(surfaceMaxLevel),
max(shellMaxLevel)));
678 if (overallMaxLevel == 0)
684 for (; iter < maxIter; iter++)
687 <<
"Big gap refinement iteration " << iter <<
nl
688 <<
"------------------------------" <<
nl
697 meshRefiner_.refineCandidates
720 Pout<<
"Dumping " << candidateCells.
size()
721 <<
" cells to cellSet candidateCellsFromBigGap." <<
endl;
722 cellSet c(
mesh,
"candidateCellsFromBigGap", candidateCells);
723 c.instance() = meshRefiner_.timeName();
729 meshRefiner_.meshCutter().consistentRefinement
735 Info<<
"Determined cells to refine in = "
736 <<
mesh.time().cpuTimeIncrement() <<
" s" <<
endl;
739 label nCellsToRefine = cellsToRefine.
size();
742 Info<<
"Selected for refinement : " << nCellsToRefine
743 <<
" cells (out of " <<
mesh.globalData().nTotalCells()
752 iter >= overallMaxLevel
757 Info<<
"Stopping refining since too few cells selected."
778 meshRefiner_.balanceAndRefine
780 "big gap refinement iteration " +
name(iter),
789 meshRefiner_.refineAndBalance
791 "big gap refinement iteration " +
name(iter),
813 for (iter = 0; iter < maxIter; iter++)
816 <<
"Dangling coarse cells refinement iteration " << iter <<
nl
817 <<
"--------------------------------------------" <<
nl
838 label bFaceI = cFaces[i]-
mesh.nInternalFaces();
846 if (pbm[patchI].coupled())
853 if (nIntFaces == nFaces)
855 candidateCellSet.
insert(cellI);
861 Pout<<
"Dumping " << candidateCellSet.
size()
862 <<
" cells to cellSet candidateCellSet." <<
endl;
863 candidateCellSet.
instance() = meshRefiner_.timeName();
864 candidateCellSet.
write();
866 candidateCells = candidateCellSet.
toc();
873 meshRefiner_.meshCutter().consistentRefinement
879 Info<<
"Determined cells to refine in = "
880 <<
mesh.time().cpuTimeIncrement() <<
" s" <<
endl;
883 label nCellsToRefine = cellsToRefine.
size();
886 Info<<
"Selected for refinement : " << nCellsToRefine
887 <<
" cells (out of " <<
mesh.globalData().nTotalCells()
901 Info<<
"Stopping refining since too few cells selected."
922 meshRefiner_.balanceAndRefine
924 "coarse cell refinement iteration " +
name(iter),
933 meshRefiner_.refineAndBalance
935 "coarse cell refinement iteration " +
name(iter),
961 for (;iter < maxIter; iter++)
964 <<
"Refinement transition refinement iteration " << iter <<
nl
965 <<
"--------------------------------------------" <<
nl
968 const labelList& surfaceIndex = meshRefiner_.surfaceIndex();
969 const hexRef8& cutter = meshRefiner_.meshCutter();
997 label faceI = cFaces[cFaceI];
999 if (surfaceIndex[faceI] != -1)
1002 if (fLevel != cLevel)
1004 transitionCells.
insert(cellI);
1135 label cellI = iter.key();
1140 bool foundOpposite =
false;
1144 label faceI = cFaces[cFaceI];
1148 surfaceIndex[faceI] != -1
1154 if (faceOwner[faceI] != cellI)
1162 label face2I = cFaces[cFaceI2];
1167 && surfaceIndex[face2I] != -1
1172 if (faceOwner[face2I] != cellI)
1178 if ((
n&n2) < oppositeCos)
1180 foundOpposite =
true;
1196 candidateCellSet.
insert(cellI);
1202 Pout<<
"Dumping " << candidateCellSet.
size()
1203 <<
" cells to cellSet candidateCellSet." <<
endl;
1204 candidateCellSet.
instance() = meshRefiner_.timeName();
1205 candidateCellSet.
write();
1207 candidateCells = candidateCellSet.
toc();
1214 meshRefiner_.meshCutter().consistentRefinement
1220 Info<<
"Determined cells to refine in = "
1221 <<
mesh.time().cpuTimeIncrement() <<
" s" <<
endl;
1224 label nCellsToRefine = cellsToRefine.
size();
1227 Info<<
"Selected for refinement : " << nCellsToRefine
1228 <<
" cells (out of " <<
mesh.globalData().nTotalCells()
1242 Info<<
"Stopping refining since too few cells selected."
1263 meshRefiner_.balanceAndRefine
1265 "interface cell refinement iteration " +
name(iter),
1274 meshRefiner_.refineAndBalance
1276 "interface cell refinement iteration " +
name(iter),
1292 const label nBufferLayers
1296 <<
"Removing mesh beyond surface intersections" <<
nl
1297 <<
"------------------------------------------" <<
nl
1307 meshRefiner_.splitMesh
1310 globalToMasterPatch_,
1311 globalToSlavePatch_,
1319 Pout<<
"Writing subsetted mesh to time "
1320 << meshRefiner_.timeName() <<
endl;
1326 meshRefinement::writeLevel()
1327 | meshRefinement::WRITEMESH
1329 mesh.time().path()/meshRefiner_.timeName()
1331 Pout<<
"Dumped mesh in = "
1332 <<
mesh.time().cpuTimeIncrement() <<
" s\n" <<
nl <<
endl;
1346 meshRefiner_.userFaceData().setSize(1);
1349 meshRefiner_.userFaceData()[0].first() = meshRefinement::REMOVE;
1350 meshRefiner_.userFaceData()[0].second() = createWithValues<labelList>
1354 meshRefiner_.intersectedFaces(),
1361 label overallMaxShellLevel = meshRefiner_.shells().maxLevel();
1364 for (iter = 0; iter < maxIter; iter++)
1367 <<
"Shell refinement iteration " << iter <<
nl
1368 <<
"----------------------------" <<
nl
1373 meshRefiner_.refineCandidates
1395 Pout<<
"Dumping " << candidateCells.
size()
1396 <<
" cells to cellSet candidateCellsFromShells." <<
endl;
1398 cellSet c(
mesh,
"candidateCellsFromShells", candidateCells);
1399 c.instance() = meshRefiner_.timeName();
1412 findIndices(meshRefiner_.userFaceData()[0].second(), 0)
1422 cellsToRefine = meshRefiner_.meshCutter().consistentSlowRefinement
1428 meshRefiner_.intersectedPoints()
1433 cellsToRefine = meshRefiner_.meshCutter().consistentSlowRefinement2
1441 Info<<
"Determined cells to refine in = "
1442 <<
mesh.time().cpuTimeIncrement() <<
" s" <<
endl;
1445 label nCellsToRefine = cellsToRefine.
size();
1448 Info<<
"Selected for internal refinement : " << nCellsToRefine
1449 <<
" cells (out of " <<
mesh.globalData().nTotalCells()
1458 iter >= overallMaxShellLevel
1463 Info<<
"Stopping refining since too few cells selected."
1483 meshRefiner_.balanceAndRefine
1485 "shell refinement iteration " +
name(iter),
1494 meshRefiner_.refineAndBalance
1496 "shell refinement iteration " +
name(iter),
1504 meshRefiner_.userFaceData().
clear();
1514 const bool handleSnapProblems,
1519 <<
"Splitting mesh at surface intersections" <<
nl
1520 <<
"---------------------------------------" <<
nl
1533 meshRefiner_.baffleAndSplitMesh
1545 globalToMasterPatch_,
1546 globalToSlavePatch_,
1553 if (!handleSnapProblems)
1555 meshRefiner_.mergeFreeStandingBaffles
1564 globalToMasterPatch_,
1565 globalToSlavePatch_,
1586 surfaceZonesInfo::getNamedSurfaces(meshRefiner_.surfaces().surfZones());
1590 namedSurfaces.
size()
1595 <<
"Introducing zones for interfaces" <<
nl
1596 <<
"--------------------------------" <<
nl
1616 Pout<<
"Writing zoned mesh to time "
1617 << meshRefiner_.timeName() <<
endl;
1623 meshRefinement::writeLevel()
1624 | meshRefinement::WRITEMESH
1626 mesh.time().path()/meshRefiner_.timeName()
1631 meshRefinement::checkCoupledFaceZones(
mesh);
1640 const bool handleSnapProblems,
1645 <<
"Handling cells with snap problems" <<
nl
1646 <<
"---------------------------------" <<
nl
1657 const scalarField& perpAngle = meshRefiner_.surfaces().perpendicularAngle();
1659 meshRefiner_.baffleAndSplitMesh
1671 globalToMasterPatch_,
1672 globalToSlavePatch_,
1679 meshRefiner_.mergeFreeStandingBaffles
1688 globalToMasterPatch_,
1689 globalToSlavePatch_,
1701 meshRefiner_.dupNonManifoldPoints();
1709 Info<<
"Detected unsplittable baffles : " << nCouples <<
endl;
1716 meshRefiner_.mergeBaffles(couples,
Map<label>(0));
1721 meshRefiner_.checkData();
1725 meshRefiner_.splitMeshRegions
1727 globalToMasterPatch_,
1728 globalToSlavePatch_,
1736 meshRefiner_.checkData();
1739 Info<<
"Merged free-standing baffles in = "
1740 <<
mesh.time().cpuTimeIncrement() <<
" s." <<
endl;
1745 Pout<<
"Writing handleProblemCells mesh to time "
1746 << meshRefiner_.timeName() <<
endl;
1752 meshRefinement::writeLevel()
1753 | meshRefinement::WRITEMESH
1755 mesh.time().path()/meshRefiner_.timeName()
1768 if (faceZoneToPatches.size())
1771 <<
"Adding patches for face zones" <<
nl
1772 <<
"-----------------------------" <<
nl
1776 <<
setw(6) <<
"Patch"
1777 <<
setw(20) <<
"Type"
1778 <<
setw(30) <<
"Name"
1779 <<
setw(30) <<
"FaceZone"
1780 <<
setw(10) <<
"FaceType"
1782 <<
setw(6) <<
"-----"
1783 <<
setw(20) <<
"----"
1784 <<
setw(30) <<
"----"
1785 <<
setw(30) <<
"--------"
1786 <<
setw(10) <<
"--------"
1794 const word& fzName = iter.key();
1801 const word& masterName = fzName;
1810 <<
setw(20) <<
mesh.boundaryMesh()[mpI].type()
1811 <<
setw(30) << masterName
1812 <<
setw(30) << fzName
1813 <<
setw(10) << surfaceZonesInfo::faceZoneTypeNames[fzType]
1821 <<
setw(20) <<
mesh.boundaryMesh()[slI].type()
1822 <<
setw(30) << slaveName
1823 <<
setw(30) << fzName
1824 <<
setw(10) << surfaceZonesInfo::faceZoneTypeNames[fzType]
1827 meshRefiner.
addFaceZone(fzName, masterName, slaveName, fzType);
1837 const bool geometricMerge,
1843 <<
"Merge refined boundary faces" <<
nl
1844 <<
"----------------------------" <<
nl
1851 meshRefiner_.mergePatchFacesUndo
1855 meshRefiner_.meshedPatches(),
1863 meshRefiner_.mergePatchFaces
1868 meshRefiner_.meshedPatches()
1874 meshRefiner_.checkData();
1881 meshRefiner_.checkData();
1891 const bool prepareForSnapping,
1892 const bool doMergePatchFaces,
1897 <<
"Refinement phase" <<
nl
1898 <<
"----------------" <<
nl
1971 refinementInterfaceRefine
1989 zonify(refineParams, zonesToFaceZone);
2003 const word& fzName = zonesToFaceZone[czNames];
2005 const word& masterName = fzName;
2010 addFaceZones(meshRefiner_, refineParams, faceZoneToPatches);
2014 splitAndMergeBaffles
2023 if (prepareForSnapping)
2029 if (Pstream::parRun())
2032 <<
"Doing final balancing" <<
nl
2033 <<
"---------------------" <<
nl
2039 meshRefiner_.balance