Commit 188f4bd1 authored by Mark Olesen's avatar Mark Olesen Committed by Andrew Heather
Browse files

ENH: more flexible topoSetSource addOrDelete

parent 13169cf8
......@@ -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) 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)
......
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2017-2018 OpenCFD Ltd.
\\ / A nd | Copyright (C) 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);
}
......
......@@ -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);
}
......
......@@ -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)
......
......@@ -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)
......
......@@ -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);
}
}
}
......
......@@ -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) 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);
}
}
......
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2017-2018 OpenCFD Ltd.
\\ / A nd | Copyright (C) 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);
}
......
......@@ -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)
......
......@@ -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) 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:
......
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