ENH: simpler topoSet handling of zone/set
- support construct faceZoneSet from faceSet (#3126) ENH: support unregistered loading of cell/face/point sets
This commit is contained in:
parent
68c5d90ad0
commit
85771c8985
@ -160,7 +160,7 @@ bool Foam::fvMeshSubsetProxy::correct(bool verbose)
|
||||
Info<< "Subsetting mesh based on cellSet " << name_ << endl;
|
||||
}
|
||||
|
||||
cellSet cset(baseMesh_, name_);
|
||||
cellSet cset(baseMesh_, name_, IOobject::NO_REGISTER);
|
||||
|
||||
selectedCells.resize(nCells);
|
||||
for (const label idx : cset)
|
||||
|
@ -114,7 +114,7 @@ void Foam::cellToCell::applyToSet
|
||||
}
|
||||
else
|
||||
{
|
||||
cellSet loadedSet(mesh_, setName);
|
||||
cellSet loadedSet(mesh_, setName, IOobject::NO_REGISTER);
|
||||
set.addSet(loadedSet);
|
||||
}
|
||||
}
|
||||
@ -136,7 +136,7 @@ void Foam::cellToCell::applyToSet
|
||||
}
|
||||
else
|
||||
{
|
||||
cellSet loadedSet(mesh_, setName);
|
||||
cellSet loadedSet(mesh_, setName, IOobject::NO_REGISTER);
|
||||
set.subtractSet(loadedSet);
|
||||
}
|
||||
}
|
||||
|
@ -146,8 +146,7 @@ void Foam::faceToCell::combine
|
||||
else
|
||||
{
|
||||
// Load the set
|
||||
faceSet loadedSet(mesh_, setName);
|
||||
|
||||
faceSet loadedSet(mesh_, setName, IOobject::NO_REGISTER);
|
||||
const labelHashSet& faceLabels = loadedSet;
|
||||
|
||||
combineImpl(set, add, faceLabels);
|
||||
|
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2019-2022 OpenCFD Ltd.
|
||||
Copyright (C) 2019-2024 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -83,9 +83,11 @@ void Foam::haloToCell::combine(topoSet& set, const bool add) const
|
||||
// The starting set of cells
|
||||
bitSet current(cells.size());
|
||||
|
||||
if (isA<topoBitSet>(set))
|
||||
const auto* topoBitsPtr = isA<topoBitSet>(set);
|
||||
|
||||
if (topoBitsPtr)
|
||||
{
|
||||
current |= refCast<const topoBitSet>(set).addressing();
|
||||
current |= topoBitsPtr->addressing();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -126,8 +126,7 @@ void Foam::pointToCell::combine
|
||||
else
|
||||
{
|
||||
// Load the set
|
||||
pointSet loadedSet(mesh_, setName);
|
||||
|
||||
pointSet loadedSet(mesh_, setName, IOobject::NO_REGISTER);
|
||||
const labelHashSet& pointLabels = loadedSet;
|
||||
|
||||
combineImpl(set, add, pointLabels);
|
||||
|
@ -351,8 +351,7 @@ void Foam::regionToCell::combine(topoSet& set, const bool add) const
|
||||
if (isZone_)
|
||||
{
|
||||
Info<< " Using cellZone " << setName_
|
||||
<< " to delimit search region."
|
||||
<< endl;
|
||||
<< " to delimit search region." << nl;
|
||||
|
||||
selectedCell = false;
|
||||
for (const label celli : mesh_.cellZones()[setName_])
|
||||
@ -363,10 +362,9 @@ void Foam::regionToCell::combine(topoSet& set, const bool add) const
|
||||
else
|
||||
{
|
||||
Info<< " Loading cellSet " << setName_
|
||||
<< " to delimit search region."
|
||||
<< endl;
|
||||
<< " to delimit search region." << nl;
|
||||
|
||||
cellSet subSet(mesh_, setName_);
|
||||
cellSet subSet(mesh_, setName_, IOobject::NO_REGISTER);
|
||||
|
||||
selectedCell = false;
|
||||
for (const label celli : subSet)
|
||||
@ -428,14 +426,14 @@ Foam::regionToCell::regionToCell
|
||||
),
|
||||
nErode_(dict.getCheckOrDefault<label>("nErode", 0, labelMinMax::ge(0)))
|
||||
{
|
||||
// A single set or zone only!
|
||||
if (dict.readIfPresent("set", setName_))
|
||||
// A single "set" or "zone" only
|
||||
if (!dict.readIfPresent("set", setName_))
|
||||
{
|
||||
isZone_ = false;
|
||||
}
|
||||
else if (dict.readIfPresent("zone", setName_))
|
||||
{
|
||||
isZone_ = true;
|
||||
// Optional entry
|
||||
if (dict.readIfPresent("zone", setName_))
|
||||
{
|
||||
isZone_ = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -73,7 +73,7 @@ Usage
|
||||
source | Source name: regionToCell | word | yes | -
|
||||
insidePoints | Coordinate(s) that is inside connected region <!--
|
||||
--> | vectorList | yes | -
|
||||
set | Name of cellSet giving mesh subset | word | no | none
|
||||
set / zone | Name of cellSet / zone giving mesh subset | word | no | -
|
||||
nErode | Number of cell layers to erode mesh to detect holes <!--
|
||||
--> in the mesh - set to 0 if not used | label | no | 0
|
||||
\endtable
|
||||
|
@ -133,13 +133,13 @@ void Foam::targetVolumeToCell::combine(topoSet& set, const bool add) const
|
||||
<< maskSetName_ << endl;
|
||||
}
|
||||
|
||||
maskSet = false;
|
||||
cellSet subset(mesh_, maskSetName_);
|
||||
|
||||
cellSet subset(mesh_, maskSetName_, IOobject::NO_REGISTER);
|
||||
const labelHashSet& cellLabels = subset;
|
||||
|
||||
maskSet = false;
|
||||
maskSet.setMany(cellLabels.begin(), cellLabels.end());
|
||||
|
||||
nTotCells = returnReduce(subset.size(), sumOp<label>());
|
||||
nTotCells = returnReduce(cellLabels.size(), sumOp<label>());
|
||||
}
|
||||
|
||||
|
||||
|
@ -114,12 +114,12 @@ void Foam::setToCellZone::applyToSet
|
||||
}
|
||||
|
||||
// Load the sets
|
||||
cellSet fSet(mesh_, setName_);
|
||||
cellSet loadedSet(mesh_, setName_, IOobject::NO_REGISTER);
|
||||
|
||||
// Start off from copy
|
||||
DynamicList<label> newAddressing(zoneSet.addressing());
|
||||
|
||||
for (const label celli : fSet)
|
||||
for (const label celli : loadedSet)
|
||||
{
|
||||
if (!zoneSet.found(celli))
|
||||
{
|
||||
@ -139,7 +139,7 @@ void Foam::setToCellZone::applyToSet
|
||||
}
|
||||
|
||||
// Load the set
|
||||
cellSet loadedSet(mesh_, setName_);
|
||||
cellSet loadedSet(mesh_, setName_, IOobject::NO_REGISTER);
|
||||
|
||||
// Start off empty
|
||||
DynamicList<label> newAddressing(zoneSet.addressing().size());
|
||||
|
@ -221,11 +221,11 @@ void Foam::cellToFace::combine
|
||||
// Load the set
|
||||
if (!exists(mesh_.time().path()/topoSet::localPath(mesh_, setName)))
|
||||
{
|
||||
SeriousError<< "Cannot load set "
|
||||
<< setName << endl;
|
||||
SeriousError
|
||||
<< "Cannot load set " << setName << endl;
|
||||
}
|
||||
|
||||
cellSet loadedSet(mesh_, setName);
|
||||
cellSet loadedSet(mesh_, setName, IOobject::NO_REGISTER);
|
||||
const labelHashSet& cellLabels = loadedSet;
|
||||
|
||||
combineImpl(set, add, cellLabels);
|
||||
|
@ -114,7 +114,7 @@ void Foam::faceToFace::applyToSet
|
||||
}
|
||||
else
|
||||
{
|
||||
faceSet loadedSet(mesh_, setName);
|
||||
faceSet loadedSet(mesh_, setName, IOobject::NO_REGISTER);
|
||||
|
||||
set.addSet(loadedSet);
|
||||
}
|
||||
@ -137,7 +137,7 @@ void Foam::faceToFace::applyToSet
|
||||
}
|
||||
else
|
||||
{
|
||||
faceSet loadedSet(mesh_, setName);
|
||||
faceSet loadedSet(mesh_, setName, IOobject::NO_REGISTER);
|
||||
|
||||
set.subtractSet(loadedSet);
|
||||
}
|
||||
|
@ -1148,7 +1148,7 @@ void Foam::holeToFace::applyToSet
|
||||
bitSet isBlockedFace(mesh_.nFaces());
|
||||
for (const word& setName : blockedFaceNames_)
|
||||
{
|
||||
const faceSet loadedSet(mesh_, setName);
|
||||
faceSet loadedSet(mesh_, setName, IOobject::NO_REGISTER);
|
||||
isBlockedFace.setMany(loadedSet.begin(), loadedSet.end());
|
||||
}
|
||||
|
||||
@ -1158,7 +1158,7 @@ void Foam::holeToFace::applyToSet
|
||||
{
|
||||
for (const word& setName : blockedCellNames_)
|
||||
{
|
||||
const cellSet loadedSet(mesh_, setName);
|
||||
cellSet loadedSet(mesh_, setName, IOobject::NO_REGISTER);
|
||||
isCandidateCell.setMany(loadedSet.begin(), loadedSet.end());
|
||||
}
|
||||
}
|
||||
|
@ -172,8 +172,7 @@ void Foam::pointToFace::combine
|
||||
else
|
||||
{
|
||||
// Load the set
|
||||
pointSet loadedSet(mesh_, setName);
|
||||
|
||||
pointSet loadedSet(mesh_, setName, IOobject::NO_REGISTER);
|
||||
const labelHashSet& pointLabels = loadedSet;
|
||||
|
||||
combineImpl(set, add, pointLabels);
|
||||
|
@ -146,7 +146,7 @@ void Foam::regionToFace::combine
|
||||
if (verbose_)
|
||||
{
|
||||
Info<< " Loading subset " << setName_
|
||||
<< " to delimit search region." << endl;
|
||||
<< " to delimit search region." << nl;
|
||||
}
|
||||
|
||||
indirectPrimitivePatch patch
|
||||
@ -236,12 +236,10 @@ Foam::regionToFace::regionToFace
|
||||
isZone_(false),
|
||||
nearPoint_(dict.get<point>("nearPoint"))
|
||||
{
|
||||
if (dict.readIfPresent("set", setName_))
|
||||
{
|
||||
isZone_ = false;
|
||||
}
|
||||
else
|
||||
// A single "set" or "zone" only
|
||||
if (!dict.readIfPresent("set", setName_))
|
||||
{
|
||||
// Mandatory entry
|
||||
dict.readEntry("zone", setName_);
|
||||
isZone_ = true;
|
||||
}
|
||||
@ -285,7 +283,7 @@ void Foam::regionToFace::applyToSet
|
||||
}
|
||||
else
|
||||
{
|
||||
faceSet subSet(mesh_, setName_);
|
||||
faceSet subSet(mesh_, setName_, IOobject::NO_REGISTER);
|
||||
combine(set, true, subSet.sortedToc());
|
||||
}
|
||||
}
|
||||
@ -305,7 +303,7 @@ void Foam::regionToFace::applyToSet
|
||||
}
|
||||
else
|
||||
{
|
||||
faceSet subSet(mesh_, setName_);
|
||||
faceSet subSet(mesh_, setName_, IOobject::NO_REGISTER);
|
||||
combine(set, false, subSet.sortedToc());
|
||||
}
|
||||
}
|
||||
|
@ -61,7 +61,7 @@ Usage
|
||||
type | Type name: faceSet | word | yes | -
|
||||
action | Action applied on faces - see below | word | yes | -
|
||||
source | Source name: regionToFace | word | yes | -
|
||||
set | Name of faceSet restricting search | word | yes | -
|
||||
set / zone | Name of faceSet / zone restricting search | word | yes | -
|
||||
nearPoint | The point on/near to the region | vector | yes | -
|
||||
\endtable
|
||||
|
||||
@ -81,8 +81,8 @@ SourceFiles
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef regionToFace_H
|
||||
#define regionToFace_H
|
||||
#ifndef Foam_regionToFace_H
|
||||
#define Foam_regionToFace_H
|
||||
|
||||
#include "topoSetFaceSource.H"
|
||||
#include "indirectPrimitivePatch.H"
|
||||
|
@ -230,7 +230,7 @@ void Foam::cellToFaceZone::applyToSet
|
||||
else
|
||||
{
|
||||
// Load the sets
|
||||
const cellSet loadedSet(mesh_, setName);
|
||||
cellSet loadedSet(mesh_, setName, IOobject::NO_REGISTER);
|
||||
whichCells.setMany(loadedSet.begin(), loadedSet.end());
|
||||
}
|
||||
|
||||
@ -276,7 +276,7 @@ void Foam::cellToFaceZone::applyToSet
|
||||
else
|
||||
{
|
||||
// Load the sets
|
||||
const cellSet loadedSet(mesh_, setName);
|
||||
cellSet loadedSet(mesh_, setName, IOobject::NO_REGISTER);
|
||||
whichCells.setMany(loadedSet.begin(), loadedSet.end());
|
||||
}
|
||||
// Select outside faces
|
||||
|
@ -128,8 +128,8 @@ void Foam::setAndNormalToFaceZone::applyToSet
|
||||
}
|
||||
|
||||
// Load the sets
|
||||
faceSet loadedSet(mesh_, setName_);
|
||||
labelHashSet& faceIds = loadedSet;
|
||||
faceSet loadedSet(mesh_, setName_, IOobject::NO_REGISTER);
|
||||
const labelHashSet& faceLabels = loadedSet;
|
||||
|
||||
// Start off from copy
|
||||
DynamicList<label> newAddressing(zoneSet.addressing());
|
||||
@ -138,7 +138,7 @@ void Foam::setAndNormalToFaceZone::applyToSet
|
||||
const faceList& faces = mesh_.faces();
|
||||
const pointField& points = mesh_.points();
|
||||
|
||||
for (const label facei : faceIds)
|
||||
for (const label facei : faceLabels)
|
||||
{
|
||||
if (!zoneSet.found(facei))
|
||||
{
|
||||
@ -169,7 +169,7 @@ void Foam::setAndNormalToFaceZone::applyToSet
|
||||
}
|
||||
|
||||
// Load the set
|
||||
faceSet loadedSet(mesh_, setName_);
|
||||
faceSet loadedSet(mesh_, setName_, IOobject::NO_REGISTER);
|
||||
|
||||
// Start off empty
|
||||
DynamicList<label> newAddressing(zoneSet.addressing().size());
|
||||
|
@ -122,7 +122,7 @@ void Foam::setToFaceZone::applyToSet
|
||||
}
|
||||
|
||||
// Load the sets
|
||||
faceSet loadedSet(mesh_, setName_);
|
||||
faceSet loadedSet(mesh_, setName_, IOobject::NO_REGISTER);
|
||||
const labelHashSet& faceLabels = loadedSet;
|
||||
|
||||
// Start off from copy
|
||||
@ -151,7 +151,7 @@ void Foam::setToFaceZone::applyToSet
|
||||
}
|
||||
|
||||
// Load the set
|
||||
faceSet loadedSet(mesh_, setName_);
|
||||
faceSet loadedSet(mesh_, setName_, IOobject::NO_REGISTER);
|
||||
|
||||
// Start off empty
|
||||
DynamicList<label> newAddressing(zoneSet.addressing().size());
|
||||
|
@ -135,8 +135,8 @@ void Foam::setsToFaceZone::applyToSet
|
||||
}
|
||||
|
||||
// Load the sets
|
||||
faceSet fSet(mesh_, faceSetName_);
|
||||
cellSet cSet(mesh_, cellSetName_);
|
||||
faceSet fSet(mesh_, faceSetName_, IOobject::NO_REGISTER);
|
||||
cellSet cSet(mesh_, cellSetName_, IOobject::NO_REGISTER);
|
||||
|
||||
// Start off from copy
|
||||
DynamicList<label> newAddressing(zoneSet.addressing());
|
||||
|
@ -70,7 +70,7 @@ void Foam::cellToPoint::combineImpl
|
||||
const Selector& cellLabels
|
||||
) const
|
||||
{
|
||||
// Add all point from cells in loadedSet
|
||||
// Add all points from given cells
|
||||
for (const label celli : cellLabels)
|
||||
{
|
||||
const labelList& cFaces = mesh_.cells()[celli];
|
||||
@ -101,8 +101,7 @@ void Foam::cellToPoint::combine
|
||||
else
|
||||
{
|
||||
// Load the set
|
||||
cellSet loadedSet(mesh_, setName);
|
||||
|
||||
cellSet loadedSet(mesh_, setName, IOobject::NO_REGISTER);
|
||||
const labelHashSet& cellLabels = loadedSet;
|
||||
|
||||
combineImpl(set, add, cellLabels);
|
||||
|
@ -72,7 +72,7 @@ void Foam::faceToPoint::combine
|
||||
{
|
||||
const auto& faceLabels = mesh_.faceZones()[setName].addressing();
|
||||
|
||||
// Add all points from faces in loadedSet
|
||||
// Add all points from given faces
|
||||
for (const label facei : faceLabels)
|
||||
{
|
||||
const face& f = mesh_.faces()[facei];
|
||||
@ -83,10 +83,10 @@ void Foam::faceToPoint::combine
|
||||
else
|
||||
{
|
||||
// Load the set
|
||||
faceSet loadedSet(mesh_, setName);
|
||||
faceSet loadedSet(mesh_, setName, IOobject::NO_REGISTER);
|
||||
const labelHashSet& faceLabels = loadedSet;
|
||||
|
||||
// Add all points from faces in loadedSet
|
||||
// Add all points from given faces
|
||||
for (const label facei : faceLabels)
|
||||
{
|
||||
const face& f = mesh_.faces()[facei];
|
||||
|
@ -114,7 +114,7 @@ void Foam::pointToPoint::applyToSet
|
||||
}
|
||||
else
|
||||
{
|
||||
pointSet loadedSet(mesh_, setName);
|
||||
pointSet loadedSet(mesh_, setName, IOobject::NO_REGISTER);
|
||||
|
||||
set.addSet(loadedSet);
|
||||
}
|
||||
@ -137,7 +137,7 @@ void Foam::pointToPoint::applyToSet
|
||||
}
|
||||
else
|
||||
{
|
||||
pointSet loadedSet(mesh_, setName);
|
||||
pointSet loadedSet(mesh_, setName, IOobject::NO_REGISTER);
|
||||
|
||||
set.subtractSet(loadedSet);
|
||||
}
|
||||
|
@ -114,7 +114,7 @@ void Foam::setToPointZone::applyToSet
|
||||
}
|
||||
|
||||
// Load the set
|
||||
pointSet loadedSet(mesh_, setName_);
|
||||
pointSet loadedSet(mesh_, setName_, IOobject::NO_REGISTER);
|
||||
const labelHashSet& pointLabels = loadedSet;
|
||||
|
||||
// Start off from copy
|
||||
@ -140,7 +140,7 @@ void Foam::setToPointZone::applyToSet
|
||||
}
|
||||
|
||||
// Load the set
|
||||
pointSet loadedSet(mesh_, setName_);
|
||||
pointSet loadedSet(mesh_, setName_, IOobject::NO_REGISTER);
|
||||
|
||||
// Start off empty
|
||||
DynamicList<label> newAddressing(zoneSet.addressing().size());
|
||||
|
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2018-2022 OpenCFD Ltd.
|
||||
Copyright (C) 2018-2024 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -34,18 +34,12 @@ License
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
defineTypeNameAndDebug(cellBitSet, 0);
|
||||
defineTypeName(cellBitSet);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::cellBitSet::cellBitSet(const polyMesh& mesh)
|
||||
:
|
||||
cellBitSet(mesh, false)
|
||||
{}
|
||||
|
||||
|
||||
Foam::cellBitSet::cellBitSet(const polyMesh& mesh, const bool val)
|
||||
:
|
||||
topoBitSet(mesh, "cellBitSet", mesh.nCells(), val)
|
||||
|
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2018-2022 OpenCFD Ltd.
|
||||
Copyright (C) 2018-2024 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -96,16 +96,14 @@ class cellBitSet
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("cellBitSet");
|
||||
TypeNameNoDebug("cellBitSet");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct with nCells elements, all elements unset
|
||||
explicit cellBitSet(const polyMesh& mesh);
|
||||
|
||||
//- Construct with nCells elements, using initial val
|
||||
cellBitSet(const polyMesh& mesh, const bool val);
|
||||
//- Construct with nCells elements,
|
||||
//- all elements unset or initial value
|
||||
explicit cellBitSet(const polyMesh& mesh, const bool val = false);
|
||||
|
||||
//- Copy construct from bitset, resizing to nCells elements as required
|
||||
cellBitSet(const polyMesh& mesh, const bitSet& bits);
|
||||
|
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011 OpenFOAM Foundation
|
||||
Copyright (C) 2016-2022 OpenCFD Ltd.
|
||||
Copyright (C) 2016-2024 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -37,11 +37,10 @@ License
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
defineTypeNameAndDebug(cellSet, 0);
|
||||
|
||||
addToRunTimeSelectionTable(topoSet, cellSet, word);
|
||||
addToRunTimeSelectionTable(topoSet, cellSet, size);
|
||||
addToRunTimeSelectionTable(topoSet, cellSet, set);
|
||||
defineTypeName(cellSet);
|
||||
addToRunTimeSelectionTable(topoSet, cellSet, word);
|
||||
addToRunTimeSelectionTable(topoSet, cellSet, size);
|
||||
addToRunTimeSelectionTable(topoSet, cellSet, set);
|
||||
}
|
||||
|
||||
|
||||
@ -53,18 +52,24 @@ Foam::cellSet::cellSet(const IOobject& io)
|
||||
{}
|
||||
|
||||
|
||||
Foam::cellSet::cellSet(const IOobject& io, const Foam::zero)
|
||||
:
|
||||
topoSet(io, Foam::zero{})
|
||||
{}
|
||||
|
||||
|
||||
Foam::cellSet::cellSet
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
const word& name,
|
||||
IOobjectOption::readOption rOpt,
|
||||
IOobjectOption::writeOption wOpt
|
||||
IOobjectOption::writeOption wOpt,
|
||||
IOobjectOption::registerOption reg
|
||||
)
|
||||
:
|
||||
topoSet(mesh, typeName, name, rOpt, wOpt)
|
||||
topoSet(mesh, typeName, name, rOpt, wOpt, reg)
|
||||
{
|
||||
// Make sure set within valid range
|
||||
check(mesh.nCells());
|
||||
check(mesh.nCells()); // Valid range?
|
||||
}
|
||||
|
||||
|
||||
@ -72,11 +77,11 @@ Foam::cellSet::cellSet
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
const word& name,
|
||||
const label size,
|
||||
const label initialCapacity,
|
||||
IOobjectOption::writeOption wOpt
|
||||
)
|
||||
:
|
||||
topoSet(mesh, name, size, wOpt)
|
||||
topoSet(mesh, name, initialCapacity, wOpt)
|
||||
{}
|
||||
|
||||
|
||||
@ -149,14 +154,14 @@ Foam::cellSet::cellSet
|
||||
(
|
||||
const Time& runTime,
|
||||
const word& name,
|
||||
const label size,
|
||||
const label initialCapacity,
|
||||
IOobjectOption::writeOption wOpt
|
||||
)
|
||||
:
|
||||
topoSet
|
||||
(
|
||||
findIOobject(runTime, name, IOobject::NO_READ, wOpt),
|
||||
size
|
||||
initialCapacity
|
||||
)
|
||||
{}
|
||||
|
||||
@ -177,6 +182,28 @@ Foam::cellSet::cellSet
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
|
||||
|
||||
Foam::labelHashSet Foam::cellSet::readContents
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
const word& name
|
||||
)
|
||||
{
|
||||
cellSet reader
|
||||
(
|
||||
topoSet::findIOobject(mesh, name, IOobjectOption::NO_REGISTER),
|
||||
Foam::zero{}
|
||||
);
|
||||
|
||||
labelHashSet labels;
|
||||
reader.readIOcontents(typeName, labels);
|
||||
reader.checkLabels(labels, mesh.nCells()); // Valid range?
|
||||
|
||||
return labels;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
Foam::label Foam::cellSet::maxSize(const polyMesh& mesh) const
|
||||
|
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011 OpenFOAM Foundation
|
||||
Copyright (C) 2016-2022 OpenCFD Ltd.
|
||||
Copyright (C) 2016-2024 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -62,7 +62,7 @@ class cellSet
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("cellSet");
|
||||
TypeNameNoDebug("cellSet");
|
||||
|
||||
|
||||
// Constructors
|
||||
@ -70,25 +70,43 @@ public:
|
||||
//- Construct from IOobject. No checking.
|
||||
explicit cellSet(const IOobject& io);
|
||||
|
||||
//- Construct from polyMesh and name. Checks for valid cell ids.
|
||||
//- Construct empty (no-read) with IOobject information
|
||||
cellSet(const IOobject& io, const Foam::zero);
|
||||
|
||||
//- Construct from polyMesh (registry) and name.
|
||||
//- Checks for valid cell ids.
|
||||
cellSet
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
const word& name,
|
||||
IOobjectOption::readOption rOpt = IOobjectOption::MUST_READ,
|
||||
IOobjectOption::writeOption wOpt = IOobjectOption::NO_WRITE
|
||||
IOobjectOption::writeOption wOpt = IOobjectOption::NO_WRITE,
|
||||
IOobjectOption::registerOption reg = IOobjectOption::LEGACY_REGISTER
|
||||
);
|
||||
|
||||
//- Construct empty with initial size for labelHashSet
|
||||
//- Construct from polyMesh (registry), name and registration option
|
||||
cellSet
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
const word& name,
|
||||
const label size,
|
||||
IOobjectOption::registerOption reg,
|
||||
IOobjectOption::readOption rOpt = IOobjectOption::MUST_READ,
|
||||
IOobjectOption::writeOption wOpt = IOobjectOption::NO_WRITE
|
||||
)
|
||||
:
|
||||
cellSet(mesh, name, rOpt, wOpt, reg)
|
||||
{}
|
||||
|
||||
//- Construct empty (no-read) with initial labelHashSet capacity
|
||||
cellSet
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
const word& name,
|
||||
const label initialCapacity,
|
||||
IOobjectOption::writeOption wOpt = IOobjectOption::NO_WRITE
|
||||
);
|
||||
|
||||
//- Construct from existing set
|
||||
//- Copy construct (no-read) from existing set
|
||||
cellSet
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
@ -97,7 +115,8 @@ public:
|
||||
IOobjectOption::writeOption wOpt = IOobjectOption::NO_WRITE
|
||||
);
|
||||
|
||||
//- Construct (no-read) with copy of labelHashSet
|
||||
//- Copy construct (no-read) from labelHashSet,
|
||||
//- with search for IOobject instance.
|
||||
cellSet
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
@ -106,7 +125,8 @@ public:
|
||||
IOobjectOption::writeOption wOpt = IOobjectOption::NO_WRITE
|
||||
);
|
||||
|
||||
//- Construct (no-read) with moving labelHashSet
|
||||
//- Move construct (no-read) from labelHashSet,
|
||||
//- with search for IOobject instance.
|
||||
cellSet
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
@ -115,7 +135,8 @@ public:
|
||||
IOobjectOption::writeOption wOpt = IOobjectOption::NO_WRITE
|
||||
);
|
||||
|
||||
//- Construct (no-read) with copy labels
|
||||
//- Copy construct (no-read) from labels,
|
||||
//- with search for IOobject instance.
|
||||
cellSet
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
@ -125,34 +146,46 @@ public:
|
||||
);
|
||||
|
||||
|
||||
// Used for tetMesh cellSet only.
|
||||
//- Construct from objectRegistry and name.
|
||||
//- Used for tetMesh cellSet only.
|
||||
cellSet
|
||||
(
|
||||
const Time&,
|
||||
const word& name,
|
||||
IOobjectOption::readOption rOpt = IOobjectOption::MUST_READ,
|
||||
IOobjectOption::writeOption wOpt = IOobjectOption::NO_WRITE
|
||||
);
|
||||
|
||||
//- Construct from objectRegistry and name.
|
||||
cellSet
|
||||
(
|
||||
const Time&,
|
||||
const word& name,
|
||||
IOobjectOption::readOption rOpt = IOobjectOption::MUST_READ,
|
||||
IOobjectOption::writeOption wOpt = IOobjectOption::NO_WRITE
|
||||
);
|
||||
//- Construct empty (no-read) with initial labelHashSet capacity
|
||||
//- from objectRegistry.
|
||||
//- Used for tetMesh cellSet only.
|
||||
cellSet
|
||||
(
|
||||
const Time&,
|
||||
const word& name,
|
||||
const label initialCapacity,
|
||||
IOobjectOption::writeOption wOpt = IOobjectOption::NO_WRITE
|
||||
);
|
||||
|
||||
//- Construct empty from objectRegistry.
|
||||
cellSet
|
||||
(
|
||||
const Time&,
|
||||
const word& name,
|
||||
const label size,
|
||||
IOobjectOption::writeOption wOpt = IOobjectOption::NO_WRITE
|
||||
);
|
||||
//- Copy construct (no-read) from labelHashSet.
|
||||
//- Used for tetMesh cellSet only.
|
||||
cellSet
|
||||
(
|
||||
const Time&,
|
||||
const word& name,
|
||||
const labelHashSet& labels,
|
||||
IOobjectOption::writeOption wOpt = IOobjectOption::NO_WRITE
|
||||
);
|
||||
|
||||
//- Construct from labelHashSet
|
||||
cellSet
|
||||
(
|
||||
const Time&,
|
||||
const word& name,
|
||||
const labelHashSet& labels,
|
||||
IOobjectOption::writeOption wOpt = IOobjectOption::NO_WRITE
|
||||
);
|
||||
|
||||
// Factory Methods
|
||||
|
||||
//- Read and return contents. Intermediate IOobject is not registered
|
||||
static labelHashSet readContents
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
const word& name
|
||||
);
|
||||
|
||||
|
||||
//- Destructor
|
||||
|
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2017 OpenFOAM Foundation
|
||||
Copyright (C) 2018-2022,2024 OpenCFD Ltd.
|
||||
Copyright (C) 2018-2024 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -36,18 +36,18 @@ License
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
defineTypeNameAndDebug(cellZoneSet, 0);
|
||||
defineTypeName(cellZoneSet);
|
||||
addToRunTimeSelectionTable(topoSet, cellZoneSet, word);
|
||||
addToRunTimeSelectionTable(topoSet, cellZoneSet, size);
|
||||
addToRunTimeSelectionTable(topoSet, cellZoneSet, set);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
void Foam::cellZoneSet::updateSet()
|
||||
{
|
||||
labelList order(sortedOrder(addressing_));
|
||||
inplaceReorder(order, addressing_);
|
||||
Foam::sort(addressing_);
|
||||
|
||||
cellSet::clearStorage();
|
||||
cellSet::reserve(addressing_.size());
|
||||
@ -61,46 +61,46 @@ Foam::cellZoneSet::cellZoneSet
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
const word& name,
|
||||
IOobjectOption::readOption rOpt,
|
||||
const label initialCapacity,
|
||||
IOobjectOption::writeOption wOpt
|
||||
)
|
||||
:
|
||||
cellSet(mesh, name, 1024), // do not read cellSet
|
||||
mesh_(mesh),
|
||||
addressing_()
|
||||
{
|
||||
const cellZoneMesh& cellZones = mesh.cellZones();
|
||||
label zoneID = cellZones.findZoneID(name);
|
||||
|
||||
if
|
||||
(
|
||||
IOobjectOption::isReadRequired(rOpt)
|
||||
|| (IOobjectOption::isReadOptional(rOpt) && zoneID != -1)
|
||||
)
|
||||
{
|
||||
const cellZone& fz = cellZones[zoneID];
|
||||
addressing_ = fz;
|
||||
}
|
||||
|
||||
updateSet();
|
||||
|
||||
check(mesh.nCells());
|
||||
}
|
||||
cellSet(mesh, name, initialCapacity, wOpt), // Construct no-read
|
||||
mesh_(mesh)
|
||||
{}
|
||||
|
||||
|
||||
Foam::cellZoneSet::cellZoneSet
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
const word& name,
|
||||
const label size,
|
||||
IOobjectOption::readOption rOpt,
|
||||
IOobjectOption::writeOption wOpt
|
||||
)
|
||||
:
|
||||
cellSet(mesh, name, size, wOpt),
|
||||
mesh_(mesh),
|
||||
addressing_()
|
||||
cellZoneSet(mesh, name, label(0), wOpt) // Construct no-read
|
||||
{
|
||||
const auto& zones = mesh.cellZones();
|
||||
const auto* zonePtr = zones.cfindZone(name);
|
||||
|
||||
if (!zonePtr)
|
||||
{
|
||||
if (IOobjectOption::isReadRequired(rOpt))
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Zone named " << name << " not found. "
|
||||
<< "List of available zone names: " << zones.names() << nl
|
||||
<< exit(FatalError);
|
||||
}
|
||||
}
|
||||
else if (IOobjectOption::isAnyRead(rOpt))
|
||||
{
|
||||
const auto& zn = *zonePtr;
|
||||
addressing_ = zn;
|
||||
}
|
||||
|
||||
updateSet();
|
||||
check(mesh.nCells());
|
||||
}
|
||||
|
||||
|
||||
@ -112,15 +112,19 @@ Foam::cellZoneSet::cellZoneSet
|
||||
IOobjectOption::writeOption wOpt
|
||||
)
|
||||
:
|
||||
cellSet(mesh, name, set.size(), wOpt),
|
||||
mesh_(mesh),
|
||||
addressing_
|
||||
(
|
||||
isA<const cellZoneSet>(set)
|
||||
? refCast<const cellZoneSet>(set).addressing()
|
||||
: set.sortedToc()
|
||||
)
|
||||
cellZoneSet(mesh, name, label(0), wOpt) // Construct no-read
|
||||
{
|
||||
const auto* zonePtr = isA<cellZoneSet>(set);
|
||||
|
||||
if (zonePtr)
|
||||
{
|
||||
addressing_ = zonePtr->addressing();
|
||||
}
|
||||
else
|
||||
{
|
||||
addressing_ = set.sortedToc();
|
||||
}
|
||||
|
||||
updateSet();
|
||||
}
|
||||
|
||||
@ -141,7 +145,7 @@ void Foam::cellZoneSet::invert(const label maxLen)
|
||||
}
|
||||
|
||||
// Fill
|
||||
addressing_.setSize(n);
|
||||
addressing_.resize_nocopy(n);
|
||||
n = 0;
|
||||
|
||||
for (label celli = 0; celli < maxLen; ++celli)
|
||||
@ -157,31 +161,15 @@ void Foam::cellZoneSet::invert(const label maxLen)
|
||||
}
|
||||
|
||||
|
||||
void Foam::cellZoneSet::subset(const topoSet& set)
|
||||
void Foam::cellZoneSet::subset(const labelUList& elems)
|
||||
{
|
||||
DynamicList<label> newAddressing(addressing_.size());
|
||||
|
||||
const auto* setPtr = dynamic_cast<const cellZoneSet*>(&set);
|
||||
|
||||
if (setPtr)
|
||||
for (const label id : elems)
|
||||
{
|
||||
for (const label celli : setPtr->addressing())
|
||||
if (found(id))
|
||||
{
|
||||
if (found(celli))
|
||||
{
|
||||
newAddressing.append(celli);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Assume a cellSet
|
||||
for (const label celli : refCast<const cellSet>(set).sortedToc())
|
||||
{
|
||||
if (found(celli))
|
||||
{
|
||||
newAddressing.append(celli);
|
||||
}
|
||||
newAddressing.push_back(id);
|
||||
}
|
||||
}
|
||||
|
||||
@ -190,15 +178,32 @@ void Foam::cellZoneSet::subset(const topoSet& set)
|
||||
}
|
||||
|
||||
|
||||
void Foam::cellZoneSet::subset(const labelUList& set)
|
||||
void Foam::cellZoneSet::subset(const topoSet& set)
|
||||
{
|
||||
DynamicList<label> newAddressing(addressing_.size());
|
||||
const auto* zonePtr = isA<cellZoneSet>(set);
|
||||
|
||||
for (const label celli : set)
|
||||
if (zonePtr)
|
||||
{
|
||||
if (found(celli))
|
||||
// Is a cellZoneSet
|
||||
this->subset(zonePtr->addressing());
|
||||
}
|
||||
else
|
||||
{
|
||||
// Assume a cellSet
|
||||
this->subset(refCast<const cellSet>(set).sortedToc());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::cellZoneSet::addSet(const labelUList& elems)
|
||||
{
|
||||
DynamicList<label> newAddressing(addressing_);
|
||||
|
||||
for (const label id : elems)
|
||||
{
|
||||
if (!found(id))
|
||||
{
|
||||
newAddressing.append(celli);
|
||||
newAddressing.push_back(id);
|
||||
}
|
||||
}
|
||||
|
||||
@ -209,46 +214,33 @@ void Foam::cellZoneSet::subset(const labelUList& set)
|
||||
|
||||
void Foam::cellZoneSet::addSet(const topoSet& set)
|
||||
{
|
||||
DynamicList<label> newAddressing(addressing_);
|
||||
const auto* zonePtr = isA<cellZoneSet>(set);
|
||||
|
||||
const auto* setPtr = dynamic_cast<const cellZoneSet*>(&set);
|
||||
|
||||
if (setPtr)
|
||||
if (zonePtr)
|
||||
{
|
||||
for (const label celli : setPtr->addressing())
|
||||
{
|
||||
if (!found(celli))
|
||||
{
|
||||
newAddressing.append(celli);
|
||||
}
|
||||
}
|
||||
// Is a cellZoneSet
|
||||
this->addSet(zonePtr->addressing());
|
||||
}
|
||||
else
|
||||
{
|
||||
// Assume a cellSet
|
||||
for (const label celli : refCast<const cellSet>(set).sortedToc())
|
||||
{
|
||||
if (!found(celli))
|
||||
{
|
||||
newAddressing.append(celli);
|
||||
}
|
||||
}
|
||||
this->addSet(refCast<const cellSet>(set).sortedToc());
|
||||
}
|
||||
|
||||
addressing_.transfer(newAddressing);
|
||||
updateSet();
|
||||
}
|
||||
|
||||
|
||||
void Foam::cellZoneSet::addSet(const labelUList& set)
|
||||
void Foam::cellZoneSet::subtractSet(const labelUList& elems)
|
||||
{
|
||||
DynamicList<label> newAddressing(addressing_);
|
||||
DynamicList<label> newAddressing(addressing_.size());
|
||||
|
||||
for (const label celli : set)
|
||||
const labelHashSet set(elems);
|
||||
|
||||
for (const label id : addressing_)
|
||||
{
|
||||
if (!found(celli))
|
||||
if (!set.found(id))
|
||||
{
|
||||
newAddressing.append(celli);
|
||||
// Retain if not in the topoSet (parameter)
|
||||
newAddressing.push_back(id);
|
||||
}
|
||||
}
|
||||
|
||||
@ -261,32 +253,12 @@ void Foam::cellZoneSet::subtractSet(const topoSet& set)
|
||||
{
|
||||
DynamicList<label> newAddressing(addressing_.size());
|
||||
|
||||
for (const label celli : addressing_)
|
||||
for (const label id : addressing_)
|
||||
{
|
||||
if (!set.found(celli))
|
||||
if (!set.found(id))
|
||||
{
|
||||
// Not found in zoneSet so add
|
||||
newAddressing.append(celli);
|
||||
}
|
||||
}
|
||||
|
||||
addressing_.transfer(newAddressing);
|
||||
updateSet();
|
||||
}
|
||||
|
||||
|
||||
void Foam::cellZoneSet::subtractSet(const labelUList& elems)
|
||||
{
|
||||
DynamicList<label> newAddressing(addressing_.size());
|
||||
|
||||
const labelHashSet zoneSet(elems);
|
||||
|
||||
for (const label celli : addressing_)
|
||||
{
|
||||
if (!zoneSet.found(celli))
|
||||
{
|
||||
// Not found in zoneSet so add
|
||||
newAddressing.append(celli);
|
||||
newAddressing.push_back(id);
|
||||
}
|
||||
}
|
||||
|
||||
@ -318,56 +290,49 @@ bool Foam::cellZoneSet::writeObject
|
||||
) const
|
||||
{
|
||||
// Write shadow cellSet
|
||||
word oldTypeName = typeName;
|
||||
const word oldTypeName = typeName;
|
||||
const_cast<word&>(type()) = cellSet::typeName;
|
||||
bool ok = cellSet::writeObject(streamOpt, writeOnProc);
|
||||
const_cast<word&>(type()) = oldTypeName;
|
||||
|
||||
// Modify cellZone
|
||||
cellZoneMesh& cellZones = const_cast<polyMesh&>(mesh_).cellZones();
|
||||
label zoneID = cellZones.findZoneID(name());
|
||||
auto& zones = const_cast<polyMesh&>(mesh_).cellZones();
|
||||
auto* zonePtr = zones.findZone(name());
|
||||
|
||||
if (zoneID == -1)
|
||||
if (zonePtr)
|
||||
{
|
||||
zoneID = cellZones.size();
|
||||
|
||||
cellZones.emplace_back
|
||||
(
|
||||
name(),
|
||||
addressing_,
|
||||
zoneID,
|
||||
cellZones
|
||||
);
|
||||
zonePtr->resetAddressing(addressing_);
|
||||
}
|
||||
else
|
||||
{
|
||||
cellZones[zoneID] = addressing_;
|
||||
zones.emplace_back
|
||||
(
|
||||
name(),
|
||||
addressing_,
|
||||
zones.size(), // zoneID
|
||||
zones
|
||||
);
|
||||
}
|
||||
cellZones.clearAddressing();
|
||||
zones.clearAddressing();
|
||||
|
||||
return ok && cellZones.write(writeOnProc);
|
||||
return ok && zones.write(writeOnProc);
|
||||
}
|
||||
|
||||
|
||||
void Foam::cellZoneSet::updateMesh(const mapPolyMesh& morphMap)
|
||||
{
|
||||
// cellZone
|
||||
labelList newAddressing(addressing_.size());
|
||||
DynamicList<label> newAddressing(addressing_.size());
|
||||
|
||||
label n = 0;
|
||||
for (const label celli : addressing_)
|
||||
{
|
||||
label newCelli = morphMap.reverseCellMap()[celli];
|
||||
if (newCelli >= 0)
|
||||
{
|
||||
newAddressing[n] = newCelli;
|
||||
++n;
|
||||
newAddressing.push_back(newCelli);
|
||||
}
|
||||
}
|
||||
newAddressing.resize(n);
|
||||
|
||||
addressing_.transfer(newAddressing);
|
||||
|
||||
updateSet();
|
||||
}
|
||||
|
||||
|
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2017 OpenFOAM Foundation
|
||||
Copyright (C) 2018-2022 OpenCFD Ltd.
|
||||
Copyright (C) 2018-2024 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -62,7 +62,7 @@ class cellZoneSet
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("cellZoneSet");
|
||||
TypeNameNoDebug("cellZoneSet");
|
||||
|
||||
|
||||
// Constructors
|
||||
@ -76,16 +76,16 @@ public:
|
||||
IOobjectOption::writeOption wOpt = IOobjectOption::NO_WRITE
|
||||
);
|
||||
|
||||
//- Construct from initial size for labelHashSet
|
||||
//- Construct empty (no-read) with initial labelHashSet capacity.
|
||||
cellZoneSet
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
const word& name,
|
||||
const label size,
|
||||
const label initialCapacity,
|
||||
IOobjectOption::writeOption wOpt = IOobjectOption::NO_WRITE
|
||||
);
|
||||
|
||||
//- Copy construct from existing set
|
||||
//- Copy construct (no-read) from existing set
|
||||
cellZoneSet
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
@ -102,16 +102,17 @@ public:
|
||||
|
||||
// Member functions
|
||||
|
||||
const labelList& addressing() const
|
||||
const labelList& addressing() const noexcept
|
||||
{
|
||||
return addressing_;
|
||||
}
|
||||
|
||||
labelList& addressing()
|
||||
labelList& addressing() noexcept
|
||||
{
|
||||
return addressing_;
|
||||
}
|
||||
|
||||
|
||||
//- Sort addressing and make cellSet part consistent with addressing
|
||||
void updateSet();
|
||||
|
||||
@ -119,26 +120,24 @@ public:
|
||||
// Insert all members [0,maxLen) which were not in set
|
||||
virtual void invert(const label maxLen);
|
||||
|
||||
//- Subset contents. Only elements present in both sets remain.
|
||||
virtual void subset(const labelUList& elems);
|
||||
|
||||
//- Subset contents. Only elements present in both sets remain.
|
||||
virtual void subset(const topoSet& set);
|
||||
|
||||
//- Add elements present in set.
|
||||
//- Add given elements to the set
|
||||
virtual void addSet(const labelUList& elems);
|
||||
|
||||
//- Add given elements to the set
|
||||
virtual void addSet(const topoSet& set);
|
||||
|
||||
//- Subtract elements present in set.
|
||||
//- Subtract given elements from the set
|
||||
virtual void subtractSet(const labelUList& elems);
|
||||
|
||||
//- Subtract given elements from the set
|
||||
virtual void subtractSet(const topoSet& set);
|
||||
|
||||
// Variants taking labelUList&
|
||||
|
||||
//- Subset contents. Only elements present in both sets remain.
|
||||
virtual void subset(const labelUList& set);
|
||||
|
||||
//- Add elements present in set.
|
||||
virtual void addSet(const labelUList& set);
|
||||
|
||||
//- Subtract elements present in set.
|
||||
virtual void subtractSet(const labelUList& set);
|
||||
|
||||
//- Sync cellSet across coupled patches; update cellZone from cellSet
|
||||
virtual void sync(const polyMesh& mesh);
|
||||
|
||||
|
@ -35,18 +35,12 @@ License
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
defineTypeNameAndDebug(faceBitSet, 0);
|
||||
defineTypeName(faceBitSet);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::faceBitSet::faceBitSet(const polyMesh& mesh)
|
||||
:
|
||||
faceBitSet(mesh, false)
|
||||
{}
|
||||
|
||||
|
||||
Foam::faceBitSet::faceBitSet(const polyMesh& mesh, const bool val)
|
||||
:
|
||||
topoBitSet(mesh, "faceBitSet", mesh.nFaces(), val)
|
||||
|
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2018 OpenCFD Ltd.
|
||||
Copyright (C) 2018-2024 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -56,16 +56,14 @@ class faceBitSet
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("faceBitSet");
|
||||
TypeNameNoDebug("faceBitSet");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct with nFaces elements, all elements unset
|
||||
explicit faceBitSet(const polyMesh& mesh);
|
||||
|
||||
//- Construct with nFaces elements, using initial val
|
||||
faceBitSet(const polyMesh& mesh, const bool val);
|
||||
//- Construct with nFaces elements,
|
||||
//- all elements unset or initial value
|
||||
explicit faceBitSet(const polyMesh& mesh, const bool val = false);
|
||||
|
||||
//- Copy construct from bitset, resizing to nFaces elements as required
|
||||
faceBitSet(const polyMesh& mesh, const bitSet& bits);
|
||||
|
@ -35,7 +35,7 @@ License
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
defineTypeNameAndDebug(faceBoolSet, 0);
|
||||
defineTypeName(faceBoolSet);
|
||||
}
|
||||
|
||||
|
||||
|
@ -56,7 +56,7 @@ class faceBoolSet
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("faceBoolSet");
|
||||
TypeNameNoDebug("faceBoolSet");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
Copyright (C) 2016-2022 OpenCFD Ltd.
|
||||
Copyright (C) 2016-2024 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -37,7 +37,7 @@ License
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
defineTypeNameAndDebug(faceSet, 0);
|
||||
defineTypeName(faceSet);
|
||||
addToRunTimeSelectionTable(topoSet, faceSet, word);
|
||||
addToRunTimeSelectionTable(topoSet, faceSet, size);
|
||||
addToRunTimeSelectionTable(topoSet, faceSet, set);
|
||||
@ -51,17 +51,24 @@ Foam::faceSet::faceSet(const IOobject& io)
|
||||
{}
|
||||
|
||||
|
||||
Foam::faceSet::faceSet(const IOobject& io, const Foam::zero)
|
||||
:
|
||||
topoSet(io, Foam::zero{})
|
||||
{}
|
||||
|
||||
|
||||
Foam::faceSet::faceSet
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
const word& name,
|
||||
IOobjectOption::readOption rOpt,
|
||||
IOobjectOption::writeOption wOpt
|
||||
IOobjectOption::writeOption wOpt,
|
||||
IOobjectOption::registerOption reg
|
||||
)
|
||||
:
|
||||
topoSet(mesh, typeName, name, rOpt, wOpt)
|
||||
topoSet(mesh, typeName, name, rOpt, wOpt, reg)
|
||||
{
|
||||
check(mesh.nFaces());
|
||||
check(mesh.nFaces()); // Valid range?
|
||||
}
|
||||
|
||||
|
||||
@ -69,11 +76,11 @@ Foam::faceSet::faceSet
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
const word& name,
|
||||
const label size,
|
||||
const label initialCapacity,
|
||||
IOobjectOption::writeOption wOpt
|
||||
)
|
||||
:
|
||||
topoSet(mesh, name, size, wOpt)
|
||||
topoSet(mesh, name, initialCapacity, wOpt)
|
||||
{}
|
||||
|
||||
|
||||
@ -125,6 +132,28 @@ Foam::faceSet::faceSet
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
|
||||
|
||||
Foam::labelHashSet Foam::faceSet::readContents
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
const word& name
|
||||
)
|
||||
{
|
||||
faceSet reader
|
||||
(
|
||||
topoSet::findIOobject(mesh, name, IOobjectOption::NO_REGISTER),
|
||||
Foam::zero{}
|
||||
);
|
||||
|
||||
labelHashSet labels;
|
||||
reader.readIOcontents(typeName, labels);
|
||||
reader.checkLabels(labels, mesh.nFaces()); // Valid range?
|
||||
|
||||
return labels;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
void Foam::faceSet::sync(const polyMesh& mesh)
|
||||
|
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011 OpenFOAM Foundation
|
||||
Copyright (C) 2016-2022 OpenCFD Ltd.
|
||||
Copyright (C) 2016-2024 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -56,33 +56,50 @@ class faceSet
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("faceSet");
|
||||
TypeNameNoDebug("faceSet");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from IOobject
|
||||
//- Construct from IOobject. No checking.
|
||||
explicit faceSet(const IOobject& io);
|
||||
|
||||
//- Construct from objectRegistry and name
|
||||
//- Construct empty (no-read) with IOobject information
|
||||
faceSet(const IOobject& io, const Foam::zero);
|
||||
|
||||
//- Construct from polyMesh (registry) and name
|
||||
faceSet
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
const word& name,
|
||||
IOobjectOption::readOption rOpt = IOobjectOption::MUST_READ,
|
||||
IOobjectOption::writeOption wOpt = IOobjectOption::NO_WRITE
|
||||
IOobjectOption::writeOption wOpt = IOobjectOption::NO_WRITE,
|
||||
IOobjectOption::registerOption reg = IOobjectOption::LEGACY_REGISTER
|
||||
);
|
||||
|
||||
//- Construct empty with initial size for labelHashSet
|
||||
//- Construct from polyMesh (registry), name and registration option
|
||||
faceSet
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
const word& name,
|
||||
const label size,
|
||||
IOobjectOption::registerOption reg,
|
||||
IOobjectOption::readOption rOpt = IOobjectOption::MUST_READ,
|
||||
IOobjectOption::writeOption wOpt = IOobjectOption::NO_WRITE
|
||||
)
|
||||
:
|
||||
faceSet(mesh, name, rOpt, wOpt, reg)
|
||||
{}
|
||||
|
||||
//- Construct empty (no-read) with initial labelHashSet capacity.
|
||||
faceSet
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
const word& name,
|
||||
const label initialCapacity,
|
||||
IOobjectOption::writeOption wOpt = IOobjectOption::NO_WRITE
|
||||
);
|
||||
|
||||
//- Construct from existing set
|
||||
//- Copy construct (no-read) from existing set
|
||||
faceSet
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
@ -91,7 +108,8 @@ public:
|
||||
IOobjectOption::writeOption wOpt = IOobjectOption::NO_WRITE
|
||||
);
|
||||
|
||||
//- Construct (no-read) with copy of labelHashSet
|
||||
//- Copy construct (no-read) from labelHashSet,
|
||||
//- with search for IOobject instance.
|
||||
faceSet
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
@ -100,7 +118,8 @@ public:
|
||||
IOobjectOption::writeOption wOpt = IOobjectOption::NO_WRITE
|
||||
);
|
||||
|
||||
//- Construct (no-read) with moving labelHashSet
|
||||
//- Move construct (no-read) from labelHashSet,
|
||||
//- with search for IOobject instance.
|
||||
faceSet
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
@ -109,7 +128,8 @@ public:
|
||||
IOobjectOption::writeOption wOpt = IOobjectOption::NO_WRITE
|
||||
);
|
||||
|
||||
//- Construct (no-read) with copy of labels
|
||||
//- Copy construct (no-read) from labels,
|
||||
//- with search for IOobject instance.
|
||||
faceSet
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
@ -119,6 +139,16 @@ public:
|
||||
);
|
||||
|
||||
|
||||
// Factory Methods
|
||||
|
||||
//- Read and return contents. Intermediate IOobject is not registered
|
||||
static labelHashSet readContents
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
const word& name
|
||||
);
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~faceSet() = default;
|
||||
|
||||
|
@ -40,7 +40,7 @@ License
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
defineTypeNameAndDebug(faceZoneSet, 0);
|
||||
defineTypeName(faceZoneSet);
|
||||
addToRunTimeSelectionTable(topoSet, faceZoneSet, word);
|
||||
addToRunTimeSelectionTable(topoSet, faceZoneSet, size);
|
||||
addToRunTimeSelectionTable(topoSet, faceZoneSet, set);
|
||||
@ -51,9 +51,18 @@ namespace Foam
|
||||
|
||||
void Foam::faceZoneSet::updateSet()
|
||||
{
|
||||
labelList order(sortedOrder(addressing_));
|
||||
addressing_ = labelUIndList(addressing_, order)();
|
||||
flipMap_ = boolUIndList(flipMap_, order)();
|
||||
if (flipMap_.size() == addressing_.size())
|
||||
{
|
||||
labelList order(Foam::sortedOrder(addressing_));
|
||||
addressing_ = labelUIndList(addressing_, order)();
|
||||
flipMap_ = boolUIndList(flipMap_, order)();
|
||||
}
|
||||
else
|
||||
{
|
||||
Foam::sort(addressing_);
|
||||
flipMap_.resize_nocopy(addressing_.size());
|
||||
flipMap_ = false;
|
||||
}
|
||||
|
||||
faceSet::clearStorage();
|
||||
faceSet::reserve(addressing_.size());
|
||||
@ -67,57 +76,47 @@ Foam::faceZoneSet::faceZoneSet
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
const word& name,
|
||||
IOobjectOption::readOption rOpt,
|
||||
const label initialCapacity,
|
||||
IOobjectOption::writeOption wOpt
|
||||
)
|
||||
:
|
||||
faceSet(mesh, name, 1024), // do not read faceSet
|
||||
mesh_(mesh),
|
||||
addressing_(),
|
||||
flipMap_()
|
||||
{
|
||||
const faceZoneMesh& faceZones = mesh.faceZones();
|
||||
label zoneID = faceZones.findZoneID(name);
|
||||
|
||||
if (IOobjectOption::isReadRequired(rOpt) && zoneID == -1)
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Zone named " << name << " not found. "
|
||||
<< "List of available zone names: " << faceZones.names()
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
if
|
||||
(
|
||||
IOobjectOption::isReadRequired(rOpt)
|
||||
|| (IOobjectOption::isReadOptional(rOpt) && zoneID != -1)
|
||||
)
|
||||
{
|
||||
const faceZone& fz = faceZones[zoneID];
|
||||
addressing_ = fz.addressing();
|
||||
flipMap_ = fz.flipMap();
|
||||
}
|
||||
|
||||
updateSet();
|
||||
|
||||
check(mesh.nFaces());
|
||||
}
|
||||
faceSet(mesh, name, initialCapacity, wOpt), // Construct no-read
|
||||
mesh_(mesh)
|
||||
{}
|
||||
|
||||
|
||||
Foam::faceZoneSet::faceZoneSet
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
const word& name,
|
||||
const label size,
|
||||
IOobjectOption::readOption rOpt,
|
||||
IOobjectOption::writeOption wOpt
|
||||
)
|
||||
:
|
||||
faceSet(mesh, name, size, wOpt),
|
||||
mesh_(mesh),
|
||||
addressing_(),
|
||||
flipMap_()
|
||||
faceZoneSet(mesh, name, label(0), wOpt) // Construct no-read
|
||||
{
|
||||
const auto& zones = mesh.faceZones();
|
||||
const auto* zonePtr = zones.cfindZone(name);
|
||||
|
||||
if (!zonePtr)
|
||||
{
|
||||
if (IOobjectOption::isReadRequired(rOpt))
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Zone named " << name << " not found. "
|
||||
<< "List of available zone names: " << zones.names() << nl
|
||||
<< exit(FatalError);
|
||||
}
|
||||
}
|
||||
else if (IOobjectOption::isAnyRead(rOpt))
|
||||
{
|
||||
const auto& zn = *zonePtr;
|
||||
addressing_ = zn.addressing();
|
||||
flipMap_ = zn.flipMap();
|
||||
}
|
||||
|
||||
updateSet();
|
||||
check(mesh.nFaces());
|
||||
}
|
||||
|
||||
|
||||
@ -129,11 +128,21 @@ Foam::faceZoneSet::faceZoneSet
|
||||
IOobjectOption::writeOption wOpt
|
||||
)
|
||||
:
|
||||
faceSet(mesh, name, set.size(), wOpt),
|
||||
mesh_(mesh),
|
||||
addressing_(refCast<const faceZoneSet>(set).addressing()),
|
||||
flipMap_(refCast<const faceZoneSet>(set).flipMap())
|
||||
faceZoneSet(mesh, name, label(0), wOpt) // Construct no-read
|
||||
{
|
||||
const auto* zonePtr = isA<faceZoneSet>(set);
|
||||
|
||||
if (zonePtr)
|
||||
{
|
||||
addressing_ = zonePtr->addressing();
|
||||
flipMap_ = zonePtr->flipMap();
|
||||
}
|
||||
else
|
||||
{
|
||||
// No flipMap for faceSet - handled in updateSet()
|
||||
addressing_ = set.sortedToc();
|
||||
}
|
||||
|
||||
updateSet();
|
||||
}
|
||||
|
||||
@ -145,24 +154,24 @@ void Foam::faceZoneSet::invert(const label maxLen)
|
||||
// Count
|
||||
label n = 0;
|
||||
|
||||
for (label facei = 0; facei < maxLen; ++facei)
|
||||
for (label id = 0; id < maxLen; ++id)
|
||||
{
|
||||
if (!found(facei))
|
||||
if (!topoSet::contains(id))
|
||||
{
|
||||
++n;
|
||||
}
|
||||
}
|
||||
|
||||
// Fill
|
||||
addressing_.setSize(n);
|
||||
flipMap_.setSize(n);
|
||||
addressing_.resize_nocopy(n);
|
||||
flipMap_.resize_nocopy(n);
|
||||
n = 0;
|
||||
|
||||
for (label facei = 0; facei < maxLen; ++facei)
|
||||
for (label id = 0; id < maxLen; ++id)
|
||||
{
|
||||
if (!found(facei))
|
||||
if (!topoSet::contains(id))
|
||||
{
|
||||
addressing_[n] = facei;
|
||||
addressing_[n] = id;
|
||||
flipMap_[n] = false; //? or true?
|
||||
++n;
|
||||
}
|
||||
@ -204,7 +213,7 @@ void Foam::faceZoneSet::subset
|
||||
}
|
||||
}
|
||||
|
||||
if (nConflict > 0)
|
||||
if (nConflict)
|
||||
{
|
||||
WarningInFunction
|
||||
<< "subset : there are " << nConflict
|
||||
@ -220,24 +229,28 @@ void Foam::faceZoneSet::subset
|
||||
|
||||
void Foam::faceZoneSet::subset(const topoSet& set)
|
||||
{
|
||||
const auto* setPtr = dynamic_cast<const faceZoneSet*>(&set);
|
||||
const auto* zonePtr = isA<faceZoneSet>(set);
|
||||
|
||||
if (setPtr)
|
||||
if (zonePtr)
|
||||
{
|
||||
subset(setPtr->name(), setPtr->addressing(), setPtr->flipMap());
|
||||
subset(zonePtr->name(), zonePtr->addressing(), zonePtr->flipMap());
|
||||
}
|
||||
else
|
||||
{
|
||||
// Assume a faceSet. Ignore flipMap
|
||||
const auto& fSet = refCast<const faceSet>(set);
|
||||
subset(fSet.name(), fSet.sortedToc(), boolList::null());
|
||||
subset
|
||||
(
|
||||
set.name(),
|
||||
refCast<const faceSet>(set).sortedToc(),
|
||||
boolList::null()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::faceZoneSet::subset(const labelUList& set)
|
||||
void Foam::faceZoneSet::subset(const labelUList& elems)
|
||||
{
|
||||
subset(word::null, set, boolList::null());
|
||||
subset(word::null, elems, boolList::null());
|
||||
}
|
||||
|
||||
|
||||
@ -292,24 +305,28 @@ void Foam::faceZoneSet::addSet
|
||||
|
||||
void Foam::faceZoneSet::addSet(const topoSet& set)
|
||||
{
|
||||
const auto* setPtr = dynamic_cast<const faceZoneSet*>(&set);
|
||||
const auto* zonePtr = isA<faceZoneSet>(set);
|
||||
|
||||
if (setPtr)
|
||||
if (zonePtr)
|
||||
{
|
||||
addSet(setPtr->name(), setPtr->addressing(), setPtr->flipMap());
|
||||
addSet(zonePtr->name(), zonePtr->addressing(), zonePtr->flipMap());
|
||||
}
|
||||
else
|
||||
{
|
||||
// Assume a faceSet. Ignore flipMap
|
||||
const auto& fSet = refCast<const faceSet>(set);
|
||||
addSet(fSet.name(), fSet.sortedToc(), boolList::null());
|
||||
addSet
|
||||
(
|
||||
set.name(),
|
||||
refCast<const faceSet>(set).sortedToc(),
|
||||
boolList::null()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::faceZoneSet::addSet(const labelUList& set)
|
||||
void Foam::faceZoneSet::addSet(const labelUList& elems)
|
||||
{
|
||||
addSet(word::null, set, boolList::null());
|
||||
addSet(word::null, elems, boolList::null());
|
||||
}
|
||||
|
||||
|
||||
@ -366,24 +383,28 @@ void Foam::faceZoneSet::subtractSet
|
||||
|
||||
void Foam::faceZoneSet::subtractSet(const topoSet& set)
|
||||
{
|
||||
const auto* setPtr = dynamic_cast<const faceZoneSet*>(&set);
|
||||
const auto* zonePtr = isA<faceZoneSet>(set);
|
||||
|
||||
if (setPtr)
|
||||
if (zonePtr)
|
||||
{
|
||||
subtractSet(setPtr->name(), setPtr->addressing(), setPtr->flipMap());
|
||||
subtractSet(zonePtr->name(), zonePtr->addressing(), zonePtr->flipMap());
|
||||
}
|
||||
else
|
||||
{
|
||||
// Assume a faceSet. Ignore flipMap
|
||||
const auto& fSet = refCast<const faceSet>(set);
|
||||
subtractSet(fSet.name(), fSet.sortedToc(), boolList::null());
|
||||
subtractSet
|
||||
(
|
||||
set.name(),
|
||||
refCast<const faceSet>(set).sortedToc(),
|
||||
boolList::null()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::faceZoneSet::subtractSet(const labelUList& set)
|
||||
void Foam::faceZoneSet::subtractSet(const labelUList& elems)
|
||||
{
|
||||
subtractSet(word::null, set, boolList::null());
|
||||
subtractSet(word::null, elems, boolList::null());
|
||||
}
|
||||
|
||||
|
||||
@ -517,58 +538,51 @@ bool Foam::faceZoneSet::writeObject
|
||||
) const
|
||||
{
|
||||
// Write shadow faceSet
|
||||
word oldTypeName = typeName;
|
||||
const word oldTypeName = typeName;
|
||||
const_cast<word&>(type()) = faceSet::typeName;
|
||||
bool ok = faceSet::writeObject(streamOpt, writeOnProc);
|
||||
const_cast<word&>(type()) = oldTypeName;
|
||||
|
||||
// Modify faceZone
|
||||
faceZoneMesh& faceZones = const_cast<polyMesh&>(mesh_).faceZones();
|
||||
label zoneID = faceZones.findZoneID(name());
|
||||
auto& zones = const_cast<polyMesh&>(mesh_).faceZones();
|
||||
auto* zonePtr = zones.findZone(name());
|
||||
|
||||
if (zoneID == -1)
|
||||
if (zonePtr)
|
||||
{
|
||||
zoneID = faceZones.size();
|
||||
|
||||
faceZones.emplace_back
|
||||
zonePtr->resetAddressing(addressing_, flipMap_);
|
||||
}
|
||||
else
|
||||
{
|
||||
zones.emplace_back
|
||||
(
|
||||
name(),
|
||||
addressing_,
|
||||
flipMap_,
|
||||
zoneID,
|
||||
faceZones
|
||||
zones.size(), // zoneID
|
||||
zones
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
faceZones[zoneID].resetAddressing(addressing_, flipMap_);
|
||||
}
|
||||
faceZones.clearAddressing();
|
||||
zones.clearAddressing();
|
||||
|
||||
return ok && faceZones.write(writeOnProc);
|
||||
return ok && zones.write(writeOnProc);
|
||||
}
|
||||
|
||||
|
||||
void Foam::faceZoneSet::updateMesh(const mapPolyMesh& morphMap)
|
||||
{
|
||||
// faceZone
|
||||
labelList newAddressing(addressing_.size());
|
||||
boolList newFlipMap(flipMap_.size(), false);
|
||||
DynamicList<label> newAddressing(addressing_.size());
|
||||
DynamicList<bool> newFlipMap(flipMap_.size());
|
||||
|
||||
label n = 0;
|
||||
forAll(addressing_, i)
|
||||
{
|
||||
label facei = addressing_[i];
|
||||
label newFacei = morphMap.reverseFaceMap()[facei];
|
||||
if (newFacei >= 0)
|
||||
{
|
||||
newAddressing[n] = newFacei;
|
||||
newFlipMap[n] = flipMap_[i];
|
||||
n++;
|
||||
newAddressing.push_back(newFacei);
|
||||
newFlipMap.push_back(flipMap_[i]);
|
||||
}
|
||||
}
|
||||
newAddressing.setSize(n);
|
||||
newFlipMap.setSize(n);
|
||||
|
||||
addressing_.transfer(newAddressing);
|
||||
flipMap_.transfer(newFlipMap);
|
||||
|
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2017 OpenFOAM Foundation
|
||||
Copyright (C) 2018-2022 OpenCFD Ltd.
|
||||
Copyright (C) 2018-2024 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -89,7 +89,7 @@ class faceZoneSet
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("faceZoneSet");
|
||||
TypeNameNoDebug("faceZoneSet");
|
||||
|
||||
|
||||
// Constructors
|
||||
@ -103,16 +103,16 @@ public:
|
||||
IOobjectOption::writeOption wOpt = IOobjectOption::NO_WRITE
|
||||
);
|
||||
|
||||
//- Construct with initial size for labelHashSet
|
||||
//- Construct empty (no-read) with initial labelHashSet capacity.
|
||||
faceZoneSet
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
const word& name,
|
||||
const label size,
|
||||
const label initialCapacity,
|
||||
IOobjectOption::writeOption wOpt = IOobjectOption::NO_WRITE
|
||||
);
|
||||
|
||||
//- Copy construct from existing set
|
||||
//- Copy construct (no-read) from existing set
|
||||
faceZoneSet
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
@ -157,27 +157,24 @@ public:
|
||||
// Insert all members [0,maxLen) which were not in set.
|
||||
virtual void invert(const label maxLen);
|
||||
|
||||
//- Subset contents. Only elements present in both sets remain.
|
||||
virtual void subset(const labelUList& elems);
|
||||
|
||||
//- Subset contents. Only elements present in both sets remain.
|
||||
virtual void subset(const topoSet& set);
|
||||
|
||||
//- Add elements present in set.
|
||||
//- Add given elements to the set
|
||||
virtual void addSet(const labelUList& elems);
|
||||
|
||||
//- Add given elements to the set
|
||||
virtual void addSet(const topoSet& set);
|
||||
|
||||
//- Subtract elements present in set.
|
||||
//- Subtract given elements from the set
|
||||
virtual void subtractSet(const labelUList& elems);
|
||||
|
||||
//- Subtract given elements from the set
|
||||
virtual void subtractSet(const topoSet& set);
|
||||
|
||||
// Variants taking labelUList&
|
||||
|
||||
//- Subset contents. Only elements present in both sets remain.
|
||||
virtual void subset(const labelUList& set);
|
||||
|
||||
//- Add elements present in set.
|
||||
virtual void addSet(const labelUList& set);
|
||||
|
||||
//- Subtract elements present in set.
|
||||
virtual void subtractSet(const labelUList& set);
|
||||
|
||||
|
||||
//- Sync faceZoneSet across coupled patches.
|
||||
virtual void sync(const polyMesh& mesh);
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2018 OpenCFD Ltd.
|
||||
Copyright (C) 2018-2024 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -35,18 +35,12 @@ License
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
defineTypeNameAndDebug(pointBitSet, 0);
|
||||
defineTypeName(pointBitSet);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::pointBitSet::pointBitSet(const polyMesh& mesh)
|
||||
:
|
||||
pointBitSet(mesh, false)
|
||||
{}
|
||||
|
||||
|
||||
Foam::pointBitSet::pointBitSet(const polyMesh& mesh, const bool val)
|
||||
:
|
||||
topoBitSet(mesh, "pointBitSet", mesh.nPoints(), val)
|
||||
|
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2018 OpenCFD Ltd.
|
||||
Copyright (C) 2018-2024 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -56,16 +56,14 @@ class pointBitSet
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("pointBitSet");
|
||||
TypeNameNoDebug("pointBitSet");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct with nPoints elements, all elements unset
|
||||
explicit pointBitSet(const polyMesh& mesh);
|
||||
|
||||
//- Construct with nPoints elements, using initial val
|
||||
pointBitSet(const polyMesh& mesh, const bool val);
|
||||
//- Construct with nPoints elements,
|
||||
//- all elements unset or initial value
|
||||
explicit pointBitSet(const polyMesh& mesh, const bool val);
|
||||
|
||||
//- Copy construct from bitset, resizing to nPoints elements as required
|
||||
pointBitSet(const polyMesh& mesh, const bitSet& bits);
|
||||
|
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
Copyright (C) 2016-2022 OpenCFD Ltd.
|
||||
Copyright (C) 2016-2024 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -37,13 +37,14 @@ License
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
defineTypeNameAndDebug(pointSet, 0);
|
||||
defineTypeName(pointSet);
|
||||
addToRunTimeSelectionTable(topoSet, pointSet, word);
|
||||
addToRunTimeSelectionTable(topoSet, pointSet, size);
|
||||
addToRunTimeSelectionTable(topoSet, pointSet, set);
|
||||
}
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::pointSet::pointSet(const IOobject& io)
|
||||
:
|
||||
@ -51,17 +52,24 @@ Foam::pointSet::pointSet(const IOobject& io)
|
||||
{}
|
||||
|
||||
|
||||
Foam::pointSet::pointSet(const IOobject& io, const Foam::zero)
|
||||
:
|
||||
topoSet(io, Foam::zero{})
|
||||
{}
|
||||
|
||||
|
||||
Foam::pointSet::pointSet
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
const word& name,
|
||||
IOobjectOption::readOption rOpt,
|
||||
IOobjectOption::writeOption wOpt
|
||||
IOobjectOption::writeOption wOpt,
|
||||
IOobjectOption::registerOption reg
|
||||
)
|
||||
:
|
||||
topoSet(mesh, typeName, name, rOpt, wOpt)
|
||||
topoSet(mesh, typeName, name, rOpt, wOpt, reg)
|
||||
{
|
||||
check(mesh.nPoints());
|
||||
check(mesh.nPoints()); // Valid range?
|
||||
}
|
||||
|
||||
|
||||
@ -69,11 +77,11 @@ Foam::pointSet::pointSet
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
const word& name,
|
||||
const label size,
|
||||
const label initialCapacity,
|
||||
IOobjectOption::writeOption wOpt
|
||||
)
|
||||
:
|
||||
topoSet(mesh, name, size, wOpt)
|
||||
topoSet(mesh, name, initialCapacity, wOpt)
|
||||
{}
|
||||
|
||||
|
||||
@ -125,6 +133,28 @@ Foam::pointSet::pointSet
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
|
||||
|
||||
Foam::labelHashSet Foam::pointSet::readContents
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
const word& name
|
||||
)
|
||||
{
|
||||
pointSet reader
|
||||
(
|
||||
topoSet::findIOobject(mesh, name, IOobjectOption::NO_REGISTER),
|
||||
Foam::zero{}
|
||||
);
|
||||
|
||||
labelHashSet labels;
|
||||
reader.readIOcontents(typeName, labels);
|
||||
reader.checkLabels(labels, mesh.nPoints()); // Valid range?
|
||||
|
||||
return labels;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
void Foam::pointSet::sync(const polyMesh& mesh)
|
||||
|
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011 OpenFOAM Foundation
|
||||
Copyright (C) 2016-2022 OpenCFD Ltd.
|
||||
Copyright (C) 2016-2024 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -56,7 +56,7 @@ class pointSet
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("pointSet");
|
||||
TypeNameNoDebug("pointSet");
|
||||
|
||||
|
||||
// Constructors
|
||||
@ -64,25 +64,42 @@ public:
|
||||
//- Construct from IOobject
|
||||
explicit pointSet(const IOobject& io);
|
||||
|
||||
//- Construct from objectRegistry and name
|
||||
//- Construct empty (no-read) with IOobject information
|
||||
pointSet(const IOobject& io, const Foam::zero);
|
||||
|
||||
//- Construct from polyMesh (registry) and name
|
||||
pointSet
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
const word& name,
|
||||
IOobjectOption::readOption rOpt = IOobjectOption::MUST_READ,
|
||||
IOobjectOption::writeOption wOpt = IOobjectOption::NO_WRITE
|
||||
IOobjectOption::writeOption wOpt = IOobjectOption::NO_WRITE,
|
||||
IOobjectOption::registerOption reg = IOobjectOption::LEGACY_REGISTER
|
||||
);
|
||||
|
||||
//- Construct empty with initial size for labelHashSet
|
||||
//- Construct from polyMesh (registry), name and registration option
|
||||
pointSet
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
const word& name,
|
||||
const label size,
|
||||
IOobjectOption::registerOption reg,
|
||||
IOobjectOption::readOption rOpt = IOobjectOption::MUST_READ,
|
||||
IOobjectOption::writeOption wOpt = IOobjectOption::NO_WRITE
|
||||
)
|
||||
:
|
||||
pointSet(mesh, name, rOpt, wOpt, reg)
|
||||
{}
|
||||
|
||||
//- Construct empty (no-read) with initial labelHashSet capacity.
|
||||
pointSet
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
const word& name,
|
||||
const label initialCapacity,
|
||||
IOobjectOption::writeOption wOpt = IOobjectOption::NO_WRITE
|
||||
);
|
||||
|
||||
//- Construct from existing set
|
||||
//- Copy construct (no-read) from existing set
|
||||
pointSet
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
@ -91,7 +108,8 @@ public:
|
||||
IOobjectOption::writeOption wOpt = IOobjectOption::NO_WRITE
|
||||
);
|
||||
|
||||
//- Construct (no-read) with copy of labelHashSet
|
||||
//- Copy construct (no-read) from labelHashSet,
|
||||
//- with search for IOobject instance.
|
||||
pointSet
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
@ -100,7 +118,8 @@ public:
|
||||
IOobjectOption::writeOption wOpt = IOobjectOption::NO_WRITE
|
||||
);
|
||||
|
||||
//- Construct (no-read) with moving labelHashSet
|
||||
//- Move construct (no-read) from labelHashSet,
|
||||
//- with search for IOobject instance.
|
||||
pointSet
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
@ -109,7 +128,8 @@ public:
|
||||
IOobjectOption::writeOption wOpt = IOobjectOption::NO_WRITE
|
||||
);
|
||||
|
||||
//- Construct (no-read) with copy of labels
|
||||
//- Copy construct (no-read) from labels,
|
||||
//- with search for IOobject instance.
|
||||
pointSet
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
@ -119,11 +139,21 @@ public:
|
||||
);
|
||||
|
||||
|
||||
// Factory Methods
|
||||
|
||||
//- Read and return contents. Intermediate IOobject is not registered
|
||||
static labelHashSet readContents
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
const word& name
|
||||
);
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~pointSet() = default;
|
||||
|
||||
|
||||
// Member functions
|
||||
// Member Functions
|
||||
|
||||
//- Sync set across coupled patches. Adds coupled points to set.
|
||||
virtual void sync(const polyMesh& mesh);
|
||||
|
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2017 OpenFOAM Foundation
|
||||
Copyright (C) 2018-2022,2024 OpenCFD Ltd.
|
||||
Copyright (C) 2018-2024 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -37,18 +37,18 @@ License
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
defineTypeNameAndDebug(pointZoneSet, 0);
|
||||
defineTypeName(pointZoneSet);
|
||||
addToRunTimeSelectionTable(topoSet, pointZoneSet, word);
|
||||
addToRunTimeSelectionTable(topoSet, pointZoneSet, size);
|
||||
addToRunTimeSelectionTable(topoSet, pointZoneSet, set);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
void Foam::pointZoneSet::updateSet()
|
||||
{
|
||||
labelList order(sortedOrder(addressing_));
|
||||
inplaceReorder(order, addressing_);
|
||||
Foam::sort(addressing_);
|
||||
|
||||
pointSet::clearStorage();
|
||||
pointSet::reserve(addressing_.size());
|
||||
@ -62,46 +62,46 @@ Foam::pointZoneSet::pointZoneSet
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
const word& name,
|
||||
IOobjectOption::readOption rOpt,
|
||||
const label initialCapacity,
|
||||
IOobjectOption::writeOption wOpt
|
||||
)
|
||||
:
|
||||
pointSet(mesh, name, 1024), // do not read pointSet
|
||||
mesh_(mesh),
|
||||
addressing_()
|
||||
{
|
||||
const pointZoneMesh& pointZones = mesh.pointZones();
|
||||
label zoneID = pointZones.findZoneID(name);
|
||||
|
||||
if
|
||||
(
|
||||
IOobjectOption::isReadRequired(rOpt)
|
||||
|| (IOobjectOption::isReadOptional(rOpt) && zoneID != -1)
|
||||
)
|
||||
{
|
||||
const pointZone& fz = pointZones[zoneID];
|
||||
addressing_ = fz;
|
||||
}
|
||||
|
||||
updateSet();
|
||||
|
||||
check(mesh.nPoints());
|
||||
}
|
||||
pointSet(mesh, name, initialCapacity, wOpt), // Construct no-read
|
||||
mesh_(mesh)
|
||||
{}
|
||||
|
||||
|
||||
Foam::pointZoneSet::pointZoneSet
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
const word& name,
|
||||
const label size,
|
||||
IOobjectOption::readOption rOpt,
|
||||
IOobjectOption::writeOption wOpt
|
||||
)
|
||||
:
|
||||
pointSet(mesh, name, size, wOpt),
|
||||
mesh_(mesh),
|
||||
addressing_()
|
||||
pointZoneSet(mesh, name, label(0), wOpt) // Construct no-read
|
||||
{
|
||||
const auto& zones = mesh.pointZones();
|
||||
const auto* zonePtr = zones.cfindZone(name);
|
||||
|
||||
if (!zonePtr)
|
||||
{
|
||||
if (IOobjectOption::isReadRequired(rOpt))
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Zone named " << name << " not found. "
|
||||
<< "List of available zone names: " << zones.names() << nl
|
||||
<< exit(FatalError);
|
||||
}
|
||||
}
|
||||
else if (IOobjectOption::isAnyRead(rOpt))
|
||||
{
|
||||
const auto& zn = *zonePtr;
|
||||
addressing_ = zn;
|
||||
}
|
||||
|
||||
updateSet();
|
||||
check(mesh.nPoints());
|
||||
}
|
||||
|
||||
|
||||
@ -113,15 +113,19 @@ Foam::pointZoneSet::pointZoneSet
|
||||
IOobjectOption::writeOption wOpt
|
||||
)
|
||||
:
|
||||
pointSet(mesh, name, set.size(), wOpt),
|
||||
mesh_(mesh),
|
||||
addressing_
|
||||
(
|
||||
isA<const pointZoneSet>(set)
|
||||
? refCast<const pointZoneSet>(set).addressing()
|
||||
: set.sortedToc()
|
||||
)
|
||||
pointZoneSet(mesh, name, label(0), wOpt) // Construct no-read
|
||||
{
|
||||
const auto* zonePtr = isA<pointZoneSet>(set);
|
||||
|
||||
if (zonePtr)
|
||||
{
|
||||
addressing_ = zonePtr->addressing();
|
||||
}
|
||||
else
|
||||
{
|
||||
addressing_ = set.sortedToc();
|
||||
}
|
||||
|
||||
updateSet();
|
||||
}
|
||||
|
||||
@ -133,23 +137,23 @@ void Foam::pointZoneSet::invert(const label maxLen)
|
||||
// Count
|
||||
label n = 0;
|
||||
|
||||
for (label pointi = 0; pointi < maxLen; ++pointi)
|
||||
for (label id = 0; id < maxLen; ++id)
|
||||
{
|
||||
if (!found(pointi))
|
||||
if (!found(id))
|
||||
{
|
||||
++n;
|
||||
}
|
||||
}
|
||||
|
||||
// Fill
|
||||
addressing_.setSize(n);
|
||||
addressing_.resize_nocopy(n);
|
||||
n = 0;
|
||||
|
||||
for (label pointi = 0; pointi < maxLen; ++pointi)
|
||||
for (label id = 0; id < maxLen; ++id)
|
||||
{
|
||||
if (!found(pointi))
|
||||
if (!found(id))
|
||||
{
|
||||
addressing_[n] = pointi;
|
||||
addressing_[n] = id;
|
||||
++n;
|
||||
}
|
||||
}
|
||||
@ -157,31 +161,15 @@ void Foam::pointZoneSet::invert(const label maxLen)
|
||||
}
|
||||
|
||||
|
||||
void Foam::pointZoneSet::subset(const topoSet& set)
|
||||
void Foam::pointZoneSet::subset(const labelUList& elems)
|
||||
{
|
||||
DynamicList<label> newAddressing(addressing_.size());
|
||||
|
||||
const auto* setPtr = dynamic_cast<const pointZoneSet*>(&set);
|
||||
|
||||
if (setPtr)
|
||||
for (const label id : elems)
|
||||
{
|
||||
for (const label pointi : setPtr->addressing())
|
||||
if (found(id))
|
||||
{
|
||||
if (found(pointi))
|
||||
{
|
||||
newAddressing.append(pointi);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Assume a pointSet
|
||||
for (const label pointi : refCast<const pointSet>(set).sortedToc())
|
||||
{
|
||||
if (found(pointi))
|
||||
{
|
||||
newAddressing.append(pointi);
|
||||
}
|
||||
newAddressing.push_back(id);
|
||||
}
|
||||
}
|
||||
|
||||
@ -190,15 +178,32 @@ void Foam::pointZoneSet::subset(const topoSet& set)
|
||||
}
|
||||
|
||||
|
||||
void Foam::pointZoneSet::subset(const labelUList& set)
|
||||
void Foam::pointZoneSet::subset(const topoSet& set)
|
||||
{
|
||||
DynamicList<label> newAddressing(addressing_.size());
|
||||
const auto* zonePtr = isA<pointZoneSet>(set);
|
||||
|
||||
for (const label pointi : set)
|
||||
if (zonePtr)
|
||||
{
|
||||
if (found(pointi))
|
||||
// Is a pointZoneSet
|
||||
this->subset(zonePtr->addressing());
|
||||
}
|
||||
else
|
||||
{
|
||||
// Assume a pointSet
|
||||
this->subset(refCast<const pointSet>(set).sortedToc());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::pointZoneSet::addSet(const labelUList& elems)
|
||||
{
|
||||
DynamicList<label> newAddressing(addressing_);
|
||||
|
||||
for (const label id : elems)
|
||||
{
|
||||
if (!found(id))
|
||||
{
|
||||
newAddressing.append(pointi);
|
||||
newAddressing.push_back(id);
|
||||
}
|
||||
}
|
||||
|
||||
@ -209,46 +214,33 @@ void Foam::pointZoneSet::subset(const labelUList& set)
|
||||
|
||||
void Foam::pointZoneSet::addSet(const topoSet& set)
|
||||
{
|
||||
DynamicList<label> newAddressing(addressing_);
|
||||
const auto* zonePtr = isA<pointZoneSet>(set);
|
||||
|
||||
const auto* setPtr = dynamic_cast<const pointZoneSet*>(&set);
|
||||
|
||||
if (setPtr)
|
||||
if (zonePtr)
|
||||
{
|
||||
for (const label pointi : setPtr->addressing())
|
||||
{
|
||||
if (!found(pointi))
|
||||
{
|
||||
newAddressing.append(pointi);
|
||||
}
|
||||
}
|
||||
// Is a pointZoneSet
|
||||
this->addSet(zonePtr->addressing());
|
||||
}
|
||||
else
|
||||
{
|
||||
// Assume a pointSet
|
||||
for (const label pointi : refCast<const pointSet>(set).sortedToc())
|
||||
{
|
||||
if (!found(pointi))
|
||||
{
|
||||
newAddressing.append(pointi);
|
||||
}
|
||||
}
|
||||
this->addSet(refCast<const pointSet>(set).sortedToc());
|
||||
}
|
||||
|
||||
addressing_.transfer(newAddressing);
|
||||
updateSet();
|
||||
}
|
||||
|
||||
|
||||
void Foam::pointZoneSet::addSet(const labelUList& set)
|
||||
void Foam::pointZoneSet::subtractSet(const labelUList& elems)
|
||||
{
|
||||
DynamicList<label> newAddressing(addressing_);
|
||||
DynamicList<label> newAddressing(addressing_.size());
|
||||
|
||||
for (const label pointi : set)
|
||||
const labelHashSet set(elems);
|
||||
|
||||
for (const label id : addressing_)
|
||||
{
|
||||
if (!found(pointi))
|
||||
if (!set.found(id))
|
||||
{
|
||||
newAddressing.append(pointi);
|
||||
// Retain if not in the topoSet (parameter)
|
||||
newAddressing.push_back(id);
|
||||
}
|
||||
}
|
||||
|
||||
@ -261,32 +253,12 @@ void Foam::pointZoneSet::subtractSet(const topoSet& set)
|
||||
{
|
||||
DynamicList<label> newAddressing(addressing_.size());
|
||||
|
||||
for (label pointi : addressing_)
|
||||
for (const label id : addressing_)
|
||||
{
|
||||
if (!set.found(pointi))
|
||||
if (!set.found(id))
|
||||
{
|
||||
// Not found in zoneSet so add
|
||||
newAddressing.append(pointi);
|
||||
}
|
||||
}
|
||||
|
||||
addressing_.transfer(newAddressing);
|
||||
updateSet();
|
||||
}
|
||||
|
||||
|
||||
void Foam::pointZoneSet::subtractSet(const labelUList& elems)
|
||||
{
|
||||
DynamicList<label> newAddressing(addressing_.size());
|
||||
|
||||
const labelHashSet zoneSet(elems);
|
||||
|
||||
for (const label pointi : addressing_)
|
||||
{
|
||||
if (!zoneSet.found(pointi))
|
||||
{
|
||||
// Not found in zoneSet so add
|
||||
newAddressing.append(pointi);
|
||||
// Retain if not in the topoSet (parameter)
|
||||
newAddressing.push_back(id);
|
||||
}
|
||||
}
|
||||
|
||||
@ -318,56 +290,49 @@ bool Foam::pointZoneSet::writeObject
|
||||
) const
|
||||
{
|
||||
// Write shadow pointSet
|
||||
word oldTypeName = typeName;
|
||||
const word oldTypeName = typeName;
|
||||
const_cast<word&>(type()) = pointSet::typeName;
|
||||
bool ok = pointSet::writeObject(streamOpt, writeOnProc);
|
||||
const_cast<word&>(type()) = oldTypeName;
|
||||
|
||||
// Modify pointZone
|
||||
pointZoneMesh& pointZones = const_cast<polyMesh&>(mesh_).pointZones();
|
||||
label zoneID = pointZones.findZoneID(name());
|
||||
auto& zones = const_cast<polyMesh&>(mesh_).pointZones();
|
||||
auto* zonePtr = zones.findZone(name());
|
||||
|
||||
if (zoneID == -1)
|
||||
if (zonePtr)
|
||||
{
|
||||
zoneID = pointZones.size();
|
||||
|
||||
pointZones.emplace_back
|
||||
(
|
||||
name(),
|
||||
addressing_,
|
||||
zoneID,
|
||||
pointZones
|
||||
);
|
||||
zonePtr->resetAddressing(addressing_);
|
||||
}
|
||||
else
|
||||
{
|
||||
pointZones[zoneID] = addressing_;
|
||||
zones.emplace_back
|
||||
(
|
||||
name(),
|
||||
addressing_,
|
||||
zones.size(), // zoneID
|
||||
zones
|
||||
);
|
||||
}
|
||||
pointZones.clearAddressing();
|
||||
zones.clearAddressing();
|
||||
|
||||
return ok && pointZones.write(writeOnProc);
|
||||
return ok && zones.write(writeOnProc);
|
||||
}
|
||||
|
||||
|
||||
void Foam::pointZoneSet::updateMesh(const mapPolyMesh& morphMap)
|
||||
{
|
||||
// pointZone
|
||||
labelList newAddressing(addressing_.size());
|
||||
DynamicList<label> newAddressing(addressing_.size());
|
||||
|
||||
label n = 0;
|
||||
for (const label pointi : addressing_)
|
||||
{
|
||||
const label newPointi = morphMap.reversePointMap()[pointi];
|
||||
if (newPointi >= 0)
|
||||
{
|
||||
newAddressing[n] = newPointi;
|
||||
++n;
|
||||
newAddressing.push_back(newPointi);
|
||||
}
|
||||
}
|
||||
newAddressing.resize(n);
|
||||
|
||||
addressing_.transfer(newAddressing);
|
||||
|
||||
updateSet();
|
||||
}
|
||||
|
||||
|
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2017 OpenFOAM Foundation
|
||||
Copyright (C) 2018-2022 OpenCFD Ltd.
|
||||
Copyright (C) 2018-2024 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -60,11 +60,10 @@ class pointZoneSet
|
||||
|
||||
labelList addressing_;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("pointZoneSet");
|
||||
TypeNameNoDebug("pointZoneSet");
|
||||
|
||||
|
||||
// Constructors
|
||||
@ -78,16 +77,16 @@ public:
|
||||
IOobjectOption::writeOption wOpt = IOobjectOption::NO_WRITE
|
||||
);
|
||||
|
||||
//- Construct empty with initial size for labelHashSet
|
||||
//- Construct empty (no-read) with initial labelHashSet capacity.
|
||||
pointZoneSet
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
const word& name,
|
||||
const label size,
|
||||
const label initialCapacity,
|
||||
IOobjectOption::writeOption wOpt = IOobjectOption::NO_WRITE
|
||||
);
|
||||
|
||||
//- Copy construct from existing set
|
||||
//- Copy construct (no-read) from existing set
|
||||
pointZoneSet
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
@ -101,18 +100,19 @@ public:
|
||||
virtual ~pointZoneSet() = default;
|
||||
|
||||
|
||||
// Member functions
|
||||
// Member Functions
|
||||
|
||||
const labelList& addressing() const
|
||||
const labelList& addressing() const noexcept
|
||||
{
|
||||
return addressing_;
|
||||
}
|
||||
|
||||
labelList& addressing()
|
||||
labelList& addressing() noexcept
|
||||
{
|
||||
return addressing_;
|
||||
}
|
||||
|
||||
|
||||
//- Sort addressing and make pointSet part consistent with addressing
|
||||
void updateSet();
|
||||
|
||||
@ -120,26 +120,24 @@ public:
|
||||
// Insert all members [0,maxLen) which were not in set
|
||||
virtual void invert(const label maxLen);
|
||||
|
||||
//- Subset contents. Only elements present in both sets remain.
|
||||
virtual void subset(const labelUList& elems);
|
||||
|
||||
//- Subset contents. Only elements present in both sets remain.
|
||||
virtual void subset(const topoSet& set);
|
||||
|
||||
//- Add elements present in set.
|
||||
//- Add given elements to the set
|
||||
virtual void addSet(const labelUList& elems);
|
||||
|
||||
//- Add given elements to the set
|
||||
virtual void addSet(const topoSet& set);
|
||||
|
||||
//- Subtract elements present in set.
|
||||
//- Subtract given elements from the set
|
||||
virtual void subtractSet(const labelUList& elems);
|
||||
|
||||
//- Subtract given elements from the set
|
||||
virtual void subtractSet(const topoSet& set);
|
||||
|
||||
// Variants taking labelUList&
|
||||
|
||||
//- Subset contents. Only elements present in both sets remain.
|
||||
virtual void subset(const labelUList& set);
|
||||
|
||||
//- Add elements present in set.
|
||||
virtual void addSet(const labelUList& set);
|
||||
|
||||
//- Subtract elements present in set.
|
||||
virtual void subtractSet(const labelUList& set);
|
||||
|
||||
|
||||
//- Sync pointZoneSet across coupled patches.
|
||||
virtual void sync(const polyMesh& mesh);
|
||||
|
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2018 OpenCFD Ltd.
|
||||
Copyright (C) 2018-2024 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -126,9 +126,8 @@ Foam::topoBitSet::topoBitSet
|
||||
IOobject::NO_WRITE,
|
||||
IOobject::NO_REGISTER
|
||||
),
|
||||
label(0) // zero-sized (unallocated) labelHashSet
|
||||
),
|
||||
selected_()
|
||||
Foam::zero{} // Empty labelHashSet (initialCapacity = 0)
|
||||
)
|
||||
{}
|
||||
|
||||
|
||||
@ -178,6 +177,12 @@ Foam::topoBitSet::topoBitSet
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
bool Foam::topoBitSet::contains(const label id) const
|
||||
{
|
||||
return selected_.test(id);
|
||||
}
|
||||
|
||||
|
||||
bool Foam::topoBitSet::found(const label id) const
|
||||
{
|
||||
return selected_.test(id);
|
||||
@ -218,9 +223,12 @@ void Foam::topoBitSet::invert(const label maxLen)
|
||||
void Foam::topoBitSet::subset(const topoSet& set)
|
||||
{
|
||||
// Only retain entries found in both sets
|
||||
if (isA<topoBitSet>(set))
|
||||
|
||||
const auto* topoBitsPtr = isA<topoBitSet>(set);
|
||||
|
||||
if (topoBitsPtr)
|
||||
{
|
||||
selected_ &= refCast<const topoBitSet>(set).selected_;
|
||||
selected_ &= topoBitsPtr->selected_;
|
||||
}
|
||||
else if (set.empty())
|
||||
{
|
||||
@ -242,25 +250,27 @@ void Foam::topoBitSet::subset(const topoSet& set)
|
||||
void Foam::topoBitSet::subset(const labelUList& elems)
|
||||
{
|
||||
// Only retain entries found in both sets
|
||||
bitSet newSelected(selected_.size());
|
||||
bitSet newLabels(selected_.size());
|
||||
|
||||
for (const label id : elems)
|
||||
{
|
||||
if (selected_[id])
|
||||
if (selected_.test(id))
|
||||
{
|
||||
newSelected.set(id);
|
||||
newLabels.set(id);
|
||||
}
|
||||
}
|
||||
selected_ = newSelected;
|
||||
selected_.transfer(newLabels);
|
||||
}
|
||||
|
||||
|
||||
void Foam::topoBitSet::addSet(const topoSet& set)
|
||||
{
|
||||
// Add entries to the set
|
||||
if (isA<topoBitSet>(set))
|
||||
const auto* topoBitsPtr = isA<topoBitSet>(set);
|
||||
|
||||
if (topoBitsPtr)
|
||||
{
|
||||
selected_ |= refCast<const topoBitSet>(set).selected_;
|
||||
selected_ |= topoBitsPtr->selected_;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -281,9 +291,11 @@ void Foam::topoBitSet::addSet(const labelUList& elems)
|
||||
void Foam::topoBitSet::subtractSet(const topoSet& set)
|
||||
{
|
||||
// Subtract entries from the set
|
||||
if (isA<topoBitSet>(set))
|
||||
const auto* topoBitsPtr = isA<topoBitSet>(set);
|
||||
|
||||
if (topoBitsPtr)
|
||||
{
|
||||
selected_ -= refCast<const topoBitSet>(set).selected_;
|
||||
selected_ -= topoBitsPtr->selected_;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -70,10 +70,10 @@ protected:
|
||||
virtual void check(const label maxSize);
|
||||
|
||||
|
||||
//- Construct with empty selection
|
||||
//- Construct (no-read) with empty selection
|
||||
topoBitSet(const polyMesh& mesh, const word& setName);
|
||||
|
||||
//- Construct with size elements
|
||||
//- Construct (no-read) with \c size elements of initial value
|
||||
topoBitSet
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
@ -82,7 +82,7 @@ protected:
|
||||
const bool val
|
||||
);
|
||||
|
||||
//- Copy construct with bitset values, size elements
|
||||
//- Copy construct from bitset values, size elements
|
||||
topoBitSet
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
@ -91,7 +91,7 @@ protected:
|
||||
const bitSet& bits
|
||||
);
|
||||
|
||||
//- Move construct with bitset values, size elements
|
||||
//- Move construct from bitset values, size elements
|
||||
topoBitSet
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
@ -127,6 +127,9 @@ public:
|
||||
selected_.reset();
|
||||
}
|
||||
|
||||
//- Has the given index?
|
||||
virtual bool contains(const label id) const;
|
||||
|
||||
//- Has the given index?
|
||||
virtual bool found(const label id) const;
|
||||
|
||||
@ -146,25 +149,23 @@ public:
|
||||
// Insert all members [0,maxLen) which were not in set.
|
||||
virtual void invert(const label maxLen);
|
||||
|
||||
//- Subset contents. Only elements present in both sets remain.
|
||||
virtual void subset(const labelUList& elems);
|
||||
|
||||
//- Subset contents. Only elements present in both sets remain.
|
||||
virtual void subset(const topoSet& set);
|
||||
|
||||
//- Add elements present in set.
|
||||
//- Add given elements to the set
|
||||
virtual void addSet(const labelUList& elems);
|
||||
|
||||
//- Add given elements to the set
|
||||
virtual void addSet(const topoSet& set);
|
||||
|
||||
//- Subtract elements present in set.
|
||||
//- Subtract given elements from the set
|
||||
virtual void subtractSet(const labelUList& elems);
|
||||
|
||||
//- Subtract given elements from the set
|
||||
virtual void subtractSet(const topoSet& set);
|
||||
|
||||
// Variants taking labelUList&
|
||||
|
||||
//- Subset contents. Only elements present in both sets remain.
|
||||
virtual void subset(const labelUList& set);
|
||||
|
||||
//- Add elements present in set.
|
||||
virtual void addSet(const labelUList& set);
|
||||
|
||||
//- Subtract elements present in set.
|
||||
virtual void subtractSet(const labelUList& set);
|
||||
};
|
||||
|
||||
|
||||
|
@ -135,9 +135,8 @@ Foam::topoBoolSet::topoBoolSet
|
||||
IOobject::NO_WRITE,
|
||||
IOobject::NO_REGISTER
|
||||
),
|
||||
label(0) // zero-sized (unallocated) labelHashSet
|
||||
),
|
||||
selected_()
|
||||
Foam::zero{} // Empty labelHashSet (initialCapacity = 0)
|
||||
)
|
||||
{}
|
||||
|
||||
|
||||
@ -187,6 +186,12 @@ Foam::topoBoolSet::topoBoolSet
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
bool Foam::topoBoolSet::contains(const label id) const
|
||||
{
|
||||
return selected_.test(id);
|
||||
}
|
||||
|
||||
|
||||
bool Foam::topoBoolSet::found(const label id) const
|
||||
{
|
||||
return selected_.test(id);
|
||||
|
@ -70,10 +70,10 @@ protected:
|
||||
virtual void check(const label maxSize);
|
||||
|
||||
|
||||
//- Construct with empty selection
|
||||
//- Construct (no-read) with empty selection
|
||||
topoBoolSet(const polyMesh& mesh, const word& setName);
|
||||
|
||||
//- Construct with size elements
|
||||
//- Construct (no-read) with \c size elements of initial value
|
||||
topoBoolSet
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
@ -100,7 +100,6 @@ protected:
|
||||
boolList&& bools
|
||||
);
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Destructor
|
||||
@ -127,6 +126,9 @@ public:
|
||||
selected_ = false;
|
||||
}
|
||||
|
||||
//- Has the given index?
|
||||
virtual bool contains(const label id) const;
|
||||
|
||||
//- Has the given index?
|
||||
virtual bool found(const label id) const;
|
||||
|
||||
@ -146,25 +148,23 @@ public:
|
||||
// Insert all members [0,maxLen) which were not in set.
|
||||
virtual void invert(const label maxLen);
|
||||
|
||||
//- Subset contents. Only elements present in both sets remain.
|
||||
virtual void subset(const labelUList& elems);
|
||||
|
||||
//- Subset contents. Only elements present in both sets remain.
|
||||
virtual void subset(const topoSet& set);
|
||||
|
||||
//- Add elements present in set.
|
||||
//- Add given elements to the set
|
||||
virtual void addSet(const labelUList& elems);
|
||||
|
||||
//- Add given elements to the set
|
||||
virtual void addSet(const topoSet& set);
|
||||
|
||||
//- Subtract elements present in set.
|
||||
//- Subtract given elements from the set.
|
||||
virtual void subtractSet(const labelUList& elems);
|
||||
|
||||
//- Subtract given elements from the set.
|
||||
virtual void subtractSet(const topoSet& set);
|
||||
|
||||
// Variants taking labelUList&
|
||||
|
||||
//- Subset contents. Only elements present in both sets remain.
|
||||
virtual void subset(const labelUList& set);
|
||||
|
||||
//- Add elements present in set.
|
||||
virtual void addSet(const labelUList& set);
|
||||
|
||||
//- Subtract elements present in set.
|
||||
virtual void subtractSet(const labelUList& set);
|
||||
};
|
||||
|
||||
|
||||
|
@ -140,6 +140,30 @@ Foam::fileName Foam::topoSet::localPath
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
bool Foam::topoSet::readIOcontents
|
||||
(
|
||||
const word& wantedType,
|
||||
labelHashSet& contents
|
||||
)
|
||||
{
|
||||
if (isReadRequired() || (isReadOptional() && headerOk()))
|
||||
{
|
||||
Istream& is = readStream(wantedType);
|
||||
|
||||
if (is.good())
|
||||
{
|
||||
is >> contents;
|
||||
close();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
|
||||
|
||||
// Update stored cell numbers using map.
|
||||
@ -200,10 +224,8 @@ void Foam::topoSet::updateLabels(const labelUList& map)
|
||||
}
|
||||
|
||||
|
||||
void Foam::topoSet::check(const label maxSize)
|
||||
void Foam::topoSet::checkLabels(const labelUList& labels, const label maxSize)
|
||||
{
|
||||
const labelHashSet& labels = *this;
|
||||
|
||||
for (const label oldId : labels)
|
||||
{
|
||||
if (oldId < 0 || oldId >= maxSize)
|
||||
@ -211,21 +233,41 @@ void Foam::topoSet::check(const label maxSize)
|
||||
FatalErrorInFunction
|
||||
<< "Illegal content " << oldId << " of set:" << name()
|
||||
<< " of type " << type() << nl
|
||||
<< "Value should be between [0," << maxSize << ')'
|
||||
<< endl
|
||||
<< "Value should be between [0," << maxSize << ')' << nl
|
||||
<< abort(FatalError);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Write maxElem elements, starting at iter. Updates iter and elemI.
|
||||
void Foam::topoSet::writeDebug
|
||||
void Foam::topoSet::checkLabels(const labelHashSet& labels, const label maxSize)
|
||||
{
|
||||
for (const label oldId : labels)
|
||||
{
|
||||
if (oldId < 0 || oldId >= maxSize)
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Illegal content " << oldId << " of set:" << name()
|
||||
<< " of type " << type() << nl
|
||||
<< "Value should be between [0," << maxSize << ')' << nl
|
||||
<< abort(FatalError);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::topoSet::check(const label maxSize)
|
||||
{
|
||||
checkLabels(*this, maxSize);
|
||||
}
|
||||
|
||||
|
||||
// Write maxElem elements, starting at iter. Updates iter
|
||||
Foam::label Foam::topoSet::writeDebug
|
||||
(
|
||||
Ostream& os,
|
||||
const label maxElem,
|
||||
topoSet::const_iterator& iter,
|
||||
label& elemI
|
||||
labelHashSet::const_iterator& iter
|
||||
) const
|
||||
{
|
||||
label n = 0;
|
||||
@ -239,19 +281,19 @@ void Foam::topoSet::writeDebug
|
||||
os << iter.key() << ' ';
|
||||
|
||||
++n;
|
||||
++elemI;
|
||||
}
|
||||
|
||||
return n;
|
||||
}
|
||||
|
||||
|
||||
// Write maxElem elements, starting at iter. Updates iter and elemI.
|
||||
void Foam::topoSet::writeDebug
|
||||
// Write maxElem elements, starting at iter. Updates iter
|
||||
Foam::label Foam::topoSet::writeDebug
|
||||
(
|
||||
Ostream& os,
|
||||
const pointField& coords,
|
||||
const label maxElem,
|
||||
topoSet::const_iterator& iter,
|
||||
label& elemI
|
||||
labelHashSet::const_iterator& iter
|
||||
) const
|
||||
{
|
||||
label n = 0;
|
||||
@ -265,8 +307,9 @@ void Foam::topoSet::writeDebug
|
||||
os << iter.key() << coords[iter.key()] << ' ';
|
||||
|
||||
++n;
|
||||
++elemI;
|
||||
}
|
||||
|
||||
return n;
|
||||
}
|
||||
|
||||
|
||||
@ -283,22 +326,20 @@ void Foam::topoSet::writeDebug
|
||||
os << "Set bounding box: min = "
|
||||
<< bb.min() << " max = " << bb.max() << " metres." << nl << endl;
|
||||
|
||||
label n = 0;
|
||||
|
||||
topoSet::const_iterator iter = this->cbegin();
|
||||
labelHashSet::const_iterator iter = labelHashSet::cbegin();
|
||||
|
||||
if (size() <= maxLen)
|
||||
{
|
||||
writeDebug(os, coords, maxLen, iter, n);
|
||||
writeDebug(os, coords, maxLen, iter);
|
||||
}
|
||||
else
|
||||
{
|
||||
label halfLen = maxLen/2;
|
||||
const label halfLen = maxLen/2;
|
||||
|
||||
os << "Size larger than " << maxLen << ". Printing first and last "
|
||||
<< halfLen << " elements:" << nl << endl;
|
||||
|
||||
writeDebug(os, coords, halfLen, iter, n);
|
||||
label n = writeDebug(os, coords, halfLen, iter);
|
||||
|
||||
os << nl << " .." << nl << endl;
|
||||
|
||||
@ -307,7 +348,7 @@ void Foam::topoSet::writeDebug
|
||||
++iter;
|
||||
}
|
||||
|
||||
writeDebug(os, coords, halfLen, iter, n);
|
||||
writeDebug(os, coords, halfLen, iter);
|
||||
}
|
||||
}
|
||||
|
||||
@ -319,7 +360,8 @@ Foam::IOobject Foam::topoSet::findIOobject
|
||||
const polyMesh& mesh,
|
||||
const word& name,
|
||||
IOobjectOption::readOption rOpt,
|
||||
IOobjectOption::writeOption wOpt
|
||||
IOobjectOption::writeOption wOpt,
|
||||
IOobjectOption::registerOption reg
|
||||
)
|
||||
{
|
||||
IOobject io
|
||||
@ -329,13 +371,14 @@ Foam::IOobject Foam::topoSet::findIOobject
|
||||
(
|
||||
mesh.meshDir()/"sets",
|
||||
word::null,
|
||||
IOobject::READ_IF_PRESENT,
|
||||
IOobjectOption::READ_IF_PRESENT,
|
||||
mesh.facesInstance()
|
||||
),
|
||||
polyMesh::meshSubDir/"sets",
|
||||
mesh,
|
||||
rOpt,
|
||||
wOpt
|
||||
wOpt,
|
||||
reg
|
||||
);
|
||||
|
||||
if (!io.typeHeaderOk<topoSet>(false) && disallowGenericSets != 0)
|
||||
@ -353,7 +396,8 @@ Foam::IOobject Foam::topoSet::findIOobject
|
||||
const Time& runTime,
|
||||
const word& name,
|
||||
IOobjectOption::readOption rOpt,
|
||||
IOobjectOption::writeOption wOpt
|
||||
IOobjectOption::writeOption wOpt,
|
||||
IOobjectOption::registerOption reg
|
||||
)
|
||||
{
|
||||
return IOobject
|
||||
@ -364,6 +408,8 @@ Foam::IOobject Foam::topoSet::findIOobject
|
||||
polyMesh::meshSubDir/"sets",
|
||||
word::null,
|
||||
IOobject::MUST_READ,
|
||||
|
||||
// The stop instance with "polyMesh/faces"
|
||||
runTime.findInstance
|
||||
(
|
||||
polyMesh::meshSubDir,
|
||||
@ -374,7 +420,8 @@ Foam::IOobject Foam::topoSet::findIOobject
|
||||
polyMesh::meshSubDir/"sets",
|
||||
runTime,
|
||||
rOpt,
|
||||
wOpt
|
||||
wOpt,
|
||||
reg
|
||||
);
|
||||
}
|
||||
|
||||
@ -385,97 +432,20 @@ Foam::topoSet::topoSet(const IOobject& io, const word& wantedType)
|
||||
:
|
||||
regIOobject(io)
|
||||
{
|
||||
if (isReadRequired() || (isReadOptional() && headerOk()))
|
||||
{
|
||||
if (readStream(wantedType).good())
|
||||
{
|
||||
readStream(wantedType) >> static_cast<labelHashSet&>(*this);
|
||||
|
||||
close();
|
||||
}
|
||||
}
|
||||
readIOcontents(wantedType, static_cast<labelHashSet&>(*this));
|
||||
}
|
||||
|
||||
|
||||
Foam::topoSet::topoSet
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
const word& wantedType,
|
||||
const word& name,
|
||||
IOobjectOption::readOption rOpt,
|
||||
IOobjectOption::writeOption wOpt
|
||||
)
|
||||
Foam::topoSet::topoSet(const IOobject& io, const Foam::zero)
|
||||
:
|
||||
regIOobject(findIOobject(mesh, name, rOpt, wOpt))
|
||||
{
|
||||
if (isReadRequired() || (isReadOptional() && headerOk()))
|
||||
{
|
||||
if (readStream(wantedType).good())
|
||||
{
|
||||
readStream(wantedType) >> static_cast<labelHashSet&>(*this);
|
||||
|
||||
close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Foam::topoSet::topoSet
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
const word& name,
|
||||
const label size,
|
||||
IOobjectOption::writeOption wOpt
|
||||
)
|
||||
:
|
||||
regIOobject(findIOobject(mesh, name, IOobject::NO_READ, wOpt)),
|
||||
labelHashSet(size)
|
||||
regIOobject(io)
|
||||
{}
|
||||
|
||||
|
||||
Foam::topoSet::topoSet
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
const word& name,
|
||||
const labelHashSet& labels,
|
||||
IOobjectOption::writeOption wOpt
|
||||
)
|
||||
:
|
||||
regIOobject(findIOobject(mesh, name, IOobject::NO_READ, wOpt)),
|
||||
labelHashSet(labels)
|
||||
{}
|
||||
|
||||
|
||||
Foam::topoSet::topoSet
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
const word& name,
|
||||
labelHashSet&& labels,
|
||||
IOobjectOption::writeOption wOpt
|
||||
)
|
||||
:
|
||||
regIOobject(findIOobject(mesh, name, IOobject::NO_READ, wOpt)),
|
||||
labelHashSet(std::move(labels))
|
||||
{}
|
||||
|
||||
|
||||
Foam::topoSet::topoSet
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
const word& name,
|
||||
const labelUList& labels,
|
||||
IOobjectOption::writeOption wOpt
|
||||
)
|
||||
:
|
||||
regIOobject(findIOobject(mesh, name, IOobject::NO_READ, wOpt)),
|
||||
labelHashSet(labels)
|
||||
{}
|
||||
|
||||
|
||||
Foam::topoSet::topoSet(const IOobject& io, const label size)
|
||||
Foam::topoSet::topoSet(const IOobject& io, const label initialCapacity)
|
||||
:
|
||||
regIOobject(io),
|
||||
labelHashSet(size)
|
||||
labelHashSet(initialCapacity)
|
||||
{}
|
||||
|
||||
|
||||
@ -493,11 +463,89 @@ Foam::topoSet::topoSet(const IOobject& io, labelHashSet&& labels)
|
||||
{}
|
||||
|
||||
|
||||
Foam::topoSet::topoSet
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
const word& wantedType,
|
||||
const word& name,
|
||||
IOobjectOption::readOption rOpt,
|
||||
IOobjectOption::writeOption wOpt,
|
||||
IOobjectOption::registerOption reg
|
||||
)
|
||||
:
|
||||
regIOobject(findIOobject(mesh, name, rOpt, wOpt, reg))
|
||||
{
|
||||
readIOcontents(wantedType, static_cast<labelHashSet&>(*this));
|
||||
}
|
||||
|
||||
|
||||
Foam::topoSet::topoSet
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
const word& name,
|
||||
const label initialCapacity,
|
||||
IOobjectOption::writeOption wOpt,
|
||||
IOobjectOption::registerOption reg
|
||||
)
|
||||
:
|
||||
regIOobject(findIOobject(mesh, name, IOobject::NO_READ, wOpt, reg)),
|
||||
labelHashSet(initialCapacity)
|
||||
{}
|
||||
|
||||
|
||||
Foam::topoSet::topoSet
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
const word& name,
|
||||
const labelHashSet& labels,
|
||||
IOobjectOption::writeOption wOpt,
|
||||
IOobjectOption::registerOption reg
|
||||
)
|
||||
:
|
||||
regIOobject(findIOobject(mesh, name, IOobject::NO_READ, wOpt, reg)),
|
||||
labelHashSet(labels)
|
||||
{}
|
||||
|
||||
|
||||
Foam::topoSet::topoSet
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
const word& name,
|
||||
labelHashSet&& labels,
|
||||
IOobjectOption::writeOption wOpt,
|
||||
IOobjectOption::registerOption reg
|
||||
)
|
||||
:
|
||||
regIOobject(findIOobject(mesh, name, IOobject::NO_READ, wOpt, reg)),
|
||||
labelHashSet(std::move(labels))
|
||||
{}
|
||||
|
||||
|
||||
Foam::topoSet::topoSet
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
const word& name,
|
||||
const labelUList& labels,
|
||||
IOobjectOption::writeOption wOpt,
|
||||
IOobjectOption::registerOption reg
|
||||
)
|
||||
:
|
||||
regIOobject(findIOobject(mesh, name, IOobject::NO_READ, wOpt, reg)),
|
||||
labelHashSet(labels)
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
bool Foam::topoSet::contains(const label id) const
|
||||
{
|
||||
return static_cast<const labelHashSet&>(*this).contains(id);
|
||||
}
|
||||
|
||||
|
||||
bool Foam::topoSet::found(const label id) const
|
||||
{
|
||||
return static_cast<const labelHashSet&>(*this).found(id);
|
||||
return static_cast<const labelHashSet&>(*this).contains(id);
|
||||
}
|
||||
|
||||
|
||||
@ -534,13 +582,13 @@ void Foam::topoSet::invert(const label maxLen)
|
||||
);
|
||||
|
||||
clear(); // Maybe don't trust the previous move operation
|
||||
reserve(max(64, (maxLen - original.size())));
|
||||
reserve(Foam::max(64, (maxLen - original.size())));
|
||||
|
||||
for (label id=0; id < maxLen; ++id)
|
||||
for (label id = 0; id < maxLen; ++id)
|
||||
{
|
||||
if (!original.found(id))
|
||||
if (!original.contains(id))
|
||||
{
|
||||
this->set(id);
|
||||
labelHashSet::set(id);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -558,10 +606,11 @@ void Foam::topoSet::subset(const labelUList& elems)
|
||||
// Only retain entries found in both sets
|
||||
auto& currentSet = static_cast<labelHashSet&>(*this);
|
||||
|
||||
DynamicList<label> newElems(elems.size()+currentSet.size());
|
||||
DynamicList<label> newElems(Foam::min(elems.size(), currentSet.size()));
|
||||
|
||||
for (const label elem : elems)
|
||||
{
|
||||
if (currentSet.found(elem))
|
||||
if (currentSet.contains(elem))
|
||||
{
|
||||
newElems.push_back(elem);
|
||||
}
|
||||
@ -609,22 +658,20 @@ void Foam::topoSet::sync(const polyMesh&)
|
||||
|
||||
void Foam::topoSet::writeDebug(Ostream& os, const label maxLen) const
|
||||
{
|
||||
label n = 0;
|
||||
|
||||
topoSet::const_iterator iter = this->cbegin();
|
||||
labelHashSet::const_iterator iter = labelHashSet::cbegin();
|
||||
|
||||
if (size() <= maxLen)
|
||||
{
|
||||
writeDebug(os, maxLen, iter, n);
|
||||
writeDebug(os, maxLen, iter);
|
||||
}
|
||||
else
|
||||
{
|
||||
label halfLen = maxLen/2;
|
||||
const label halfLen = maxLen/2;
|
||||
|
||||
os << "Size larger than " << maxLen << ". Printing first and last "
|
||||
<< halfLen << " elements:" << nl << endl;
|
||||
|
||||
writeDebug(os, halfLen, iter, n);
|
||||
label n = writeDebug(os, halfLen, iter);
|
||||
|
||||
os << nl << " .." << nl << endl;
|
||||
|
||||
@ -633,7 +680,7 @@ void Foam::topoSet::writeDebug(Ostream& os, const label maxLen) const
|
||||
++iter;
|
||||
}
|
||||
|
||||
writeDebug(os, halfLen, iter, n);
|
||||
writeDebug(os, halfLen, iter);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -70,6 +70,15 @@ protected:
|
||||
|
||||
// Protected Member Functions
|
||||
|
||||
//- Read into labelHashSet if IOobject flags set. Return true if read.
|
||||
bool readIOcontents(const word& wantedType, labelHashSet& contents);
|
||||
|
||||
//- Check limits on addressable range.
|
||||
void checkLabels(const labelUList& labels, const label maxSize);
|
||||
|
||||
//- Check limits on addressable range.
|
||||
void checkLabels(const labelHashSet& labels, const label maxSize);
|
||||
|
||||
//- Update map from map.
|
||||
// Used to update cell/face labels after morphing
|
||||
virtual void updateLabels(const labelUList& map);
|
||||
@ -77,24 +86,25 @@ protected:
|
||||
//- Check limits on addressable range.
|
||||
virtual void check(const label maxSize);
|
||||
|
||||
//- Write part of contents nicely formatted. Prints labels only.
|
||||
void writeDebug
|
||||
//- Write part of contents nicely formatted.
|
||||
// Prints labels only.
|
||||
// \returns number of labels written
|
||||
label writeDebug
|
||||
(
|
||||
Ostream& os,
|
||||
const label maxElem,
|
||||
topoSet::const_iterator& iter,
|
||||
label& elemI
|
||||
labelHashSet::const_iterator& iter
|
||||
) const;
|
||||
|
||||
//- Write part of contents nicely formatted. Prints label
|
||||
// and corresponding coordinate.
|
||||
void writeDebug
|
||||
//- Write part of contents nicely formatted.
|
||||
// Prints label and corresponding coordinate.
|
||||
// \returns number of labels written
|
||||
label writeDebug
|
||||
(
|
||||
Ostream& os,
|
||||
const pointField& coords,
|
||||
const label maxElem,
|
||||
topoSet::const_iterator& iter,
|
||||
label& elemI
|
||||
labelHashSet::const_iterator& iter
|
||||
) const;
|
||||
|
||||
//- Write labels and coordinates columnwise to os. Truncate to maxLen.
|
||||
@ -123,22 +133,37 @@ public:
|
||||
//- Name of file set will use.
|
||||
static fileName localPath(const polyMesh& mesh, const word& name);
|
||||
|
||||
//- Find IOobject in the polyMesh/sets (used as constructor helper)
|
||||
//- Find IOobject in the polyMesh/sets/ (used as constructor helper)
|
||||
static IOobject findIOobject
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
const word& name,
|
||||
IOobjectOption::readOption rOpt = IOobjectOption::MUST_READ,
|
||||
IOobjectOption::writeOption wOpt = IOobjectOption::NO_WRITE
|
||||
IOobjectOption::writeOption wOpt = IOobjectOption::NO_WRITE,
|
||||
IOobjectOption::registerOption reg = IOobjectOption::LEGACY_REGISTER
|
||||
);
|
||||
|
||||
//- Find IOobject in the polyMesh/sets (used as constructor helper)
|
||||
//- Find IOobject in the polyMesh/sets/ (used as constructor helper)
|
||||
static IOobject findIOobject
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
const word& name,
|
||||
IOobjectOption::registerOption reg,
|
||||
IOobjectOption::readOption rOpt = IOobjectOption::MUST_READ,
|
||||
IOobjectOption::writeOption wOpt = IOobjectOption::NO_WRITE
|
||||
)
|
||||
{
|
||||
return findIOobject(mesh, name, rOpt, wOpt, reg);
|
||||
}
|
||||
|
||||
//- Find IOobject in the polyMesh/sets/ (used as constructor helper)
|
||||
static IOobject findIOobject
|
||||
(
|
||||
const Time& runTime,
|
||||
const word& name,
|
||||
IOobjectOption::readOption rOpt = IOobjectOption::MUST_READ,
|
||||
IOobjectOption::writeOption wOpt = IOobjectOption::NO_WRITE
|
||||
IOobjectOption::writeOption wOpt = IOobjectOption::NO_WRITE,
|
||||
IOobjectOption::registerOption reg = IOobjectOption::LEGACY_REGISTER
|
||||
);
|
||||
|
||||
|
||||
@ -196,6 +221,21 @@ public:
|
||||
// Can't use typeName info here since subclasses not yet instantiated
|
||||
topoSet(const IOobject& io, const word& wantedType);
|
||||
|
||||
//- Construct empty (no-read) with IOobject information
|
||||
topoSet(const IOobject& io, const Foam::zero);
|
||||
|
||||
//- Construct empty (no-read) with initial labelHashSet capacity,
|
||||
//- with IOobject information
|
||||
topoSet(const IOobject& io, const label initialCapacity);
|
||||
|
||||
//- Copy construct (no-read) from labelHashSet,
|
||||
//- with IOobject information.
|
||||
topoSet(const IOobject& io, const labelHashSet& labels);
|
||||
|
||||
//- Move construct (no-read) from labelHashSet,
|
||||
//- with IOobject information.
|
||||
topoSet(const IOobject& io, labelHashSet&& labels);
|
||||
|
||||
//- Construct from polyMesh and name.
|
||||
// Searches for a polyMesh/sets directory but not beyond the
|
||||
// mesh.facesInstance().
|
||||
@ -205,21 +245,23 @@ public:
|
||||
const word& wantedType,
|
||||
const word& name,
|
||||
IOobjectOption::readOption rOpt = IOobjectOption::MUST_READ,
|
||||
IOobjectOption::writeOption wOpt = IOobjectOption::NO_WRITE
|
||||
IOobjectOption::writeOption wOpt = IOobjectOption::NO_WRITE,
|
||||
IOobjectOption::registerOption reg = IOobjectOption::LEGACY_REGISTER
|
||||
);
|
||||
|
||||
//- Construct empty from additional size of labelHashSet.
|
||||
//- Construct empty (no-read) with initial labelHashSet capacity.
|
||||
// Searches for a polyMesh/sets directory but not beyond the
|
||||
// mesh.facesInstance().
|
||||
topoSet
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
const word& name,
|
||||
const label size,
|
||||
IOobjectOption::writeOption wOpt = IOobjectOption::NO_WRITE
|
||||
const label initialCapacity,
|
||||
IOobjectOption::writeOption wOpt = IOobjectOption::NO_WRITE,
|
||||
IOobjectOption::registerOption reg = IOobjectOption::LEGACY_REGISTER
|
||||
);
|
||||
|
||||
//- Construct (no-read) with copy of labelHashSet
|
||||
//- Copy construct (no-read) from labelHashSet.
|
||||
// Searches for a polyMesh/sets directory but not beyond the
|
||||
// mesh.facesInstance().
|
||||
topoSet
|
||||
@ -227,10 +269,11 @@ public:
|
||||
const polyMesh& mesh,
|
||||
const word& name,
|
||||
const labelHashSet& labels,
|
||||
IOobjectOption::writeOption wOpt = IOobjectOption::NO_WRITE
|
||||
IOobjectOption::writeOption wOpt = IOobjectOption::NO_WRITE,
|
||||
IOobjectOption::registerOption reg = IOobjectOption::LEGACY_REGISTER
|
||||
);
|
||||
|
||||
//- Construct (no-read) with moving labelHashSet
|
||||
//- Move construct (no-read) from labelHashSet.
|
||||
// Searches for a polyMesh/sets directory but not beyond the
|
||||
// mesh.facesInstance().
|
||||
topoSet
|
||||
@ -238,10 +281,11 @@ public:
|
||||
const polyMesh& mesh,
|
||||
const word& name,
|
||||
labelHashSet&& labels,
|
||||
IOobjectOption::writeOption wOpt = IOobjectOption::NO_WRITE
|
||||
IOobjectOption::writeOption wOpt = IOobjectOption::NO_WRITE,
|
||||
IOobjectOption::registerOption reg = IOobjectOption::LEGACY_REGISTER
|
||||
);
|
||||
|
||||
//- Construct (no-read) with copy of labels
|
||||
//- Copy construct (no-read) from list of labels.
|
||||
// Searches for a polyMesh/sets directory but not beyond the
|
||||
// mesh.facesInstance().
|
||||
topoSet
|
||||
@ -249,18 +293,10 @@ public:
|
||||
const polyMesh& mesh,
|
||||
const word& name,
|
||||
const labelUList& labels,
|
||||
IOobjectOption::writeOption wOpt = IOobjectOption::NO_WRITE
|
||||
IOobjectOption::writeOption wOpt = IOobjectOption::NO_WRITE,
|
||||
IOobjectOption::registerOption reg = IOobjectOption::LEGACY_REGISTER
|
||||
);
|
||||
|
||||
//- Construct empty from IOobject and HashSet size.
|
||||
topoSet(const IOobject& io, const label size);
|
||||
|
||||
//- Construct from IOobject and copy of labelHashSet.
|
||||
topoSet(const IOobject& io, const labelHashSet& labels);
|
||||
|
||||
//- Construct from IOobject and move labelHashSet.
|
||||
topoSet(const IOobject& io, labelHashSet&& labels);
|
||||
|
||||
|
||||
//- Clone
|
||||
autoPtr<topoSet> clone() const
|
||||
@ -309,6 +345,9 @@ public:
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Has the given index?
|
||||
virtual bool contains(const label id) const;
|
||||
|
||||
//- Has the given index?
|
||||
virtual bool found(const label id) const;
|
||||
|
||||
@ -329,23 +368,23 @@ public:
|
||||
virtual void invert(const label maxLen);
|
||||
|
||||
//- Subset contents. Only elements present in both sets remain.
|
||||
virtual void subset(const topoSet& set);
|
||||
virtual void subset(const labelUList& elems);
|
||||
|
||||
//- Subset contents. Only elements present in both sets remain.
|
||||
virtual void subset(const labelUList& set);
|
||||
virtual void subset(const topoSet& set);
|
||||
|
||||
//- Add elements
|
||||
//- Add given elements to the set
|
||||
virtual void addSet(const labelUList& elems);
|
||||
|
||||
//- Add given elements to the set
|
||||
virtual void addSet(const topoSet& set);
|
||||
|
||||
//- Add elements
|
||||
virtual void addSet(const labelUList& set);
|
||||
//- Subtract given elements from the set
|
||||
virtual void subtractSet(const labelUList& elems);
|
||||
|
||||
//- Subtract elements
|
||||
//- Subtract given elements from the set
|
||||
virtual void subtractSet(const topoSet& set);
|
||||
|
||||
//- Subtract elements
|
||||
virtual void subtractSet(const labelUList& set);
|
||||
|
||||
|
||||
//- Sync set across coupled patches.
|
||||
virtual void sync(const polyMesh& mesh);
|
||||
@ -374,19 +413,23 @@ public:
|
||||
//- Return max allowable index (+1). Not implemented.
|
||||
virtual label maxSize(const polyMesh& mesh) const = 0;
|
||||
|
||||
//- Helper: call updateMesh on all sets in container (and
|
||||
// updates instance)
|
||||
//- Helper: call updateMesh on all items in container
|
||||
//- (and updates instance)
|
||||
template<class Container>
|
||||
static void updateMesh
|
||||
(
|
||||
const fileName& instance,
|
||||
const mapPolyMesh&,
|
||||
Container&
|
||||
Container& items
|
||||
);
|
||||
|
||||
//- Helper: set instance on all sets in container
|
||||
//- Helper: set instance on all items in container
|
||||
template<class Container>
|
||||
static void setInstance(const fileName& instance, Container&);
|
||||
static void setInstance
|
||||
(
|
||||
const fileName& instance,
|
||||
Container& items
|
||||
);
|
||||
|
||||
//- Helper: remove all sets files from mesh instance
|
||||
static void removeFiles(const polyMesh&);
|
||||
|
@ -25,19 +25,18 @@ License
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class Container>
|
||||
void Foam::topoSet::setInstance
|
||||
(
|
||||
const fileName& instance,
|
||||
Container& lst
|
||||
Container& items
|
||||
)
|
||||
{
|
||||
forAll(lst, i)
|
||||
for (auto& item : items)
|
||||
{
|
||||
lst[i].instance() = instance;
|
||||
item.instance() = instance;
|
||||
}
|
||||
}
|
||||
|
||||
@ -47,13 +46,13 @@ void Foam::topoSet::updateMesh
|
||||
(
|
||||
const fileName& instance,
|
||||
const mapPolyMesh& map,
|
||||
Container& lst
|
||||
Container& items
|
||||
)
|
||||
{
|
||||
forAll(lst, i)
|
||||
for (auto& item : items)
|
||||
{
|
||||
lst[i].instance() = instance;
|
||||
lst[i].updateMesh(map);
|
||||
item.instance() = instance;
|
||||
item.updateMesh(map);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -377,14 +377,16 @@ void Foam::regionsToCell::combine(topoSet& set, const bool add) const
|
||||
// Note: wip. Select cells first
|
||||
boolList selectedCell(mesh_.nCells(), true);
|
||||
|
||||
if (setName_.size() && setName_ != "none")
|
||||
if (!setName_.empty() && setName_ != "none")
|
||||
{
|
||||
Info<< " Loading subset " << setName_ << " to delimit search region."
|
||||
<< endl;
|
||||
cellSet subSet(mesh_, setName_);
|
||||
Info<< " Loading subset " << setName_
|
||||
<< " to delimit search region." << nl;
|
||||
|
||||
cellSet loadedSet(mesh_, setName_, IOobject::NO_REGISTER);
|
||||
const labelHashSet& cellLabels = loadedSet;
|
||||
|
||||
selectedCell = false;
|
||||
for (const label celli : static_cast<const labelHashSet&>(subSet))
|
||||
for (const label celli : cellLabels)
|
||||
{
|
||||
selectedCell[celli] = true;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user