mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: For cell size functions of equal priority, choose the smallest size, not average.
This commit is contained in:
@ -39,6 +39,7 @@ Foam::cellSizeControlSurfaces::cellSizeControlSurfaces
|
|||||||
cvMesh_(cvMesh),
|
cvMesh_(cvMesh),
|
||||||
allGeometry_(allGeometry),
|
allGeometry_(allGeometry),
|
||||||
surfaces_(),
|
surfaces_(),
|
||||||
|
cellSizeFunctions_(),
|
||||||
defaultCellSize_(readScalar(motionControlDict.lookup("defaultCellSize"))),
|
defaultCellSize_(readScalar(motionControlDict.lookup("defaultCellSize"))),
|
||||||
defaultPriority_
|
defaultPriority_
|
||||||
(
|
(
|
||||||
@ -161,44 +162,89 @@ Foam::scalar Foam::cellSizeControlSurfaces::cellSize
|
|||||||
bool isSurfacePoint
|
bool isSurfacePoint
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
scalar sizeAccumulator = 0;
|
|
||||||
scalar numberOfFunctions = 0;
|
|
||||||
|
|
||||||
label previousPriority = defaultPriority_;
|
// Regions requesting with the same priority take the average
|
||||||
|
|
||||||
|
// scalar sizeAccumulator = 0;
|
||||||
|
// scalar numberOfFunctions = 0;
|
||||||
|
|
||||||
|
// label previousPriority = defaultPriority_;
|
||||||
|
|
||||||
|
// if (cellSizeFunctions_.size())
|
||||||
|
// {
|
||||||
|
// previousPriority =
|
||||||
|
// cellSizeFunctions_[cellSizeFunctions_.size() - 1].priority();
|
||||||
|
|
||||||
|
// forAll(cellSizeFunctions_, i)
|
||||||
|
// {
|
||||||
|
// const cellSizeFunction& cSF = cellSizeFunctions_[i];
|
||||||
|
|
||||||
|
// if (cSF.priority() < previousPriority && numberOfFunctions > 0)
|
||||||
|
// {
|
||||||
|
// return sizeAccumulator/numberOfFunctions;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// scalar sizeI;
|
||||||
|
|
||||||
|
// if (cSF.cellSize(pt, sizeI, isSurfacePoint))
|
||||||
|
// {
|
||||||
|
// previousPriority = cSF.priority();
|
||||||
|
|
||||||
|
// sizeAccumulator += sizeI;
|
||||||
|
// numberOfFunctions++;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
// if (previousPriority == defaultPriority_ || numberOfFunctions == 0)
|
||||||
|
// {
|
||||||
|
// sizeAccumulator += defaultCellSize_;
|
||||||
|
// numberOfFunctions++;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// return sizeAccumulator/numberOfFunctions;
|
||||||
|
|
||||||
|
|
||||||
|
// Regions requesting with the same priority take the smallest
|
||||||
|
|
||||||
|
scalar minSize = defaultCellSize_;
|
||||||
|
|
||||||
if (cellSizeFunctions_.size())
|
if (cellSizeFunctions_.size())
|
||||||
{
|
{
|
||||||
previousPriority =
|
// Initialise to the last (lowest) priority
|
||||||
cellSizeFunctions_[cellSizeFunctions_.size() - 1].priority();
|
label previousPriority = cellSizeFunctions_.last().priority();
|
||||||
|
|
||||||
forAll(cellSizeFunctions_, i)
|
forAll(cellSizeFunctions_, i)
|
||||||
{
|
{
|
||||||
const cellSizeFunction& cSF = cellSizeFunctions_[i];
|
const cellSizeFunction& cSF = cellSizeFunctions_[i];
|
||||||
|
|
||||||
if (cSF.priority() < previousPriority && numberOfFunctions > 0)
|
if (cSF.priority() < previousPriority)
|
||||||
{
|
{
|
||||||
return sizeAccumulator/numberOfFunctions;
|
return minSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
scalar sizeI;
|
scalar sizeI;
|
||||||
|
|
||||||
if (cSF.cellSize(pt, sizeI, isSurfacePoint))
|
if (cSF.cellSize(pt, sizeI, isSurfacePoint))
|
||||||
{
|
{
|
||||||
previousPriority = cSF.priority();
|
if (cSF.priority() == previousPriority)
|
||||||
|
{
|
||||||
|
if (sizeI < minSize)
|
||||||
|
{
|
||||||
|
minSize = sizeI;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
minSize = sizeI;
|
||||||
|
}
|
||||||
|
|
||||||
sizeAccumulator += sizeI;
|
previousPriority = cSF.priority();
|
||||||
numberOfFunctions++;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (previousPriority == defaultPriority_ || numberOfFunctions == 0)
|
return minSize;
|
||||||
{
|
|
||||||
sizeAccumulator += defaultCellSize_;
|
|
||||||
numberOfFunctions++;
|
|
||||||
}
|
|
||||||
|
|
||||||
return sizeAccumulator/numberOfFunctions;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -237,7 +283,3 @@ Foam::scalarField Foam::cellSizeControlSurfaces::cellSize
|
|||||||
|
|
||||||
|
|
||||||
// ************************************************************************* //
|
// ************************************************************************* //
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -74,8 +74,7 @@ class cellSizeControlSurfaces
|
|||||||
scalar defaultCellSize_;
|
scalar defaultCellSize_;
|
||||||
|
|
||||||
//- Assigning a priority to all requests for cell sizes, the highest
|
//- Assigning a priority to all requests for cell sizes, the highest
|
||||||
// overrules. Regions requesting with the same priority take the
|
// overrules.
|
||||||
// average
|
|
||||||
label defaultPriority_;
|
label defaultPriority_;
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user