Error in logic for cell size function handling, giving wrong results.

This commit is contained in:
graham
2009-07-29 18:42:49 +01:00
parent 8e46fdf2d3
commit 002c0b4e2a
2 changed files with 15 additions and 36 deletions

View File

@ -154,29 +154,6 @@ Foam::cellSizeControlSurfaces::~cellSizeControlSurfaces()
{}
// * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * //
bool Foam::cellSizeControlSurfaces::samePriorityNext(label i) const
{
if (i == cellSizeFunctions_.size() - 1)
{
// Last element in the list, compare to default priority
return
cellSizeFunctions_[i].priority()
== defaultPriority_;
}
else
{
// Not the last element, compare to the next element in the list
return
cellSizeFunctions_[i].priority()
== cellSizeFunctions_[i + 1].priority();
}
}
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
Foam::scalar Foam::cellSizeControlSurfaces::cellSize
@ -188,26 +165,34 @@ Foam::scalar Foam::cellSizeControlSurfaces::cellSize
scalar sizeAccumulator = 0;
scalar numberOfFunctions = 0;
label 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 (!samePriorityNext(i))
{
return sizeAccumulator/numberOfFunctions;
}
}
}
sizeAccumulator += defaultCellSize_;
numberOfFunctions++;
if (previousPriority == defaultPriority_ || numberOfFunctions == 0)
{
sizeAccumulator += defaultCellSize_;
numberOfFunctions++;
}
return sizeAccumulator/numberOfFunctions;
}

View File

@ -82,12 +82,6 @@ class cellSizeControlSurfaces
// Private Member Functions
//- Helper function to decide whether to terminate searching
// cellSizeFunctions by determining if the next cellSizeFunction has
// the same priority, includes looking off the end of the
// cellSizeFunctions_ list at the defaultPriority_ value
bool samePriorityNext(label i) const;
//- Disallow default bitwise copy construct
cellSizeControlSurfaces(const cellSizeControlSurfaces&);