ENH: snappyHexMesh: express small regions. Fixes #2379

Extend selection of small cells to use absolute cell count
This commit is contained in:
mattijs 2022-02-24 09:41:21 +00:00
parent 5386dd56db
commit ff8518a89a
4 changed files with 18 additions and 5 deletions

View File

@ -480,6 +480,8 @@ castellatedMeshControls
// when generating meshes with faceZones as baffles or boundary
// faces.
//minCellFraction 0.001;
// Optional: same but in absolute number of cells. Default is 0.
//nMinCells 100;
}
// Settings for the snapping.

View File

@ -95,6 +95,7 @@ Foam::refinementParameters::refinementParameters
nErodeCellZone_(dict.getOrDefault<label>("nCellZoneErodeIter", 0)),
nFilterIter_(dict.getOrDefault<label>("nFilterIter", 2)),
minCellFraction_(dict.getOrDefault<scalar>("minCellFraction", 0)),
nMinCells_(dict.getOrDefault<label>("nMinCells", 0)),
dryRun_(dryRun)
{
point locationInMesh;

View File

@ -115,6 +115,8 @@ class refinementParameters
const scalar minCellFraction_;
const label nMinCells_;
const bool dryRun_;
@ -244,6 +246,13 @@ public:
return minCellFraction_;
}
//- When are disconnected regions small. Absolute number of cells
// in a zone or background. Default 0.
label nMinCells() const
{
return nMinCells_;
}
// Other

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2015 OpenFOAM Foundation
Copyright (C) 2015-2021 OpenCFD Ltd.
Copyright (C) 2015-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -3209,21 +3209,22 @@ void Foam::snappyRefineDriver::deleteSmallRegions
forAll(nCellsPerRegion, regioni)
{
const label zonei = regionToZone[regioni];
label& nRegionCells = nCellsPerRegion[regioni];
if
(
nCellsPerRegion[regioni]
< refineParams.minCellFraction()*nCellsPerZone[zonei]
nRegionCells < refineParams.minCellFraction()*nCellsPerZone[zonei]
|| nRegionCells < refineParams.nMinCells()
)
{
Info<< "Deleting region " << regioni
<< " (size " << nCellsPerRegion[regioni]
<< " (size " << nRegionCells
<< ") of zone size " << nCellsPerZone[zonei]
<< endl;
// Mark region to be deleted. 0 size (= global) should never
// occur.
nCellsPerRegion[regioni] = 0;
nRegionCells = 0;
}
}