mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: dynamicRefineFvMesh: #1203 base unrefinement on max, not min of surrounding cells
This commit is contained in:
@ -59,7 +59,15 @@ Foam::label Foam::dynamicRefineFvMesh::count
|
|||||||
{
|
{
|
||||||
n++;
|
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;
|
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::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)
|
forAll(pointCells(), pointI)
|
||||||
{
|
{
|
||||||
@ -671,7 +679,7 @@ Foam::dynamicRefineFvMesh::minCellField(const volScalarField& vFld) const
|
|||||||
|
|
||||||
forAll(pCells, i)
|
forAll(pCells, i)
|
||||||
{
|
{
|
||||||
pFld[pointI] = min(pFld[pointI], vFld[pCells[i]]);
|
pFld[pointI] = max(pFld[pointI], vFld[pCells[i]]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return pFld;
|
return pFld;
|
||||||
@ -774,10 +782,11 @@ Foam::labelList Foam::dynamicRefineFvMesh::selectRefineCells
|
|||||||
calculateProtectedCells(unrefineableCell);
|
calculateProtectedCells(unrefineableCell);
|
||||||
|
|
||||||
// Count current selection
|
// 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
|
// Collect all cells
|
||||||
DynamicList<label> candidates(nCells());
|
DynamicList<label> candidates(nLocalCandidates);
|
||||||
|
|
||||||
if (nCandidates < nTotToRefine)
|
if (nCandidates < nTotToRefine)
|
||||||
{
|
{
|
||||||
@ -1263,25 +1272,28 @@ bool Foam::dynamicRefineFvMesh::update()
|
|||||||
readScalar(refineDict.lookup("lowerRefineLevel"));
|
readScalar(refineDict.lookup("lowerRefineLevel"));
|
||||||
const scalar upperRefineLevel =
|
const scalar upperRefineLevel =
|
||||||
readScalar(refineDict.lookup("upperRefineLevel"));
|
readScalar(refineDict.lookup("upperRefineLevel"));
|
||||||
const scalar unrefineLevel =
|
const scalar unrefineLevel = refineDict.lookupOrDefault<scalar>
|
||||||
readScalar(refineDict.lookup("unrefineLevel"));
|
(
|
||||||
|
"unrefineLevel",
|
||||||
|
GREAT
|
||||||
|
);
|
||||||
const label nBufferLayers =
|
const label nBufferLayers =
|
||||||
readLabel(refineDict.lookup("nBufferLayers"));
|
readLabel(refineDict.lookup("nBufferLayers"));
|
||||||
|
|
||||||
// Cells marked for refinement or otherwise protected from unrefinement.
|
// Cells marked for refinement or otherwise protected from unrefinement.
|
||||||
PackedBoolList refineCell(nCells());
|
PackedBoolList refineCell(nCells());
|
||||||
|
|
||||||
|
// Determine candidates for refinement (looking at field only)
|
||||||
|
selectRefineCandidates
|
||||||
|
(
|
||||||
|
lowerRefineLevel,
|
||||||
|
upperRefineLevel,
|
||||||
|
vFld,
|
||||||
|
refineCell
|
||||||
|
);
|
||||||
|
|
||||||
if (globalData().nTotalCells() < maxCells)
|
if (globalData().nTotalCells() < maxCells)
|
||||||
{
|
{
|
||||||
// Determine candidates for refinement (looking at field only)
|
|
||||||
selectRefineCandidates
|
|
||||||
(
|
|
||||||
lowerRefineLevel,
|
|
||||||
upperRefineLevel,
|
|
||||||
vFld,
|
|
||||||
refineCell
|
|
||||||
);
|
|
||||||
|
|
||||||
// Select subset of candidates. Take into account max allowable
|
// Select subset of candidates. Take into account max allowable
|
||||||
// cells, refinement level, protected cells.
|
// cells, refinement level, protected cells.
|
||||||
labelList cellsToRefine
|
labelList cellsToRefine
|
||||||
@ -1352,7 +1364,7 @@ bool Foam::dynamicRefineFvMesh::update()
|
|||||||
(
|
(
|
||||||
unrefineLevel,
|
unrefineLevel,
|
||||||
refineCell,
|
refineCell,
|
||||||
minCellField(vFld)
|
maxCellField(vFld)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@ -37,8 +37,8 @@ Description
|
|||||||
// Refine field inbetween lower..upper
|
// Refine field inbetween lower..upper
|
||||||
lowerRefineLevel 0.001;
|
lowerRefineLevel 0.001;
|
||||||
upperRefineLevel 0.999;
|
upperRefineLevel 0.999;
|
||||||
// If value < unrefineLevel unrefine
|
// If value < unrefineLevel (default=GREAT) unrefine
|
||||||
unrefineLevel 10;
|
//unrefineLevel 10;
|
||||||
// Have slower than 2:1 refinement
|
// Have slower than 2:1 refinement
|
||||||
nBufferLayers 1;
|
nBufferLayers 1;
|
||||||
// Refine cells only up to maxRefinement levels
|
// Refine cells only up to maxRefinement levels
|
||||||
@ -79,7 +79,7 @@ namespace Foam
|
|||||||
{
|
{
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------*\
|
/*---------------------------------------------------------------------------*\
|
||||||
Class dynamicRefineFvMesh Declaration
|
Class dynamicRefineFvMesh Declaration
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
class dynamicRefineFvMesh
|
class dynamicRefineFvMesh
|
||||||
@ -139,8 +139,8 @@ protected:
|
|||||||
//- Get per cell max of connected point
|
//- Get per cell max of connected point
|
||||||
scalarField maxPointField(const scalarField&) const;
|
scalarField maxPointField(const scalarField&) const;
|
||||||
|
|
||||||
//- Get point min of connected cell
|
//- Get point max of connected cell
|
||||||
scalarField minCellField(const volScalarField&) const;
|
scalarField maxCellField(const volScalarField&) const;
|
||||||
|
|
||||||
scalarField cellToPoint(const scalarField& vFld) const;
|
scalarField cellToPoint(const scalarField& vFld) const;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user