ENH: more flexible topoSetSource addOrDelete

This commit is contained in:
Mark Olesen
2019-08-09 11:00:47 +02:00
parent 3fd5e53007
commit a5a9f65b95
10 changed files with 49 additions and 44 deletions

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2004-2010, 2018 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2004-2010, 2018-2019 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2011-2017 OpenFOAM Foundation
@ -82,10 +82,7 @@ void Foam::pointToCell::combine
{
const labelList& pCells = mesh_.pointCells()[pointi];
for (const label celli : pCells)
{
addOrDelete(set, celli, add);
}
addOrDelete(set, pCells, add);
}
}
else if (option_ == EDGE)

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2004-2011, 2017-2018 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2004-2011, 2017-2019 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2011-2016 OpenFOAM Foundation
@ -164,11 +164,7 @@ void Foam::surfaceToCell::combine(topoSet& set, const bool add) const
forAll(isInside, celli)
{
if (isInside[celli] && includeInside_)
{
addOrDelete(set, celli, add);
}
else if (!isInside[celli] && includeOutside_)
if (isInside[celli] ? includeInside_ : includeOutside_)
{
addOrDelete(set, celli, add);
}

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2018 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2018-2019 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2012-2017 OpenFOAM Foundation
@ -273,11 +273,7 @@ void Foam::targetVolumeToCell::combine(topoSet& set, const bool add) const
<< selectedVol << endl;
}
// Loop over selected cells only
for (const label celli : selected)
{
addOrDelete(set, celli, add);
}
addOrDelete(set, selected, add);
}

View File

@ -89,10 +89,7 @@ void Foam::cellToFace::combine
{
const labelList& cFaces = mesh_.cells()[celli];
for (const label facei : cFaces)
{
addOrDelete(set, facei, add);
}
addOrDelete(set, cFaces, add);
}
}
else if (option_ == BOTH)

View File

@ -99,10 +99,7 @@ void Foam::pointToFace::combine
{
const labelList& pFaces = mesh_.pointFaces()[pointi];
for (const label facei : pFaces)
{
addOrDelete(set, facei, add);
}
addOrDelete(set, pFaces, add);
}
}
else if (option_ == ALL)

View File

@ -81,10 +81,7 @@ void Foam::cellToPoint::combine
{
const face& f = mesh_.faces()[facei];
for (const label pointi : f)
{
addOrDelete(set, pointi, add);
}
addOrDelete(set, f, add);
}
}
}

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2004-2010, 2018 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2004-2010, 2018-2019 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2011-2017 OpenFOAM Foundation
@ -76,10 +76,7 @@ void Foam::faceToPoint::combine
{
const face& f = mesh_.faces()[facei];
for (const label pointi : f)
{
addOrDelete(set, pointi, add);
}
addOrDelete(set, f, add);
}
}

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2004-2010, 2017-2018 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2004-2010, 2017-2019 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2011-2016 OpenFOAM Foundation
@ -80,13 +80,7 @@ void Foam::surfaceToPoint::combine(topoSet& set, const bool add) const
forAll(pointInside, pointi)
{
bool isInside = pointInside[pointi];
if
(
(isInside && includeInside_)
|| (!isInside && includeOutside_)
)
if (pointInside[pointi] ? includeInside_ : includeOutside_)
{
addOrDelete(set, pointi, add);
}

View File

@ -27,6 +27,7 @@ License
#include "topoSetSource.H"
#include "polyMesh.H"
#include "bitSet.H"
#include "topoSet.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
@ -200,6 +201,30 @@ void Foam::topoSetSource::addOrDelete
}
void Foam::topoSetSource::addOrDelete
(
topoSet& set,
const bitSet& labels,
const bool add
) const
{
if (add)
{
for (const label id : labels)
{
set.set(id);
}
}
else
{
for (const label id : labels)
{
set.unset(id);
}
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::topoSetSource::topoSetSource(const polyMesh& mesh)

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2004-2010, 2018 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2004-2010, 2018-2019 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2011-2016 OpenFOAM Foundation
@ -54,8 +54,9 @@ SourceFiles
namespace Foam
{
// Forward declarations
// Forward Declarations
class polyMesh;
class bitSet;
class topoSet;
/*---------------------------------------------------------------------------*\
@ -154,6 +155,14 @@ protected:
const bool add
) const;
//- Add or delete labels from set. Add when 'add' is true
void addOrDelete
(
topoSet& set,
const bitSet& labels,
const bool add
) const;
private: