ENH: improve HashSet construction and assignment
- make construct from UList explicit and provide corresponding assignment operator. - add construct,insert,set,assignment from FixedList. This is convenient when dealing with things like edges or triFaces.
This commit is contained in:
parent
a2ddf7dd48
commit
6a5ea9a2bf
@ -128,6 +128,9 @@ int main(int argc, char *argv[])
|
||||
1, 11, 42
|
||||
};
|
||||
|
||||
setB = FixedList<label, 4>({1, 2, 3, 4});
|
||||
setB = {1, 2, 4};
|
||||
setB = List<label>({1, 2, 4});
|
||||
Info<< "setB : " << setB << endl;
|
||||
|
||||
labelPair pair(12, 15);
|
||||
|
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
|
||||
\\/ M anipulation | Copyright (C) 2016-2017 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -27,6 +27,52 @@ License
|
||||
#define HashSet_C
|
||||
|
||||
#include "HashSet.H"
|
||||
#include "FixedList.H"
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
template<class Key, class Hash>
|
||||
template<class InputIter>
|
||||
inline Foam::label Foam::HashSet<Key, Hash>::insertMultiple
|
||||
(
|
||||
const InputIter begIter,
|
||||
const InputIter endIter
|
||||
)
|
||||
{
|
||||
label changed = 0;
|
||||
for (InputIter iter = begIter; iter != endIter; ++iter)
|
||||
{
|
||||
if (insert(*iter))
|
||||
{
|
||||
++changed;
|
||||
}
|
||||
}
|
||||
return changed;
|
||||
}
|
||||
|
||||
|
||||
template<class Key, class Hash>
|
||||
template<class InputIter>
|
||||
inline Foam::label Foam::HashSet<Key, Hash>::assignMultiple
|
||||
(
|
||||
const InputIter begIter,
|
||||
const InputIter endIter,
|
||||
const label sz
|
||||
)
|
||||
{
|
||||
if (!this->capacity())
|
||||
{
|
||||
// Could be zero-sized from a previous transfer()?
|
||||
this->resize(sz);
|
||||
}
|
||||
else
|
||||
{
|
||||
this->clear();
|
||||
}
|
||||
|
||||
return insertMultiple(begIter, endIter);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
@ -35,9 +81,22 @@ Foam::HashSet<Key, Hash>::HashSet(const UList<Key>& lst)
|
||||
:
|
||||
HashTable<nil, Key, Hash>(2*lst.size())
|
||||
{
|
||||
forAll(lst, elemI)
|
||||
for (const auto& k : lst)
|
||||
{
|
||||
this->insert(lst[elemI]);
|
||||
this->insert(k);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<class Key, class Hash>
|
||||
template<unsigned Size>
|
||||
Foam::HashSet<Key, Hash>::HashSet(const FixedList<Key, Size>& lst)
|
||||
:
|
||||
HashTable<nil, Key, Hash>(2*lst.size())
|
||||
{
|
||||
for (const auto& k : lst)
|
||||
{
|
||||
this->insert(k);
|
||||
}
|
||||
}
|
||||
|
||||
@ -47,7 +106,7 @@ Foam::HashSet<Key, Hash>::HashSet(std::initializer_list<Key> lst)
|
||||
:
|
||||
HashTable<nil, Key, Hash>(2*lst.size())
|
||||
{
|
||||
for (const Key& k : lst)
|
||||
for (const auto& k : lst)
|
||||
{
|
||||
this->insert(k);
|
||||
}
|
||||
@ -81,36 +140,47 @@ Foam::HashSet<Key, Hash>::HashSet
|
||||
template<class Key, class Hash>
|
||||
Foam::label Foam::HashSet<Key, Hash>::insert(const UList<Key>& lst)
|
||||
{
|
||||
label count = 0;
|
||||
forAll(lst, elemI)
|
||||
{
|
||||
if (this->insert(lst[elemI]))
|
||||
{
|
||||
++count;
|
||||
}
|
||||
}
|
||||
return insertMultiple(lst.begin(), lst.end());
|
||||
}
|
||||
|
||||
return count;
|
||||
template<class Key, class Hash>
|
||||
template<unsigned Size>
|
||||
Foam::label Foam::HashSet<Key, Hash>::insert(const FixedList<Key, Size>& lst)
|
||||
{
|
||||
return insertMultiple(lst.begin(), lst.end());
|
||||
}
|
||||
|
||||
template<class Key, class Hash>
|
||||
Foam::label Foam::HashSet<Key, Hash>::insert(std::initializer_list<Key> lst)
|
||||
{
|
||||
label count = 0;
|
||||
for (const Key& k : lst)
|
||||
{
|
||||
if (this->insert(k))
|
||||
{
|
||||
++count;
|
||||
}
|
||||
}
|
||||
|
||||
return count;
|
||||
return insertMultiple(lst.begin(), lst.end());
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
|
||||
|
||||
template<class Key, class Hash>
|
||||
void Foam::HashSet<Key, Hash>::operator=(const UList<Key>& lst)
|
||||
{
|
||||
assignMultiple(lst.begin(), lst.end(), lst.size());
|
||||
}
|
||||
|
||||
|
||||
template<class Key, class Hash>
|
||||
template<unsigned Size>
|
||||
void Foam::HashSet<Key, Hash>::operator=(const FixedList<Key, Size>& lst)
|
||||
{
|
||||
assignMultiple(lst.begin(), lst.end(), lst.size());
|
||||
}
|
||||
|
||||
|
||||
template<class Key, class Hash>
|
||||
void Foam::HashSet<Key, Hash>::operator=(std::initializer_list<Key> lst)
|
||||
{
|
||||
assignMultiple(lst.begin(), lst.end(), lst.size());
|
||||
}
|
||||
|
||||
|
||||
template<class Key, class Hash>
|
||||
inline bool Foam::HashSet<Key, Hash>::operator[](const Key& key) const
|
||||
{
|
||||
|
@ -61,6 +61,25 @@ class HashSet
|
||||
:
|
||||
public HashTable<nil, Key, Hash>
|
||||
{
|
||||
// Private Member Functions
|
||||
|
||||
//- Insert values, using begin/end iterators.
|
||||
template<class InputIter>
|
||||
inline label insertMultiple
|
||||
(
|
||||
const InputIter begIter,
|
||||
const InputIter endIter
|
||||
);
|
||||
|
||||
//- Assign using begin/end iterators.
|
||||
template<class InputIter>
|
||||
inline label assignMultiple
|
||||
(
|
||||
const InputIter begIter,
|
||||
const InputIter endIter,
|
||||
const label sz
|
||||
);
|
||||
|
||||
|
||||
public:
|
||||
|
||||
@ -83,7 +102,11 @@ public:
|
||||
{}
|
||||
|
||||
//- Construct from UList of Key
|
||||
HashSet(const UList<Key>& lst);
|
||||
explicit HashSet(const UList<Key>& lst);
|
||||
|
||||
//- Construct from FixedList of Key
|
||||
template<unsigned Size>
|
||||
explicit HashSet(const FixedList<Key, Size>& lst);
|
||||
|
||||
//- Construct from an initializer list of Key
|
||||
HashSet(std::initializer_list<Key> lst);
|
||||
@ -109,7 +132,7 @@ public:
|
||||
//- Construct from the keys of another HashTable,
|
||||
// the type of values held is arbitrary.
|
||||
template<class AnyType, class AnyHash>
|
||||
HashSet(const HashTable<AnyType, Key, AnyHash>& h);
|
||||
explicit HashSet(const HashTable<AnyType, Key, AnyHash>& h);
|
||||
|
||||
|
||||
// Member Functions
|
||||
@ -126,6 +149,11 @@ public:
|
||||
// Return the number of new elements inserted
|
||||
label insert(const UList<Key>& lst);
|
||||
|
||||
//- Insert keys from the list of Key
|
||||
// Return the number of new elements inserted
|
||||
template<unsigned Size>
|
||||
label insert(const FixedList<Key, Size>& lst);
|
||||
|
||||
//- Insert keys from a initializer list of Key
|
||||
// Return the number of new elements inserted
|
||||
label insert(std::initializer_list<Key> lst);
|
||||
@ -142,6 +170,13 @@ public:
|
||||
return insert(lst);
|
||||
}
|
||||
|
||||
//- Same as insert (cannot overwrite nil content)
|
||||
template<unsigned Size>
|
||||
label set(const FixedList<Key, Size>& lst)
|
||||
{
|
||||
return insert(lst);
|
||||
}
|
||||
|
||||
//- Same as insert (cannot overwrite nil content)
|
||||
label set(std::initializer_list<Key> lst)
|
||||
{
|
||||
@ -187,6 +222,17 @@ public:
|
||||
bool operator!=(const HashSet<Key, Hash>& rhs) const;
|
||||
|
||||
|
||||
//- Assignment from a UList of keys
|
||||
void operator=(const UList<Key>& lst);
|
||||
|
||||
//- Assignment from a FixedList of keys
|
||||
template<unsigned Size>
|
||||
void operator=(const FixedList<Key, Size>& lst);
|
||||
|
||||
//- Assignment from an initializer list of keys
|
||||
void operator=(std::initializer_list<Key> lst);
|
||||
|
||||
|
||||
//- Combine entries from HashSets
|
||||
void operator|=(const HashSet<Key, Hash>& rhs);
|
||||
|
||||
|
@ -1384,6 +1384,23 @@ void Foam::fvMeshSubset::setLargeCellSubset
|
||||
}
|
||||
|
||||
|
||||
void Foam::fvMeshSubset::setLargeCellSubset
|
||||
(
|
||||
const UList<label>& globalCellMap,
|
||||
const label patchID,
|
||||
const bool syncPar
|
||||
)
|
||||
{
|
||||
labelList region(baseMesh().nCells(), 0);
|
||||
|
||||
for (auto cellId : globalCellMap)
|
||||
{
|
||||
region[cellId] = 1;
|
||||
}
|
||||
setLargeCellSubset(region, 1, patchID, syncPar);
|
||||
}
|
||||
|
||||
|
||||
void Foam::fvMeshSubset::setLargeCellSubset
|
||||
(
|
||||
const labelHashSet& globalCellMap,
|
||||
|
@ -177,6 +177,14 @@ public:
|
||||
const bool syncCouples = true
|
||||
);
|
||||
|
||||
//- setLargeCellSubset but only marking certain cells
|
||||
void setLargeCellSubset
|
||||
(
|
||||
const UList<label>& globalCellMap,
|
||||
const label patchID = -1,
|
||||
const bool syncPar = true
|
||||
);
|
||||
|
||||
//- setLargeCellSubset but with labelHashSet.
|
||||
void setLargeCellSubset
|
||||
(
|
||||
|
@ -90,6 +90,22 @@ void Foam::motionSmootherAlgo::checkFld(const pointScalarField& fld)
|
||||
}
|
||||
|
||||
|
||||
Foam::labelHashSet Foam::motionSmootherAlgo::getPoints
|
||||
(
|
||||
const UList<label>& faceLabels
|
||||
) const
|
||||
{
|
||||
labelHashSet usedPoints(mesh_.nPoints()/100);
|
||||
|
||||
for (auto faceId : faceLabels)
|
||||
{
|
||||
usedPoints.insert(mesh_.faces()[faceId]);
|
||||
}
|
||||
|
||||
return usedPoints;
|
||||
}
|
||||
|
||||
|
||||
Foam::labelHashSet Foam::motionSmootherAlgo::getPoints
|
||||
(
|
||||
const labelHashSet& faceLabels
|
||||
@ -99,12 +115,7 @@ Foam::labelHashSet Foam::motionSmootherAlgo::getPoints
|
||||
|
||||
forAllConstIter(labelHashSet, faceLabels, iter)
|
||||
{
|
||||
const face& f = mesh_.faces()[iter.key()];
|
||||
|
||||
forAll(f, fp)
|
||||
{
|
||||
usedPoints.insert(f[fp]);
|
||||
}
|
||||
usedPoints.insert(mesh_.faces()[iter.key()]);
|
||||
}
|
||||
|
||||
return usedPoints;
|
||||
|
@ -209,7 +209,10 @@ class motionSmootherAlgo
|
||||
static void checkFld(const pointScalarField&);
|
||||
|
||||
//- Get points used by given faces
|
||||
labelHashSet getPoints(const labelHashSet&) const;
|
||||
labelHashSet getPoints(const UList<label>& faceLabels) const;
|
||||
|
||||
//- Get points used by given faces
|
||||
labelHashSet getPoints(const labelHashSet& faceLabels) const;
|
||||
|
||||
//- Calculate per-edge weight
|
||||
tmp<scalarField> calcEdgeWeights(const pointField&) const;
|
||||
|
@ -42,7 +42,7 @@ defineTypeNameAndDebug(edgeCollapser, 0);
|
||||
}
|
||||
|
||||
|
||||
Foam::HashSet<Foam::label> Foam::edgeCollapser::checkBadFaces
|
||||
Foam::labelHashSet Foam::edgeCollapser::checkBadFaces
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
const dictionary& meshQualityDict
|
||||
|
@ -263,7 +263,7 @@ public:
|
||||
// Check
|
||||
|
||||
//- Calls motionSmoother::checkMesh and returns a set of bad faces
|
||||
static HashSet<label> checkBadFaces
|
||||
static labelHashSet checkBadFaces
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
const dictionary& meshQualityDict
|
||||
|
@ -178,7 +178,7 @@ bool Foam::functionObjects::ddt2::execute()
|
||||
{
|
||||
results_.clear();
|
||||
|
||||
wordHashSet candidates = subsetStrings(selectFields_, mesh_.names());
|
||||
wordHashSet candidates(subsetStrings(selectFields_, mesh_.names()));
|
||||
DynamicList<word> missing(selectFields_.size());
|
||||
DynamicList<word> ignored(selectFields_.size());
|
||||
|
||||
|
@ -135,7 +135,7 @@ bool Foam::functionObjects::zeroGradient::execute()
|
||||
{
|
||||
results_.clear();
|
||||
|
||||
wordHashSet candidates = subsetStrings(selectFields_, mesh_.names());
|
||||
wordHashSet candidates(subsetStrings(selectFields_, mesh_.names()));
|
||||
DynamicList<word> missing(selectFields_.size());
|
||||
DynamicList<word> ignored(selectFields_.size());
|
||||
|
||||
|
@ -246,7 +246,7 @@ bool Foam::functionObjects::ensightWrite::write()
|
||||
ensCase().setTime(t.value(), t.timeIndex());
|
||||
}
|
||||
|
||||
wordHashSet candidates = subsetStrings(selectFields_, mesh_.names());
|
||||
wordHashSet candidates(subsetStrings(selectFields_, mesh_.names()));
|
||||
DynamicList<word> missing(selectFields_.size());
|
||||
DynamicList<word> ignored(selectFields_.size());
|
||||
|
||||
|
@ -1352,6 +1352,12 @@ public:
|
||||
const labelHashSet& set
|
||||
) const;
|
||||
|
||||
// Pick up faces of cells of faces in set.
|
||||
labelList growFaceCellFace
|
||||
(
|
||||
const UList<label>& set
|
||||
) const;
|
||||
|
||||
// Pick up faces of cells of faces in set.
|
||||
labelList growFaceCellFace
|
||||
(
|
||||
|
@ -790,6 +790,62 @@ Foam::labelList Foam::meshRefinement::collectFaces
|
||||
}
|
||||
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
// Pick up faces of cells of faces in set.
|
||||
// file-scope
|
||||
static inline void markGrowFaceCellFace
|
||||
(
|
||||
const polyMesh& pMesh,
|
||||
const label faceI,
|
||||
boolList& selected
|
||||
)
|
||||
{
|
||||
const label own = pMesh.faceOwner()[faceI];
|
||||
|
||||
const cell& ownFaces = pMesh.cells()[own];
|
||||
forAll(ownFaces, ownFaceI)
|
||||
{
|
||||
selected[ownFaces[ownFaceI]] = true;
|
||||
}
|
||||
|
||||
if (pMesh.isInternalFace(faceI))
|
||||
{
|
||||
const label nbr = pMesh.faceNeighbour()[faceI];
|
||||
|
||||
const cell& nbrFaces = pMesh.cells()[nbr];
|
||||
forAll(nbrFaces, nbrFaceI)
|
||||
{
|
||||
selected[nbrFaces[nbrFaceI]] = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Pick up faces of cells of faces in set.
|
||||
Foam::labelList Foam::meshRefinement::growFaceCellFace
|
||||
(
|
||||
const UList<label>& set
|
||||
) const
|
||||
{
|
||||
boolList selected(mesh_.nFaces(), false);
|
||||
|
||||
for (auto faceI : set)
|
||||
{
|
||||
markGrowFaceCellFace(mesh_, faceI, selected);
|
||||
}
|
||||
|
||||
syncTools::syncFaceList
|
||||
(
|
||||
mesh_,
|
||||
selected,
|
||||
orEqOp<bool>() // combine operator
|
||||
);
|
||||
return findIndices(selected, true);
|
||||
}
|
||||
|
||||
|
||||
// Pick up faces of cells of faces in set.
|
||||
Foam::labelList Foam::meshRefinement::growFaceCellFace
|
||||
(
|
||||
@ -798,29 +854,12 @@ Foam::labelList Foam::meshRefinement::growFaceCellFace
|
||||
{
|
||||
boolList selected(mesh_.nFaces(), false);
|
||||
|
||||
forAllConstIter(faceSet, set, iter)
|
||||
forAllConstIter(labelHashSet, set, iter)
|
||||
{
|
||||
label faceI = iter.key();
|
||||
|
||||
label own = mesh_.faceOwner()[faceI];
|
||||
|
||||
const cell& ownFaces = mesh_.cells()[own];
|
||||
forAll(ownFaces, ownFaceI)
|
||||
{
|
||||
selected[ownFaces[ownFaceI]] = true;
|
||||
}
|
||||
|
||||
if (mesh_.isInternalFace(faceI))
|
||||
{
|
||||
label nbr = mesh_.faceNeighbour()[faceI];
|
||||
|
||||
const cell& nbrFaces = mesh_.cells()[nbr];
|
||||
forAll(nbrFaces, nbrFaceI)
|
||||
{
|
||||
selected[nbrFaces[nbrFaceI]] = true;
|
||||
}
|
||||
}
|
||||
const label faceI = iter.key();
|
||||
markGrowFaceCellFace(mesh_, faceI, selected);
|
||||
}
|
||||
|
||||
syncTools::syncFaceList
|
||||
(
|
||||
mesh_,
|
||||
|
@ -30,29 +30,26 @@ License
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
#include "mapDistributePolyMesh.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
defineTypeNameAndDebug(cellSet, 0);
|
||||
|
||||
addToRunTimeSelectionTable(topoSet, cellSet, word);
|
||||
addToRunTimeSelectionTable(topoSet, cellSet, size);
|
||||
addToRunTimeSelectionTable(topoSet, cellSet, set);
|
||||
|
||||
}
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
cellSet::cellSet(const IOobject& obj)
|
||||
Foam::cellSet::cellSet(const IOobject& obj)
|
||||
:
|
||||
topoSet(obj, typeName)
|
||||
{}
|
||||
|
||||
|
||||
cellSet::cellSet
|
||||
Foam::cellSet::cellSet
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
const word& name,
|
||||
@ -67,7 +64,7 @@ cellSet::cellSet
|
||||
}
|
||||
|
||||
|
||||
cellSet::cellSet
|
||||
Foam::cellSet::cellSet
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
const word& name,
|
||||
@ -79,7 +76,7 @@ cellSet::cellSet
|
||||
{}
|
||||
|
||||
|
||||
cellSet::cellSet
|
||||
Foam::cellSet::cellSet
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
const word& name,
|
||||
@ -91,7 +88,7 @@ cellSet::cellSet
|
||||
{}
|
||||
|
||||
|
||||
cellSet::cellSet
|
||||
Foam::cellSet::cellSet
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
const word& name,
|
||||
@ -103,8 +100,20 @@ cellSet::cellSet
|
||||
{}
|
||||
|
||||
|
||||
Foam::cellSet::cellSet
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
const word& name,
|
||||
const UList<label>& set,
|
||||
writeOption w
|
||||
)
|
||||
:
|
||||
topoSet(mesh, name, set, w)
|
||||
{}
|
||||
|
||||
|
||||
// Database constructors (for when no mesh available)
|
||||
cellSet::cellSet
|
||||
Foam::cellSet::cellSet
|
||||
(
|
||||
const Time& runTime,
|
||||
const word& name,
|
||||
@ -114,32 +123,13 @@ cellSet::cellSet
|
||||
:
|
||||
topoSet
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
name,
|
||||
runTime.findInstance
|
||||
(
|
||||
polyMesh::meshSubDir/"sets", //polyMesh::meshSubDir,
|
||||
word::null, //"faces"
|
||||
IOobject::MUST_READ,
|
||||
runTime.findInstance
|
||||
(
|
||||
polyMesh::meshSubDir,
|
||||
"faces",
|
||||
IOobject::READ_IF_PRESENT
|
||||
)
|
||||
),
|
||||
polyMesh::meshSubDir/"sets",
|
||||
runTime,
|
||||
r,
|
||||
w
|
||||
),
|
||||
findIOobject(runTime, name, r, w),
|
||||
typeName
|
||||
)
|
||||
{}
|
||||
|
||||
|
||||
cellSet::cellSet
|
||||
Foam::cellSet::cellSet
|
||||
(
|
||||
const Time& runTime,
|
||||
const word& name,
|
||||
@ -149,32 +139,13 @@ cellSet::cellSet
|
||||
:
|
||||
topoSet
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
name,
|
||||
runTime.findInstance
|
||||
(
|
||||
polyMesh::meshSubDir/"sets", //polyMesh::meshSubDir,
|
||||
word::null, //"faces"
|
||||
IOobject::NO_READ,
|
||||
runTime.findInstance
|
||||
(
|
||||
polyMesh::meshSubDir,
|
||||
"faces",
|
||||
IOobject::READ_IF_PRESENT
|
||||
)
|
||||
),
|
||||
polyMesh::meshSubDir/"sets",
|
||||
runTime,
|
||||
IOobject::NO_READ,
|
||||
w
|
||||
),
|
||||
findIOobject(runTime, name, IOobject::NO_READ, w),
|
||||
size
|
||||
)
|
||||
{}
|
||||
|
||||
|
||||
cellSet::cellSet
|
||||
Foam::cellSet::cellSet
|
||||
(
|
||||
const Time& runTime,
|
||||
const word& name,
|
||||
@ -184,26 +155,7 @@ cellSet::cellSet
|
||||
:
|
||||
topoSet
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
name,
|
||||
runTime.findInstance
|
||||
(
|
||||
polyMesh::meshSubDir/"sets", //polyMesh::meshSubDir,
|
||||
word::null, //"faces"
|
||||
IOobject::NO_READ,
|
||||
runTime.findInstance
|
||||
(
|
||||
polyMesh::meshSubDir,
|
||||
"faces",
|
||||
IOobject::READ_IF_PRESENT
|
||||
)
|
||||
),
|
||||
polyMesh::meshSubDir/"sets",
|
||||
runTime,
|
||||
IOobject::NO_READ,
|
||||
w
|
||||
),
|
||||
findIOobject(runTime, name, IOobject::NO_READ, w),
|
||||
set
|
||||
)
|
||||
{}
|
||||
@ -211,25 +163,25 @@ cellSet::cellSet
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
cellSet::~cellSet()
|
||||
Foam::cellSet::~cellSet()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
label cellSet::maxSize(const polyMesh& mesh) const
|
||||
Foam::label Foam::cellSet::maxSize(const polyMesh& mesh) const
|
||||
{
|
||||
return mesh.nCells();
|
||||
}
|
||||
|
||||
|
||||
void cellSet::updateMesh(const mapPolyMesh& morphMap)
|
||||
void Foam::cellSet::updateMesh(const mapPolyMesh& morphMap)
|
||||
{
|
||||
updateLabels(morphMap.reverseCellMap());
|
||||
}
|
||||
|
||||
|
||||
void cellSet::distribute(const mapDistributePolyMesh& map)
|
||||
void Foam::cellSet::distribute(const mapDistributePolyMesh& map)
|
||||
{
|
||||
boolList inSet(map.nOldCells());
|
||||
forAllConstIter(cellSet, *this, iter)
|
||||
@ -271,8 +223,4 @@ void Foam::cellSet::writeDebug
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// ************************************************************************* //
|
||||
|
@ -53,7 +53,7 @@ class cellSet
|
||||
// Private Member Functions
|
||||
|
||||
//- Disallow default bitwise copy construct
|
||||
cellSet(const cellSet&);
|
||||
cellSet(const cellSet&) = delete;
|
||||
|
||||
|
||||
public:
|
||||
@ -81,7 +81,7 @@ public:
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
const word& name,
|
||||
const label sizes,
|
||||
const label size,
|
||||
writeOption w=NO_WRITE
|
||||
);
|
||||
|
||||
@ -90,7 +90,7 @@ public:
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
const word& name,
|
||||
const topoSet&,
|
||||
const topoSet& set,
|
||||
writeOption w=NO_WRITE
|
||||
);
|
||||
|
||||
@ -99,7 +99,16 @@ public:
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
const word& name,
|
||||
const labelHashSet&,
|
||||
const labelHashSet& set,
|
||||
writeOption w=NO_WRITE
|
||||
);
|
||||
|
||||
//- Construct from additional list of labels for the labelHashSet
|
||||
cellSet
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
const word& name,
|
||||
const UList<label>& set,
|
||||
writeOption w=NO_WRITE
|
||||
);
|
||||
|
||||
|
@ -31,29 +31,26 @@ License
|
||||
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
defineTypeNameAndDebug(faceSet, 0);
|
||||
|
||||
addToRunTimeSelectionTable(topoSet, faceSet, word);
|
||||
addToRunTimeSelectionTable(topoSet, faceSet, size);
|
||||
addToRunTimeSelectionTable(topoSet, faceSet, set);
|
||||
}
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
faceSet::faceSet(const IOobject& obj)
|
||||
Foam::faceSet::faceSet(const IOobject& obj)
|
||||
:
|
||||
topoSet(obj, typeName)
|
||||
{}
|
||||
|
||||
|
||||
faceSet::faceSet
|
||||
Foam::faceSet::faceSet
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
const word& name,
|
||||
@ -67,7 +64,7 @@ faceSet::faceSet
|
||||
}
|
||||
|
||||
|
||||
faceSet::faceSet
|
||||
Foam::faceSet::faceSet
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
const word& name,
|
||||
@ -79,7 +76,7 @@ faceSet::faceSet
|
||||
{}
|
||||
|
||||
|
||||
faceSet::faceSet
|
||||
Foam::faceSet::faceSet
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
const word& name,
|
||||
@ -91,7 +88,7 @@ faceSet::faceSet
|
||||
{}
|
||||
|
||||
|
||||
faceSet::faceSet
|
||||
Foam::faceSet::faceSet
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
const word& name,
|
||||
@ -103,15 +100,27 @@ faceSet::faceSet
|
||||
{}
|
||||
|
||||
|
||||
Foam::faceSet::faceSet
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
const word& name,
|
||||
const UList<label>& set,
|
||||
writeOption w
|
||||
)
|
||||
:
|
||||
topoSet(mesh, name, set, w)
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
faceSet::~faceSet()
|
||||
Foam::faceSet::~faceSet()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
void faceSet::sync(const polyMesh& mesh)
|
||||
void Foam::faceSet::sync(const polyMesh& mesh)
|
||||
{
|
||||
boolList set(mesh.nFaces(), false);
|
||||
|
||||
@ -150,19 +159,19 @@ void faceSet::sync(const polyMesh& mesh)
|
||||
}
|
||||
|
||||
|
||||
label faceSet::maxSize(const polyMesh& mesh) const
|
||||
Foam::label Foam::faceSet::maxSize(const polyMesh& mesh) const
|
||||
{
|
||||
return mesh.nFaces();
|
||||
}
|
||||
|
||||
|
||||
void faceSet::updateMesh(const mapPolyMesh& morphMap)
|
||||
void Foam::faceSet::updateMesh(const mapPolyMesh& morphMap)
|
||||
{
|
||||
updateLabels(morphMap.reverseFaceMap());
|
||||
}
|
||||
|
||||
|
||||
void faceSet::distribute(const mapDistributePolyMesh& map)
|
||||
void Foam::faceSet::distribute(const mapDistributePolyMesh& map)
|
||||
{
|
||||
boolList inSet(map.nOldFaces());
|
||||
forAllConstIter(faceSet, *this, iter)
|
||||
@ -193,7 +202,7 @@ void faceSet::distribute(const mapDistributePolyMesh& map)
|
||||
}
|
||||
|
||||
|
||||
void faceSet::writeDebug
|
||||
void Foam::faceSet::writeDebug
|
||||
(
|
||||
Ostream& os,
|
||||
const primitiveMesh& mesh,
|
||||
@ -204,8 +213,4 @@ void faceSet::writeDebug
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// ************************************************************************* //
|
||||
|
@ -51,7 +51,6 @@ class faceSet
|
||||
public topoSet
|
||||
{
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
@ -78,7 +77,7 @@ public:
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
const word& name,
|
||||
const label,
|
||||
const label size,
|
||||
writeOption w=NO_WRITE
|
||||
);
|
||||
|
||||
@ -87,7 +86,7 @@ public:
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
const word& name,
|
||||
const topoSet&,
|
||||
const topoSet& set,
|
||||
writeOption w=NO_WRITE
|
||||
);
|
||||
|
||||
@ -96,7 +95,16 @@ public:
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
const word& name,
|
||||
const labelHashSet&,
|
||||
const labelHashSet& set,
|
||||
writeOption w=NO_WRITE
|
||||
);
|
||||
|
||||
//- Construct from additional list of labels for the labelHashSet
|
||||
faceSet
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
const word& name,
|
||||
const UList<label>& set,
|
||||
writeOption w=NO_WRITE
|
||||
);
|
||||
|
||||
|
@ -28,32 +28,28 @@ License
|
||||
#include "polyMesh.H"
|
||||
#include "syncTools.H"
|
||||
#include "mapDistributePolyMesh.H"
|
||||
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
defineTypeNameAndDebug(pointSet, 0);
|
||||
|
||||
addToRunTimeSelectionTable(topoSet, pointSet, word);
|
||||
addToRunTimeSelectionTable(topoSet, pointSet, size);
|
||||
addToRunTimeSelectionTable(topoSet, pointSet, set);
|
||||
|
||||
}
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
pointSet::pointSet(const IOobject& obj)
|
||||
Foam::pointSet::pointSet(const IOobject& obj)
|
||||
:
|
||||
topoSet(obj, typeName)
|
||||
{}
|
||||
|
||||
|
||||
pointSet::pointSet
|
||||
Foam::pointSet::pointSet
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
const word& name,
|
||||
@ -67,7 +63,7 @@ pointSet::pointSet
|
||||
}
|
||||
|
||||
|
||||
pointSet::pointSet
|
||||
Foam::pointSet::pointSet
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
const word& name,
|
||||
@ -79,7 +75,7 @@ pointSet::pointSet
|
||||
{}
|
||||
|
||||
|
||||
pointSet::pointSet
|
||||
Foam::pointSet::pointSet
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
const word& name,
|
||||
@ -91,7 +87,7 @@ pointSet::pointSet
|
||||
{}
|
||||
|
||||
|
||||
pointSet::pointSet
|
||||
Foam::pointSet::pointSet
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
const word& name,
|
||||
@ -103,15 +99,27 @@ pointSet::pointSet
|
||||
{}
|
||||
|
||||
|
||||
Foam::pointSet::pointSet
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
const word& name,
|
||||
const UList<label>& set,
|
||||
writeOption w
|
||||
)
|
||||
:
|
||||
topoSet(mesh, name, set, w)
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
pointSet::~pointSet()
|
||||
Foam::pointSet::~pointSet()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
void pointSet::sync(const polyMesh& mesh)
|
||||
void Foam::pointSet::sync(const polyMesh& mesh)
|
||||
{
|
||||
// Convert to boolList
|
||||
|
||||
@ -145,19 +153,19 @@ void pointSet::sync(const polyMesh& mesh)
|
||||
}
|
||||
|
||||
|
||||
label pointSet::maxSize(const polyMesh& mesh) const
|
||||
Foam::label Foam::pointSet::maxSize(const polyMesh& mesh) const
|
||||
{
|
||||
return mesh.nPoints();
|
||||
}
|
||||
|
||||
|
||||
void pointSet::updateMesh(const mapPolyMesh& morphMap)
|
||||
void Foam::pointSet::updateMesh(const mapPolyMesh& morphMap)
|
||||
{
|
||||
updateLabels(morphMap.reversePointMap());
|
||||
}
|
||||
|
||||
|
||||
void pointSet::distribute(const mapDistributePolyMesh& map)
|
||||
void Foam::pointSet::distribute(const mapDistributePolyMesh& map)
|
||||
{
|
||||
boolList inSet(map.nOldPoints());
|
||||
forAllConstIter(pointSet, *this, iter)
|
||||
@ -188,7 +196,7 @@ void pointSet::distribute(const mapDistributePolyMesh& map)
|
||||
}
|
||||
|
||||
|
||||
void pointSet::writeDebug
|
||||
void Foam::pointSet::writeDebug
|
||||
(
|
||||
Ostream& os,
|
||||
const primitiveMesh& mesh,
|
||||
@ -198,8 +206,4 @@ void pointSet::writeDebug
|
||||
topoSet::writeDebug(os, mesh.points(), maxLen);
|
||||
}
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// ************************************************************************* //
|
||||
|
@ -78,7 +78,16 @@ public:
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
const word& name,
|
||||
const label,
|
||||
const label size,
|
||||
writeOption w=NO_WRITE
|
||||
);
|
||||
|
||||
//- Construct from existing set
|
||||
pointSet
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
const word& name,
|
||||
const topoSet& set,
|
||||
writeOption w=NO_WRITE
|
||||
);
|
||||
|
||||
@ -87,16 +96,16 @@ public:
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
const word& name,
|
||||
const topoSet&,
|
||||
const labelHashSet& set,
|
||||
writeOption w=NO_WRITE
|
||||
);
|
||||
|
||||
//- Construct from additional labelHashSet
|
||||
//- Construct from additional list of labels for the labelHashSet
|
||||
pointSet
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
const word& name,
|
||||
const labelHashSet&,
|
||||
const UList<label>& set,
|
||||
writeOption w=NO_WRITE
|
||||
);
|
||||
|
||||
|
@ -289,6 +289,63 @@ void Foam::topoSet::writeDebug
|
||||
}
|
||||
|
||||
|
||||
Foam::IOobject Foam::topoSet::findIOobject
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
const word& name,
|
||||
readOption r,
|
||||
writeOption w
|
||||
)
|
||||
{
|
||||
return IOobject
|
||||
(
|
||||
name,
|
||||
mesh.time().findInstance
|
||||
(
|
||||
mesh.dbDir()/polyMesh::meshSubDir/"sets",
|
||||
word::null,
|
||||
r,
|
||||
mesh.facesInstance()
|
||||
),
|
||||
polyMesh::meshSubDir/"sets",
|
||||
mesh,
|
||||
r,
|
||||
w
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Foam::IOobject Foam::topoSet::findIOobject
|
||||
(
|
||||
const Time& runTime,
|
||||
const word& name,
|
||||
readOption r,
|
||||
writeOption w
|
||||
)
|
||||
{
|
||||
return IOobject
|
||||
(
|
||||
name,
|
||||
runTime.findInstance
|
||||
(
|
||||
polyMesh::meshSubDir/"sets",
|
||||
word::null,
|
||||
IOobject::MUST_READ,
|
||||
runTime.findInstance
|
||||
(
|
||||
polyMesh::meshSubDir,
|
||||
"faces",
|
||||
IOobject::READ_IF_PRESENT
|
||||
)
|
||||
),
|
||||
polyMesh::meshSubDir/"sets",
|
||||
runTime,
|
||||
r,
|
||||
w
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::topoSet::topoSet(const IOobject& obj, const word& wantedType)
|
||||
@ -324,24 +381,7 @@ Foam::topoSet::topoSet
|
||||
writeOption w
|
||||
)
|
||||
:
|
||||
regIOobject
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
name,
|
||||
mesh.time().findInstance
|
||||
(
|
||||
mesh.dbDir()/polyMesh::meshSubDir/"sets",
|
||||
word::null,
|
||||
r, //IOobject::MUST_READ,
|
||||
mesh.facesInstance()
|
||||
),
|
||||
polyMesh::meshSubDir/"sets",
|
||||
mesh,
|
||||
r,
|
||||
w
|
||||
)
|
||||
)
|
||||
regIOobject(findIOobject(mesh, name, r, w))
|
||||
{
|
||||
if
|
||||
(
|
||||
@ -371,24 +411,7 @@ Foam::topoSet::topoSet
|
||||
writeOption w
|
||||
)
|
||||
:
|
||||
regIOobject
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
name,
|
||||
mesh.time().findInstance
|
||||
(
|
||||
mesh.dbDir()/polyMesh::meshSubDir/"sets",
|
||||
word::null,
|
||||
IOobject::NO_READ,
|
||||
mesh.facesInstance()
|
||||
),
|
||||
polyMesh::meshSubDir/"sets",
|
||||
mesh,
|
||||
IOobject::NO_READ,
|
||||
w
|
||||
)
|
||||
),
|
||||
regIOobject(findIOobject(mesh, name, IOobject::NO_READ, w)),
|
||||
labelHashSet(size)
|
||||
{}
|
||||
|
||||
@ -401,24 +424,20 @@ Foam::topoSet::topoSet
|
||||
writeOption w
|
||||
)
|
||||
:
|
||||
regIOobject
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
name,
|
||||
mesh.time().findInstance
|
||||
(
|
||||
mesh.dbDir()/polyMesh::meshSubDir/"sets",
|
||||
word::null,
|
||||
IOobject::NO_READ,
|
||||
mesh.facesInstance()
|
||||
),
|
||||
polyMesh::meshSubDir/"sets",
|
||||
mesh,
|
||||
IOobject::NO_READ,
|
||||
w
|
||||
)
|
||||
),
|
||||
regIOobject(findIOobject(mesh, name, IOobject::NO_READ, w)),
|
||||
labelHashSet(set)
|
||||
{}
|
||||
|
||||
|
||||
Foam::topoSet::topoSet
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
const word& name,
|
||||
const UList<label>& set,
|
||||
writeOption w
|
||||
)
|
||||
:
|
||||
regIOobject(findIOobject(mesh, name, IOobject::NO_READ, w)),
|
||||
labelHashSet(set)
|
||||
{}
|
||||
|
||||
|
@ -108,7 +108,29 @@ protected:
|
||||
|
||||
|
||||
//- Disallow default bitwise copy construct
|
||||
topoSet(const topoSet&);
|
||||
topoSet(const topoSet&) = delete;
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
//- Helper for constructor - return IOobject in the polyMesh/sets
|
||||
static IOobject findIOobject
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
const word& name,
|
||||
readOption r,
|
||||
writeOption w
|
||||
);
|
||||
|
||||
//- Helper for constructor - return IOobject in the polyMesh/sets
|
||||
static IOobject findIOobject
|
||||
(
|
||||
const Time& runTime,
|
||||
const word& name,
|
||||
readOption r,
|
||||
writeOption w
|
||||
);
|
||||
|
||||
|
||||
public:
|
||||
|
||||
@ -175,7 +197,7 @@ public:
|
||||
|
||||
//- Construct from IOobject as explicitly passed type.
|
||||
// Can't use typeName info here since subclasses not yet instantiated
|
||||
topoSet(const IOobject&, const word& wantedType);
|
||||
topoSet(const IOobject& obj, const word& wantedType);
|
||||
|
||||
//- Construct from polyMesh and name. Searches for a polyMesh/sets
|
||||
// directory but not beyond mesh.facesInstance.
|
||||
@ -195,7 +217,7 @@ public:
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
const word& name,
|
||||
const label,
|
||||
const label size,
|
||||
writeOption w=NO_WRITE
|
||||
);
|
||||
|
||||
@ -206,7 +228,18 @@ public:
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
const word& name,
|
||||
const labelHashSet&,
|
||||
const labelHashSet& set,
|
||||
writeOption w=NO_WRITE
|
||||
);
|
||||
|
||||
//- Construct empty from additional labelHashSet
|
||||
// Searches for a polyMesh/sets
|
||||
// directory but not beyond mesh.facesInstance.
|
||||
topoSet
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
const word& name,
|
||||
const UList<label>&,
|
||||
writeOption w=NO_WRITE
|
||||
);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user