mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
Merge branch 'master' of ssh://noisy/home/noisy3/OpenFOAM/OpenFOAM-dev
This commit is contained in:
@ -3,35 +3,42 @@ global/dimensionedConstants/dimensionedConstants.C
|
||||
global/argList/argList.C
|
||||
global/clock/clock.C
|
||||
|
||||
primitives/bools/bool/bool.C
|
||||
primitives/bools/bool/boolIO.C
|
||||
primitives/bools/Switch/Switch.C
|
||||
primitives/bools/Switch/SwitchIO.C
|
||||
bools = primitives/bools
|
||||
$(bools)/bool/bool.C
|
||||
$(bools)/bool/boolIO.C
|
||||
$(bools)/Switch/Switch.C
|
||||
$(bools)/Switch/SwitchIO.C
|
||||
|
||||
primitives/char/charIO.C
|
||||
primitives/int/intIO.C
|
||||
primitives/uint/uintIO.C
|
||||
primitives/long/longIO.C
|
||||
primitives/longLong/longLongIO.C
|
||||
primitives/ulong/ulongIO.C
|
||||
primitives/label/label.C
|
||||
primitives/uLabel/uLabel.C
|
||||
|
||||
ints = primitives/ints
|
||||
$(ints)/int/intIO.C
|
||||
$(ints)/uint/uintIO.C
|
||||
$(ints)/long/longIO.C
|
||||
$(ints)/longLong/longLongIO.C
|
||||
$(ints)/ulong/ulongIO.C
|
||||
$(ints)/label/label.C
|
||||
$(ints)/uLabel/uLabel.C
|
||||
|
||||
primitives/Scalar/doubleScalar/doubleScalar.C
|
||||
primitives/Scalar/floatScalar/floatScalar.C
|
||||
primitives/Scalar/scalar/scalar.C
|
||||
primitives/labelVector/labelVector.C
|
||||
primitives/vector/vector.C
|
||||
primitives/vector2D/vector2D.C
|
||||
primitives/sphericalTensor/sphericalTensor.C
|
||||
primitives/sphericalTensor2D/sphericalTensor2D.C
|
||||
primitives/diagTensor/diagTensor.C
|
||||
primitives/symmTensor/symmTensor.C
|
||||
primitives/tensor/tensor.C
|
||||
primitives/tensor2D/tensor2D.C
|
||||
primitives/labelSphericalTensor/labelSphericalTensor.C
|
||||
primitives/labelSymmTensor/labelSymmTensor.C
|
||||
primitives/labelTensor/labelTensor.C
|
||||
primitives/DiagTensor/diagTensor/diagTensor.C
|
||||
primitives/SphericalTensor/sphericalTensor/sphericalTensor.C
|
||||
primitives/SphericalTensor/labelSphericalTensor/labelSphericalTensor.C
|
||||
primitives/SymmTensor/labelSymmTensor/labelSymmTensor.C
|
||||
primitives/SymmTensor/symmTensor/symmTensor.C
|
||||
primitives/Tensor/labelTensor/labelTensor.C
|
||||
primitives/Tensor/tensor/tensor.C
|
||||
primitives/Vector/complexVector/complexVector.C
|
||||
primitives/Vector/labelVector/labelVector.C
|
||||
primitives/Vector/vector/vector.C
|
||||
|
||||
primitives/Tensor2D/tensor2D/tensor2D.C
|
||||
primitives/SphericalTensor2D/sphericalTensor2D/sphericalTensor2D.C
|
||||
primitives/Vector2D/vector2D/vector2D.C
|
||||
|
||||
primitives/complex/complex.C
|
||||
primitives/complexVector/complexVector.C
|
||||
primitives/quaternion/quaternion.C
|
||||
primitives/septernion/septernion.C
|
||||
|
||||
@ -45,6 +52,8 @@ $(strings)/fileName/fileNameIO.C
|
||||
$(strings)/keyType/keyTypeIO.C
|
||||
$(strings)/wordRe/wordReIO.C
|
||||
|
||||
primitives/hashes/Hasher/Hasher.C
|
||||
|
||||
sha1 = primitives/hashes/SHA1
|
||||
$(sha1)/SHA1.C
|
||||
$(sha1)/SHA1Digest.C
|
||||
|
||||
@ -83,7 +83,7 @@ public:
|
||||
// Constructors
|
||||
|
||||
//- Construct given initial table size
|
||||
HashPtrTable(const label size = 100);
|
||||
HashPtrTable(const label size = 128);
|
||||
|
||||
//- Construct from Istream using given Istream constructor class
|
||||
template<class INew>
|
||||
|
||||
@ -33,14 +33,14 @@ License
|
||||
|
||||
template<class Key, class Hash>
|
||||
template<class AnyType>
|
||||
Foam::HashSet<Key, Hash>::HashSet(const HashTable<AnyType, Key, Hash>& ht)
|
||||
Foam::HashSet<Key, Hash>::HashSet(const HashTable<AnyType, Key, Hash>& h)
|
||||
:
|
||||
HashTable<nil, Key, Hash>(ht.size())
|
||||
HashTable<nil, Key, Hash>(h.size())
|
||||
{
|
||||
for
|
||||
(
|
||||
typename HashTable<AnyType, Key, Hash>::const_iterator cit = ht.begin();
|
||||
cit != ht.end();
|
||||
typename HashTable<AnyType, Key, Hash>::const_iterator cit = h.cbegin();
|
||||
cit != h.cend();
|
||||
++cit
|
||||
)
|
||||
{
|
||||
@ -62,7 +62,7 @@ template<class Key, class Hash>
|
||||
bool Foam::HashSet<Key, Hash>::operator==(const HashSet<Key, Hash>& rhs) const
|
||||
{
|
||||
// Are all lhs elements in rhs?
|
||||
for (const_iterator iter = this->begin(); iter != this->end(); ++iter)
|
||||
for (const_iterator iter = this->cbegin(); iter != this->cend(); ++iter)
|
||||
{
|
||||
if (!rhs.found(iter.key()))
|
||||
{
|
||||
@ -71,7 +71,7 @@ bool Foam::HashSet<Key, Hash>::operator==(const HashSet<Key, Hash>& rhs) const
|
||||
}
|
||||
|
||||
// Are all rhs elements in lhs?
|
||||
for (const_iterator iter = rhs.begin(); iter != rhs.end(); ++iter)
|
||||
for (const_iterator iter = rhs.cbegin(); iter != rhs.cend(); ++iter)
|
||||
{
|
||||
if (!found(iter.key()))
|
||||
{
|
||||
@ -94,7 +94,7 @@ template<class Key, class Hash>
|
||||
void Foam::HashSet<Key, Hash>::operator|=(const HashSet<Key, Hash>& rhs)
|
||||
{
|
||||
// Add rhs elements into lhs
|
||||
for (const_iterator iter = rhs.begin(); iter != rhs.end(); ++iter)
|
||||
for (const_iterator iter = rhs.cbegin(); iter != rhs.cend(); ++iter)
|
||||
{
|
||||
insert(iter.key());
|
||||
}
|
||||
@ -105,7 +105,7 @@ template<class Key, class Hash>
|
||||
void Foam::HashSet<Key, Hash>::operator&=(const HashSet<Key, Hash>& rhs)
|
||||
{
|
||||
// Remove elements not also found in rhs
|
||||
for (iterator iter = this->begin(); iter != this->end(); ++iter)
|
||||
for (iterator iter = this->cbegin(); iter != this->cend(); ++iter)
|
||||
{
|
||||
if (!rhs.found(iter.key()))
|
||||
{
|
||||
@ -119,7 +119,7 @@ template<class Key, class Hash>
|
||||
void Foam::HashSet<Key, Hash>::operator^=(const HashSet<Key, Hash>& rhs)
|
||||
{
|
||||
// Add missed rhs elements, remove duplicate elements
|
||||
for (const_iterator iter = rhs.begin(); iter != rhs.end(); ++iter)
|
||||
for (const_iterator iter = rhs.cbegin(); iter != rhs.cend(); ++iter)
|
||||
{
|
||||
if (found(iter.key()))
|
||||
{
|
||||
@ -138,7 +138,7 @@ template<class Key, class Hash>
|
||||
void Foam::HashSet<Key, Hash>::operator-=(const HashSet<Key, Hash>& rhs)
|
||||
{
|
||||
// Remove rhs elements from lhs
|
||||
for (const_iterator iter = rhs.begin(); iter != rhs.end(); ++iter)
|
||||
for (const_iterator iter = rhs.cbegin(); iter != rhs.cend(); ++iter)
|
||||
{
|
||||
erase(iter.key());
|
||||
}
|
||||
|
||||
@ -72,7 +72,7 @@ public:
|
||||
// Constructors
|
||||
|
||||
//- Construct given initial size
|
||||
HashSet(const label size = 100)
|
||||
HashSet(const label size = 128)
|
||||
:
|
||||
HashTable<nil, Key, Hash>(size)
|
||||
{}
|
||||
|
||||
@ -30,20 +30,49 @@ License
|
||||
#include "HashTable.H"
|
||||
#include "List.H"
|
||||
|
||||
// * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * //
|
||||
|
||||
template<class T, class Key, class Hash>
|
||||
Foam::label Foam::HashTable<T, Key, Hash>::canonicalSize(const label size)
|
||||
{
|
||||
if (size < 1)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
// enforce power of two
|
||||
unsigned int goodSize = size;
|
||||
|
||||
if (goodSize & (goodSize - 1))
|
||||
{
|
||||
// brute-force is fast enough
|
||||
goodSize = 1;
|
||||
while (goodSize < unsigned(size))
|
||||
{
|
||||
goodSize <<= 1;
|
||||
}
|
||||
}
|
||||
|
||||
return goodSize;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
template<class T, class Key, class Hash>
|
||||
Foam::HashTable<T, Key, Hash>::HashTable(const label size)
|
||||
:
|
||||
tableSize_(size),
|
||||
table_(NULL),
|
||||
HashTableName(),
|
||||
nElmts_(0),
|
||||
tableSize_(canonicalSize(size)),
|
||||
table_(NULL),
|
||||
endIter_(*this, NULL, 0),
|
||||
endConstIter_(*this, NULL, 0)
|
||||
{
|
||||
if (tableSize_)
|
||||
{
|
||||
table_ = new hashedEntry*[tableSize_];
|
||||
|
||||
for (label hashIdx = 0; hashIdx < tableSize_; hashIdx++)
|
||||
{
|
||||
table_[hashIdx] = 0;
|
||||
@ -56,9 +85,9 @@ template<class T, class Key, class Hash>
|
||||
Foam::HashTable<T, Key, Hash>::HashTable(const HashTable<T, Key, Hash>& ht)
|
||||
:
|
||||
HashTableName(),
|
||||
nElmts_(0),
|
||||
tableSize_(ht.tableSize_),
|
||||
table_(NULL),
|
||||
nElmts_(0),
|
||||
endIter_(*this, NULL, 0),
|
||||
endConstIter_(*this, NULL, 0)
|
||||
{
|
||||
@ -71,7 +100,7 @@ Foam::HashTable<T, Key, Hash>::HashTable(const HashTable<T, Key, Hash>& ht)
|
||||
table_[hashIdx] = 0;
|
||||
}
|
||||
|
||||
for (const_iterator iter = ht.begin(); iter != ht.end(); ++iter)
|
||||
for (const_iterator iter = ht.cbegin(); iter != ht.cend(); ++iter)
|
||||
{
|
||||
insert(iter.key(), *iter);
|
||||
}
|
||||
@ -85,9 +114,9 @@ Foam::HashTable<T, Key, Hash>::HashTable
|
||||
)
|
||||
:
|
||||
HashTableName(),
|
||||
nElmts_(0),
|
||||
tableSize_(0),
|
||||
table_(NULL),
|
||||
nElmts_(0),
|
||||
endIter_(*this, NULL, 0),
|
||||
endConstIter_(*this, NULL, 0)
|
||||
{
|
||||
@ -113,9 +142,9 @@ Foam::HashTable<T, Key, Hash>::~HashTable()
|
||||
template<class T, class Key, class Hash>
|
||||
bool Foam::HashTable<T, Key, Hash>::found(const Key& key) const
|
||||
{
|
||||
if (tableSize_)
|
||||
if (nElmts_)
|
||||
{
|
||||
label hashIdx = Hash()(key, tableSize_);
|
||||
const label hashIdx = hashKeyIndex(key);
|
||||
|
||||
for (hashedEntry* ep = table_[hashIdx]; ep; ep = ep->next_)
|
||||
{
|
||||
@ -145,9 +174,9 @@ Foam::HashTable<T, Key, Hash>::find
|
||||
const Key& key
|
||||
)
|
||||
{
|
||||
if (tableSize_)
|
||||
if (nElmts_)
|
||||
{
|
||||
label hashIdx = Hash()(key, tableSize_);
|
||||
const label hashIdx = hashKeyIndex(key);
|
||||
|
||||
for (hashedEntry* ep = table_[hashIdx]; ep; ep = ep->next_)
|
||||
{
|
||||
@ -177,9 +206,9 @@ Foam::HashTable<T, Key, Hash>::find
|
||||
const Key& key
|
||||
) const
|
||||
{
|
||||
if (tableSize_)
|
||||
if (nElmts_)
|
||||
{
|
||||
label hashIdx = Hash()(key, tableSize_);
|
||||
const label hashIdx = hashKeyIndex(key);
|
||||
|
||||
for (hashedEntry* ep = table_[hashIdx]; ep; ep = ep->next_)
|
||||
{
|
||||
@ -198,7 +227,7 @@ Foam::HashTable<T, Key, Hash>::find
|
||||
}
|
||||
# endif
|
||||
|
||||
return end();
|
||||
return cend();
|
||||
}
|
||||
|
||||
|
||||
@ -209,7 +238,7 @@ Foam::List<Key> Foam::HashTable<T, Key, Hash>::toc() const
|
||||
List<Key> tofc(nElmts_);
|
||||
label i = 0;
|
||||
|
||||
for (const_iterator iter = begin(); iter != end(); ++iter)
|
||||
for (const_iterator iter = cbegin(); iter != cend(); ++iter)
|
||||
{
|
||||
tofc[i++] = iter.key();
|
||||
}
|
||||
@ -231,7 +260,8 @@ bool Foam::HashTable<T, Key, Hash>::set
|
||||
resize(2);
|
||||
}
|
||||
|
||||
label hashIdx = Hash()(key, tableSize_);
|
||||
const label hashIdx = hashKeyIndex(key);
|
||||
|
||||
hashedEntry* existing = 0;
|
||||
hashedEntry* prev = 0;
|
||||
|
||||
@ -351,7 +381,7 @@ bool Foam::HashTable<T, Key, Hash>::erase(const iterator& cit)
|
||||
else
|
||||
{
|
||||
// No previous found. Mark with special value which is
|
||||
// - not end()
|
||||
// - not end()/cend()
|
||||
// - handled by operator++
|
||||
it.elmtPtr_ = reinterpret_cast<hashedEntry*>(this);
|
||||
it.hashIndex_ = -1;
|
||||
@ -449,14 +479,16 @@ Foam::label Foam::HashTable<T, Key, Hash>::erase
|
||||
|
||||
|
||||
template<class T, class Key, class Hash>
|
||||
void Foam::HashTable<T, Key, Hash>::resize(const label newSize)
|
||||
void Foam::HashTable<T, Key, Hash>::resize(const label sz)
|
||||
{
|
||||
label newSize = canonicalSize(sz);
|
||||
|
||||
if (newSize == tableSize_)
|
||||
{
|
||||
# ifdef FULLDEBUG
|
||||
if (debug)
|
||||
{
|
||||
Info<< "HashTable<T, Key, Hash>::resize(const label newSize) : "
|
||||
Info<< "HashTable<T, Key, Hash>::resize(const label) : "
|
||||
<< "new table size == old table size\n";
|
||||
}
|
||||
# endif
|
||||
@ -466,7 +498,7 @@ void Foam::HashTable<T, Key, Hash>::resize(const label newSize)
|
||||
|
||||
HashTable<T, Key, Hash>* newTable = new HashTable<T, Key, Hash>(newSize);
|
||||
|
||||
for (const_iterator iter = begin(); iter != end(); ++iter)
|
||||
for (const_iterator iter = cbegin(); iter != cend(); ++iter)
|
||||
{
|
||||
newTable->insert(iter.key(), *iter);
|
||||
}
|
||||
@ -565,7 +597,7 @@ void Foam::HashTable<T, Key, Hash>::operator=
|
||||
clear();
|
||||
}
|
||||
|
||||
for (const_iterator iter = rhs.begin(); iter != rhs.end(); ++iter)
|
||||
for (const_iterator iter = rhs.cbegin(); iter != rhs.cend(); ++iter)
|
||||
{
|
||||
insert(iter.key(), *iter);
|
||||
}
|
||||
@ -579,22 +611,22 @@ bool Foam::HashTable<T, Key, Hash>::operator==
|
||||
) const
|
||||
{
|
||||
// Are all my elements in rhs?
|
||||
for (const_iterator iter = begin(); iter != end(); ++iter)
|
||||
for (const_iterator iter = cbegin(); iter != cend(); ++iter)
|
||||
{
|
||||
const_iterator fnd = rhs.find(iter.key());
|
||||
|
||||
if (fnd == rhs.end() || fnd() != iter())
|
||||
if (fnd == rhs.cend() || fnd() != iter())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Are all rhs elements in me?
|
||||
for (const_iterator iter = rhs.begin(); iter != rhs.end(); ++iter)
|
||||
for (const_iterator iter = rhs.cbegin(); iter != rhs.cend(); ++iter)
|
||||
{
|
||||
const_iterator fnd = find(iter.key());
|
||||
|
||||
if (fnd == end() || fnd() != iter())
|
||||
if (fnd == cend() || fnd() != iter())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -39,9 +39,10 @@ SourceFiles
|
||||
#define HashTable_H
|
||||
|
||||
#include "label.H"
|
||||
#include "uLabel.H"
|
||||
#include "word.H"
|
||||
#include "className.H"
|
||||
#include "Xfer.H"
|
||||
#include "className.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -108,18 +109,25 @@ class HashTable
|
||||
|
||||
// Private data: size of table, the table and current number of elements
|
||||
|
||||
//- The current number of elements in table
|
||||
label nElmts_;
|
||||
|
||||
//- Number of primary entries allocated in table (not necessarily used)
|
||||
label tableSize_;
|
||||
|
||||
//- The table of primary entries
|
||||
hashedEntry** table_;
|
||||
|
||||
//- The current number of elements in table
|
||||
label nElmts_;
|
||||
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Return a canonical (power-of-two) size
|
||||
static label canonicalSize(const label);
|
||||
|
||||
//- Return the hash index of the Key within the current table size.
|
||||
// No checks for zero-sized tables.
|
||||
inline label hashKeyIndex(const Key&) const;
|
||||
|
||||
//- Assign a new hashedEntry to a possibly already existing key
|
||||
bool set(const Key&, const T& newElmt, bool protect);
|
||||
|
||||
@ -142,10 +150,10 @@ public:
|
||||
// Constructors
|
||||
|
||||
//- Construct given initial table size
|
||||
HashTable(const label size = 100);
|
||||
HashTable(const label size = 128);
|
||||
|
||||
//- Construct from Istream
|
||||
HashTable(Istream&, const label size = 100);
|
||||
HashTable(Istream&, const label size = 128);
|
||||
|
||||
//- Construct as copy
|
||||
HashTable(const HashTable<T, Key, Hash>&);
|
||||
@ -183,6 +191,8 @@ public:
|
||||
//- Return the table of contents
|
||||
List<Key> toc() const;
|
||||
|
||||
//- Print information
|
||||
Ostream& printInfo(Ostream&) const;
|
||||
|
||||
// Edit
|
||||
|
||||
@ -280,7 +290,7 @@ public:
|
||||
// Private data
|
||||
|
||||
//- Reference to the HashTable this is an iterator for
|
||||
HashTable<T, Key, Hash>& curHashTable_;
|
||||
HashTable<T, Key, Hash>& hashTable_;
|
||||
|
||||
//- Current element
|
||||
hashedEntry* elmtPtr_;
|
||||
@ -288,7 +298,6 @@ public:
|
||||
//- Current hash index
|
||||
label hashIndex_;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
// Constructors
|
||||
@ -301,7 +310,6 @@ public:
|
||||
label hashIndex
|
||||
);
|
||||
|
||||
|
||||
// Member operators
|
||||
|
||||
inline void operator=(const iterator&);
|
||||
@ -318,7 +326,7 @@ public:
|
||||
inline iterator& operator++();
|
||||
inline iterator operator++(int);
|
||||
|
||||
inline const Key& key();
|
||||
inline const Key& key() const;
|
||||
};
|
||||
|
||||
|
||||
@ -339,7 +347,7 @@ public:
|
||||
// Private data
|
||||
|
||||
//- Reference to the HashTable this is an iterator for
|
||||
const HashTable<T, Key, Hash>& curHashTable_;
|
||||
const HashTable<T, Key, Hash>& hashTable_;
|
||||
|
||||
//- Current element
|
||||
const hashedEntry* elmtPtr_;
|
||||
@ -380,7 +388,7 @@ public:
|
||||
inline const_iterator& operator++();
|
||||
inline const_iterator operator++(int);
|
||||
|
||||
inline const Key& key();
|
||||
inline const Key& key() const;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -42,6 +42,17 @@ inline Foam::HashTable<T, Key, Hash>::hashedEntry::hashedEntry
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * //
|
||||
|
||||
template<class T, class Key, class Hash>
|
||||
inline Foam::label
|
||||
Foam::HashTable<T, Key, Hash>::hashKeyIndex(const Key& key) const
|
||||
{
|
||||
// size is power of two - this is the modulus
|
||||
return Hash()(key) & (tableSize_ - 1);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class T, class Key, class Hash>
|
||||
@ -112,7 +123,7 @@ inline const T& Foam::HashTable<T, Key, Hash>::operator[](const Key& key) const
|
||||
{
|
||||
const_iterator iter = find(key);
|
||||
|
||||
if (iter == end())
|
||||
if (iter == cend())
|
||||
{
|
||||
FatalErrorIn("HashTable<T, Key, Hash>::operator[](const Key&) const")
|
||||
<< key << " not found in table. Valid entries: "
|
||||
@ -146,12 +157,12 @@ inline T& Foam::HashTable<T, Key, Hash>::operator()(const Key& key)
|
||||
template<class T, class Key, class Hash>
|
||||
inline Foam::HashTable<T, Key, Hash>::iterator::iterator
|
||||
(
|
||||
HashTable<T, Key, Hash>& curHashTable,
|
||||
HashTable<T, Key, Hash>& hashTbl,
|
||||
hashedEntry* elmt,
|
||||
label hashIndex
|
||||
)
|
||||
:
|
||||
curHashTable_(curHashTable),
|
||||
hashTable_(hashTbl),
|
||||
elmtPtr_(elmt),
|
||||
hashIndex_(hashIndex)
|
||||
{}
|
||||
@ -241,12 +252,12 @@ Foam::HashTable<T, Key, Hash>::iterator::operator++()
|
||||
// Step to the next table entry
|
||||
while
|
||||
(
|
||||
++hashIndex_ < curHashTable_.tableSize_
|
||||
&& !(elmtPtr_ = curHashTable_.table_[hashIndex_])
|
||||
++hashIndex_ < hashTable_.tableSize_
|
||||
&& !(elmtPtr_ = hashTable_.table_[hashIndex_])
|
||||
)
|
||||
{}
|
||||
|
||||
if (hashIndex_ == curHashTable_.tableSize_)
|
||||
if (hashIndex_ == hashTable_.tableSize_)
|
||||
{
|
||||
// make end iterator
|
||||
elmtPtr_ = 0;
|
||||
@ -271,7 +282,7 @@ Foam::HashTable<T, Key, Hash>::iterator::operator++
|
||||
|
||||
template<class T, class Key, class Hash>
|
||||
inline
|
||||
const Key& Foam::HashTable<T, Key, Hash>::iterator::key()
|
||||
const Key& Foam::HashTable<T, Key, Hash>::iterator::key() const
|
||||
{
|
||||
return elmtPtr_->key_;
|
||||
}
|
||||
@ -283,8 +294,15 @@ Foam::HashTable<T, Key, Hash>::begin()
|
||||
{
|
||||
label i = 0;
|
||||
|
||||
while (table_ && !table_[i] && ++i < tableSize_)
|
||||
{}
|
||||
if (nElmts_)
|
||||
{
|
||||
while (table_ && !table_[i] && ++i < tableSize_)
|
||||
{}
|
||||
}
|
||||
else
|
||||
{
|
||||
i = tableSize_;
|
||||
}
|
||||
|
||||
if (i == tableSize_)
|
||||
{
|
||||
@ -317,12 +335,12 @@ Foam::HashTable<T, Key, Hash>::end()
|
||||
template<class T, class Key, class Hash>
|
||||
inline Foam::HashTable<T, Key, Hash>::const_iterator::const_iterator
|
||||
(
|
||||
const HashTable<T, Key, Hash>& curHashTable,
|
||||
const HashTable<T, Key, Hash>& hashTbl,
|
||||
const hashedEntry* elmt,
|
||||
label hashIndex
|
||||
)
|
||||
:
|
||||
curHashTable_(curHashTable),
|
||||
hashTable_(hashTbl),
|
||||
elmtPtr_(elmt),
|
||||
hashIndex_(hashIndex)
|
||||
{}
|
||||
@ -334,7 +352,7 @@ inline Foam::HashTable<T, Key, Hash>::const_iterator::const_iterator
|
||||
const iterator& iter
|
||||
)
|
||||
:
|
||||
curHashTable_(iter.curHashTable_),
|
||||
hashTable_(iter.hashTable_),
|
||||
elmtPtr_(iter.elmtPtr_),
|
||||
hashIndex_(iter.hashIndex_)
|
||||
{}
|
||||
@ -413,14 +431,14 @@ Foam::HashTable<T, Key, Hash>::const_iterator::operator++()
|
||||
if
|
||||
(
|
||||
!(elmtPtr_ = elmtPtr_->next_)
|
||||
&& ++hashIndex_ < curHashTable_.tableSize_
|
||||
&& !(elmtPtr_ = curHashTable_.table_[hashIndex_])
|
||||
&& ++hashIndex_ < hashTable_.tableSize_
|
||||
&& !(elmtPtr_ = hashTable_.table_[hashIndex_])
|
||||
)
|
||||
{
|
||||
while
|
||||
(
|
||||
++hashIndex_ < curHashTable_.tableSize_
|
||||
&& !(elmtPtr_ = curHashTable_.table_[hashIndex_])
|
||||
++hashIndex_ < hashTable_.tableSize_
|
||||
&& !(elmtPtr_ = hashTable_.table_[hashIndex_])
|
||||
)
|
||||
{}
|
||||
}
|
||||
@ -444,7 +462,7 @@ Foam::HashTable<T, Key, Hash>::const_iterator::operator++
|
||||
|
||||
template<class T, class Key, class Hash>
|
||||
inline
|
||||
const Key& Foam::HashTable<T, Key, Hash>::const_iterator::key()
|
||||
const Key& Foam::HashTable<T, Key, Hash>::const_iterator::key() const
|
||||
{
|
||||
return elmtPtr_->key_;
|
||||
}
|
||||
@ -456,8 +474,15 @@ Foam::HashTable<T, Key, Hash>::cbegin() const
|
||||
{
|
||||
label i = 0;
|
||||
|
||||
while (table_ && !table_[i] && ++i < tableSize_)
|
||||
{}
|
||||
if (nElmts_)
|
||||
{
|
||||
while (table_ && !table_[i] && ++i < tableSize_)
|
||||
{}
|
||||
}
|
||||
else
|
||||
{
|
||||
i = tableSize_;
|
||||
}
|
||||
|
||||
if (i == tableSize_)
|
||||
{
|
||||
|
||||
@ -33,21 +33,61 @@ License
|
||||
template<class T, class Key, class Hash>
|
||||
Foam::HashTable<T, Key, Hash>::HashTable(Istream& is, const label size)
|
||||
:
|
||||
tableSize_(size),
|
||||
table_(new hashedEntry*[tableSize_]),
|
||||
HashTableName(),
|
||||
nElmts_(0),
|
||||
tableSize_(canonicalSize(size)),
|
||||
table_(new hashedEntry*[tableSize_]),
|
||||
endIter_(*this, NULL, 0),
|
||||
endConstIter_(*this, NULL, 0)
|
||||
{
|
||||
for (label i=0; i<tableSize_; i++)
|
||||
for (label hashIdx = 0; hashIdx < tableSize_; hashIdx++)
|
||||
{
|
||||
table_[i] = 0;
|
||||
table_[hashIdx] = 0;
|
||||
}
|
||||
|
||||
operator>>(is, *this);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
|
||||
|
||||
template<class T, class Key, class Hash>
|
||||
Foam::Ostream&
|
||||
Foam::HashTable<T, Key, Hash>::printInfo(Ostream& os) const
|
||||
{
|
||||
label used = 0;
|
||||
label maxChain = 0;
|
||||
unsigned avgChain = 0;
|
||||
|
||||
for (label hashIdx = 0; hashIdx < tableSize_; ++hashIdx)
|
||||
{
|
||||
label count = 0;
|
||||
for (hashedEntry* ep = table_[hashIdx]; ep; ep = ep->next_)
|
||||
{
|
||||
++count;
|
||||
}
|
||||
|
||||
if (count)
|
||||
{
|
||||
++used;
|
||||
avgChain += count;
|
||||
|
||||
if (maxChain < count)
|
||||
{
|
||||
maxChain = count;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
os << "HashTable<T,Key,Hash>"
|
||||
<< " elements:" << size() << " slots:" << used << "/" << tableSize_
|
||||
<< " chaining(avg/max):" << (used ? float(avgChain/used) : 0)
|
||||
<< "/" << maxChain << endl;
|
||||
|
||||
return os;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
|
||||
|
||||
template<class T, class Key, class Hash>
|
||||
@ -133,10 +173,13 @@ Foam::Istream& Foam::operator>>(Istream& is, HashTable<T, Key, Hash>& L)
|
||||
)
|
||||
{
|
||||
is.putBack(lastToken);
|
||||
|
||||
Key key;
|
||||
is >> key;
|
||||
|
||||
T element;
|
||||
is >> element;
|
||||
|
||||
L.insert(key, element);
|
||||
|
||||
is.fatalCheck
|
||||
@ -174,8 +217,8 @@ Foam::Ostream& Foam::operator<<(Ostream& os, const HashTable<T, Key, Hash>& L)
|
||||
// Write contents
|
||||
for
|
||||
(
|
||||
typename HashTable<T, Key, Hash>::const_iterator iter = L.begin();
|
||||
iter != L.end();
|
||||
typename HashTable<T, Key, Hash>::const_iterator iter = L.cbegin();
|
||||
iter != L.cend();
|
||||
++iter
|
||||
)
|
||||
{
|
||||
|
||||
@ -63,7 +63,7 @@ public:
|
||||
// Constructors
|
||||
|
||||
//- Construct given initial size
|
||||
Map(const label size = 100)
|
||||
Map(const label size = 128)
|
||||
:
|
||||
HashTable<T, label, Hash<label> >(size)
|
||||
{}
|
||||
|
||||
@ -58,7 +58,7 @@ public:
|
||||
// Constructors
|
||||
|
||||
//- Construct given initial map size
|
||||
PtrMap(const label size = 100)
|
||||
PtrMap(const label size = 128)
|
||||
:
|
||||
HashPtrTable<T, label, Hash<label> >(size)
|
||||
{}
|
||||
|
||||
@ -31,6 +31,33 @@ License
|
||||
#include "List.H"
|
||||
#include "IOstreams.H"
|
||||
|
||||
// * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * //
|
||||
|
||||
template<class T, class Key, class Hash>
|
||||
Foam::label Foam::StaticHashTable<T, Key, Hash>::canonicalSize(const label size)
|
||||
{
|
||||
if (size < 1)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
// enforce power of two
|
||||
unsigned int goodSize = size;
|
||||
|
||||
if (goodSize & (goodSize - 1))
|
||||
{
|
||||
// brute-force is fast enough
|
||||
goodSize = 1;
|
||||
while (goodSize < unsigned(size))
|
||||
{
|
||||
goodSize <<= 1;
|
||||
}
|
||||
}
|
||||
|
||||
return goodSize;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
// Construct given initial table size
|
||||
@ -38,8 +65,8 @@ template<class T, class Key, class Hash>
|
||||
Foam::StaticHashTable<T, Key, Hash>::StaticHashTable(const label size)
|
||||
:
|
||||
StaticHashTableName(),
|
||||
keys_(size),
|
||||
objects_(size),
|
||||
keys_(canonicalSize(size)),
|
||||
objects_(keys_.size()),
|
||||
nElmts_(0),
|
||||
endIter_(*this, keys_.size(), 0),
|
||||
endConstIter_(*this, keys_.size(), 0)
|
||||
@ -75,7 +102,7 @@ Foam::StaticHashTable<T, Key, Hash>::StaticHashTable
|
||||
template<class T, class Key, class Hash>
|
||||
Foam::StaticHashTable<T, Key, Hash>::StaticHashTable
|
||||
(
|
||||
const Xfer<StaticHashTable<T, Key, Hash> >& ht
|
||||
const Xfer< StaticHashTable<T, Key, Hash> >& ht
|
||||
)
|
||||
:
|
||||
StaticHashTableName(),
|
||||
@ -101,14 +128,17 @@ Foam::StaticHashTable<T, Key, Hash>::~StaticHashTable()
|
||||
template<class T, class Key, class Hash>
|
||||
bool Foam::StaticHashTable<T, Key, Hash>::found(const Key& key) const
|
||||
{
|
||||
label hashIdx = Hash()(key, keys_.size());
|
||||
const List<Key>& localKeys = keys_[hashIdx];
|
||||
|
||||
forAll(localKeys, elemIdx)
|
||||
if (nElmts_)
|
||||
{
|
||||
if (key == localKeys[elemIdx])
|
||||
const label hashIdx = hashKeyIndex(key);
|
||||
const List<Key>& localKeys = keys_[hashIdx];
|
||||
|
||||
forAll(localKeys, elemIdx)
|
||||
{
|
||||
return true;
|
||||
if (key == localKeys[elemIdx])
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -131,14 +161,17 @@ Foam::StaticHashTable<T, Key, Hash>::find
|
||||
const Key& key
|
||||
)
|
||||
{
|
||||
label hashIdx = Hash()(key, keys_.size());
|
||||
const List<Key>& localKeys = keys_[hashIdx];
|
||||
|
||||
forAll(localKeys, elemIdx)
|
||||
if (nElmts_)
|
||||
{
|
||||
if (key == localKeys[elemIdx])
|
||||
const label hashIdx = hashKeyIndex(key);
|
||||
const List<Key>& localKeys = keys_[hashIdx];
|
||||
|
||||
forAll(localKeys, elemIdx)
|
||||
{
|
||||
return iterator(*this, hashIdx, elemIdx);
|
||||
if (key == localKeys[elemIdx])
|
||||
{
|
||||
return iterator(*this, hashIdx, elemIdx);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -161,14 +194,17 @@ Foam::StaticHashTable<T, Key, Hash>::find
|
||||
const Key& key
|
||||
) const
|
||||
{
|
||||
label hashIdx = Hash()(key, keys_.size());
|
||||
const List<Key>& localKeys = keys_[hashIdx];
|
||||
|
||||
forAll(localKeys, elemIdx)
|
||||
if (nElmts_)
|
||||
{
|
||||
if (key == localKeys[elemIdx])
|
||||
const label hashIdx = hashKeyIndex(key);
|
||||
const List<Key>& localKeys = keys_[hashIdx];
|
||||
|
||||
forAll(localKeys, elemIdx)
|
||||
{
|
||||
return const_iterator(*this, hashIdx, elemIdx);
|
||||
if (key == localKeys[elemIdx])
|
||||
{
|
||||
return const_iterator(*this, hashIdx, elemIdx);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -180,7 +216,7 @@ Foam::StaticHashTable<T, Key, Hash>::find
|
||||
}
|
||||
# endif
|
||||
|
||||
return end();
|
||||
return cend();
|
||||
}
|
||||
|
||||
|
||||
@ -191,7 +227,7 @@ Foam::List<Key> Foam::StaticHashTable<T, Key, Hash>::toc() const
|
||||
List<Key> tofc(nElmts_);
|
||||
label i = 0;
|
||||
|
||||
for (const_iterator iter = begin(); iter != end(); ++iter)
|
||||
for (const_iterator iter = cbegin(); iter != cend(); ++iter)
|
||||
{
|
||||
tofc[i++] = iter.key();
|
||||
}
|
||||
@ -208,7 +244,7 @@ bool Foam::StaticHashTable<T, Key, Hash>::set
|
||||
const bool protect
|
||||
)
|
||||
{
|
||||
label hashIdx = Hash()(key, keys_.size());
|
||||
const label hashIdx = hashKeyIndex(key);
|
||||
List<Key>& localKeys = keys_[hashIdx];
|
||||
|
||||
label existing = localKeys.size();
|
||||
@ -268,7 +304,7 @@ bool Foam::StaticHashTable<T, Key, Hash>::erase(const iterator& cit)
|
||||
List<T>& localObjects = objects_[cit.hashIndex_];
|
||||
|
||||
// Copy down
|
||||
for (label i = cit.elementIndex_+1; i < localKeys.size(); i++)
|
||||
for (label i = cit.elemIndex_+1; i < localKeys.size(); i++)
|
||||
{
|
||||
localKeys[i-1] = localKeys[i];
|
||||
localObjects[i-1] = localObjects[i];
|
||||
@ -279,8 +315,8 @@ bool Foam::StaticHashTable<T, Key, Hash>::erase(const iterator& cit)
|
||||
// adjust iterator after erase
|
||||
iterator& it = const_cast<iterator&>(cit);
|
||||
|
||||
it.elementIndex_--;
|
||||
if (it.elementIndex_ < 0)
|
||||
it.elemIndex_--;
|
||||
if (it.elemIndex_ < 0)
|
||||
{
|
||||
// No previous element in the local list
|
||||
|
||||
@ -291,7 +327,7 @@ bool Foam::StaticHashTable<T, Key, Hash>::erase(const iterator& cit)
|
||||
if (it.hashIndex_ >= 0)
|
||||
{
|
||||
// The last element in the local list
|
||||
it.elementIndex_ = objects_[it.hashIndex_].size() - 1;
|
||||
it.elemIndex_ = objects_[it.hashIndex_].size() - 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -299,7 +335,7 @@ bool Foam::StaticHashTable<T, Key, Hash>::erase(const iterator& cit)
|
||||
// - not end()
|
||||
// - handled by operator++
|
||||
it.hashIndex_ = -1;
|
||||
it.elementIndex_ = 0;
|
||||
it.elemIndex_ = 0;
|
||||
}
|
||||
}
|
||||
|
||||
@ -369,8 +405,10 @@ Foam::label Foam::StaticHashTable<T, Key, Hash>::erase
|
||||
|
||||
|
||||
template<class T, class Key, class Hash>
|
||||
void Foam::StaticHashTable<T, Key, Hash>::resize(const label newSize)
|
||||
void Foam::StaticHashTable<T, Key, Hash>::resize(const label sz)
|
||||
{
|
||||
label newSize = canonicalSize(sz);
|
||||
|
||||
if (newSize == keys_.size())
|
||||
{
|
||||
# ifdef FULLDEBUG
|
||||
@ -388,7 +426,7 @@ void Foam::StaticHashTable<T, Key, Hash>::resize(const label newSize)
|
||||
{
|
||||
FatalErrorIn
|
||||
(
|
||||
"StaticHashTable<T, Key, Hash>::StaticHashTable(const label size)"
|
||||
"StaticHashTable<T, Key, Hash>::resize(const label)"
|
||||
) << "Illegal size " << newSize << " for StaticHashTable."
|
||||
<< " Minimum size is 1" << abort(FatalError);
|
||||
}
|
||||
@ -396,7 +434,7 @@ void Foam::StaticHashTable<T, Key, Hash>::resize(const label newSize)
|
||||
|
||||
StaticHashTable<T, Key, Hash> newTable(newSize);
|
||||
|
||||
for (iterator iter = begin(); iter != end(); ++iter)
|
||||
for (const_iterator iter = cbegin(); iter != cend(); ++iter)
|
||||
{
|
||||
newTable.insert(iter.key(), *iter);
|
||||
}
|
||||
@ -493,7 +531,7 @@ void Foam::StaticHashTable<T, Key, Hash>::operator=
|
||||
}
|
||||
|
||||
|
||||
for (const_iterator iter = rhs.begin(); iter != rhs.end(); ++iter)
|
||||
for (const_iterator iter = rhs.cbegin(); iter != rhs.cend(); ++iter)
|
||||
{
|
||||
insert(iter.key(), *iter);
|
||||
}
|
||||
@ -506,22 +544,22 @@ bool Foam::StaticHashTable<T, Key, Hash>::operator==
|
||||
) const
|
||||
{
|
||||
// Are all my elements in rhs?
|
||||
for (const_iterator iter = begin(); iter != end(); ++iter)
|
||||
for (const_iterator iter = cbegin(); iter != cend(); ++iter)
|
||||
{
|
||||
const_iterator fnd = rhs.find(iter.key());
|
||||
|
||||
if (fnd == rhs.end() || fnd() != iter())
|
||||
if (fnd == rhs.cend() || fnd() != iter())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Are all rhs elements in me?
|
||||
for (const_iterator iter = rhs.begin(); iter != rhs.end(); ++iter)
|
||||
for (const_iterator iter = rhs.cbegin(); iter != rhs.cend(); ++iter)
|
||||
{
|
||||
const_iterator fnd = find(iter.key());
|
||||
|
||||
if (fnd == end() || fnd() != iter())
|
||||
if (fnd == cend() || fnd() != iter())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -32,7 +32,6 @@ Note
|
||||
Uses straight lists as underlying type.
|
||||
Is slower to insert than the standard HashTable, but should be more
|
||||
memory efficient and faster to access.
|
||||
Explicitly does not have default size.
|
||||
|
||||
SourceFiles
|
||||
StaticHashTableI.H
|
||||
@ -45,9 +44,10 @@ SourceFiles
|
||||
#define StaticHashTable_H
|
||||
|
||||
#include "label.H"
|
||||
#include "uLabel.H"
|
||||
#include "word.H"
|
||||
#include "className.H"
|
||||
#include "Xfer.H"
|
||||
#include "className.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -99,6 +99,13 @@ class StaticHashTable
|
||||
//- The current number of elements in table
|
||||
label nElmts_;
|
||||
|
||||
//- Return a canonical (power-of-two) size
|
||||
static label canonicalSize(const label);
|
||||
|
||||
//- Return the hash index of the Key within the current table size.
|
||||
// No checks for zero-sized tables.
|
||||
inline label hashKeyIndex(const Key&) const;
|
||||
|
||||
//- Assign a new hashed entry to a possibly already existing key
|
||||
bool set(const Key&, const T& newElmt, bool protect);
|
||||
|
||||
@ -141,16 +148,16 @@ public:
|
||||
// Constructors
|
||||
|
||||
//- Construct given initial table size
|
||||
StaticHashTable(const label size = 100);
|
||||
StaticHashTable(const label size = 128);
|
||||
|
||||
//- Construct from Istream
|
||||
StaticHashTable(Istream&, const label size = 100);
|
||||
StaticHashTable(Istream&, const label size = 128);
|
||||
|
||||
//- Construct as copy
|
||||
StaticHashTable(const StaticHashTable<T, Key, Hash>&);
|
||||
|
||||
//- Construct by transferring the parameter contents
|
||||
StaticHashTable(const Xfer<StaticHashTable<T, Key, Hash> >&);
|
||||
StaticHashTable(const Xfer< StaticHashTable<T, Key, Hash> >&);
|
||||
|
||||
// Destructor
|
||||
|
||||
@ -181,6 +188,9 @@ public:
|
||||
//- Return the table of contents
|
||||
List<Key> toc() const;
|
||||
|
||||
//- Print information
|
||||
Ostream& printInfo(Ostream&) const;
|
||||
|
||||
|
||||
// Edit
|
||||
|
||||
@ -215,7 +225,7 @@ public:
|
||||
void transfer(StaticHashTable<T, Key, Hash>&);
|
||||
|
||||
//- Transfer contents to the Xfer container
|
||||
inline Xfer<StaticHashTable<T, Key, Hash> > xfer();
|
||||
inline Xfer< StaticHashTable<T, Key, Hash> > xfer();
|
||||
|
||||
|
||||
// Member Operators
|
||||
@ -273,13 +283,13 @@ public:
|
||||
// Private data
|
||||
|
||||
//- Reference to the StaticHashTable this is an iterator for
|
||||
TableRef curHashTable_;
|
||||
TableRef hashTable_;
|
||||
|
||||
//- Current hash index
|
||||
label hashIndex_;
|
||||
|
||||
//- Index of current element at hashIndex
|
||||
label elementIndex_;
|
||||
label elemIndex_;
|
||||
|
||||
public:
|
||||
|
||||
@ -288,9 +298,9 @@ public:
|
||||
//- Construct from hash table, hash index and element index
|
||||
inline Iterator
|
||||
(
|
||||
TableRef curHashTable,
|
||||
TableRef,
|
||||
label hashIndex_,
|
||||
label elementIndex_
|
||||
label elemIndex_
|
||||
);
|
||||
|
||||
//- Construct from the non-const iterator
|
||||
@ -299,13 +309,13 @@ public:
|
||||
|
||||
// Member operators
|
||||
|
||||
inline void operator=(const iterator& iter);
|
||||
inline void operator=(const iterator&);
|
||||
|
||||
inline bool operator==(const iterator& iter) const;
|
||||
inline bool operator==(const const_iterator& iter) const;
|
||||
inline bool operator==(const iterator&) const;
|
||||
inline bool operator==(const const_iterator&) const;
|
||||
|
||||
inline bool operator!=(const iterator& iter) const;
|
||||
inline bool operator!=(const const_iterator& iter) const;
|
||||
inline bool operator!=(const iterator&) const;
|
||||
inline bool operator!=(const const_iterator&) const;
|
||||
|
||||
inline TRef operator*();
|
||||
inline TRef operator()();
|
||||
@ -313,7 +323,7 @@ public:
|
||||
inline Iterator& operator++();
|
||||
inline Iterator operator++(int);
|
||||
|
||||
inline const Key& key();
|
||||
inline const Key& key() const;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -29,6 +29,17 @@ License
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Classes * * * * * * * * * * * * //
|
||||
|
||||
// * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * //
|
||||
|
||||
template<class T, class Key, class Hash>
|
||||
inline Foam::label
|
||||
Foam::StaticHashTable<T, Key, Hash>::hashKeyIndex(const Key& key) const
|
||||
{
|
||||
// size is power of two - this is the modulus
|
||||
return Hash()(key) & (keys_.size() - 1);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class T, class Key, class Hash>
|
||||
@ -68,7 +79,7 @@ inline bool Foam::StaticHashTable<T, Key, Hash>::set
|
||||
|
||||
|
||||
template<class T, class Key, class Hash>
|
||||
inline Foam::Xfer<Foam::StaticHashTable<T, Key, Hash> >
|
||||
inline Foam::Xfer< Foam::StaticHashTable<T, Key, Hash> >
|
||||
Foam::StaticHashTable<T, Key, Hash>::xfer()
|
||||
{
|
||||
return xferMove(*this);
|
||||
@ -102,7 +113,7 @@ inline const T& Foam::StaticHashTable<T, Key, Hash>::operator[]
|
||||
{
|
||||
const_iterator iter = find(key);
|
||||
|
||||
if (iter == end())
|
||||
if (iter == cend())
|
||||
{
|
||||
FatalErrorIn
|
||||
(
|
||||
@ -139,14 +150,14 @@ template<class T, class Key, class Hash>
|
||||
template<class TRef, class TableRef>
|
||||
inline Foam::StaticHashTable<T, Key, Hash>::Iterator<TRef, TableRef>::Iterator
|
||||
(
|
||||
TableRef curHashTable,
|
||||
TableRef hashTbl,
|
||||
label hashIndex,
|
||||
label elementIndex
|
||||
label elemIndex
|
||||
)
|
||||
:
|
||||
curHashTable_(curHashTable),
|
||||
hashTable_(hashTbl),
|
||||
hashIndex_(hashIndex),
|
||||
elementIndex_(elementIndex)
|
||||
elemIndex_(elemIndex)
|
||||
{}
|
||||
|
||||
|
||||
@ -157,9 +168,9 @@ inline Foam::StaticHashTable<T, Key, Hash>::Iterator<TRef, TableRef>::Iterator
|
||||
const iterator& iter
|
||||
)
|
||||
:
|
||||
curHashTable_(iter.curHashTable_),
|
||||
hashTable_(iter.hashTable_),
|
||||
hashIndex_(iter.hashIndex_),
|
||||
elementIndex_(iter.elementIndex_)
|
||||
elemIndex_(iter.elemIndex_)
|
||||
{}
|
||||
|
||||
|
||||
@ -172,7 +183,7 @@ Foam::StaticHashTable<T, Key, Hash>::Iterator<TRef, TableRef>::operator=
|
||||
)
|
||||
{
|
||||
this->hashIndex_ = iter.hashIndex_;
|
||||
this->elementIndex_ = iter.elementIndex_;
|
||||
this->elemIndex_ = iter.elemIndex_;
|
||||
}
|
||||
|
||||
|
||||
@ -184,7 +195,7 @@ Foam::StaticHashTable<T, Key, Hash>::Iterator<TRef, TableRef>::operator==
|
||||
const iterator& iter
|
||||
) const
|
||||
{
|
||||
return hashIndex_ == iter.hashIndex_ && elementIndex_ == iter.elementIndex_;
|
||||
return hashIndex_ == iter.hashIndex_ && elemIndex_ == iter.elemIndex_;
|
||||
}
|
||||
|
||||
|
||||
@ -196,7 +207,7 @@ Foam::StaticHashTable<T, Key, Hash>::Iterator<TRef, TableRef>::operator==
|
||||
const const_iterator& iter
|
||||
) const
|
||||
{
|
||||
return hashIndex_ == iter.hashIndex_ && elementIndex_ == iter.elementIndex_;
|
||||
return hashIndex_ == iter.hashIndex_ && elemIndex_ == iter.elemIndex_;
|
||||
}
|
||||
|
||||
|
||||
@ -229,7 +240,7 @@ template<class TRef, class TableRef>
|
||||
inline TRef
|
||||
Foam::StaticHashTable<T, Key, Hash>::Iterator<TRef, TableRef>::operator*()
|
||||
{
|
||||
return curHashTable_.objects_[hashIndex_][elementIndex_];
|
||||
return hashTable_.objects_[hashIndex_][elemIndex_];
|
||||
}
|
||||
|
||||
|
||||
@ -260,29 +271,29 @@ Foam::StaticHashTable<T, Key, Hash>::Iterator
|
||||
if (hashIndex_ >= 0)
|
||||
{
|
||||
// Try the next element on the local list
|
||||
elementIndex_++;
|
||||
elemIndex_++;
|
||||
|
||||
if (elementIndex_ < curHashTable_.objects_[hashIndex_].size())
|
||||
if (elemIndex_ < hashTable_.objects_[hashIndex_].size())
|
||||
{
|
||||
return *this;
|
||||
}
|
||||
}
|
||||
|
||||
// Step to the next table entry
|
||||
elementIndex_ = 0;
|
||||
elemIndex_ = 0;
|
||||
|
||||
while
|
||||
(
|
||||
++hashIndex_ < curHashTable_.objects_.size()
|
||||
&& !curHashTable_.objects_[hashIndex_].size()
|
||||
++hashIndex_ < hashTable_.objects_.size()
|
||||
&& !hashTable_.objects_[hashIndex_].size()
|
||||
)
|
||||
{}
|
||||
|
||||
|
||||
if (hashIndex_ >= curHashTable_.objects_.size())
|
||||
if (hashIndex_ >= hashTable_.objects_.size())
|
||||
{
|
||||
// make end iterator
|
||||
hashIndex_ = curHashTable_.keys_.size();
|
||||
hashIndex_ = hashTable_.keys_.size();
|
||||
}
|
||||
|
||||
return *this;
|
||||
@ -315,9 +326,9 @@ Foam::StaticHashTable<T, Key, Hash>::Iterator
|
||||
template<class T, class Key, class Hash>
|
||||
template<class TRef, class TableRef>
|
||||
inline const Key&
|
||||
Foam::StaticHashTable<T, Key, Hash>::Iterator<TRef, TableRef>::key()
|
||||
Foam::StaticHashTable<T, Key, Hash>::Iterator<TRef, TableRef>::key() const
|
||||
{
|
||||
return curHashTable_.keys_[hashIndex_][elementIndex_];
|
||||
return hashTable_.keys_[hashIndex_][elemIndex_];
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -33,7 +33,7 @@ License
|
||||
template<class T, class Key, class Hash>
|
||||
Foam::StaticHashTable<T, Key, Hash>::StaticHashTable
|
||||
(
|
||||
Istream& is,
|
||||
Istream& is,
|
||||
const label size
|
||||
)
|
||||
:
|
||||
@ -57,6 +57,41 @@ Foam::StaticHashTable<T, Key, Hash>::StaticHashTable
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
|
||||
|
||||
template<class T, class Key, class Hash>
|
||||
Foam::Ostream&
|
||||
Foam::StaticHashTable<T, Key, Hash>::printInfo(Ostream& os) const
|
||||
{
|
||||
label used = 0;
|
||||
label maxChain = 0;
|
||||
unsigned avgChain = 0;
|
||||
|
||||
// Find first non-empty entry
|
||||
forAll(keys_, hashIdx)
|
||||
{
|
||||
const label count = keys_[hashIdx].size();
|
||||
if (count)
|
||||
{
|
||||
++used;
|
||||
avgChain += count;
|
||||
|
||||
if (maxChain < count)
|
||||
{
|
||||
maxChain = count;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
os << "StaticHashTable<T,Key,Hash>"
|
||||
<< " elements:" << size() << " slots:" << used << "/" << keys_.size()
|
||||
<< " chaining(avg/max):" << (used ? float(avgChain/used) : 0)
|
||||
<< "/" << maxChain << endl;
|
||||
|
||||
return os;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
|
||||
|
||||
template<class T, class Key, class Hash>
|
||||
@ -142,10 +177,13 @@ Foam::Istream& Foam::operator>>(Istream& is, StaticHashTable<T, Key, Hash>& L)
|
||||
)
|
||||
{
|
||||
is.putBack(lastToken);
|
||||
|
||||
Key key;
|
||||
is >> key;
|
||||
|
||||
T element;
|
||||
is >> element;
|
||||
|
||||
L.insert(key, element);
|
||||
|
||||
is.fatalCheck
|
||||
|
||||
@ -38,6 +38,7 @@ SourceFiles
|
||||
#define LList_H
|
||||
|
||||
#include "label.H"
|
||||
#include "uLabel.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
|
||||
@ -38,6 +38,7 @@ SourceFiles
|
||||
#define UILList_H
|
||||
|
||||
#include "label.H"
|
||||
#include "uLabel.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
|
||||
@ -38,6 +38,7 @@ SourceFiles
|
||||
|
||||
#include "bool.H"
|
||||
#include "label.H"
|
||||
#include "uLabel.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
|
||||
@ -38,6 +38,7 @@ SourceFiles
|
||||
|
||||
#include "bool.H"
|
||||
#include "label.H"
|
||||
#include "uLabel.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
|
||||
@ -31,7 +31,7 @@ License
|
||||
|
||||
// * * * * * * * * * * * * * * STL Member Functions * * * * * * * * * * * * //
|
||||
|
||||
template<class T, Foam::label Size>
|
||||
template<class T, unsigned Size>
|
||||
void Foam::FixedList<T, Size>::swap(FixedList<T, Size>& a)
|
||||
{
|
||||
List_ACCESS(T, (*this), vp);
|
||||
@ -47,7 +47,7 @@ void Foam::FixedList<T, Size>::swap(FixedList<T, Size>& a)
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
|
||||
|
||||
template<class T, Foam::label Size>
|
||||
template<class T, unsigned Size>
|
||||
bool Foam::FixedList<T, Size>::operator==(const FixedList<T, Size>& a) const
|
||||
{
|
||||
bool equal = true;
|
||||
@ -63,20 +63,20 @@ bool Foam::FixedList<T, Size>::operator==(const FixedList<T, Size>& a) const
|
||||
}
|
||||
|
||||
|
||||
template<class T, Foam::label Size>
|
||||
template<class T, unsigned Size>
|
||||
bool Foam::FixedList<T, Size>::operator!=(const FixedList<T, Size>& a) const
|
||||
{
|
||||
return !operator==(a);
|
||||
}
|
||||
|
||||
|
||||
template<class T, Foam::label Size>
|
||||
template<class T, unsigned Size>
|
||||
bool Foam::FixedList<T, Size>::operator<(const FixedList<T, Size>& a) const
|
||||
{
|
||||
for
|
||||
(
|
||||
const_iterator vi = begin(), ai = a.begin();
|
||||
vi < end() && ai < a.end();
|
||||
const_iterator vi = cbegin(), ai = a.cbegin();
|
||||
vi < cend() && ai < a.cend();
|
||||
vi++, ai++
|
||||
)
|
||||
{
|
||||
@ -101,21 +101,21 @@ bool Foam::FixedList<T, Size>::operator<(const FixedList<T, Size>& a) const
|
||||
}
|
||||
|
||||
|
||||
template<class T, Foam::label Size>
|
||||
template<class T, unsigned Size>
|
||||
bool Foam::FixedList<T, Size>::operator>(const FixedList<T, Size>& a) const
|
||||
{
|
||||
return a.operator<(*this);
|
||||
}
|
||||
|
||||
|
||||
template<class T, Foam::label Size>
|
||||
template<class T, unsigned Size>
|
||||
bool Foam::FixedList<T, Size>::operator<=(const FixedList<T, Size>& a) const
|
||||
{
|
||||
return !operator>(a);
|
||||
}
|
||||
|
||||
|
||||
template<class T, Foam::label Size>
|
||||
template<class T, unsigned Size>
|
||||
bool Foam::FixedList<T, Size>::operator>=(const FixedList<T, Size>& a) const
|
||||
{
|
||||
return !operator<(a);
|
||||
|
||||
@ -38,9 +38,12 @@ SourceFiles
|
||||
#ifndef FixedList_H
|
||||
#define FixedList_H
|
||||
|
||||
#include "bool.H"
|
||||
#include "label.H"
|
||||
#include "uLabel.H"
|
||||
#include "Hash.H"
|
||||
#include "autoPtr.H"
|
||||
#include "StaticAssert.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -49,12 +52,12 @@ namespace Foam
|
||||
|
||||
// Forward declaration of friend functions and operators
|
||||
|
||||
template<class T, label Size> class FixedList;
|
||||
template<class T, unsigned Size> class FixedList;
|
||||
|
||||
template<class T, label Size>
|
||||
template<class T, unsigned Size>
|
||||
Istream& operator>>(Istream&, FixedList<T, Size>&);
|
||||
|
||||
template<class T, label Size>
|
||||
template<class T, unsigned Size>
|
||||
Ostream& operator<<(Ostream&, const FixedList<T, Size>&);
|
||||
|
||||
template<class T> class UList;
|
||||
@ -65,9 +68,12 @@ template<class T> class SLList;
|
||||
Class FixedList Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
template<class T, label Size>
|
||||
template<class T, unsigned Size>
|
||||
class FixedList
|
||||
{
|
||||
//- Size must be positive (non-zero) and also fit as a signed value
|
||||
StaticAssert(Size && Size <= INT_MAX);
|
||||
|
||||
// Private data
|
||||
|
||||
//- Vector of values of type T of size Size.
|
||||
@ -76,20 +82,19 @@ class FixedList
|
||||
|
||||
public:
|
||||
|
||||
//- Hashing function class
|
||||
// Rotating hash from http://burtleburtle.net/bob/hash/doobs.html
|
||||
template<class HashT=Hash<T> >
|
||||
//- Hashing function class.
|
||||
// Use Hasher directly for contiguous data. Otherwise hash incrementally.
|
||||
template< class HashT=Hash<T> >
|
||||
class Hash
|
||||
:
|
||||
public Foam::Hash<FixedList<T, Size> >
|
||||
{
|
||||
public:
|
||||
inline Hash();
|
||||
label operator()(const FixedList<T, Size>&) const;
|
||||
label operator()
|
||||
Hash()
|
||||
{}
|
||||
|
||||
inline unsigned operator()
|
||||
(
|
||||
const FixedList<T, Size>&,
|
||||
const label tableSize
|
||||
unsigned seed = 0
|
||||
) const;
|
||||
};
|
||||
|
||||
@ -123,7 +128,7 @@ public:
|
||||
FixedList(Istream&);
|
||||
|
||||
//- Clone
|
||||
inline autoPtr<FixedList<T, Size> > clone() const;
|
||||
inline autoPtr< FixedList<T, Size> > clone() const;
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
@ -26,47 +26,48 @@ License
|
||||
|
||||
#include "UList.H"
|
||||
#include "SLList.H"
|
||||
#include "contiguous.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
template<class T, Foam::label Size>
|
||||
template<class T, unsigned Size>
|
||||
inline Foam::FixedList<T, Size>::FixedList()
|
||||
{}
|
||||
|
||||
|
||||
template<class T, Foam::label Size>
|
||||
template<class T, unsigned Size>
|
||||
inline Foam::FixedList<T, Size>::FixedList(const T v[Size])
|
||||
{
|
||||
for (register label i=0; i<Size; i++)
|
||||
for (register unsigned i=0; i<Size; i++)
|
||||
{
|
||||
v_[i] = v[i];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<class T, Foam::label Size>
|
||||
template<class T, unsigned Size>
|
||||
inline Foam::FixedList<T, Size>::FixedList(const T& t)
|
||||
{
|
||||
for (register label i=0; i<Size; i++)
|
||||
for (register unsigned i=0; i<Size; i++)
|
||||
{
|
||||
v_[i] = t;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<class T, Foam::label Size>
|
||||
template<class T, unsigned Size>
|
||||
inline Foam::FixedList<T, Size>::FixedList(const UList<T>& lst)
|
||||
{
|
||||
checkSize(lst.size());
|
||||
|
||||
for (register label i=0; i<Size; i++)
|
||||
for (register unsigned i=0; i<Size; i++)
|
||||
{
|
||||
v_[i] = lst[i];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<class T, Foam::label Size>
|
||||
template<class T, unsigned Size>
|
||||
inline Foam::FixedList<T, Size>::FixedList(const SLList<T>& lst)
|
||||
{
|
||||
checkSize(lst.size());
|
||||
@ -84,41 +85,41 @@ inline Foam::FixedList<T, Size>::FixedList(const SLList<T>& lst)
|
||||
}
|
||||
|
||||
|
||||
template<class T, Foam::label Size>
|
||||
template<class T, unsigned Size>
|
||||
inline Foam::FixedList<T, Size>::FixedList(const FixedList<T, Size>& lst)
|
||||
{
|
||||
for (register label i=0; i<Size; i++)
|
||||
for (register unsigned i=0; i<Size; i++)
|
||||
{
|
||||
v_[i] = lst[i];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<class T, Foam::label Size>
|
||||
inline Foam::autoPtr<Foam::FixedList<T, Size> >
|
||||
template<class T, unsigned Size>
|
||||
inline Foam::autoPtr< Foam::FixedList<T, Size> >
|
||||
Foam::FixedList<T, Size>::clone() const
|
||||
{
|
||||
return autoPtr<FixedList<T, Size> >(new FixedList<T, Size>(*this));
|
||||
return autoPtr< FixedList<T, Size> >(new FixedList<T, Size>(*this));
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class T, Foam::label Size>
|
||||
template<class T, unsigned Size>
|
||||
inline const Foam::FixedList<T, Size>& Foam::FixedList<T, Size>::null()
|
||||
{
|
||||
return *reinterpret_cast< FixedList<T, Size>* >(0);
|
||||
}
|
||||
|
||||
|
||||
template<class T, Foam::label Size>
|
||||
template<class T, unsigned Size>
|
||||
inline Foam::label Foam::FixedList<T, Size>::fcIndex(const label i) const
|
||||
{
|
||||
return (i == Size-1 ? 0 : i+1);
|
||||
}
|
||||
|
||||
|
||||
template<class T, Foam::label Size>
|
||||
template<class T, unsigned Size>
|
||||
inline Foam::label Foam::FixedList<T, Size>::rcIndex(const label i) const
|
||||
{
|
||||
return (i ? i-1 : Size-1);
|
||||
@ -126,51 +127,51 @@ inline Foam::label Foam::FixedList<T, Size>::rcIndex(const label i) const
|
||||
|
||||
|
||||
// Check start is within valid range (0 ... size-1).
|
||||
template<class T, Foam::label Size>
|
||||
template<class T, unsigned Size>
|
||||
inline void Foam::FixedList<T, Size>::checkStart(const label start) const
|
||||
{
|
||||
if (start<0 || (start && start>=Size))
|
||||
if (start < 0 || (start && unsigned(start) >= Size))
|
||||
{
|
||||
FatalErrorIn("FixedList<T, Size>::checkStart(const label)")
|
||||
<< "start " << start << " out of range 0 ... " << max(Size-1, 0)
|
||||
<< "start " << start << " out of range 0 ... " << (Size-1)
|
||||
<< abort(FatalError);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Check size is within valid range (0 ... size).
|
||||
template<class T, Foam::label Size>
|
||||
template<class T, unsigned Size>
|
||||
inline void Foam::FixedList<T, Size>::checkSize(const label size) const
|
||||
{
|
||||
if (size<0 || size>Size)
|
||||
if (size < 0 || unsigned(size) > Size)
|
||||
{
|
||||
FatalErrorIn("FixedList<T, Size>::checkSize(const label)")
|
||||
<< "size " << size << " out of range 0 ... " << Size
|
||||
<< "size " << size << " out of range 0 ... " << (Size)
|
||||
<< abort(FatalError);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Check index i is within valid range (0 ... size-1).
|
||||
template<class T, Foam::label Size>
|
||||
template<class T, unsigned Size>
|
||||
inline void Foam::FixedList<T, Size>::checkIndex(const label i) const
|
||||
{
|
||||
if (!Size)
|
||||
{
|
||||
FatalErrorIn("FixedList<T, Size>::checkIndex(const label)")
|
||||
<< "attempt to access element from zero sized list"
|
||||
<< "attempt to access element from zero-sized list"
|
||||
<< abort(FatalError);
|
||||
}
|
||||
else if (i<0 || i>=Size)
|
||||
else if (i < 0 || i >= label(Size))
|
||||
{
|
||||
FatalErrorIn("FixedList<T, Size>::checkIndex(const label)")
|
||||
<< "index " << i << " out of range 0 ... " << Size-1
|
||||
<< "index " << i << " out of range 0 ... " << (Size-1)
|
||||
<< abort(FatalError);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<class T, Foam::label Size>
|
||||
template<class T, unsigned Size>
|
||||
inline void Foam::FixedList<T, Size>::resize(const label s)
|
||||
{
|
||||
# ifdef FULLDEBUG
|
||||
@ -178,7 +179,7 @@ inline void Foam::FixedList<T, Size>::resize(const label s)
|
||||
# endif
|
||||
}
|
||||
|
||||
template<class T, Foam::label Size>
|
||||
template<class T, unsigned Size>
|
||||
inline void Foam::FixedList<T, Size>::setSize(const label s)
|
||||
{
|
||||
# ifdef FULLDEBUG
|
||||
@ -186,17 +187,17 @@ inline void Foam::FixedList<T, Size>::setSize(const label s)
|
||||
# endif
|
||||
}
|
||||
|
||||
template<class T, Foam::label Size>
|
||||
template<class T, unsigned Size>
|
||||
inline void Foam::FixedList<T, Size>::transfer(const FixedList<T, Size>& lst)
|
||||
{
|
||||
for (register label i=0; i<Size; i++)
|
||||
for (register unsigned i=0; i<Size; i++)
|
||||
{
|
||||
v_[i] = lst[i];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<class T, Foam::label Size>
|
||||
template<class T, unsigned Size>
|
||||
inline const T*
|
||||
Foam::FixedList<T, Size>::cdata() const
|
||||
{
|
||||
@ -204,7 +205,7 @@ Foam::FixedList<T, Size>::cdata() const
|
||||
}
|
||||
|
||||
|
||||
template<class T, Foam::label Size>
|
||||
template<class T, unsigned Size>
|
||||
inline T*
|
||||
Foam::FixedList<T, Size>::data()
|
||||
{
|
||||
@ -215,7 +216,7 @@ Foam::FixedList<T, Size>::data()
|
||||
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
|
||||
|
||||
// element access
|
||||
template<class T, Foam::label Size>
|
||||
template<class T, unsigned Size>
|
||||
inline T& Foam::FixedList<T, Size>::operator[](const label i)
|
||||
{
|
||||
# ifdef FULLDEBUG
|
||||
@ -226,7 +227,7 @@ inline T& Foam::FixedList<T, Size>::operator[](const label i)
|
||||
|
||||
|
||||
// const element access
|
||||
template<class T, Foam::label Size>
|
||||
template<class T, unsigned Size>
|
||||
inline const T& Foam::FixedList<T, Size>::operator[](const label i) const
|
||||
{
|
||||
# ifdef FULLDEBUG
|
||||
@ -236,27 +237,27 @@ inline const T& Foam::FixedList<T, Size>::operator[](const label i) const
|
||||
}
|
||||
|
||||
|
||||
template<class T, Foam::label Size>
|
||||
template<class T, unsigned Size>
|
||||
inline void Foam::FixedList<T, Size>::operator=(const T lst[Size])
|
||||
{
|
||||
for (register label i=0; i<Size; i++)
|
||||
for (register unsigned i=0; i<Size; i++)
|
||||
{
|
||||
v_[i] = lst[i];
|
||||
}
|
||||
}
|
||||
|
||||
template<class T, Foam::label Size>
|
||||
template<class T, unsigned Size>
|
||||
inline void Foam::FixedList<T, Size>::operator=(const UList<T>& lst)
|
||||
{
|
||||
checkSize(lst.size());
|
||||
|
||||
for (register label i=0; i<Size; i++)
|
||||
for (register unsigned i=0; i<Size; i++)
|
||||
{
|
||||
v_[i] = lst[i];
|
||||
}
|
||||
}
|
||||
|
||||
template<class T, Foam::label Size>
|
||||
template<class T, unsigned Size>
|
||||
inline void Foam::FixedList<T, Size>::operator=(const SLList<T>& lst)
|
||||
{
|
||||
checkSize(lst.size());
|
||||
@ -273,10 +274,10 @@ inline void Foam::FixedList<T, Size>::operator=(const SLList<T>& lst)
|
||||
}
|
||||
}
|
||||
|
||||
template<class T, Foam::label Size>
|
||||
template<class T, unsigned Size>
|
||||
inline void Foam::FixedList<T, Size>::operator=(const T& t)
|
||||
{
|
||||
for (register label i=0; i<Size; i++)
|
||||
for (register unsigned i=0; i<Size; i++)
|
||||
{
|
||||
v_[i] = t;
|
||||
}
|
||||
@ -285,7 +286,7 @@ inline void Foam::FixedList<T, Size>::operator=(const T& t)
|
||||
|
||||
// * * * * * * * * * * * * * * STL Member Functions * * * * * * * * * * * * //
|
||||
|
||||
template<class T, Foam::label Size>
|
||||
template<class T, unsigned Size>
|
||||
inline typename Foam::FixedList<T, Size>::iterator
|
||||
Foam::FixedList<T, Size>::begin()
|
||||
{
|
||||
@ -293,7 +294,7 @@ Foam::FixedList<T, Size>::begin()
|
||||
}
|
||||
|
||||
|
||||
template<class T, Foam::label Size>
|
||||
template<class T, unsigned Size>
|
||||
inline typename Foam::FixedList<T, Size>::const_iterator
|
||||
Foam::FixedList<T, Size>::begin() const
|
||||
{
|
||||
@ -301,7 +302,7 @@ Foam::FixedList<T, Size>::begin() const
|
||||
}
|
||||
|
||||
|
||||
template<class T, Foam::label Size>
|
||||
template<class T, unsigned Size>
|
||||
inline typename Foam::FixedList<T, Size>::const_iterator
|
||||
Foam::FixedList<T, Size>::cbegin() const
|
||||
{
|
||||
@ -309,7 +310,7 @@ Foam::FixedList<T, Size>::cbegin() const
|
||||
}
|
||||
|
||||
|
||||
template<class T, Foam::label Size>
|
||||
template<class T, unsigned Size>
|
||||
inline typename Foam::FixedList<T, Size>::iterator
|
||||
Foam::FixedList<T, Size>::end()
|
||||
{
|
||||
@ -317,7 +318,7 @@ Foam::FixedList<T, Size>::end()
|
||||
}
|
||||
|
||||
|
||||
template<class T, Foam::label Size>
|
||||
template<class T, unsigned Size>
|
||||
inline typename Foam::FixedList<T, Size>::const_iterator
|
||||
Foam::FixedList<T, Size>::end() const
|
||||
{
|
||||
@ -325,7 +326,7 @@ Foam::FixedList<T, Size>::end() const
|
||||
}
|
||||
|
||||
|
||||
template<class T, Foam::label Size>
|
||||
template<class T, unsigned Size>
|
||||
inline typename Foam::FixedList<T, Size>::const_iterator
|
||||
Foam::FixedList<T, Size>::cend() const
|
||||
{
|
||||
@ -333,7 +334,7 @@ Foam::FixedList<T, Size>::cend() const
|
||||
}
|
||||
|
||||
|
||||
template<class T, Foam::label Size>
|
||||
template<class T, unsigned Size>
|
||||
inline typename Foam::FixedList<T, Size>::iterator
|
||||
Foam::FixedList<T, Size>::rbegin()
|
||||
{
|
||||
@ -341,7 +342,7 @@ Foam::FixedList<T, Size>::rbegin()
|
||||
}
|
||||
|
||||
|
||||
template<class T, Foam::label Size>
|
||||
template<class T, unsigned Size>
|
||||
inline typename Foam::FixedList<T, Size>::const_iterator
|
||||
Foam::FixedList<T, Size>::rbegin() const
|
||||
{
|
||||
@ -349,7 +350,7 @@ Foam::FixedList<T, Size>::rbegin() const
|
||||
}
|
||||
|
||||
|
||||
template<class T, Foam::label Size>
|
||||
template<class T, unsigned Size>
|
||||
inline typename Foam::FixedList<T, Size>::const_iterator
|
||||
Foam::FixedList<T, Size>::crbegin() const
|
||||
{
|
||||
@ -357,7 +358,7 @@ Foam::FixedList<T, Size>::crbegin() const
|
||||
}
|
||||
|
||||
|
||||
template<class T, Foam::label Size>
|
||||
template<class T, unsigned Size>
|
||||
inline typename Foam::FixedList<T, Size>::iterator
|
||||
Foam::FixedList<T, Size>::rend()
|
||||
{
|
||||
@ -365,7 +366,7 @@ Foam::FixedList<T, Size>::rend()
|
||||
}
|
||||
|
||||
|
||||
template<class T, Foam::label Size>
|
||||
template<class T, unsigned Size>
|
||||
inline typename Foam::FixedList<T, Size>::const_iterator
|
||||
Foam::FixedList<T, Size>::rend() const
|
||||
{
|
||||
@ -373,7 +374,7 @@ Foam::FixedList<T, Size>::rend() const
|
||||
}
|
||||
|
||||
|
||||
template<class T, Foam::label Size>
|
||||
template<class T, unsigned Size>
|
||||
inline typename Foam::FixedList<T, Size>::const_iterator
|
||||
Foam::FixedList<T, Size>::crend() const
|
||||
{
|
||||
@ -381,21 +382,21 @@ Foam::FixedList<T, Size>::crend() const
|
||||
}
|
||||
|
||||
|
||||
template<class T, Foam::label Size>
|
||||
template<class T, unsigned Size>
|
||||
inline Foam::label Foam::FixedList<T, Size>::size() const
|
||||
{
|
||||
return Size;
|
||||
}
|
||||
|
||||
|
||||
template<class T, Foam::label Size>
|
||||
template<class T, unsigned Size>
|
||||
inline Foam::label Foam::FixedList<T, Size>::max_size() const
|
||||
{
|
||||
return Size;
|
||||
}
|
||||
|
||||
|
||||
template<class T, Foam::label Size>
|
||||
template<class T, unsigned Size>
|
||||
inline bool Foam::FixedList<T, Size>::empty() const
|
||||
{
|
||||
return false;
|
||||
@ -403,42 +404,33 @@ inline bool Foam::FixedList<T, Size>::empty() const
|
||||
|
||||
|
||||
#ifndef __CINT__
|
||||
template<class T, Foam::label Size>
|
||||
template<class T, unsigned Size>
|
||||
template<class HashT>
|
||||
inline Foam::FixedList<T, Size>::Hash<HashT>::Hash()
|
||||
{}
|
||||
|
||||
//- Rotating Hash. From http://burtleburtle.net/bob/hash/doobs.html
|
||||
template<class T, Foam::label Size>
|
||||
template<class HashT>
|
||||
inline Foam::label Foam::FixedList<T, Size>::Hash<HashT>::operator()
|
||||
(
|
||||
const FixedList<T, Size>& lst
|
||||
) const
|
||||
{
|
||||
static const label farbit(8*sizeof(label)-4);
|
||||
|
||||
label val = Size;
|
||||
|
||||
for (register int i=0; i<Size; i++)
|
||||
{
|
||||
val = (val<<4)^(val>>farbit)^HashT()(lst[i]);
|
||||
}
|
||||
|
||||
return val;
|
||||
}
|
||||
|
||||
template<class T, Foam::label Size>
|
||||
template<class HashT>
|
||||
inline Foam::label Foam::FixedList<T, Size>::Hash<HashT>::operator()
|
||||
inline unsigned Foam::FixedList<T, Size>::Hash<HashT>::operator()
|
||||
(
|
||||
const FixedList<T, Size>& lst,
|
||||
const label tableSize
|
||||
unsigned seed
|
||||
) const
|
||||
{
|
||||
return mag(operator()(lst)) % tableSize;
|
||||
}
|
||||
#endif
|
||||
if (contiguous<T>())
|
||||
{
|
||||
// hash directly
|
||||
return Hasher(lst.v_, sizeof(lst.v_), seed);
|
||||
}
|
||||
else
|
||||
{
|
||||
// hash incrementally
|
||||
unsigned val = seed;
|
||||
|
||||
for (register unsigned i=0; i<Size; i++)
|
||||
{
|
||||
val = HashT()(lst[i], val);
|
||||
}
|
||||
|
||||
return val;
|
||||
}
|
||||
}
|
||||
|
||||
#endif // __CINT__
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -32,14 +32,14 @@ License
|
||||
|
||||
// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
|
||||
|
||||
template<class T, Foam::label Size>
|
||||
template<class T, unsigned Size>
|
||||
Foam::FixedList<T, Size>::FixedList(Istream& is)
|
||||
{
|
||||
operator>>(is, *this);
|
||||
}
|
||||
|
||||
|
||||
template<class T, Foam::label Size>
|
||||
template<class T, unsigned Size>
|
||||
Foam::Istream& Foam::operator>>(Foam::Istream& is, FixedList<T, Size>& L)
|
||||
{
|
||||
is.fatalCheck("operator>>(Istream&, FixedList<T, Size>&)");
|
||||
@ -86,7 +86,7 @@ Foam::Istream& Foam::operator>>(Foam::Istream& is, FixedList<T, Size>& L)
|
||||
|
||||
if (listDelimiter == token::BEGIN_LIST)
|
||||
{
|
||||
for (register label i=0; i<Size; i++)
|
||||
for (register unsigned i=0; i<Size; i++)
|
||||
{
|
||||
is >> L[i];
|
||||
|
||||
@ -108,7 +108,7 @@ Foam::Istream& Foam::operator>>(Foam::Istream& is, FixedList<T, Size>& L)
|
||||
"reading the single entry"
|
||||
);
|
||||
|
||||
for (register label i=0; i<Size; i++)
|
||||
for (register unsigned i=0; i<Size; i++)
|
||||
{
|
||||
L[i] = element;
|
||||
}
|
||||
@ -134,7 +134,7 @@ Foam::Istream& Foam::operator>>(Foam::Istream& is, FixedList<T, Size>& L)
|
||||
|
||||
// * * * * * * * * * * * * * * * Ostream Operator * * * * * * * * * * * * * //
|
||||
|
||||
template<class T, Foam::label Size>
|
||||
template<class T, unsigned Size>
|
||||
void Foam::FixedList<T, Size>::writeEntry(Ostream& os) const
|
||||
{
|
||||
if
|
||||
@ -153,7 +153,7 @@ void Foam::FixedList<T, Size>::writeEntry(Ostream& os) const
|
||||
}
|
||||
|
||||
|
||||
template<class T, Foam::label Size>
|
||||
template<class T, unsigned Size>
|
||||
void Foam::FixedList<T, Size>::writeEntry
|
||||
(
|
||||
const word& keyword,
|
||||
@ -166,7 +166,7 @@ void Foam::FixedList<T, Size>::writeEntry
|
||||
}
|
||||
|
||||
|
||||
template<class T, Foam::label Size>
|
||||
template<class T, unsigned Size>
|
||||
Foam::Ostream& Foam::operator<<(Ostream& os, const FixedList<T, Size>& L)
|
||||
{
|
||||
// Write list contents depending on data format
|
||||
|
||||
@ -205,7 +205,7 @@ Foam::List<T>::List(InputIterator first, InputIterator last)
|
||||
|
||||
// Construct as copy of FixedList<T, Size>
|
||||
template<class T>
|
||||
template<Foam::label Size>
|
||||
template<unsigned Size>
|
||||
Foam::List<T>::List(const FixedList<T, Size>& lst)
|
||||
:
|
||||
UList<T>(NULL, Size)
|
||||
|
||||
@ -59,7 +59,7 @@ template<class T> class List;
|
||||
|
||||
template<class T> Istream& operator>>(Istream&, List<T>&);
|
||||
|
||||
template<class T, label Size> class FixedList;
|
||||
template<class T, unsigned Size> class FixedList;
|
||||
template<class T> class PtrList;
|
||||
template<class T> class SLList;
|
||||
template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv>
|
||||
@ -117,7 +117,7 @@ public:
|
||||
List(InputIterator first, InputIterator last);
|
||||
|
||||
//- Construct as copy of FixedList<T, Size>
|
||||
template<label Size>
|
||||
template<unsigned Size>
|
||||
List(const FixedList<T, Size>&);
|
||||
|
||||
//- Construct as copy of PtrList<T>
|
||||
|
||||
@ -76,9 +76,6 @@ Note
|
||||
SeeAlso
|
||||
Foam::DynamicList
|
||||
|
||||
ToDo
|
||||
Checks for bad template parameters (ie, nBits=0, nBits too large)?
|
||||
|
||||
SourceFiles
|
||||
PackedListI.H
|
||||
PackedList.C
|
||||
@ -89,6 +86,7 @@ SourceFiles
|
||||
#define PackedList_H
|
||||
|
||||
#include "labelList.H"
|
||||
#include "StaticAssert.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -120,6 +118,10 @@ class PackedList
|
||||
typedef unsigned int StorageType;
|
||||
typedef List<StorageType> StorageList;
|
||||
|
||||
//- nBits must be positive (non-zero) and fit within the storage
|
||||
// For simplicity, assume 8-bit bytes
|
||||
StaticAssert(nBits && nBits < (sizeof(StorageType) << 3));
|
||||
|
||||
// Private data
|
||||
|
||||
//- Number of nBits entries
|
||||
@ -148,9 +150,11 @@ public:
|
||||
//- Masking for all bits below the offset
|
||||
inline static unsigned int maskLower(unsigned offset);
|
||||
|
||||
// Forward declaration of iteratorBase
|
||||
// Forward declaration of iterators
|
||||
|
||||
class iteratorBase;
|
||||
class iterator;
|
||||
class const_iterator;
|
||||
|
||||
// Constructors
|
||||
|
||||
@ -328,7 +332,7 @@ public:
|
||||
|
||||
// Member Operators
|
||||
|
||||
//- Compare positions
|
||||
//- Compare values (not positions)
|
||||
inline bool operator==(const iteratorBase&) const;
|
||||
inline bool operator!=(const iteratorBase&) const;
|
||||
|
||||
@ -355,7 +359,10 @@ public:
|
||||
public iteratorBase
|
||||
{
|
||||
|
||||
//- Should never violate const-ness!
|
||||
//- Disallow copy constructor from const_iterator - violates const-ness!
|
||||
iterator(const const_iterator&);
|
||||
|
||||
//- Disallow assignment from const_iterator - violates const-ness!
|
||||
void operator=(const const_iterator&);
|
||||
|
||||
public:
|
||||
@ -375,6 +382,10 @@ public:
|
||||
|
||||
// Member Operators
|
||||
|
||||
//- Compare positions (not values)
|
||||
inline bool operator==(const iteratorBase&) const;
|
||||
inline bool operator!=(const iteratorBase&) const;
|
||||
|
||||
//- Assign from iteratorBase, eg iter = packedlist[i]
|
||||
// An out-of-range iterator is assigned end()
|
||||
inline iterator& operator=(const iteratorBase&);
|
||||
@ -420,17 +431,21 @@ public:
|
||||
|
||||
//- Construct from iterator base, eg iter(packedlist[i])
|
||||
// but also "const_iterator iter = packedlist[i];"
|
||||
// An out-of-range iterator is assigned end()
|
||||
// An out-of-range iterator is assigned cend()
|
||||
inline const_iterator(const iteratorBase&);
|
||||
|
||||
//- Construct from base list and position index
|
||||
inline const_iterator(const PackedList*, const label);
|
||||
|
||||
//- Construct from non-const iterator
|
||||
//- Construct from iterator
|
||||
inline const_iterator(const iterator&);
|
||||
|
||||
// Member operators
|
||||
|
||||
//- Compare positions (not values)
|
||||
inline bool operator==(const iteratorBase&) const;
|
||||
inline bool operator!=(const iteratorBase&) const;
|
||||
|
||||
//- Assign from iteratorBase or derived
|
||||
// eg, iter = packedlist[i] or even iter = list.begin()
|
||||
inline const_iterator& operator=(const iteratorBase&);
|
||||
|
||||
@ -176,7 +176,7 @@ inline bool Foam::PackedList<nBits>::iteratorBase::operator==
|
||||
const iteratorBase& iter
|
||||
) const
|
||||
{
|
||||
return this->index_ == iter.index_;
|
||||
return this->get() == iter.get();
|
||||
}
|
||||
|
||||
|
||||
@ -186,7 +186,7 @@ inline bool Foam::PackedList<nBits>::iteratorBase::operator!=
|
||||
const iteratorBase& iter
|
||||
) const
|
||||
{
|
||||
return this->index_ != iter.index_;
|
||||
return this->get() != iter.get();
|
||||
}
|
||||
|
||||
|
||||
@ -311,6 +311,48 @@ inline Foam::PackedList<nBits>::const_iterator::const_iterator
|
||||
{}
|
||||
|
||||
|
||||
template<unsigned nBits>
|
||||
inline bool Foam::PackedList<nBits>::iterator::operator==
|
||||
(
|
||||
const iteratorBase& iter
|
||||
) const
|
||||
{
|
||||
return this->index_ == iter.index_;
|
||||
}
|
||||
|
||||
|
||||
template<unsigned nBits>
|
||||
inline bool Foam::PackedList<nBits>::iterator::operator!=
|
||||
(
|
||||
const iteratorBase& iter
|
||||
) const
|
||||
{
|
||||
return this->index_ != iter.index_;
|
||||
}
|
||||
|
||||
|
||||
|
||||
template<unsigned nBits>
|
||||
inline bool Foam::PackedList<nBits>::const_iterator::operator==
|
||||
(
|
||||
const iteratorBase& iter
|
||||
) const
|
||||
{
|
||||
return this->index_ == iter.index_;
|
||||
}
|
||||
|
||||
|
||||
template<unsigned nBits>
|
||||
inline bool Foam::PackedList<nBits>::const_iterator::operator!=
|
||||
(
|
||||
const iteratorBase& iter
|
||||
) const
|
||||
{
|
||||
return this->index_ != iter.index_;
|
||||
}
|
||||
|
||||
|
||||
|
||||
template<unsigned nBits>
|
||||
inline typename Foam::PackedList<nBits>::iterator&
|
||||
Foam::PackedList<nBits>::iterator::operator=(const iteratorBase& iter)
|
||||
@ -744,7 +786,7 @@ inline bool Foam::PackedList<nBits>::set
|
||||
<< "negative index " << i << " max=" << size_-1
|
||||
<< abort(FatalError);
|
||||
}
|
||||
#endif
|
||||
# endif
|
||||
|
||||
// lazy evaluation - increase size on assigment
|
||||
if (i >= size_)
|
||||
|
||||
@ -53,9 +53,9 @@ inline Foam::SubList<T>::SubList
|
||||
{
|
||||
# ifdef FULLDEBUG
|
||||
|
||||
// Artificially allowing the start of a zero-sized subList to be
|
||||
// Artificially allow the start of a zero-sized subList to be
|
||||
// one past the end of the original list.
|
||||
if (subSize > 0)
|
||||
if (subSize)
|
||||
{
|
||||
list.checkStart(startIndex);
|
||||
list.checkSize(startIndex + subSize);
|
||||
@ -84,7 +84,7 @@ inline const Foam::SubList<T>& Foam::SubList<T>::null()
|
||||
template<class T>
|
||||
inline Foam::SubList<T>::operator const Foam::List<T>&() const
|
||||
{
|
||||
return *reinterpret_cast<const List<T>*>(this);
|
||||
return *reinterpret_cast< const List<T>* >(this);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -43,8 +43,9 @@ SourceFiles
|
||||
#ifndef UList_H
|
||||
#define UList_H
|
||||
|
||||
#include "label.H"
|
||||
#include "bool.H"
|
||||
#include "label.H"
|
||||
#include "uLabel.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
|
||||
@ -37,6 +37,7 @@ SourceFiles
|
||||
#define NamedEnum_H
|
||||
|
||||
#include "HashTable.H"
|
||||
#include "StaticAssert.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -52,6 +53,9 @@ class NamedEnum
|
||||
:
|
||||
public HashTable<int>
|
||||
{
|
||||
//- nEnum must be positive (non-zero)
|
||||
StaticAssert(nEnum > 0);
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Disallow default bitwise copy construct
|
||||
@ -99,7 +103,7 @@ public:
|
||||
return Enum(HashTable<int>::operator[](name));
|
||||
}
|
||||
|
||||
//- Return the name or the given enumeration element
|
||||
//- Return the name of the given enumeration element
|
||||
const char* operator[](const Enum e) const
|
||||
{
|
||||
return names[e];
|
||||
|
||||
@ -26,15 +26,10 @@ License
|
||||
|
||||
#include "Callback.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
template<class CallbackType>
|
||||
Callback<CallbackType>::Callback(CallbackRegistry<CallbackType>& cbr)
|
||||
Foam::Callback<CallbackType>::Callback(CallbackRegistry<CallbackType>& cbr)
|
||||
:
|
||||
cbr_(cbr)
|
||||
{
|
||||
@ -43,7 +38,7 @@ Callback<CallbackType>::Callback(CallbackRegistry<CallbackType>& cbr)
|
||||
|
||||
|
||||
template<class CallbackType>
|
||||
Callback<CallbackType>::Callback(const Callback<CallbackType>& cb)
|
||||
Foam::Callback<CallbackType>::Callback(const Callback<CallbackType>& cb)
|
||||
:
|
||||
cbr_(cb.cbr_)
|
||||
{
|
||||
@ -54,7 +49,7 @@ Callback<CallbackType>::Callback(const Callback<CallbackType>& cb)
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
template<class CallbackType>
|
||||
Callback<CallbackType>::~Callback()
|
||||
Foam::Callback<CallbackType>::~Callback()
|
||||
{
|
||||
checkOut();
|
||||
}
|
||||
@ -63,7 +58,7 @@ Callback<CallbackType>::~Callback()
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class CallbackType>
|
||||
bool Callback<CallbackType>::checkIn()
|
||||
bool Foam::Callback<CallbackType>::checkIn()
|
||||
{
|
||||
if (!Callback<CallbackType>::link::registered())
|
||||
{
|
||||
@ -78,7 +73,7 @@ bool Callback<CallbackType>::checkIn()
|
||||
|
||||
|
||||
template<class CallbackType>
|
||||
bool Callback<CallbackType>::checkOut()
|
||||
bool Foam::Callback<CallbackType>::checkOut()
|
||||
{
|
||||
if (Callback<CallbackType>::link::registered())
|
||||
{
|
||||
@ -100,8 +95,4 @@ bool Callback<CallbackType>::checkOut()
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -30,10 +30,7 @@ License
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
defineTypeNameAndDebug(IOobject, 0);
|
||||
}
|
||||
defineTypeNameAndDebug(Foam::IOobject, 0);
|
||||
|
||||
// * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
|
||||
@ -353,11 +353,11 @@ public:
|
||||
//- Write the standard OpenFOAM file/dictionary banner
|
||||
// Optionally without -*- C++ -*- editor hint (eg, for logs)
|
||||
template<class Stream>
|
||||
static inline void writeBanner(Stream& os, bool noHint=false);
|
||||
static inline Stream& writeBanner(Stream& os, bool noHint=false);
|
||||
|
||||
//- Write the standard file section divider
|
||||
template<class Stream>
|
||||
static inline void writeDivider(Stream& os);
|
||||
static inline Stream& writeDivider(Stream& os);
|
||||
|
||||
//- Write header
|
||||
bool writeHeader(Ostream&) const;
|
||||
|
||||
@ -29,7 +29,7 @@ License
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class Stream>
|
||||
inline void Foam::IOobject::writeBanner(Stream& os, bool noHint)
|
||||
inline Stream& Foam::IOobject::writeBanner(Stream& os, bool noHint)
|
||||
{
|
||||
static bool spacesSet(false);
|
||||
static char spaces[40];
|
||||
@ -68,14 +68,18 @@ inline void Foam::IOobject::writeBanner(Stream& os, bool noHint)
|
||||
"| \\\\ / A nd | Web: www.OpenFOAM.org |\n"
|
||||
"| \\\\/ M anipulation | |\n"
|
||||
"\\*---------------------------------------------------------------------------*/\n";
|
||||
|
||||
return os;
|
||||
}
|
||||
|
||||
|
||||
template<class Stream>
|
||||
inline void Foam::IOobject::writeDivider(Stream& os)
|
||||
inline Stream& Foam::IOobject::writeDivider(Stream& os)
|
||||
{
|
||||
os <<
|
||||
"// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //\n";
|
||||
|
||||
return os;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -91,7 +91,7 @@ bool Foam::IOobject::readHeader(Istream& is)
|
||||
<< "First token could not be read or is not the keyword 'FoamFile'"
|
||||
<< nl << nl << "Check header is of the form:" << nl << endl;
|
||||
|
||||
writeHeader(Info);
|
||||
writeHeader(SeriousError);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -43,8 +43,8 @@ bool Foam::IOobject::writeHeader(Ostream& os) const
|
||||
return false;
|
||||
}
|
||||
|
||||
writeBanner(os);
|
||||
os << "FoamFile\n{\n"
|
||||
writeBanner(os)
|
||||
<< "FoamFile\n{\n"
|
||||
<< " version " << os.version() << ";\n"
|
||||
<< " format " << os.format() << ";\n"
|
||||
<< " class " << type() << ";\n";
|
||||
@ -58,8 +58,7 @@ bool Foam::IOobject::writeHeader(Ostream& os) const
|
||||
<< " object " << name() << ";\n"
|
||||
<< "}" << nl;
|
||||
|
||||
writeDivider(os);
|
||||
os << endl;
|
||||
writeDivider(os) << endl;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -63,7 +63,7 @@ public:
|
||||
// Constructors
|
||||
|
||||
//- Construct given an initial estimate for the number of entries
|
||||
explicit IOobjectList(const label nIoObjects = 100);
|
||||
explicit IOobjectList(const label nIoObjects = 128);
|
||||
|
||||
//- Construct from objectRegistry and instance path
|
||||
IOobjectList
|
||||
|
||||
@ -35,10 +35,8 @@ Description
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
defineTypeNameAndDebug(IOdictionary, 0);
|
||||
}
|
||||
defineTypeNameAndDebug(Foam::IOdictionary, 0);
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
|
||||
@ -30,10 +30,8 @@ License
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
defineTypeNameAndDebug(IFstream, 0);
|
||||
}
|
||||
defineTypeNameAndDebug(Foam::IFstream, 0);
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
|
||||
@ -30,10 +30,7 @@ License
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
defineTypeNameAndDebug(OFstream, 0);
|
||||
}
|
||||
defineTypeNameAndDebug(Foam::OFstream, 0);
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -46,6 +46,7 @@ SourceFiles
|
||||
#include "char.H"
|
||||
#include "bool.H"
|
||||
#include "label.H"
|
||||
#include "uLabel.H"
|
||||
#include "scalar.H"
|
||||
#include "fileName.H"
|
||||
#include "InfoProxy.H"
|
||||
|
||||
@ -28,17 +28,11 @@ Description
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "error.H"
|
||||
|
||||
#include "token.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
bool checkStream(istream& is, const string& fnName)
|
||||
bool Foam::checkStream(istream& is, const string& fnName)
|
||||
{
|
||||
if (!is.good())
|
||||
{
|
||||
@ -50,7 +44,7 @@ bool checkStream(istream& is, const string& fnName)
|
||||
}
|
||||
|
||||
|
||||
bool checkStream(ostream& os, const string& fnName)
|
||||
bool Foam::checkStream(ostream& os, const string& fnName)
|
||||
{
|
||||
if (!os.good())
|
||||
{
|
||||
@ -62,8 +56,4 @@ bool checkStream(ostream& os, const string& fnName)
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -36,8 +36,8 @@ SourceFiles
|
||||
#ifndef readHexLabel_H
|
||||
#define readHexLabel_H
|
||||
|
||||
#include "ISstream.H"
|
||||
#include "label.H"
|
||||
#include "ISstream.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
|
||||
@ -29,19 +29,13 @@ Description
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "error.H"
|
||||
|
||||
#include "token.H"
|
||||
#include "int.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
// Print state of ostream.
|
||||
|
||||
void state(ostream& to, const string& s)
|
||||
void Foam::state(ostream& to, const string& s)
|
||||
{
|
||||
state_value osState = state_value(to.rdstate());
|
||||
|
||||
@ -82,7 +76,7 @@ void state(ostream& to, const string& s)
|
||||
|
||||
|
||||
// Print state of istream.
|
||||
void state(istream& from, const string& s)
|
||||
void Foam::state(istream& from, const string& s)
|
||||
{
|
||||
state_value isState = state_value(from.rdstate());
|
||||
|
||||
@ -126,8 +120,4 @@ void state(istream& from, const string& s)
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -39,6 +39,7 @@ SourceFiles
|
||||
#define token_H
|
||||
|
||||
#include "label.H"
|
||||
#include "uLabel.H"
|
||||
#include "scalar.H"
|
||||
#include "word.H"
|
||||
#include "InfoProxy.H"
|
||||
|
||||
@ -36,9 +36,9 @@ SourceFiles
|
||||
#ifndef dlLibraryTable_H
|
||||
#define dlLibraryTable_H
|
||||
|
||||
#include "HashTable.H"
|
||||
#include "label.H"
|
||||
#include "pTraits.H"
|
||||
#include "Hash.H"
|
||||
#include "HashTable.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -46,31 +46,9 @@ namespace Foam
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class dlLibraryTable Declaration
|
||||
Class dlLibraryTable Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
//- A means of hashing pointer addresses
|
||||
template<>
|
||||
class Hash<void*>
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
Hash()
|
||||
{}
|
||||
|
||||
long operator()(const void* const& p) const
|
||||
{
|
||||
return long(p);
|
||||
}
|
||||
|
||||
label operator()(const void* const& p, const label tableSize) const
|
||||
{
|
||||
return abs(operator()(p)) % tableSize;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
class dlLibraryTable
|
||||
:
|
||||
public HashTable<fileName, void*, Hash<void*> >
|
||||
|
||||
87
src/OpenFOAM/db/error/StaticAssert.H
Normal file
87
src/OpenFOAM/db/error/StaticAssert.H
Normal file
@ -0,0 +1,87 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by the
|
||||
Free Software Foundation; either version 2 of the License, or (at your
|
||||
option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM; if not, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Class
|
||||
Foam::StaticAssertFailed
|
||||
|
||||
Description
|
||||
Macros and classes to provide static (compile-time) assertions.
|
||||
|
||||
Ideas from various sources
|
||||
(http://www.ddj.com/cpp/184401547, http://www.boost.org)
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef StaticAssert_H
|
||||
#define StaticAssert_H
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
//- Forward declaration of StaticAssertionFailed.
|
||||
// Leave as an incomplete class so that sizeof(..) fails
|
||||
template<bool Truth> class StaticAssertionFailed;
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class StaticAssertionFailed Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
//- Specialization for successful assertions
|
||||
template<>
|
||||
class StaticAssertionFailed<true>
|
||||
{};
|
||||
|
||||
|
||||
//- Helper class for handling static assertions
|
||||
template<unsigned Test>
|
||||
class StaticAssertionTest {};
|
||||
|
||||
}
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
// internal use:
|
||||
// ~~~~~~~~~~~~~
|
||||
// paste together strings, even if an argument is itself a macro
|
||||
#define StaticAssertMacro(X,Y) StaticAssertMacro1(X,Y)
|
||||
#define StaticAssertMacro1(X,Y) StaticAssertMacro2(X,Y)
|
||||
#define StaticAssertMacro2(X,Y) X##Y
|
||||
|
||||
// external use:
|
||||
// ~~~~~~~~~~~~~
|
||||
/**
|
||||
* @def StaticAssert(Test)
|
||||
* Assert that some test is true at compile-time
|
||||
*/
|
||||
#define StaticAssert(Test) \
|
||||
typedef ::Foam::StaticAssertionTest \
|
||||
< \
|
||||
sizeof( ::Foam::StaticAssertionFailed< ((Test) ? true : false) > ) \
|
||||
> StaticAssertMacro(StaticAssertionTest, __LINE__)
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -47,8 +47,8 @@ SourceFiles
|
||||
#ifndef messageStream_H
|
||||
#define messageStream_H
|
||||
|
||||
#include "string.H"
|
||||
#include "label.H"
|
||||
#include "string.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
|
||||
@ -55,7 +55,8 @@ Foam::objectRegistry::objectRegistry
|
||||
HashTable<regIOobject*>(nIoObjects),
|
||||
time_(t),
|
||||
parent_(t),
|
||||
dbDir_(name())
|
||||
dbDir_(name()),
|
||||
event_(1)
|
||||
{}
|
||||
|
||||
|
||||
@ -69,7 +70,8 @@ Foam::objectRegistry::objectRegistry
|
||||
HashTable<regIOobject*>(nIoObjects),
|
||||
time_(io.time()),
|
||||
parent_(io.db()),
|
||||
dbDir_(parent_.dbDir()/local()/name())
|
||||
dbDir_(parent_.dbDir()/local()/name()),
|
||||
event_(1)
|
||||
{
|
||||
writeOpt() = IOobject::AUTO_WRITE;
|
||||
}
|
||||
@ -135,6 +137,42 @@ const Foam::objectRegistry& Foam::objectRegistry::subRegistry
|
||||
}
|
||||
|
||||
|
||||
Foam::label Foam::objectRegistry::getEvent() const
|
||||
{
|
||||
label curEvent = event_++;
|
||||
|
||||
if (event_ == labelMax)
|
||||
{
|
||||
WarningIn("objectRegistry::getEvent() const")
|
||||
<< "Event counter has overflowed. Resetting counter on all"
|
||||
<< " dependent objects." << endl
|
||||
<< "This might cause extra evaluations." << endl;
|
||||
|
||||
// Reset event counter
|
||||
curEvent = 1;
|
||||
event_ = 2;
|
||||
|
||||
for (const_iterator iter = begin(); iter != end(); ++iter)
|
||||
{
|
||||
const regIOobject& io = *iter();
|
||||
|
||||
if (objectRegistry::debug)
|
||||
{
|
||||
Pout<< "objectRegistry::getEvent() : "
|
||||
<< "resetting count on " << iter.key() << endl;
|
||||
}
|
||||
|
||||
if (io.eventNo() != 0)
|
||||
{
|
||||
const_cast<regIOobject&>(io).eventNo() = curEvent;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return curEvent;
|
||||
}
|
||||
|
||||
|
||||
bool Foam::objectRegistry::checkIn(regIOobject& io) const
|
||||
{
|
||||
if (objectRegistry::debug)
|
||||
|
||||
@ -64,6 +64,9 @@ class objectRegistry
|
||||
//- Local directory path of this objectRegistry relative to time
|
||||
fileName dbDir_;
|
||||
|
||||
//- Current event
|
||||
mutable label event_;
|
||||
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
@ -82,12 +85,12 @@ public:
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct the time objectRegistry given an initial estimate
|
||||
//- Construct the time objectRegistry given an initial estimate
|
||||
// for the number of entries
|
||||
explicit objectRegistry
|
||||
(
|
||||
const Time& db,
|
||||
const label nIoObjects = 100
|
||||
const label nIoObjects = 128
|
||||
);
|
||||
|
||||
//- Construct a sub-registry given an IObject to describe the registry
|
||||
@ -95,7 +98,7 @@ public:
|
||||
explicit objectRegistry
|
||||
(
|
||||
const IOobject& io,
|
||||
const label nIoObjects = 100
|
||||
const label nIoObjects = 128
|
||||
);
|
||||
|
||||
|
||||
@ -151,6 +154,9 @@ public:
|
||||
template<class Type>
|
||||
const Type& lookupObject(const word& name) const;
|
||||
|
||||
//- Return new event number.
|
||||
label getEvent() const;
|
||||
|
||||
|
||||
// Edit
|
||||
|
||||
|
||||
@ -26,15 +26,12 @@ License
|
||||
|
||||
#include "objectRegistry.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
wordList objectRegistry::names() const
|
||||
Foam::wordList
|
||||
Foam::objectRegistry::names() const
|
||||
{
|
||||
wordList objectNames(size());
|
||||
|
||||
@ -54,7 +51,8 @@ wordList objectRegistry::names() const
|
||||
|
||||
|
||||
template<class Type>
|
||||
HashTable<const Type*> objectRegistry::lookupClass() const
|
||||
Foam::HashTable<const Type*>
|
||||
Foam::objectRegistry::lookupClass() const
|
||||
{
|
||||
HashTable<const Type*> objectsOfClass(size());
|
||||
|
||||
@ -75,7 +73,7 @@ HashTable<const Type*> objectRegistry::lookupClass() const
|
||||
|
||||
|
||||
template<class Type>
|
||||
bool objectRegistry::foundObject(const word& name) const
|
||||
bool Foam::objectRegistry::foundObject(const word& name) const
|
||||
{
|
||||
const_iterator iter = find(name);
|
||||
|
||||
@ -107,7 +105,7 @@ bool objectRegistry::foundObject(const word& name) const
|
||||
|
||||
|
||||
template<class Type>
|
||||
const Type& objectRegistry::lookupObject(const word& name) const
|
||||
const Type& Foam::objectRegistry::lookupObject(const word& name) const
|
||||
{
|
||||
const_iterator iter = find(name);
|
||||
|
||||
@ -154,8 +152,4 @@ const Type& objectRegistry::lookupObject(const word& name) const
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -22,9 +22,6 @@ License
|
||||
along with OpenFOAM; if not, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Description
|
||||
Constructors & destructor for regIOobject.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "regIOobject.H"
|
||||
@ -50,6 +47,7 @@ Foam::regIOobject::regIOobject(const IOobject& io)
|
||||
registered_(false),
|
||||
ownedByRegistry_(false),
|
||||
lastModified_(0),
|
||||
eventNo_(db().getEvent()),
|
||||
isPtr_(NULL)
|
||||
{
|
||||
// Register with objectRegistry if requested
|
||||
@ -67,6 +65,7 @@ Foam::regIOobject::regIOobject(const regIOobject& rio)
|
||||
registered_(false),
|
||||
ownedByRegistry_(false),
|
||||
lastModified_(rio.lastModified_),
|
||||
eventNo_(db().getEvent()),
|
||||
isPtr_(NULL)
|
||||
{
|
||||
// Do not register copy with objectRegistry
|
||||
@ -81,6 +80,7 @@ Foam::regIOobject::regIOobject(const regIOobject& rio, bool registerCopy)
|
||||
registered_(false),
|
||||
ownedByRegistry_(false),
|
||||
lastModified_(rio.lastModified_),
|
||||
eventNo_(db().getEvent()),
|
||||
isPtr_(NULL)
|
||||
{
|
||||
if (registerCopy && rio.registered_)
|
||||
@ -107,6 +107,7 @@ Foam::regIOobject::~regIOobject()
|
||||
if (isPtr_)
|
||||
{
|
||||
delete isPtr_;
|
||||
isPtr_ = NULL;
|
||||
}
|
||||
|
||||
// Check out of objectRegistry if not owned by the registry
|
||||
@ -120,41 +121,123 @@ Foam::regIOobject::~regIOobject()
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
void Foam::regIOobject::checkIn()
|
||||
bool Foam::regIOobject::checkIn()
|
||||
{
|
||||
if (!registered_)
|
||||
{
|
||||
// Attempt to register object with objectRegistry
|
||||
if (!db().checkIn(*this))
|
||||
// multiple checkin of same object is disallowed - this would mess up
|
||||
// any mapping
|
||||
registered_ = db().checkIn(*this);
|
||||
|
||||
// checkin on defaultRegion is allowed to fail, since subsetted meshes
|
||||
// are created with the same name as their originating mesh
|
||||
if (!registered_ && debug && name() != polyMesh::defaultRegion)
|
||||
{
|
||||
// Disallow checkin of same object twice since would mess up
|
||||
// any mapping.
|
||||
// Check on defaultRegion is needed to prevent subsetted meshes
|
||||
// (which are created with same name as their originating mesh)
|
||||
// from upsetting this.
|
||||
if (debug && name() != polyMesh::defaultRegion)
|
||||
{
|
||||
WarningIn("regIOobject::checkIn()")
|
||||
<< "failed to register object " << objectPath()
|
||||
WarningIn("regIOobject::checkIn()")
|
||||
<< "failed to register object " << objectPath()
|
||||
<< " the name already exists in the objectRegistry"
|
||||
<< endl;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
registered_ = true;
|
||||
<< endl;
|
||||
}
|
||||
}
|
||||
|
||||
return registered_;
|
||||
}
|
||||
|
||||
|
||||
bool Foam::regIOobject::checkOut()
|
||||
{
|
||||
if (registered_)
|
||||
{
|
||||
registered_ = false;
|
||||
return db().checkOut(*this);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool Foam::regIOobject::uptodate(const word& a) const
|
||||
{
|
||||
if (db().lookupObject<regIOobject>(a).eventNo() >= eventNo_)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::regIOobject::checkOut()
|
||||
bool Foam::regIOobject::uptodate(const word& a, const word& b) const
|
||||
{
|
||||
if (registered_)
|
||||
if
|
||||
(
|
||||
db().lookupObject<regIOobject>(a).eventNo() >= eventNo_
|
||||
|| db().lookupObject<regIOobject>(b).eventNo() >= eventNo_
|
||||
)
|
||||
{
|
||||
db().checkOut(*this);
|
||||
registered_ = false;
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool Foam::regIOobject::uptodate
|
||||
(
|
||||
const word& a,
|
||||
const word& b,
|
||||
const word& c
|
||||
) const
|
||||
{
|
||||
if
|
||||
(
|
||||
db().lookupObject<regIOobject>(a).eventNo() >= eventNo_
|
||||
|| db().lookupObject<regIOobject>(b).eventNo() >= eventNo_
|
||||
|| db().lookupObject<regIOobject>(c).eventNo() >= eventNo_
|
||||
)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool Foam::regIOobject::uptodate
|
||||
(
|
||||
const word& a,
|
||||
const word& b,
|
||||
const word& c,
|
||||
const word& d
|
||||
) const
|
||||
{
|
||||
if
|
||||
(
|
||||
db().lookupObject<regIOobject>(a).eventNo() >= eventNo_
|
||||
|| db().lookupObject<regIOobject>(b).eventNo() >= eventNo_
|
||||
|| db().lookupObject<regIOobject>(c).eventNo() >= eventNo_
|
||||
|| db().lookupObject<regIOobject>(d).eventNo() >= eventNo_
|
||||
)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//- Flag me as uptodate
|
||||
void Foam::regIOobject::setUptodate()
|
||||
{
|
||||
eventNo_ = db().getEvent();
|
||||
}
|
||||
|
||||
|
||||
@ -166,8 +249,11 @@ void Foam::regIOobject::rename(const word& newName)
|
||||
|
||||
IOobject::rename(newName);
|
||||
|
||||
// Re-register object with objectRegistry
|
||||
checkIn();
|
||||
if (registerObject())
|
||||
{
|
||||
// Re-register object with objectRegistry
|
||||
checkIn();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -185,8 +271,11 @@ void Foam::regIOobject::operator=(const IOobject& io)
|
||||
|
||||
IOobject::operator=(io);
|
||||
|
||||
// Re-register object with objectRegistry
|
||||
checkIn();
|
||||
if (registerObject())
|
||||
{
|
||||
// Re-register object with objectRegistry
|
||||
checkIn();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -45,11 +45,12 @@ SourceFiles
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class regIOobject Declaration
|
||||
Class regIOobject Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class regIOobject
|
||||
@ -70,6 +71,9 @@ private:
|
||||
//- Time of last modification
|
||||
mutable time_t lastModified_;
|
||||
|
||||
//- eventNo of last update
|
||||
label eventNo_;
|
||||
|
||||
//- Istream for reading
|
||||
Istream* isPtr_;
|
||||
|
||||
@ -115,13 +119,13 @@ public:
|
||||
|
||||
// Registration
|
||||
|
||||
//- Register object with registry
|
||||
void checkIn();
|
||||
//- Add object to registry
|
||||
bool checkIn();
|
||||
|
||||
//- Check-out object from registry
|
||||
void checkOut();
|
||||
//- Remove object from registry
|
||||
bool checkOut();
|
||||
|
||||
//- Is this object owned by the registry
|
||||
//- Is this object owned by the registry?
|
||||
inline bool ownedByRegistry() const;
|
||||
|
||||
//- Transfer ownership of this object to its registry
|
||||
@ -130,17 +134,35 @@ public:
|
||||
//- Transfer ownership of the given object pointer to its registry
|
||||
// and return reference to object.
|
||||
template<class Type>
|
||||
inline static Type& store(Type* tPtr);
|
||||
inline static Type& store(Type*);
|
||||
|
||||
//- Transfer ownership of the given object pointer to its registry
|
||||
// and return reference to object.
|
||||
template<class Type>
|
||||
inline static Type& store(autoPtr<Type>& atPtr);
|
||||
inline static Type& store(autoPtr<Type>&);
|
||||
|
||||
//- Release ownership of this object from its registry
|
||||
inline void release();
|
||||
|
||||
|
||||
// Dependency checking
|
||||
|
||||
//- Event number at last update.
|
||||
inline label eventNo() const;
|
||||
|
||||
//- Event number at last update.
|
||||
inline label& eventNo();
|
||||
|
||||
//- Am I uptodate with respect to other regIOobjects
|
||||
bool uptodate(const word&) const;
|
||||
bool uptodate(const word&, const word&) const;
|
||||
bool uptodate(const word&, const word&, const word&) const;
|
||||
bool uptodate(const word&, const word&, const word&, const word&)
|
||||
const;
|
||||
|
||||
//- Flag me as uptodate
|
||||
void setUptodate();
|
||||
|
||||
// Edit
|
||||
|
||||
//- Rename
|
||||
@ -179,9 +201,9 @@ public:
|
||||
//- Write using given format, version and compression
|
||||
virtual bool writeObject
|
||||
(
|
||||
IOstream::streamFormat fmt,
|
||||
IOstream::versionNumber ver,
|
||||
IOstream::compressionType cmp
|
||||
IOstream::streamFormat,
|
||||
IOstream::versionNumber,
|
||||
IOstream::compressionType
|
||||
) const;
|
||||
|
||||
//- Write using setting from DB
|
||||
|
||||
@ -43,7 +43,7 @@ inline Type& Foam::regIOobject::store(Type* tPtr)
|
||||
{
|
||||
if (!tPtr)
|
||||
{
|
||||
FatalErrorIn("Type& store(Type*)")
|
||||
FatalErrorIn("Type& regIOobject::store(Type*)")
|
||||
<< "object deallocated"
|
||||
<< abort(FatalError);
|
||||
}
|
||||
@ -63,13 +63,13 @@ inline Type& Foam::regIOobject::store(autoPtr<Type>& atPtr)
|
||||
{
|
||||
FatalErrorIn
|
||||
(
|
||||
"Type& store(autoPtr<Type>&)"
|
||||
"Type& regIOobject::store(autoPtr<Type>&)"
|
||||
) << "object deallocated"
|
||||
<< abort(FatalError);
|
||||
}
|
||||
|
||||
tPtr->regIOobject::ownedByRegistry_ = true;
|
||||
|
||||
|
||||
return *tPtr;
|
||||
}
|
||||
|
||||
@ -80,4 +80,15 @@ void Foam::regIOobject::release()
|
||||
}
|
||||
|
||||
|
||||
Foam::label Foam::regIOobject::eventNo() const
|
||||
{
|
||||
return eventNo_;
|
||||
}
|
||||
|
||||
Foam::label& Foam::regIOobject::eventNo()
|
||||
{
|
||||
return eventNo_;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -34,12 +34,7 @@ Description
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
bool regIOobject::writeObject
|
||||
bool Foam::regIOobject::writeObject
|
||||
(
|
||||
IOstream::streamFormat fmt,
|
||||
IOstream::versionNumber ver,
|
||||
@ -91,7 +86,7 @@ bool regIOobject::writeObject
|
||||
// Try opening an OFstream for object
|
||||
OFstream os(objectPath(), fmt, ver, cmp);
|
||||
|
||||
// If this has failed, return (leave error handling to Ostream class)
|
||||
// If any of these fail, return (leave error handling to Ostream class)
|
||||
if (!os.good())
|
||||
{
|
||||
return false;
|
||||
@ -108,7 +103,8 @@ bool regIOobject::writeObject
|
||||
return false;
|
||||
}
|
||||
|
||||
os << "\n\n// ************************************************************************* //"
|
||||
os << "\n\n"
|
||||
"// ************************************************************************* //"
|
||||
<< endl;
|
||||
|
||||
osGood = os.good();
|
||||
@ -130,7 +126,7 @@ bool regIOobject::writeObject
|
||||
}
|
||||
|
||||
|
||||
bool regIOobject::write() const
|
||||
bool Foam::regIOobject::write() const
|
||||
{
|
||||
return writeObject
|
||||
(
|
||||
@ -140,9 +136,4 @@ bool regIOobject::write() const
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -177,9 +177,9 @@ Field<Type>::Field(const typename Field<Type>::subField& sf)
|
||||
|
||||
|
||||
template<class Type>
|
||||
Field<Type>::Field(const UList<Type>& tl)
|
||||
Field<Type>::Field(const UList<Type>& list)
|
||||
:
|
||||
List<Type>(tl)
|
||||
List<Type>(list)
|
||||
{}
|
||||
|
||||
|
||||
@ -232,8 +232,7 @@ Field<Type>::Field
|
||||
FatalIOErrorIn
|
||||
(
|
||||
"Field<Type>::Field"
|
||||
"(const word& keyword, "
|
||||
"const dictionary& dict, const label s)",
|
||||
"(const word& keyword, const dictionary&, const label)",
|
||||
dict
|
||||
) << "size " << this->size()
|
||||
<< " is not equal to the given value of " << s
|
||||
@ -245,8 +244,7 @@ Field<Type>::Field
|
||||
FatalIOErrorIn
|
||||
(
|
||||
"Field<Type>::Field"
|
||||
"(const word& keyword, "
|
||||
"const dictionary& dict, const label s)",
|
||||
"(const word& keyword, const dictionary&, const label)",
|
||||
dict
|
||||
) << "expected keyword 'uniform' or 'nonuniform', found "
|
||||
<< firstToken.wordToken()
|
||||
@ -260,8 +258,7 @@ Field<Type>::Field
|
||||
IOWarningIn
|
||||
(
|
||||
"Field<Type>::Field"
|
||||
"(const word& keyword, const dictionary& dict, "
|
||||
"const label s)",
|
||||
"(const word& keyword, const dictionary&, const label)",
|
||||
dict
|
||||
) << "expected keyword 'uniform' or 'nonuniform', "
|
||||
"assuming deprecated Field format from "
|
||||
@ -277,10 +274,9 @@ Field<Type>::Field
|
||||
FatalIOErrorIn
|
||||
(
|
||||
"Field<Type>::Field"
|
||||
"(const word& keyword, "
|
||||
"const dictionary& dict, const label s)",
|
||||
"(const word& keyword, const dictionary&, const label)",
|
||||
dict
|
||||
) << "extected keyword 'uniform' or 'nonuniform', found "
|
||||
) << "expected keyword 'uniform' or 'nonuniform', found "
|
||||
<< firstToken.info()
|
||||
<< exit(FatalIOError);
|
||||
}
|
||||
@ -371,7 +367,7 @@ void Field<Type>::map
|
||||
|
||||
forAll(f, i)
|
||||
{
|
||||
const labelList& localAddrs = mapAddressing[i];
|
||||
const labelList& localAddrs = mapAddressing[i];
|
||||
const scalarList& localWeights = mapWeights[i];
|
||||
|
||||
f[i] = pTraits<Type>::zero;
|
||||
@ -622,37 +618,37 @@ void Field<Type>::writeEntry(const word& keyword, Ostream& os) const
|
||||
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
void Field<Type>::operator=(const Field<Type>& f)
|
||||
void Field<Type>::operator=(const Field<Type>& rhs)
|
||||
{
|
||||
if (this == &f)
|
||||
if (this == &rhs)
|
||||
{
|
||||
FatalErrorIn("Field<Type>::operator=(const Field<Type>&)")
|
||||
<< "attempted assignment to self"
|
||||
<< abort(FatalError);
|
||||
}
|
||||
|
||||
List<Type>::operator=(f);
|
||||
List<Type>::operator=(rhs);
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
void Field<Type>::operator=(const SubField<Type>& sf)
|
||||
void Field<Type>::operator=(const SubField<Type>& rhs)
|
||||
{
|
||||
List<Type>::operator=(sf);
|
||||
List<Type>::operator=(rhs);
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
void Field<Type>::operator=(const UList<Type>& ul)
|
||||
void Field<Type>::operator=(const UList<Type>& rhs)
|
||||
{
|
||||
List<Type>::operator=(ul);
|
||||
List<Type>::operator=(rhs);
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
void Field<Type>::operator=(const tmp<Field>& tf)
|
||||
void Field<Type>::operator=(const tmp<Field>& rhs)
|
||||
{
|
||||
if (this == &(tf()))
|
||||
if (this == &(rhs()))
|
||||
{
|
||||
FatalErrorIn("Field<Type>::operator=(const tmp<Field>&)")
|
||||
<< "attempted assignment to self"
|
||||
@ -660,7 +656,7 @@ void Field<Type>::operator=(const tmp<Field>& tf)
|
||||
}
|
||||
|
||||
// This is dodgy stuff, don't try it at home.
|
||||
Field* fieldPtr = tf.ptr();
|
||||
Field* fieldPtr = rhs.ptr();
|
||||
List<Type>::transfer(*fieldPtr);
|
||||
delete fieldPtr;
|
||||
}
|
||||
|
||||
@ -120,7 +120,7 @@ public:
|
||||
//- Construct given size and initial value
|
||||
Field(const label, const Type&);
|
||||
|
||||
//- Construct as copy of a UList<Type>
|
||||
//- Construct as copy of a UList\<Type\>
|
||||
explicit Field(const UList<Type>&);
|
||||
|
||||
//- Construct by transferring the List contents
|
||||
|
||||
@ -40,7 +40,6 @@ SourceFiles
|
||||
#ifndef SubField_H
|
||||
#define SubField_H
|
||||
|
||||
#include "Field.H"
|
||||
#include "SubList.H"
|
||||
#include "Field.H"
|
||||
|
||||
@ -49,6 +48,10 @@ SourceFiles
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
//- Pre-declare SubField and related Field type
|
||||
template<class Type> class Field;
|
||||
template<class Type> class SubField;
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class SubField Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
@ -68,20 +71,20 @@ public:
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from UnallocatedField and SubField size
|
||||
inline SubField
|
||||
(
|
||||
const SubList<Type>& slist
|
||||
);
|
||||
//- Construct from a SubList
|
||||
inline SubField(const SubList<Type>&);
|
||||
|
||||
//- Construct from UnallocatedField and SubField size
|
||||
//- Construct from a UList\<Type\>, using the entire size
|
||||
explicit inline SubField(const UList<Type>&);
|
||||
|
||||
//- Construct from a UList\<Type\> with a given size
|
||||
inline SubField
|
||||
(
|
||||
const UList<Type>& list,
|
||||
const label subSize
|
||||
);
|
||||
|
||||
//- Construct from UnallocatedField, start and end indices
|
||||
//- Construct from a UList\<Type\> with a given size and start index
|
||||
inline SubField
|
||||
(
|
||||
const UList<Type>& list,
|
||||
@ -90,10 +93,7 @@ public:
|
||||
);
|
||||
|
||||
//- Construct as copy
|
||||
inline SubField
|
||||
(
|
||||
const SubField<Type>& sfield
|
||||
);
|
||||
inline SubField(const SubField<Type>&);
|
||||
|
||||
|
||||
// Member functions
|
||||
@ -110,10 +110,10 @@ public:
|
||||
|
||||
// Member operators
|
||||
|
||||
//- Assignment from UList operator. Takes linear time.
|
||||
//- Assignment via UList operator. Takes linear time.
|
||||
inline void operator=(const SubField<Type>&);
|
||||
|
||||
//- Allow cast to a const Field<Type>&
|
||||
//- Allow cast to a const Field\<Type\>&
|
||||
inline operator const Field<Type>&() const;
|
||||
};
|
||||
|
||||
|
||||
@ -29,12 +29,23 @@ License
|
||||
template<class Type>
|
||||
inline Foam::SubField<Type>::SubField
|
||||
(
|
||||
const SubList<Type>& slist
|
||||
const SubList<Type>& list
|
||||
)
|
||||
:
|
||||
SubList<Type>(slist)
|
||||
SubList<Type>(list)
|
||||
{}
|
||||
|
||||
|
||||
template<class Type>
|
||||
inline Foam::SubField<Type>::SubField
|
||||
(
|
||||
const UList<Type>& list
|
||||
)
|
||||
:
|
||||
SubList<Type>(list, list.size())
|
||||
{}
|
||||
|
||||
|
||||
template<class Type>
|
||||
inline Foam::SubField<Type>::SubField
|
||||
(
|
||||
@ -108,7 +119,7 @@ inline void Foam::SubField<Type>::operator=(const SubField<Type>& rhs)
|
||||
template<class Type>
|
||||
inline Foam::SubField<Type>::operator const Foam::Field<Type>&() const
|
||||
{
|
||||
return *(reinterpret_cast<const Field<Type>*>(this));
|
||||
return *reinterpret_cast< const Field<Type>* >(this);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -36,8 +36,8 @@ SourceFiles
|
||||
#ifndef labelField_H
|
||||
#define labelField_H
|
||||
|
||||
#include "Field.H"
|
||||
#include "label.H"
|
||||
#include "Field.H"
|
||||
|
||||
#define TEMPLATE
|
||||
#include "FieldFunctionsM.H"
|
||||
|
||||
@ -154,7 +154,7 @@ tmp<GeometricField<scalar, PatchField, GeoMesh> > pow
|
||||
pow
|
||||
(
|
||||
gsf1.dimensions(),
|
||||
dimensionedScalar("1", 1.0, gsf2.dimensions())
|
||||
dimensionedScalar("1", gsf2.dimensions(), 1.0)
|
||||
)
|
||||
)
|
||||
);
|
||||
@ -183,7 +183,7 @@ tmp<GeometricField<scalar, PatchField, GeoMesh> > pow
|
||||
pow
|
||||
(
|
||||
gsf1.dimensions(),
|
||||
dimensionedScalar("1", 1.0, gsf2.dimensions())
|
||||
dimensionedScalar("1", gsf2.dimensions(), 1.0)
|
||||
)
|
||||
)
|
||||
);
|
||||
@ -214,7 +214,7 @@ tmp<GeometricField<scalar, PatchField, GeoMesh> > pow
|
||||
pow
|
||||
(
|
||||
gsf1.dimensions(),
|
||||
dimensionedScalar("1", 1.0, gsf2.dimensions())
|
||||
dimensionedScalar("1", gsf2.dimensions(), 1.0)
|
||||
)
|
||||
)
|
||||
);
|
||||
@ -247,7 +247,7 @@ tmp<GeometricField<scalar, PatchField, GeoMesh> > pow
|
||||
pow
|
||||
(
|
||||
gsf1.dimensions(),
|
||||
dimensionedScalar("1", 1.0, gsf2.dimensions())
|
||||
dimensionedScalar("1", gsf2.dimensions(), 1.0)
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
@ -97,6 +97,68 @@ slicedBoundaryField
|
||||
}
|
||||
|
||||
|
||||
template
|
||||
<
|
||||
class Type,
|
||||
template<class> class PatchField,
|
||||
template<class> class SlicedPatchField,
|
||||
class GeoMesh
|
||||
>
|
||||
Foam::tmp<Foam::FieldField<PatchField, Type> >
|
||||
Foam::SlicedGeometricField<Type, PatchField, SlicedPatchField, GeoMesh>::
|
||||
slicedBoundaryField
|
||||
(
|
||||
const Mesh& mesh,
|
||||
const FieldField<PatchField, Type>& bField,
|
||||
const bool preserveCouples
|
||||
)
|
||||
{
|
||||
tmp<FieldField<PatchField, Type> > tbf
|
||||
(
|
||||
new FieldField<PatchField, Type>(mesh.boundary().size())
|
||||
);
|
||||
|
||||
FieldField<PatchField, Type>& bf = tbf();
|
||||
|
||||
forAll (mesh.boundary(), patchi)
|
||||
{
|
||||
if (preserveCouples && mesh.boundary()[patchi].coupled())
|
||||
{
|
||||
// For coupled patched construct the correct patch field type
|
||||
bf.set
|
||||
(
|
||||
patchi,
|
||||
PatchField<Type>::New
|
||||
(
|
||||
mesh.boundary()[patchi].type(),
|
||||
mesh.boundary()[patchi],
|
||||
*this
|
||||
)
|
||||
);
|
||||
|
||||
// Assign field
|
||||
bf[patchi] == bField[patchi];
|
||||
}
|
||||
else
|
||||
{
|
||||
// Create unallocated copy of patch field
|
||||
bf.set
|
||||
(
|
||||
patchi,
|
||||
new SlicedPatchField<Type>
|
||||
(
|
||||
mesh.boundary()[patchi],
|
||||
DimensionedField<Type, GeoMesh>::null()
|
||||
)
|
||||
);
|
||||
bf[patchi].UList<Type>::operator=(bField[patchi]);
|
||||
}
|
||||
}
|
||||
|
||||
return tbf;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
template
|
||||
@ -204,6 +266,64 @@ SlicedGeometricField
|
||||
}
|
||||
|
||||
|
||||
template
|
||||
<
|
||||
class Type,
|
||||
template<class> class PatchField,
|
||||
template<class> class SlicedPatchField,
|
||||
class GeoMesh
|
||||
>
|
||||
Foam::SlicedGeometricField<Type, PatchField, SlicedPatchField, GeoMesh>::
|
||||
SlicedGeometricField
|
||||
(
|
||||
const IOobject& io,
|
||||
const GeometricField<Type, PatchField, GeoMesh>& gf,
|
||||
const bool preserveCouples
|
||||
)
|
||||
:
|
||||
GeometricField<Type, PatchField, GeoMesh>
|
||||
(
|
||||
io,
|
||||
gf.mesh(),
|
||||
gf.dimensions(),
|
||||
Field<Type>(),
|
||||
slicedBoundaryField(gf.mesh(), gf.boundaryField(), preserveCouples)
|
||||
)
|
||||
{
|
||||
// Set the internalField to the supplied internal field
|
||||
UList<Type>::operator=(gf.internalField());
|
||||
|
||||
correctBoundaryConditions();
|
||||
}
|
||||
|
||||
|
||||
template
|
||||
<
|
||||
class Type,
|
||||
template<class> class PatchField,
|
||||
template<class> class SlicedPatchField,
|
||||
class GeoMesh
|
||||
>
|
||||
Foam::SlicedGeometricField<Type, PatchField, SlicedPatchField, GeoMesh>::
|
||||
SlicedGeometricField
|
||||
(
|
||||
const SlicedGeometricField<Type, PatchField, SlicedPatchField, GeoMesh>& gf
|
||||
)
|
||||
:
|
||||
GeometricField<Type, PatchField, GeoMesh>
|
||||
(
|
||||
gf,
|
||||
gf.mesh(),
|
||||
gf.dimensions(),
|
||||
Field<Type>(),
|
||||
slicedBoundaryField(gf.mesh(), gf.boundaryField(), true)
|
||||
)
|
||||
{
|
||||
// Set the internalField to the supplied internal field
|
||||
UList<Type>::operator=(gf.internalField());
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
template
|
||||
|
||||
@ -87,8 +87,17 @@ private:
|
||||
const bool preserveCouples
|
||||
);
|
||||
|
||||
//- Disallow default bitwise copy construct
|
||||
SlicedGeometricField(const SlicedGeometricField&);
|
||||
//- Slice the given field and a create a PtrList of SlicedPatchField
|
||||
// from which the boundary field is built
|
||||
tmp<FieldField<PatchField, Type> > slicedBoundaryField
|
||||
(
|
||||
const Mesh& mesh,
|
||||
const FieldField<PatchField, Type>& bField,
|
||||
const bool preserveCouples
|
||||
);
|
||||
|
||||
////- Disallow default bitwise copy construct
|
||||
//SlicedGeometricField(const SlicedGeometricField&);
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const SlicedGeometricField&);
|
||||
@ -128,6 +137,27 @@ public:
|
||||
const bool preserveCouples=true
|
||||
);
|
||||
|
||||
//- Construct from GeometricField. Reuses full internal and
|
||||
// patch fields except on couples (preserveCouples=true).
|
||||
SlicedGeometricField
|
||||
(
|
||||
const IOobject&,
|
||||
const GeometricField<Type, PatchField, GeoMesh>&,
|
||||
const bool preserveCouples=true
|
||||
);
|
||||
|
||||
//- Construct as copy
|
||||
SlicedGeometricField
|
||||
(
|
||||
const SlicedGeometricField
|
||||
<
|
||||
Type,
|
||||
PatchField,
|
||||
SlicedPatchField,
|
||||
GeoMesh
|
||||
>&
|
||||
);
|
||||
|
||||
|
||||
// Destructor
|
||||
|
||||
|
||||
@ -41,10 +41,11 @@ SourceFiles
|
||||
#ifndef pointConstraint_H
|
||||
#define pointConstraint_H
|
||||
|
||||
#include "Tuple2.H"
|
||||
#include "label.H"
|
||||
#include "uLabel.H"
|
||||
#include "vector.H"
|
||||
#include "tensor.H"
|
||||
#include "Tuple2.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
|
||||
@ -285,9 +285,9 @@ Foam::argList::argList
|
||||
// Print the banner once only for parallel runs
|
||||
if (Pstream::master() && bannerEnabled)
|
||||
{
|
||||
IOobject::writeBanner(Info, true);
|
||||
Info<< "Build : " << Foam::FOAMbuild << nl
|
||||
<< "Exec : " << argListString.c_str() << nl
|
||||
IOobject::writeBanner(Info, true)
|
||||
<< "Build : " << Foam::FOAMbuild << nl
|
||||
<< "Exec : " << argListString.c_str() << nl
|
||||
<< "Date : " << dateString.c_str() << nl
|
||||
<< "Time : " << timeString.c_str() << nl
|
||||
<< "Host : " << hostName() << nl
|
||||
|
||||
@ -39,9 +39,10 @@ SourceFiles
|
||||
#ifndef Matrix_H
|
||||
#define Matrix_H
|
||||
|
||||
#include "List.H"
|
||||
#include "label.H"
|
||||
#include "bool.H"
|
||||
#include "label.H"
|
||||
#include "uLabel.H"
|
||||
#include "List.H"
|
||||
#include "autoPtr.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -60,7 +60,7 @@ void Foam::lduMatrix::Amul
|
||||
interfaceBouCoeffs,
|
||||
interfaces,
|
||||
psi,
|
||||
Apsi,
|
||||
Apsi,
|
||||
cmpt
|
||||
);
|
||||
|
||||
@ -79,7 +79,7 @@ void Foam::lduMatrix::Amul
|
||||
|
||||
register const label nFaces = upper().size();
|
||||
#ifdef ICC_IA64_PREFETCH
|
||||
#pragma swp
|
||||
#pragma swp
|
||||
#endif
|
||||
for (register label face=0; face<nFaces; face++)
|
||||
{
|
||||
@ -227,7 +227,7 @@ void Foam::lduMatrix::sumA
|
||||
}
|
||||
|
||||
#ifdef ICC_IA64_PREFETCH
|
||||
#pragma swp
|
||||
#pragma swp
|
||||
#endif
|
||||
|
||||
for (register label face=0; face<nFaces; face++)
|
||||
@ -316,7 +316,7 @@ void Foam::lduMatrix::residual
|
||||
mBouCoeffs,
|
||||
interfaces,
|
||||
psi,
|
||||
rA,
|
||||
rA,
|
||||
cmpt
|
||||
);
|
||||
|
||||
@ -336,7 +336,7 @@ void Foam::lduMatrix::residual
|
||||
|
||||
register const label nFaces = upper().size();
|
||||
#ifdef ICC_IA64_PREFETCH
|
||||
#pragma swp
|
||||
#pragma swp
|
||||
#endif
|
||||
for (register label face=0; face<nFaces; face++)
|
||||
{
|
||||
|
||||
@ -32,14 +32,9 @@ License
|
||||
#include "OStringStream.H"
|
||||
#include "Pstream.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
defineTypeNameAndDebug(commSchedule, 0);
|
||||
|
||||
}
|
||||
defineTypeNameAndDebug(Foam::commSchedule, 0);
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
@ -35,11 +35,8 @@ Description
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// Constructor from components
|
||||
labelList bandCompression(const labelListList& cellCellAddressing)
|
||||
Foam::labelList Foam::bandCompression(const labelListList& cellCellAddressing)
|
||||
{
|
||||
labelList newOrder(cellCellAddressing.size());
|
||||
|
||||
@ -106,8 +103,4 @@ labelList bandCompression(const labelListList& cellCellAddressing)
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -29,10 +29,8 @@ License
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
defineTypeNameAndDebug(lduMesh, 0);
|
||||
}
|
||||
defineTypeNameAndDebug(Foam::lduMesh, 0);
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
|
||||
@ -36,7 +36,7 @@ namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
defineTemplateTypeNameAndDebugWithName(cellIOList, "cellList", 0);
|
||||
defineTemplateTypeNameAndDebugWithName(cellIOList, "cellList", 0);
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
|
||||
@ -78,7 +78,6 @@ SourceFiles
|
||||
#ifndef cellMatcher_H
|
||||
#define cellMatcher_H
|
||||
|
||||
#include "label.H"
|
||||
#include "labelList.H"
|
||||
#include "faceList.H"
|
||||
#include "boolList.H"
|
||||
|
||||
@ -31,12 +31,7 @@ Description
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
bool operator==(const cellShape& a, const cellShape& b)
|
||||
bool Foam::operator==(const cellShape& a, const cellShape& b)
|
||||
{
|
||||
// Basic rule: we assume that the sequence of labels in each list
|
||||
// will be circular in the same order (but not necessarily in the
|
||||
@ -180,8 +175,4 @@ bool operator==(const cellShape& a, const cellShape& b)
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -56,7 +56,7 @@ public:
|
||||
// Constructors
|
||||
|
||||
//- Construct given initial map size
|
||||
EdgeMap(label size = 100)
|
||||
EdgeMap(const label size = 128)
|
||||
:
|
||||
HashTable<T, edge, Hash<edge> >(size)
|
||||
{}
|
||||
|
||||
@ -133,14 +133,37 @@ public:
|
||||
};
|
||||
|
||||
|
||||
//- Hash<edge> specialisation
|
||||
// Simple commutative hash.
|
||||
//- Hash specialization for hashing edges - a commutative hash value.
|
||||
// Hash incrementally.
|
||||
template<>
|
||||
inline label Hash<edge>::operator()(const edge& e) const
|
||||
inline unsigned Hash<edge>::operator()(const edge& e, unsigned seed) const
|
||||
{
|
||||
return e[0]*e[1] + e[0]+e[1];
|
||||
unsigned val = seed;
|
||||
|
||||
if (e[0] < e[1])
|
||||
{
|
||||
val = Hash<label>()(e[0], val);
|
||||
val = Hash<label>()(e[1], val);
|
||||
}
|
||||
else
|
||||
{
|
||||
val = Hash<label>()(e[1], val);
|
||||
val = Hash<label>()(e[0], val);
|
||||
}
|
||||
|
||||
return val;
|
||||
}
|
||||
|
||||
|
||||
//- Hash specialization for hashing edges - a commutative hash value.
|
||||
// Hash incrementally.
|
||||
template<>
|
||||
inline unsigned Hash<edge>::operator()(const edge& e) const
|
||||
{
|
||||
return Hash<edge>()(e, 0);
|
||||
}
|
||||
|
||||
|
||||
template<>
|
||||
inline bool contiguous<edge>() {return true;}
|
||||
|
||||
|
||||
@ -27,17 +27,13 @@ License
|
||||
#include "face.H"
|
||||
#include "scalarField.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
// Calculate area in contact given displacement of vertices relative to
|
||||
// the face plane. Positive displacement is above the face (no contact);
|
||||
// negative is in contact
|
||||
scalar face::areaInContact
|
||||
Foam::scalar Foam::face::areaInContact
|
||||
(
|
||||
const pointField& meshPoints,
|
||||
const scalarField& v
|
||||
@ -162,8 +158,4 @@ scalar face::areaInContact
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -24,17 +24,14 @@ License
|
||||
|
||||
Description
|
||||
Return location of contact sphere on the face
|
||||
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "face.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
scalar face::contactSphereDiameter
|
||||
Foam::scalar Foam::face::contactSphereDiameter
|
||||
(
|
||||
const point& p,
|
||||
const vector& n,
|
||||
@ -44,15 +41,12 @@ scalar face::contactSphereDiameter
|
||||
scalar magN = Foam::mag(n);
|
||||
|
||||
vector n1 = n/(magN + SMALL);
|
||||
|
||||
vector n2 = normal(meshPoints);
|
||||
|
||||
n2 /= Foam::mag(n2) + SMALL;
|
||||
|
||||
return 2*((centre(meshPoints) - p) & n2)/((n1 & n2) - 1.0);
|
||||
}
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -34,9 +34,6 @@ Description
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// Return potential intersection with face with a ray starting
|
||||
// at p, direction n (does not need to be normalized)
|
||||
// Does face-center decomposition and returns triangle intersection
|
||||
@ -46,7 +43,7 @@ namespace Foam
|
||||
// face plane and the ray and the distance is the distance between the
|
||||
// intersection point and the nearest point on the face
|
||||
|
||||
pointHit face::ray
|
||||
Foam::pointHit Foam::face::ray
|
||||
(
|
||||
const point& p,
|
||||
const vector& n,
|
||||
@ -76,7 +73,7 @@ pointHit face::ray
|
||||
nextPoint = meshPoints[f[fcIndex(pI)]];
|
||||
|
||||
// Note: for best accuracy, centre point always comes last
|
||||
//
|
||||
//
|
||||
pointHit curHit = triPointRef
|
||||
(
|
||||
meshPoints[f[pI]],
|
||||
@ -133,7 +130,7 @@ pointHit face::ray
|
||||
}
|
||||
|
||||
|
||||
pointHit face::intersection
|
||||
Foam::pointHit Foam::face::intersection
|
||||
(
|
||||
const point& p,
|
||||
const vector& q,
|
||||
@ -179,7 +176,7 @@ pointHit face::intersection
|
||||
}
|
||||
|
||||
|
||||
pointHit face::nearestPoint
|
||||
Foam::pointHit Foam::face::nearestPoint
|
||||
(
|
||||
const point& p,
|
||||
const pointField& meshPoints
|
||||
@ -200,7 +197,7 @@ pointHit face::nearestPoint
|
||||
nextPoint = meshPoints[f[fcIndex(pI)]];
|
||||
|
||||
// Note: for best accuracy, centre point always comes last
|
||||
//
|
||||
//
|
||||
triPointRef tri
|
||||
(
|
||||
meshPoints[f[pI]],
|
||||
@ -232,8 +229,4 @@ pointHit face::nearestPoint
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -30,14 +30,10 @@ Description
|
||||
#include "cellShape.H"
|
||||
#include "cellModeller.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
cellShape tetCell::tetCellShape() const
|
||||
Foam::cellShape Foam::tetCell::tetCellShape() const
|
||||
{
|
||||
static const cellModel* tetModelPtr_ = NULL;
|
||||
|
||||
@ -52,8 +48,4 @@ cellShape tetCell::tetCellShape() const
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -164,14 +164,31 @@ public:
|
||||
};
|
||||
|
||||
|
||||
//- Hash<triFace> specialisation
|
||||
// Simple commutative hash.
|
||||
//- Hash specialization for hashing triFace - a commutative hash value.
|
||||
// Hash incrementally.
|
||||
template<>
|
||||
inline label Hash<triFace>::operator()(const triFace& t) const
|
||||
inline unsigned Hash<triFace>::operator()(const triFace& t, unsigned seed) const
|
||||
{
|
||||
return (t[0]*t[1]*t[2] + t[0]+t[1]+t[2]);
|
||||
// Fortunately we don't need this very often
|
||||
const uLabel t0(t[0]);
|
||||
const uLabel t1(t[1]);
|
||||
const uLabel t2(t[2]);
|
||||
|
||||
const uLabel val = (t0*t1*t2 + t0+t1+t2);
|
||||
|
||||
return Hash<uLabel>()(val, seed);
|
||||
}
|
||||
|
||||
|
||||
//- Hash specialization for hashing triFace - a commutative hash value.
|
||||
// Hash incrementally.
|
||||
template<>
|
||||
inline unsigned Hash<triFace>::operator()(const triFace& t) const
|
||||
{
|
||||
return Hash<triFace>::operator()(t, 0);
|
||||
}
|
||||
|
||||
|
||||
template<>
|
||||
inline bool contiguous<triFace>() {return true;}
|
||||
|
||||
|
||||
@ -133,7 +133,7 @@ inline Foam::pointField Foam::triFace::points(const pointField& points) const
|
||||
|
||||
inline Foam::face Foam::triFace::triFaceFace() const
|
||||
{
|
||||
face f(3);
|
||||
Foam::face f(3);
|
||||
|
||||
f[0] = operator[](0);
|
||||
f[1] = operator[](1);
|
||||
|
||||
@ -29,14 +29,9 @@ License
|
||||
#include "facePointPatch.H"
|
||||
#include "globalPointPatch.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
pointBoundaryMesh::pointBoundaryMesh
|
||||
Foam::pointBoundaryMesh::pointBoundaryMesh
|
||||
(
|
||||
const pointMesh& m,
|
||||
const polyBoundaryMesh& basicBdry
|
||||
@ -61,7 +56,7 @@ pointBoundaryMesh::pointBoundaryMesh
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
void pointBoundaryMesh::calcGeometry()
|
||||
void Foam::pointBoundaryMesh::calcGeometry()
|
||||
{
|
||||
forAll(*this, patchi)
|
||||
{
|
||||
@ -75,7 +70,8 @@ void pointBoundaryMesh::calcGeometry()
|
||||
}
|
||||
|
||||
|
||||
const globalPointPatch& pointBoundaryMesh::globalPatch() const
|
||||
const Foam::globalPointPatch&
|
||||
Foam::pointBoundaryMesh::globalPatch() const
|
||||
{
|
||||
const pointPatchList& patches = *this;
|
||||
|
||||
@ -99,7 +95,7 @@ const globalPointPatch& pointBoundaryMesh::globalPatch() const
|
||||
}
|
||||
|
||||
|
||||
void pointBoundaryMesh::movePoints(const pointField& p)
|
||||
void Foam::pointBoundaryMesh::movePoints(const pointField& p)
|
||||
{
|
||||
pointPatchList& patches = *this;
|
||||
|
||||
@ -115,7 +111,7 @@ void pointBoundaryMesh::movePoints(const pointField& p)
|
||||
}
|
||||
|
||||
|
||||
void pointBoundaryMesh::updateMesh()
|
||||
void Foam::pointBoundaryMesh::updateMesh()
|
||||
{
|
||||
pointPatchList& patches = *this;
|
||||
|
||||
@ -131,8 +127,4 @@ void pointBoundaryMesh::updateMesh()
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -29,27 +29,20 @@ License
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
defineTypeNameAndDebug(coupledPointPatch, 0);
|
||||
defineTypeNameAndDebug(Foam::coupledPointPatch, 0);
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
coupledPointPatch::coupledPointPatch(const pointBoundaryMesh& bm)
|
||||
Foam::coupledPointPatch::coupledPointPatch(const pointBoundaryMesh& bm)
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
coupledPointPatch::~coupledPointPatch()
|
||||
Foam::coupledPointPatch::~coupledPointPatch()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -28,9 +28,6 @@ License
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
defineTypeNameAndDebug(pointPatch, 0);
|
||||
}
|
||||
defineTypeNameAndDebug(Foam::pointPatch, 0);
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -40,10 +40,7 @@ License
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
defineTypeNameAndDebug(globalMeshData, 0);
|
||||
}
|
||||
defineTypeNameAndDebug(Foam::globalMeshData, 0);
|
||||
|
||||
// Geometric matching tolerance. Factor of mesh bounding box.
|
||||
const Foam::scalar Foam::globalMeshData::matchTol_ = 1E-8;
|
||||
|
||||
@ -32,10 +32,8 @@ License
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
defineTypeNameAndDebug(polyBoundaryMesh, 0);
|
||||
}
|
||||
defineTypeNameAndDebug(Foam::polyBoundaryMesh, 0);
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
|
||||
@ -39,10 +39,8 @@ License
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
defineTypeNameAndDebug(polyMesh, 0);
|
||||
}
|
||||
defineTypeNameAndDebug(Foam::polyMesh, 0);
|
||||
|
||||
|
||||
Foam::word Foam::polyMesh::defaultRegion = "region0";
|
||||
Foam::word Foam::polyMesh::meshSubDir = "polyMesh";
|
||||
@ -54,40 +52,79 @@ void Foam::polyMesh::calcDirections() const
|
||||
{
|
||||
for (direction cmpt=0; cmpt<vector::nComponents; cmpt++)
|
||||
{
|
||||
directions_[cmpt] = 1;
|
||||
solutionD_[cmpt] = 1;
|
||||
}
|
||||
|
||||
label nEmptyPatches = 0;
|
||||
// Knock out empty and wedge directions. Note:they will be present on all
|
||||
// domains.
|
||||
|
||||
vector dirVec = vector::zero;
|
||||
label nEmptyPatches = 0;
|
||||
label nWedgePatches = 0;
|
||||
|
||||
vector emptyDirVec = vector::zero;
|
||||
vector wedgeDirVec = vector::zero;
|
||||
|
||||
forAll(boundaryMesh(), patchi)
|
||||
{
|
||||
if (isA<emptyPolyPatch>(boundaryMesh()[patchi]))
|
||||
if (boundaryMesh()[patchi].size())
|
||||
{
|
||||
if (boundaryMesh()[patchi].size())
|
||||
if (isA<emptyPolyPatch>(boundaryMesh()[patchi]))
|
||||
{
|
||||
nEmptyPatches++;
|
||||
dirVec += sum(cmptMag(boundaryMesh()[patchi].faceAreas()));
|
||||
emptyDirVec += sum(cmptMag(boundaryMesh()[patchi].faceAreas()));
|
||||
}
|
||||
else if (isA<wedgePolyPatch>(boundaryMesh()[patchi]))
|
||||
{
|
||||
const wedgePolyPatch& wpp = refCast<const wedgePolyPatch>
|
||||
(
|
||||
boundaryMesh()[patchi]
|
||||
);
|
||||
|
||||
nWedgePatches++;
|
||||
wedgeDirVec += cmptMag(wpp.centreNormal());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (nEmptyPatches)
|
||||
{
|
||||
reduce(dirVec, sumOp<vector>());
|
||||
reduce(emptyDirVec, sumOp<vector>());
|
||||
|
||||
dirVec /= mag(dirVec);
|
||||
emptyDirVec /= mag(emptyDirVec);
|
||||
|
||||
for (direction cmpt=0; cmpt<vector::nComponents; cmpt++)
|
||||
{
|
||||
if (dirVec[cmpt] > 1e-6)
|
||||
if (emptyDirVec[cmpt] > 1e-6)
|
||||
{
|
||||
directions_[cmpt] = -1;
|
||||
solutionD_[cmpt] = -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
directions_[cmpt] = 1;
|
||||
solutionD_[cmpt] = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Knock out wedge directions
|
||||
|
||||
geometricD_ = solutionD_;
|
||||
|
||||
if (nWedgePatches)
|
||||
{
|
||||
reduce(wedgeDirVec, sumOp<vector>());
|
||||
|
||||
wedgeDirVec /= mag(wedgeDirVec);
|
||||
|
||||
for (direction cmpt=0; cmpt<vector::nComponents; cmpt++)
|
||||
{
|
||||
if (wedgeDirVec[cmpt] > 1e-6)
|
||||
{
|
||||
geometricD_[cmpt] = -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
geometricD_[cmpt] = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -163,7 +200,8 @@ Foam::polyMesh::polyMesh(const IOobject& io)
|
||||
*this
|
||||
),
|
||||
bounds_(points_),
|
||||
directions_(Vector<label>::zero),
|
||||
geometricD_(Vector<label>::zero),
|
||||
solutionD_(Vector<label>::zero),
|
||||
pointZones_
|
||||
(
|
||||
IOobject
|
||||
@ -350,7 +388,8 @@ Foam::polyMesh::polyMesh
|
||||
0
|
||||
),
|
||||
bounds_(points_, syncPar),
|
||||
directions_(Vector<label>::zero),
|
||||
geometricD_(Vector<label>::zero),
|
||||
solutionD_(Vector<label>::zero),
|
||||
pointZones_
|
||||
(
|
||||
IOobject
|
||||
@ -505,7 +544,8 @@ Foam::polyMesh::polyMesh
|
||||
0
|
||||
),
|
||||
bounds_(points_, syncPar),
|
||||
directions_(Vector<label>::zero),
|
||||
geometricD_(Vector<label>::zero),
|
||||
solutionD_(Vector<label>::zero),
|
||||
pointZones_
|
||||
(
|
||||
IOobject
|
||||
@ -766,44 +806,37 @@ const Foam::fileName& Foam::polyMesh::facesInstance() const
|
||||
}
|
||||
|
||||
|
||||
const Foam::Vector<Foam::label>& Foam::polyMesh::directions() const
|
||||
const Foam::Vector<Foam::label>& Foam::polyMesh::geometricD() const
|
||||
{
|
||||
if (directions_.x() == 0)
|
||||
if (geometricD_.x() == 0)
|
||||
{
|
||||
calcDirections();
|
||||
}
|
||||
|
||||
return directions_;
|
||||
return geometricD_;
|
||||
}
|
||||
|
||||
|
||||
Foam::label Foam::polyMesh::nGeometricD() const
|
||||
{
|
||||
label nWedges = 0;
|
||||
return cmptSum(geometricD() + Vector<label>::one)/2;
|
||||
}
|
||||
|
||||
forAll(boundary_, patchi)
|
||||
|
||||
const Foam::Vector<Foam::label>& Foam::polyMesh::solutionD() const
|
||||
{
|
||||
if (solutionD_.x() == 0)
|
||||
{
|
||||
if (isA<wedgePolyPatch>(boundary_[patchi]))
|
||||
{
|
||||
nWedges++;
|
||||
}
|
||||
calcDirections();
|
||||
}
|
||||
|
||||
if (nWedges != 0 && nWedges != 2 && nWedges != 4)
|
||||
{
|
||||
FatalErrorIn("label polyMesh::nGeometricD() const")
|
||||
<< "Number of wedge patches " << nWedges << " is incorrect, "
|
||||
"should be 0, 2 or 4"
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
return nSolutionD() - nWedges/2;
|
||||
return solutionD_;
|
||||
}
|
||||
|
||||
|
||||
Foam::label Foam::polyMesh::nSolutionD() const
|
||||
{
|
||||
return cmptSum(directions() + Vector<label>::one)/2;
|
||||
return cmptSum(solutionD() + Vector<label>::one)/2;
|
||||
}
|
||||
|
||||
|
||||
@ -823,6 +856,10 @@ void Foam::polyMesh::addPatches
|
||||
<< abort(FatalError);
|
||||
}
|
||||
|
||||
// Reset valid directions
|
||||
geometricD_ = Vector<label>::zero;
|
||||
solutionD_ = Vector<label>::zero;
|
||||
|
||||
boundary_.setSize(p.size());
|
||||
|
||||
// Copy the patch pointers
|
||||
@ -1037,6 +1074,10 @@ Foam::tmp<Foam::scalarField> Foam::polyMesh::movePoints
|
||||
faceZones_.movePoints(points_);
|
||||
cellZones_.movePoints(points_);
|
||||
|
||||
// Reset valid directions (could change with rotation)
|
||||
geometricD_ = Vector<label>::zero;
|
||||
solutionD_ = Vector<label>::zero;
|
||||
|
||||
|
||||
// Hack until proper callbacks. Below are all the polyMeh MeshObjects with a
|
||||
// movePoints function.
|
||||
|
||||
@ -120,9 +120,13 @@ private:
|
||||
// Created from points on construction, updated when the mesh moves
|
||||
boundBox bounds_;
|
||||
|
||||
//- vector of non-constrained directions in mesh
|
||||
// defined according to the presence of empty and wedge patches
|
||||
mutable Vector<label> geometricD_;
|
||||
|
||||
//- vector of valid directions in mesh
|
||||
// defined according to the presence of empty patches
|
||||
mutable Vector<label> directions_;
|
||||
mutable Vector<label> solutionD_;
|
||||
|
||||
|
||||
// Zoning information
|
||||
@ -309,17 +313,22 @@ public:
|
||||
return bounds_;
|
||||
}
|
||||
|
||||
//- Return the vector of valid directions in mesh.
|
||||
// Defined according to the presence of empty patches.
|
||||
// 1 indicates valid direction and -1 an invalid direction.
|
||||
const Vector<label>& directions() const;
|
||||
//- Return the vector of geometric directions in mesh.
|
||||
// Defined according to the presence of empty and wedge patches.
|
||||
// 1 indicates unconstrained direction and -1 a constrained
|
||||
// direction.
|
||||
const Vector<label>& geometricD() const;
|
||||
|
||||
//- Return the number of valid geometric dimensions in the mesh
|
||||
label nGeometricD() const;
|
||||
|
||||
//- Return the number of valid solution dimensions in the mesh.
|
||||
// For wedge cases this includes the circumferential direction
|
||||
// in case of swirl.
|
||||
//- Return the vector of solved-for directions in mesh.
|
||||
// Differs from geometricD in that it includes for wedge cases
|
||||
// the circumferential direction in case of swirl.
|
||||
// 1 indicates valid direction and -1 an invalid direction.
|
||||
const Vector<label>& solutionD() const;
|
||||
|
||||
//- Return the number of valid solved-for dimensions in the mesh
|
||||
label nSolutionD() const;
|
||||
|
||||
//- Return point zone mesh
|
||||
|
||||
@ -68,6 +68,10 @@ void Foam::polyMesh::clearGeom()
|
||||
boundary_[patchI].clearGeom();
|
||||
}
|
||||
|
||||
// Reset valid directions (could change with rotation)
|
||||
geometricD_ = Vector<label>::zero;
|
||||
solutionD_ = Vector<label>::zero;
|
||||
|
||||
pointMesh::Delete(*this);
|
||||
}
|
||||
|
||||
@ -87,6 +91,10 @@ void Foam::polyMesh::clearAddressing()
|
||||
// recalculation
|
||||
deleteDemandDrivenData(globalMeshDataPtr_);
|
||||
|
||||
// Reset valid directions
|
||||
geometricD_ = Vector<label>::zero;
|
||||
solutionD_ = Vector<label>::zero;
|
||||
|
||||
pointMesh::Delete(*this);
|
||||
}
|
||||
|
||||
|
||||
@ -217,7 +217,8 @@ Foam::polyMesh::polyMesh
|
||||
boundaryFaces.size() + 1 // add room for a default patch
|
||||
),
|
||||
bounds_(points_, syncPar),
|
||||
directions_(Vector<label>::zero),
|
||||
geometricD_(Vector<label>::zero),
|
||||
solutionD_(Vector<label>::zero),
|
||||
pointZones_
|
||||
(
|
||||
IOobject
|
||||
|
||||
@ -268,7 +268,12 @@ Foam::polyMesh::readUpdateState Foam::polyMesh::readUpdate()
|
||||
// Calculate the geometry for the patches (transformation tensors etc.)
|
||||
boundary_.calcGeometry();
|
||||
|
||||
// Derived info
|
||||
bounds_ = boundBox(points_);
|
||||
geometricD_ = Vector<label>::zero;
|
||||
solutionD_ = Vector<label>::zero;
|
||||
|
||||
// Zones
|
||||
pointZoneMesh newPointZones
|
||||
(
|
||||
IOobject
|
||||
@ -418,6 +423,13 @@ Foam::polyMesh::readUpdateState Foam::polyMesh::readUpdate()
|
||||
false
|
||||
)
|
||||
);
|
||||
|
||||
// Derived info
|
||||
bounds_ = boundBox(points_);
|
||||
|
||||
// Rotation can cause direction vector to change
|
||||
geometricD_ = Vector<label>::zero;
|
||||
solutionD_ = Vector<label>::zero;
|
||||
|
||||
return polyMesh::POINTS_MOVED;
|
||||
}
|
||||
|
||||
@ -68,6 +68,11 @@ void Foam::polyMesh::updateMesh(const mapPolyMesh& mpm)
|
||||
newMotionPoints.map(oldMotionPoints, mpm.pointMap());
|
||||
}
|
||||
|
||||
// Reset valid directions (could change by faces put into empty patches)
|
||||
geometricD_ = Vector<label>::zero;
|
||||
solutionD_ = Vector<label>::zero;
|
||||
|
||||
|
||||
// Hack until proper callbacks. Below are all the polyMesh-MeshObjects.
|
||||
|
||||
// pointMesh
|
||||
|
||||
@ -31,10 +31,7 @@ License
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
defineTypeNameAndDebug(coupledPolyPatch, 0);
|
||||
}
|
||||
defineTypeNameAndDebug(Foam::coupledPolyPatch, 0);
|
||||
|
||||
Foam::scalar Foam::coupledPolyPatch::matchTol = 1E-3;
|
||||
|
||||
|
||||
@ -30,10 +30,9 @@ License
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
namespace Foam
|
||||
{
|
||||
defineTypeNameAndDebug(primitiveMesh, 0);
|
||||
}
|
||||
|
||||
defineTypeNameAndDebug(Foam::primitiveMesh, 0);
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
|
||||
@ -26,14 +26,10 @@ License
|
||||
|
||||
#include "primitiveMesh.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
void primitiveMesh::calcCellCells() const
|
||||
void Foam::primitiveMesh::calcCellCells() const
|
||||
{
|
||||
// Loop through faceCells and mark up neighbours
|
||||
|
||||
@ -102,7 +98,7 @@ void primitiveMesh::calcCellCells() const
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
const labelListList& primitiveMesh::cellCells() const
|
||||
const Foam::labelListList& Foam::primitiveMesh::cellCells() const
|
||||
{
|
||||
if (!ccPtr_)
|
||||
{
|
||||
@ -113,7 +109,7 @@ const labelListList& primitiveMesh::cellCells() const
|
||||
}
|
||||
|
||||
|
||||
const labelList& primitiveMesh::cellCells
|
||||
const Foam::labelList& Foam::primitiveMesh::cellCells
|
||||
(
|
||||
const label cellI,
|
||||
DynamicList<label>& storage
|
||||
@ -153,14 +149,10 @@ const labelList& primitiveMesh::cellCells
|
||||
}
|
||||
|
||||
|
||||
const labelList& primitiveMesh::cellCells(const label cellI) const
|
||||
const Foam::labelList& Foam::primitiveMesh::cellCells(const label cellI) const
|
||||
{
|
||||
return cellCells(cellI, labels_);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -30,14 +30,9 @@ Description
|
||||
|
||||
#include "primitiveMesh.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
void primitiveMesh::calcCellCentresAndVols() const
|
||||
void Foam::primitiveMesh::calcCellCentresAndVols() const
|
||||
{
|
||||
if (debug)
|
||||
{
|
||||
@ -75,7 +70,7 @@ void primitiveMesh::calcCellCentresAndVols() const
|
||||
}
|
||||
|
||||
|
||||
void primitiveMesh::makeCellCentresAndVols
|
||||
void Foam::primitiveMesh::makeCellCentresAndVols
|
||||
(
|
||||
const vectorField& fCtrs,
|
||||
const vectorField& fAreas,
|
||||
@ -152,7 +147,7 @@ void primitiveMesh::makeCellCentresAndVols
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
const vectorField& primitiveMesh::cellCentres() const
|
||||
const Foam::vectorField& Foam::primitiveMesh::cellCentres() const
|
||||
{
|
||||
if (!cellCentresPtr_)
|
||||
{
|
||||
@ -163,7 +158,7 @@ const vectorField& primitiveMesh::cellCentres() const
|
||||
}
|
||||
|
||||
|
||||
const scalarField& primitiveMesh::cellVolumes() const
|
||||
const Foam::scalarField& Foam::primitiveMesh::cellVolumes() const
|
||||
{
|
||||
if (!cellVolumesPtr_)
|
||||
{
|
||||
@ -174,8 +169,4 @@ const scalarField& primitiveMesh::cellVolumes() const
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -26,14 +26,9 @@ License
|
||||
|
||||
#include "primitiveMesh.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
void primitiveMesh::calcCells
|
||||
void Foam::primitiveMesh::calcCells
|
||||
(
|
||||
cellList& cellFaceAddr,
|
||||
const unallocLabelList& own,
|
||||
@ -102,7 +97,7 @@ void primitiveMesh::calcCells
|
||||
}
|
||||
|
||||
|
||||
void primitiveMesh::calcCells() const
|
||||
void Foam::primitiveMesh::calcCells() const
|
||||
{
|
||||
// Loop through faceCells and mark up neighbours
|
||||
|
||||
@ -139,7 +134,7 @@ void primitiveMesh::calcCells() const
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
const cellList& primitiveMesh::cells() const
|
||||
const Foam::cellList& Foam::primitiveMesh::cells() const
|
||||
{
|
||||
if (!cfPtr_)
|
||||
{
|
||||
@ -150,8 +145,4 @@ const cellList& primitiveMesh::cells() const
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -30,22 +30,18 @@ License
|
||||
#include "mathematicalConstants.H"
|
||||
#include "SortableList.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
scalar primitiveMesh::closedThreshold_ = 1.0e-6;
|
||||
scalar primitiveMesh::aspectThreshold_ = 1000;
|
||||
scalar primitiveMesh::nonOrthThreshold_ = 70; // deg
|
||||
scalar primitiveMesh::skewThreshold_ = 4;
|
||||
Foam::scalar Foam::primitiveMesh::closedThreshold_ = 1.0e-6;
|
||||
Foam::scalar Foam::primitiveMesh::aspectThreshold_ = 1000;
|
||||
Foam::scalar Foam::primitiveMesh::nonOrthThreshold_ = 70; // deg
|
||||
Foam::scalar Foam::primitiveMesh::skewThreshold_ = 4;
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
bool primitiveMesh::checkClosedBoundary(const bool report) const
|
||||
bool Foam::primitiveMesh::checkClosedBoundary(const bool report) const
|
||||
{
|
||||
if (debug)
|
||||
{
|
||||
@ -97,7 +93,7 @@ bool primitiveMesh::checkClosedBoundary(const bool report) const
|
||||
}
|
||||
|
||||
|
||||
bool primitiveMesh::checkClosedCells
|
||||
bool Foam::primitiveMesh::checkClosedCells
|
||||
(
|
||||
const bool report,
|
||||
labelHashSet* setPtr,
|
||||
@ -266,7 +262,7 @@ bool primitiveMesh::checkClosedCells
|
||||
}
|
||||
|
||||
|
||||
bool primitiveMesh::checkFaceAreas
|
||||
bool Foam::primitiveMesh::checkFaceAreas
|
||||
(
|
||||
const bool report,
|
||||
labelHashSet* setPtr
|
||||
@ -325,7 +321,7 @@ bool primitiveMesh::checkFaceAreas
|
||||
}
|
||||
|
||||
|
||||
bool primitiveMesh::checkCellVolumes
|
||||
bool Foam::primitiveMesh::checkCellVolumes
|
||||
(
|
||||
const bool report,
|
||||
labelHashSet* setPtr
|
||||
@ -392,7 +388,7 @@ bool primitiveMesh::checkCellVolumes
|
||||
}
|
||||
|
||||
|
||||
bool primitiveMesh::checkFaceOrthogonality
|
||||
bool Foam::primitiveMesh::checkFaceOrthogonality
|
||||
(
|
||||
const bool report,
|
||||
labelHashSet* setPtr
|
||||
@ -512,7 +508,7 @@ bool primitiveMesh::checkFaceOrthogonality
|
||||
}
|
||||
|
||||
|
||||
bool primitiveMesh::checkFacePyramids
|
||||
bool Foam::primitiveMesh::checkFacePyramids
|
||||
(
|
||||
const bool report,
|
||||
const scalar minPyrVol,
|
||||
@ -596,7 +592,7 @@ bool primitiveMesh::checkFacePyramids
|
||||
}
|
||||
|
||||
|
||||
bool primitiveMesh::checkFaceSkewness
|
||||
bool Foam::primitiveMesh::checkFaceSkewness
|
||||
(
|
||||
const bool report,
|
||||
labelHashSet* setPtr
|
||||
@ -740,7 +736,7 @@ bool primitiveMesh::checkFaceSkewness
|
||||
}
|
||||
|
||||
|
||||
bool primitiveMesh::checkPoints
|
||||
bool Foam::primitiveMesh::checkPoints
|
||||
(
|
||||
const bool report,
|
||||
labelHashSet* setPtr
|
||||
@ -818,7 +814,7 @@ bool primitiveMesh::checkPoints
|
||||
// E.g. maxDeg = 10 allows for angles < 190 (or 10 degrees concavity)
|
||||
// (if truly concave and points not visible from face centre the face-pyramid
|
||||
// check in checkMesh will fail)
|
||||
bool primitiveMesh::checkFaceAngles
|
||||
bool Foam::primitiveMesh::checkFaceAngles
|
||||
(
|
||||
const bool report,
|
||||
const scalar maxDeg,
|
||||
@ -946,7 +942,7 @@ bool primitiveMesh::checkFaceAngles
|
||||
// Check warpage of faces. Is calculated as the difference between areas of
|
||||
// individual triangles and the overall area of the face (which ifself is
|
||||
// is the average of the areas of the individual triangles).
|
||||
bool primitiveMesh::checkFaceFlatness
|
||||
bool Foam::primitiveMesh::checkFaceFlatness
|
||||
(
|
||||
const bool report,
|
||||
const scalar warnFlatness,
|
||||
@ -1076,7 +1072,7 @@ bool primitiveMesh::checkFaceFlatness
|
||||
// - are only in a singe non-empty direction.
|
||||
// Empty direction info is passed in as a vector of labels (synchronised)
|
||||
// which are 1 if the direction is non-empty, 0 if it is.
|
||||
bool primitiveMesh::checkEdgeAlignment
|
||||
bool Foam::primitiveMesh::checkEdgeAlignment
|
||||
(
|
||||
const bool report,
|
||||
const Vector<label>& directions,
|
||||
@ -1211,7 +1207,7 @@ bool primitiveMesh::checkEdgeAlignment
|
||||
}
|
||||
|
||||
|
||||
bool primitiveMesh::checkUpperTriangular
|
||||
bool Foam::primitiveMesh::checkUpperTriangular
|
||||
(
|
||||
const bool report,
|
||||
labelHashSet* setPtr
|
||||
@ -1376,7 +1372,7 @@ bool primitiveMesh::checkUpperTriangular
|
||||
}
|
||||
|
||||
|
||||
bool primitiveMesh::checkCellsZipUp
|
||||
bool Foam::primitiveMesh::checkCellsZipUp
|
||||
(
|
||||
const bool report,
|
||||
labelHashSet* setPtr
|
||||
@ -1477,7 +1473,7 @@ bool primitiveMesh::checkCellsZipUp
|
||||
|
||||
|
||||
// Vertices of face within point range and unique.
|
||||
bool primitiveMesh::checkFaceVertices
|
||||
bool Foam::primitiveMesh::checkFaceVertices
|
||||
(
|
||||
const bool report,
|
||||
labelHashSet* setPtr
|
||||
@ -1553,7 +1549,7 @@ bool primitiveMesh::checkFaceVertices
|
||||
|
||||
|
||||
// Check if all points on face are shared between faces.
|
||||
bool primitiveMesh::checkDuplicateFaces
|
||||
bool Foam::primitiveMesh::checkDuplicateFaces
|
||||
(
|
||||
const label faceI,
|
||||
const Map<label>& nCommonPoints,
|
||||
@ -1595,7 +1591,7 @@ bool primitiveMesh::checkDuplicateFaces
|
||||
|
||||
|
||||
// Check that shared points are in consecutive order.
|
||||
bool primitiveMesh::checkCommonOrder
|
||||
bool Foam::primitiveMesh::checkCommonOrder
|
||||
(
|
||||
const label faceI,
|
||||
const Map<label>& nCommonPoints,
|
||||
@ -1758,7 +1754,7 @@ bool primitiveMesh::checkCommonOrder
|
||||
|
||||
// Checks common vertices between faces. If more than 2 they should be
|
||||
// consecutive on both faces.
|
||||
bool primitiveMesh::checkFaceFaces
|
||||
bool Foam::primitiveMesh::checkFaceFaces
|
||||
(
|
||||
const bool report,
|
||||
labelHashSet* setPtr
|
||||
@ -1868,7 +1864,7 @@ bool primitiveMesh::checkFaceFaces
|
||||
|
||||
|
||||
// Checks cells with 1 or less internal faces. Give numerical problems.
|
||||
bool primitiveMesh::checkCellDeterminant
|
||||
bool Foam::primitiveMesh::checkCellDeterminant
|
||||
(
|
||||
const bool report, // report,
|
||||
labelHashSet* setPtr // setPtr
|
||||
@ -1990,7 +1986,7 @@ bool primitiveMesh::checkCellDeterminant
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
bool primitiveMesh::checkTopology(const bool report) const
|
||||
bool Foam::primitiveMesh::checkTopology(const bool report) const
|
||||
{
|
||||
label noFailedChecks = 0;
|
||||
|
||||
@ -2023,7 +2019,7 @@ bool primitiveMesh::checkTopology(const bool report) const
|
||||
}
|
||||
|
||||
|
||||
bool primitiveMesh::checkGeometry(const bool report) const
|
||||
bool Foam::primitiveMesh::checkGeometry(const bool report) const
|
||||
{
|
||||
label noFailedChecks = 0;
|
||||
|
||||
@ -2056,7 +2052,7 @@ bool primitiveMesh::checkGeometry(const bool report) const
|
||||
}
|
||||
|
||||
|
||||
bool primitiveMesh::checkMesh(const bool report) const
|
||||
bool Foam::primitiveMesh::checkMesh(const bool report) const
|
||||
{
|
||||
if (debug)
|
||||
{
|
||||
@ -2088,44 +2084,40 @@ bool primitiveMesh::checkMesh(const bool report) const
|
||||
}
|
||||
|
||||
|
||||
scalar primitiveMesh::setClosedThreshold(const scalar ct)
|
||||
Foam::scalar Foam::primitiveMesh::setClosedThreshold(const scalar val)
|
||||
{
|
||||
scalar oldClosedThreshold = closedThreshold_;
|
||||
closedThreshold_ = ct;
|
||||
scalar prev = closedThreshold_;
|
||||
closedThreshold_ = val;
|
||||
|
||||
return oldClosedThreshold;
|
||||
return prev;
|
||||
}
|
||||
|
||||
|
||||
scalar primitiveMesh::setAspectThreshold(const scalar at)
|
||||
Foam::scalar Foam::primitiveMesh::setAspectThreshold(const scalar val)
|
||||
{
|
||||
scalar oldAspectThreshold = aspectThreshold_;
|
||||
aspectThreshold_ = at;
|
||||
scalar prev = aspectThreshold_;
|
||||
aspectThreshold_ = val;
|
||||
|
||||
return oldAspectThreshold;
|
||||
return prev;
|
||||
}
|
||||
|
||||
|
||||
scalar primitiveMesh::setNonOrthThreshold(const scalar nt)
|
||||
Foam::scalar Foam::primitiveMesh::setNonOrthThreshold(const scalar val)
|
||||
{
|
||||
scalar oldNonOrthThreshold = nonOrthThreshold_;
|
||||
nonOrthThreshold_ = nt;
|
||||
scalar prev = nonOrthThreshold_;
|
||||
nonOrthThreshold_ = val;
|
||||
|
||||
return oldNonOrthThreshold;
|
||||
return prev;
|
||||
}
|
||||
|
||||
|
||||
scalar primitiveMesh::setSkewThreshold(const scalar st)
|
||||
Foam::scalar Foam::primitiveMesh::setSkewThreshold(const scalar val)
|
||||
{
|
||||
scalar oldSkewThreshold = skewThreshold_;
|
||||
skewThreshold_ = st;
|
||||
scalar prev = skewThreshold_;
|
||||
skewThreshold_ = val;
|
||||
|
||||
return oldSkewThreshold;
|
||||
return prev;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -27,14 +27,10 @@ License
|
||||
#include "primitiveMesh.H"
|
||||
#include "demandDrivenData.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
void primitiveMesh::printAllocated() const
|
||||
void Foam::primitiveMesh::printAllocated() const
|
||||
{
|
||||
Pout<< "primitiveMesh allocated :" << endl;
|
||||
|
||||
@ -98,7 +94,7 @@ void primitiveMesh::printAllocated() const
|
||||
{
|
||||
Pout<< " Point-point" << endl;
|
||||
}
|
||||
|
||||
|
||||
if (cpPtr_)
|
||||
{
|
||||
Pout<< " Cell-point" << endl;
|
||||
@ -128,7 +124,7 @@ void primitiveMesh::printAllocated() const
|
||||
}
|
||||
|
||||
|
||||
void primitiveMesh::clearGeom()
|
||||
void Foam::primitiveMesh::clearGeom()
|
||||
{
|
||||
if (debug)
|
||||
{
|
||||
@ -144,7 +140,7 @@ void primitiveMesh::clearGeom()
|
||||
}
|
||||
|
||||
|
||||
void primitiveMesh::clearAddressing()
|
||||
void Foam::primitiveMesh::clearAddressing()
|
||||
{
|
||||
if (debug)
|
||||
{
|
||||
@ -173,15 +169,11 @@ void primitiveMesh::clearAddressing()
|
||||
}
|
||||
|
||||
|
||||
void primitiveMesh::clearOut()
|
||||
void Foam::primitiveMesh::clearOut()
|
||||
{
|
||||
clearGeom();
|
||||
clearAddressing();
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -27,14 +27,10 @@ License
|
||||
#include "primitiveMesh.H"
|
||||
#include "ListOps.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
const labelListList& primitiveMesh::edgeCells() const
|
||||
const Foam::labelListList& Foam::primitiveMesh::edgeCells() const
|
||||
{
|
||||
if (!ecPtr_)
|
||||
{
|
||||
@ -59,7 +55,7 @@ const labelListList& primitiveMesh::edgeCells() const
|
||||
}
|
||||
|
||||
|
||||
const labelList& primitiveMesh::edgeCells
|
||||
const Foam::labelList& Foam::primitiveMesh::edgeCells
|
||||
(
|
||||
const label edgeI,
|
||||
DynamicList<label>& storage
|
||||
@ -129,14 +125,10 @@ const labelList& primitiveMesh::edgeCells
|
||||
}
|
||||
|
||||
|
||||
const labelList& primitiveMesh::edgeCells(const label edgeI) const
|
||||
const Foam::labelList& Foam::primitiveMesh::edgeCells(const label edgeI) const
|
||||
{
|
||||
return edgeCells(edgeI, labels_);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -27,14 +27,9 @@ License
|
||||
#include "primitiveMesh.H"
|
||||
#include "ListOps.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
const labelListList& primitiveMesh::edgeFaces() const
|
||||
const Foam::labelListList& Foam::primitiveMesh::edgeFaces() const
|
||||
{
|
||||
if (!efPtr_)
|
||||
{
|
||||
@ -60,7 +55,7 @@ const labelListList& primitiveMesh::edgeFaces() const
|
||||
}
|
||||
|
||||
|
||||
const labelList& primitiveMesh::edgeFaces
|
||||
const Foam::labelList& Foam::primitiveMesh::edgeFaces
|
||||
(
|
||||
const label edgeI,
|
||||
DynamicList<label>& storage
|
||||
@ -106,14 +101,10 @@ const labelList& primitiveMesh::edgeFaces
|
||||
}
|
||||
|
||||
|
||||
const labelList& primitiveMesh::edgeFaces(const label edgeI) const
|
||||
const Foam::labelList& Foam::primitiveMesh::edgeFaces(const label edgeI) const
|
||||
{
|
||||
return edgeFaces(edgeI, labels_);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user