Commit 02881f62 authored by Mark Olesen's avatar Mark Olesen
Browse files

ENH: improve flexibility of haloToCell (#2130)

- add setter/getter methods for number of grow/shrink steps,
  which allows reuse of the same object.

- remove the lower input hard-limit of 1 step, to allow definition of
  a no-op filter.

- drop early exit from grow/shrink cycle (potential parallel issues).
parent 521a9e4d
......@@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2019 OpenCFD Ltd.
Copyright (C) 2019-2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
......@@ -69,6 +69,11 @@ Foam::topoSetSource::addToUsageTable Foam::haloToCell::usage_
void Foam::haloToCell::combine(topoSet& set, const bool add) const
{
if (steps_ < 1)
{
return; // Nothing to do
}
const cellList& cells = mesh_.cells();
const labelList& faceOwn = mesh_.faceOwner();
const labelList& faceNei = mesh_.faceNeighbour();
......@@ -153,10 +158,11 @@ void Foam::haloToCell::combine(topoSet& set, const bool add) const
current -= updates;
}
if (updates.none())
{
break;
}
// Could have early exit, but needs to be parallel-synchronized
// if (returnReduce(updates.none(), andOp<bool>()))
// {
// break;
// }
addOrDelete(set, updates, add);
}
......@@ -168,11 +174,11 @@ void Foam::haloToCell::combine(topoSet& set, const bool add) const
Foam::haloToCell::haloToCell
(
const polyMesh& mesh,
const label steps
const label nsteps
)
:
topoSetCellSource(mesh),
steps_(max(steps, 1))
steps_(nsteps)
{}
......@@ -198,6 +204,20 @@ Foam::haloToCell::haloToCell
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
Foam::label Foam::haloToCell::steps() const noexcept
{
return steps_;
}
Foam::label Foam::haloToCell::steps(const label nsteps) noexcept
{
label old(steps_);
steps_ = nsteps;
return old;
}
void Foam::haloToCell::applyToSet
(
const topoSetSource::setAction action,
......
......@@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2019-2020 OpenCFD Ltd.
Copyright (C) 2019-2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
......@@ -125,7 +125,7 @@ public:
// Constructors
//- Construct from components
explicit haloToCell(const polyMesh& mesh, const label steps=1);
explicit haloToCell(const polyMesh& mesh, const label nsteps=1);
//- Construct from dictionary
haloToCell(const polyMesh& mesh, const dictionary& dict);
......@@ -140,6 +140,13 @@ public:
// Member Functions
//- The number of steps to grow/shrink
label steps() const noexcept;
//- Set number of steps to grow/shrink, return the old value
label steps(const label nsteps) noexcept;
virtual void applyToSet
(
const topoSetSource::setAction action,
......
......@@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2018-2020 OpenCFD Ltd.
Copyright (C) 2018-2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
......@@ -68,6 +68,11 @@ Foam::topoSetSource::addToUsageTable Foam::nbrToCell::usage_
void Foam::nbrToCell::combine(topoSet& set, const bool add) const
{
if (minNbrs_ < 1)
{
return; // Nothing to do
}
const cellList& cells = mesh().cells();
const polyBoundaryMesh& patches = mesh_.boundaryMesh();
......
......@@ -59,7 +59,7 @@ Usage
type | Type name: cellSet | word | yes | -
action | Action applied on cells - see below | word | yes | -
source | Source name: nbrToCell | word | yes | -
neighbours | Maximum number of neighbour cells | label | yes | -
neighbours | Maximum number of neighbour cells | label | yes | -
\endtable
Options for the \c action entry:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment