ENH: dynamicRefineFvMesh: #1203 base unrefinement on max, not min of surrounding cells

This commit is contained in:
mattijs
2014-05-28 15:23:56 +01:00
committed by Andrew Heather
parent 2abf2ff49b
commit 4015a344cd
2 changed files with 35 additions and 23 deletions

View File

@ -59,7 +59,15 @@ Foam::label Foam::dynamicRefineFvMesh::count
{
n++;
}
// debug also serves to get-around Clang compiler trying to optimsie
// out this forAll loop under O3 optimisation
if (debug)
{
Info<< "n=" << n << endl;
}
}
return n;
}
@ -659,11 +667,11 @@ Foam::dynamicRefineFvMesh::maxPointField(const scalarField& pFld) const
}
// Get min of connected cell
// Get max of connected cell
Foam::scalarField
Foam::dynamicRefineFvMesh::minCellField(const volScalarField& vFld) const
Foam::dynamicRefineFvMesh::maxCellField(const volScalarField& vFld) const
{
scalarField pFld(nPoints(), GREAT);
scalarField pFld(nPoints(), -GREAT);
forAll(pointCells(), pointI)
{
@ -671,7 +679,7 @@ Foam::dynamicRefineFvMesh::minCellField(const volScalarField& vFld) const
forAll(pCells, i)
{
pFld[pointI] = min(pFld[pointI], vFld[pCells[i]]);
pFld[pointI] = max(pFld[pointI], vFld[pCells[i]]);
}
}
return pFld;
@ -774,10 +782,11 @@ Foam::labelList Foam::dynamicRefineFvMesh::selectRefineCells
calculateProtectedCells(unrefineableCell);
// Count current selection
label nCandidates = returnReduce(count(candidateCell, 1), sumOp<label>());
label nLocalCandidates = count(candidateCell, 1);
label nCandidates = returnReduce(nLocalCandidates, sumOp<label>());
// Collect all cells
DynamicList<label> candidates(nCells());
DynamicList<label> candidates(nLocalCandidates);
if (nCandidates < nTotToRefine)
{
@ -1263,16 +1272,17 @@ bool Foam::dynamicRefineFvMesh::update()
readScalar(refineDict.lookup("lowerRefineLevel"));
const scalar upperRefineLevel =
readScalar(refineDict.lookup("upperRefineLevel"));
const scalar unrefineLevel =
readScalar(refineDict.lookup("unrefineLevel"));
const scalar unrefineLevel = refineDict.lookupOrDefault<scalar>
(
"unrefineLevel",
GREAT
);
const label nBufferLayers =
readLabel(refineDict.lookup("nBufferLayers"));
// Cells marked for refinement or otherwise protected from unrefinement.
PackedBoolList refineCell(nCells());
if (globalData().nTotalCells() < maxCells)
{
// Determine candidates for refinement (looking at field only)
selectRefineCandidates
(
@ -1282,6 +1292,8 @@ bool Foam::dynamicRefineFvMesh::update()
refineCell
);
if (globalData().nTotalCells() < maxCells)
{
// Select subset of candidates. Take into account max allowable
// cells, refinement level, protected cells.
labelList cellsToRefine
@ -1352,7 +1364,7 @@ bool Foam::dynamicRefineFvMesh::update()
(
unrefineLevel,
refineCell,
minCellField(vFld)
maxCellField(vFld)
)
);

View File

@ -37,8 +37,8 @@ Description
// Refine field inbetween lower..upper
lowerRefineLevel 0.001;
upperRefineLevel 0.999;
// If value < unrefineLevel unrefine
unrefineLevel 10;
// If value < unrefineLevel (default=GREAT) unrefine
//unrefineLevel 10;
// Have slower than 2:1 refinement
nBufferLayers 1;
// Refine cells only up to maxRefinement levels
@ -139,8 +139,8 @@ protected:
//- Get per cell max of connected point
scalarField maxPointField(const scalarField&) const;
//- Get point min of connected cell
scalarField minCellField(const volScalarField&) const;
//- Get point max of connected cell
scalarField maxCellField(const volScalarField&) const;
scalarField cellToPoint(const scalarField& vFld) const;