faceZone: Added new insert function to add elements from a Map<bool>
//- Insert given indices and corresponding face flips into zone
void insert(const Map<bool>& newIndices);
This commit is contained in:
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2011-2019 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2024 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -73,6 +73,15 @@ int main(int argc, char *argv[])
|
||||
Info<< "table4: " << table4 << nl
|
||||
<< "toc: " << table4.toc() << endl;
|
||||
|
||||
HashTable<label, label, Hash<label>> table5
|
||||
{
|
||||
List<label>{3, 5, 7},
|
||||
List<label>{10, 12, 16}
|
||||
};
|
||||
|
||||
Info<< "table5: " << table5 << nl
|
||||
<< "toc: " << table5.toc() << endl;
|
||||
|
||||
HashPtrTable<label, Foam::string> ptable1(0);
|
||||
ptable1.insert("kjhkjh", new label(10));
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2011-2019 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2024 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -45,10 +45,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
cpuTime timer;
|
||||
|
||||
// ie, a
|
||||
// Map<label> map(2 * nSize);
|
||||
// HashTable<label, label, Hash<label>> map(2 * nSize);
|
||||
HashTable<label, label, Hash<label>> map(2 * nSize);
|
||||
Map<label> map(2*nSize);
|
||||
|
||||
Info<< "Constructed map of size: " << nSize
|
||||
<< " (size " << map.size() << " capacity " << map.capacity() << ") "
|
||||
@ -62,12 +59,12 @@ int main(int argc, char *argv[])
|
||||
<< " (size " << map.size() << " capacity " << map.capacity() << ") "
|
||||
<< timer.cpuTimeIncrement() << " s\n";
|
||||
|
||||
label elemI = 0;
|
||||
label elemi = 0;
|
||||
for (label iLoop = 0; iLoop < nLoops; iLoop++)
|
||||
{
|
||||
for (label i = 0; i < nBase; i++)
|
||||
{
|
||||
map.erase(elemI++);
|
||||
map.erase(elemi++);
|
||||
}
|
||||
|
||||
map.shrink();
|
||||
|
||||
@ -79,6 +79,31 @@ Foam::HashTable<T, Key, Hash>::HashTable
|
||||
}
|
||||
|
||||
|
||||
template<class T, class Key, class Hash>
|
||||
Foam::HashTable<T, Key, Hash>::HashTable
|
||||
(
|
||||
const UList<Key>& keyList,
|
||||
const UList<T>& elmtList
|
||||
)
|
||||
:
|
||||
HashTable<T, Key, Hash>(keyList.size())
|
||||
{
|
||||
if (keyList.size() != elmtList.size())
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Lists of keys and elements have different sizes" << nl
|
||||
<< " number of keys: " << keyList.size()
|
||||
<< ", number of elements: " << elmtList.size()
|
||||
<< abort(FatalError);
|
||||
}
|
||||
|
||||
forAll(keyList, i)
|
||||
{
|
||||
insert(keyList[i], elmtList[i]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<class T, class Key, class Hash>
|
||||
Foam::HashTable<T, Key, Hash>::HashTable
|
||||
(
|
||||
|
||||
@ -206,6 +206,10 @@ public:
|
||||
//- Construct from Istream
|
||||
HashTable(Istream&, const label size = 128);
|
||||
|
||||
//- Construct from a list of keys and list of elements
|
||||
// Lists must have equal length
|
||||
HashTable(const UList<Key>& keyList, const UList<T>& elmtList);
|
||||
|
||||
//- Copy constructor
|
||||
HashTable(const HashTable<T, Key, Hash>&);
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2024 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -54,61 +54,9 @@ class Map
|
||||
|
||||
public:
|
||||
|
||||
typedef typename HashTable<T, label, Hash<label>>::iterator iterator;
|
||||
|
||||
typedef typename HashTable<T, label, Hash<label>>::const_iterator
|
||||
const_iterator;
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct given initial size
|
||||
Map(const label size = 128)
|
||||
:
|
||||
HashTable<T, label, Hash<label>>(size)
|
||||
{}
|
||||
|
||||
//- Construct from Istream
|
||||
Map(Istream& is)
|
||||
:
|
||||
HashTable<T, label, Hash<label>>(is)
|
||||
{}
|
||||
|
||||
//- Copy constructor
|
||||
Map(const Map<T>& map)
|
||||
:
|
||||
HashTable<T, label, Hash<label>>(map)
|
||||
{}
|
||||
|
||||
//- Move constructor
|
||||
Map(Map<T>&& map)
|
||||
:
|
||||
HashTable<T, label, Hash<label>>(move(map))
|
||||
{}
|
||||
|
||||
//- Move constructor
|
||||
Map(HashTable<T, label, Hash<label>>&& map)
|
||||
:
|
||||
HashTable<T, label, Hash<label>>(move(map))
|
||||
{}
|
||||
|
||||
//- Construct from an initialiser list
|
||||
Map(std::initializer_list<Tuple2<label, T>> map)
|
||||
:
|
||||
HashTable<T, label, Hash<label>>(map)
|
||||
{}
|
||||
|
||||
|
||||
// Member Operators
|
||||
|
||||
void operator=(const Map<T>& map)
|
||||
{
|
||||
HashTable<T, label, Hash<label>>::operator=(map);
|
||||
}
|
||||
|
||||
void operator=(Map<T>&& map)
|
||||
{
|
||||
HashTable<T, label, Hash<label>>::operator=(move(map));
|
||||
}
|
||||
using HashTable<T, label, Hash<label>>::HashTable;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2011-2019 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2024 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -56,42 +56,7 @@ public:
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct given initial map size
|
||||
PtrMap(const label size = 128)
|
||||
:
|
||||
HashPtrTable<T, label, Hash<label>>(size)
|
||||
{}
|
||||
|
||||
//- Construct from Istream
|
||||
PtrMap(Istream& is)
|
||||
:
|
||||
HashPtrTable<T, label, Hash<label>>(is)
|
||||
{}
|
||||
|
||||
//- Copy construct
|
||||
PtrMap(const PtrMap<T>& map)
|
||||
:
|
||||
HashPtrTable<T, label, Hash<label>>(map)
|
||||
{}
|
||||
|
||||
//- Move constructor
|
||||
PtrMap(PtrMap<T>&& map)
|
||||
:
|
||||
HashPtrTable<T, label, Hash<label>>(move(map))
|
||||
{}
|
||||
|
||||
|
||||
// Member Operators
|
||||
|
||||
void operator=(const PtrMap<T>& map)
|
||||
{
|
||||
HashPtrTable<T, label, Hash<label>>::operator=(map);
|
||||
}
|
||||
|
||||
void operator=(PtrMap<T>&& map)
|
||||
{
|
||||
HashPtrTable<T, label, Hash<label>>::operator=(move(map));
|
||||
}
|
||||
using HashPtrTable<T, label, Hash<label>>::HashPtrTable;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2011-2019 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2024 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -54,23 +54,7 @@ public:
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct given initial map size
|
||||
EdgeMap(const label size = 128)
|
||||
:
|
||||
HashTable<T, edge, Hash<edge>>(size)
|
||||
{}
|
||||
|
||||
//- Construct from Istream
|
||||
EdgeMap(Istream& is)
|
||||
:
|
||||
HashTable<T, edge, Hash<edge>>(is)
|
||||
{}
|
||||
|
||||
//- Copy constructor
|
||||
EdgeMap(const EdgeMap<T>& map)
|
||||
:
|
||||
HashTable<T, edge, Hash<edge>>(map)
|
||||
{}
|
||||
using HashTable<T, edge, Hash<edge>>::HashTable;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -132,7 +132,7 @@ void Foam::cellZone::topoChange(const polyTopoChangeMap& map)
|
||||
{
|
||||
clearAddressing();
|
||||
|
||||
labelHashSet newIndices;
|
||||
labelHashSet indices;
|
||||
const labelList& cellMap = map.cellMap();
|
||||
const labelList& reverseCellMap = map.reverseCellMap();
|
||||
|
||||
@ -140,7 +140,7 @@ void Foam::cellZone::topoChange(const polyTopoChangeMap& map)
|
||||
{
|
||||
if (cellMap[celli] >= 0 && localIndex(cellMap[celli]) != -1)
|
||||
{
|
||||
newIndices.insert(celli);
|
||||
indices.insert(celli);
|
||||
}
|
||||
}
|
||||
|
||||
@ -148,11 +148,11 @@ void Foam::cellZone::topoChange(const polyTopoChangeMap& map)
|
||||
{
|
||||
if (reverseCellMap[celli] >= 0 && localIndex(celli) != -1)
|
||||
{
|
||||
newIndices.insert(reverseCellMap[celli]);
|
||||
indices.insert(reverseCellMap[celli]);
|
||||
}
|
||||
}
|
||||
|
||||
labelList::operator=(newIndices.sortedToc());
|
||||
labelList::operator=(indices.sortedToc());
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -179,6 +179,23 @@ void Foam::faceZone::checkAddressing() const
|
||||
}
|
||||
|
||||
|
||||
void Foam::faceZone::reset(const Map<bool>& indices)
|
||||
{
|
||||
clearAddressing();
|
||||
|
||||
labelList::setSize(indices.size());
|
||||
flipMap_.setSize(indices.size());
|
||||
|
||||
label i = 0;
|
||||
forAllConstIter(Map<bool>, indices, iter)
|
||||
{
|
||||
operator[](i) = iter.key();
|
||||
flipMap_[i] = *iter;
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::faceZone::faceZone
|
||||
@ -472,6 +489,14 @@ bool Foam::faceZone::checkParallelSync(const bool report) const
|
||||
}
|
||||
|
||||
|
||||
void Foam::faceZone::insert(const Map<bool>& newIndices)
|
||||
{
|
||||
Map<bool> indices(*this, flipMap_);
|
||||
indices.insert(newIndices);
|
||||
reset(indices);
|
||||
}
|
||||
|
||||
|
||||
void Foam::faceZone::swap(faceZone& fz)
|
||||
{
|
||||
zone::swap(fz);
|
||||
@ -481,32 +506,30 @@ void Foam::faceZone::swap(faceZone& fz)
|
||||
|
||||
void Foam::faceZone::topoChange(const polyTopoChangeMap& map)
|
||||
{
|
||||
clearAddressing();
|
||||
|
||||
/*
|
||||
labelList newAddressing(size());
|
||||
boolList newFlipMap(flipMap_.size());
|
||||
label nFaces = 0;
|
||||
Map<bool> indices;
|
||||
const labelList& faceMap = map.faceMap();
|
||||
const labelList& reverseFaceMap = map.reverseFaceMap();
|
||||
|
||||
const labelList& faceMap = map.reverseFaceMap();
|
||||
|
||||
forAll(*this, i)
|
||||
forAll(faceMap, facei)
|
||||
{
|
||||
const label facei = operator[](i);
|
||||
|
||||
if (faceMap[facei] >= 0)
|
||||
const label i = localIndex(faceMap[facei]);
|
||||
if (faceMap[facei] >= 0 && i != -1)
|
||||
{
|
||||
newAddressing[nFaces] = faceMap[facei];
|
||||
newFlipMap[nFaces] = flipMap_[i]; // Keep flip map.
|
||||
nFaces++;
|
||||
indices.insert(facei, flipMap_[i]);
|
||||
}
|
||||
}
|
||||
|
||||
newAddressing.setSize(nFaces);
|
||||
newFlipMap.setSize(nFaces);
|
||||
forAll(reverseFaceMap, facei)
|
||||
{
|
||||
const label i = localIndex(facei);
|
||||
if (reverseFaceMap[facei] >= 0 && i != -1)
|
||||
{
|
||||
indices.insert(reverseFaceMap[facei], flipMap_[i]);
|
||||
}
|
||||
}
|
||||
|
||||
transfer(newAddressing);
|
||||
flipMap_.transfer(newFlipMap);
|
||||
reset(indices);
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
@ -111,6 +111,9 @@ protected:
|
||||
//- Check addressing
|
||||
void checkAddressing() const;
|
||||
|
||||
//- Reset the indices and flipMap from the given map
|
||||
void reset(const Map<bool>& indices);
|
||||
|
||||
|
||||
public:
|
||||
|
||||
@ -277,8 +280,11 @@ public:
|
||||
// true if in error.
|
||||
virtual bool checkParallelSync(const bool report = false) const;
|
||||
|
||||
//- Insert given indices and corresponding face flips into zone
|
||||
void insert(const Map<bool>& newIndices);
|
||||
|
||||
//- Swap two faceZones
|
||||
virtual void swap(faceZone&);
|
||||
void swap(faceZone&);
|
||||
|
||||
//- Correct patch after moving points
|
||||
virtual void movePoints(const pointField&);
|
||||
|
||||
@ -185,24 +185,27 @@ void Foam::pointZone::topoChange(const polyTopoChangeMap& map)
|
||||
{
|
||||
clearAddressing();
|
||||
|
||||
labelList newAddressing(size());
|
||||
label nPoints = 0;
|
||||
labelHashSet indices;
|
||||
const labelList& pointMap = map.pointMap();
|
||||
const labelList& reversePointMap = map.reversePointMap();
|
||||
|
||||
const labelList& pointMap = map.reversePointMap();
|
||||
|
||||
forAll(*this, i)
|
||||
forAll(pointMap, pointi)
|
||||
{
|
||||
const label pointi = operator[](i);
|
||||
|
||||
if (pointMap[pointi] >= 0)
|
||||
if (pointMap[pointi] >= 0 && localIndex(pointMap[pointi]) != -1)
|
||||
{
|
||||
newAddressing[nPoints] = pointMap[pointi];
|
||||
nPoints++;
|
||||
indices.insert(pointi);
|
||||
}
|
||||
}
|
||||
|
||||
newAddressing.setSize(nPoints);
|
||||
transfer(newAddressing);
|
||||
forAll(reversePointMap, pointi)
|
||||
{
|
||||
if (reversePointMap[pointi] >= 0 && localIndex(pointi) != -1)
|
||||
{
|
||||
indices.insert(reversePointMap[pointi]);
|
||||
}
|
||||
}
|
||||
|
||||
labelList::operator=(indices.sortedToc());
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -228,6 +228,13 @@ void Foam::zone::insert(const labelHashSet& newIndices)
|
||||
}
|
||||
|
||||
|
||||
void Foam::zone::swap(zone& z)
|
||||
{
|
||||
clearAddressing();
|
||||
labelList::swap(z);
|
||||
}
|
||||
|
||||
|
||||
void Foam::zone::mapMesh(const polyMeshMap&)
|
||||
{
|
||||
clearAddressing();
|
||||
|
||||
@ -170,6 +170,9 @@ public:
|
||||
//- Insert given indices into zone
|
||||
void insert(const labelHashSet& newIndices);
|
||||
|
||||
//- Swap two zones
|
||||
void swap(zone&);
|
||||
|
||||
//- Correct patch after moving points
|
||||
virtual void movePoints(const pointField&)
|
||||
{}
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2024 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -57,6 +57,7 @@ SourceFiles
|
||||
#include "point.H"
|
||||
#include "intersection.H"
|
||||
#include "HashSet.H"
|
||||
#include "Map.H"
|
||||
#include "objectHit.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
@ -64,9 +65,6 @@ SourceFiles
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
class face;
|
||||
template<class T> class Map;
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class PrimitivePatchName Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
Reference in New Issue
Block a user