Commit e67cbb7f authored by Franjo's avatar Franjo
Browse files

Merge branch 'enhancement-meshSubsetSpeedup' into developmentPublicRepo

parents 2cd934d4 da37f189
......@@ -39,6 +39,8 @@ SourceFiles
#include "HashSet.H"
#include "VRWGraph.H"
#include <set>
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
......@@ -61,7 +63,8 @@ class meshSubset
label type_;
//- labels of elements
HashSet<label> data_;
//HashSet<label> data_;
std::set<label> data_;
public:
......
......@@ -26,6 +26,7 @@ Description
\*---------------------------------------------------------------------------*/
#include "meshSubset.H"
#include "labelList.H"
#include "IOstreams.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
......@@ -75,8 +76,7 @@ inline meshSubset::meshSubset(const meshSubset& ms)
type_(ms.type_),
data_()
{
forAllConstIter(HashSet<label>, ms.data_, it)
data_.insert(it.key());
data_ = ms.data_;
}
inline meshSubset::meshSubset(Istream& is)
......@@ -109,8 +109,8 @@ inline void meshSubset::containedElements(ListType& l) const
l.setSize(data_.size());
label counter(0);
forAllConstIter(HashSet<label>, data_, it)
l[counter++] = it.key();
forAllConstIter(std::set<label>, data_, it)
l[counter++] = *it;
}
inline void meshSubset::addElement(const label elmt)
......@@ -126,35 +126,35 @@ inline void meshSubset::removeElement(const label elmt)
template<class ListType>
inline void meshSubset::updateSubset(const ListType& newLabels)
{
HashSet<label> newData(newLabels.size());
std::set<label> newData;
forAllConstIter(HashSet<label>, data_, it)
forAllConstIter(std::set<label>, data_, it)
{
if( newLabels[it.key()] < 0 )
if( newLabels[*it] < 0 )
continue;
newData.insert(newLabels[it.key()]);
newData.insert(newLabels[*it]);
}
data_.transfer(newData);
data_ = newData;
}
inline void meshSubset::updateSubset(const VRWGraph& newLabels)
{
HashSet<label> newData(newLabels.size());
std::set<label> newData;
forAllConstIter(HashSet<label>, data_, it)
forAllConstIter(std::set<label>, data_, it)
{
forAllRow(newLabels, it.key(), i)
newData.insert(newLabels(it.key(), i));
forAllRow(newLabels, *it, i)
newData.insert(newLabels(*it, i));
}
data_.transfer(newData);
data_ = newData;
}
inline bool meshSubset::contains(const label elmt) const
{
return data_.found(elmt);
return (data_.find(elmt) != data_.end());
}
inline void meshSubset::operator=(const meshSubset& ms)
......@@ -163,10 +163,7 @@ inline void meshSubset::operator=(const meshSubset& ms)
type_ = ms.type_;
data_.clear();
data_.resize(ms.data_.size());
forAllConstIter(HashSet<label>, ms.data_, it)
data_.insert(it.key());
data_ = ms.data_;
}
inline bool meshSubset::operator==(const meshSubset& ms) const
......@@ -176,8 +173,8 @@ inline bool meshSubset::operator==(const meshSubset& ms) const
if( ms.type_ != ms.type_ )
return false;
forAllConstIter(HashSet<label>, data_, it)
if( !ms.data_.found(it.key()) )
forAllConstIter(std::set<label>, data_, it)
if( ms.data_.find(*it) == ms.data_.end() )
return false;
return true;
......@@ -194,7 +191,14 @@ inline Ostream& operator<<(Ostream& os, const meshSubset& sel)
{
os.check("inline Ostream& operator<<(Ostream&, const meshSubset&)");
os << sel.name_ << nl << sel.type_ << nl << sel.data_;
os << sel.name_ << nl << sel.type_;
labelList data(sel.data_.size());
label counter(0);
forAllConstIter(std::set<label>, sel.data_, it)
data[counter++] = *it;
os << nl << data;
return os;
}
......@@ -203,7 +207,12 @@ inline Istream& operator>>(Istream& is, meshSubset& sel)
{
is.check("friend Istream& operator>>(Istream&, meshSubset&)");
is >> sel.name_ >> sel.type_ >> sel.data_;
labelList data;
is >> sel.name_ >> sel.type_ >> data;
sel.data_.clear();
forAll(data, i)
sel.data_.insert(data[i]);
is.check("friend Istream& operator>>(Istream&, meshSubset&)");
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment