mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
consistency update
- DynamicList gets append methods as per List - misc cosmetic changes
This commit is contained in:
@ -162,16 +162,31 @@ int main(int argc, char *argv[])
|
|||||||
<< " " << dlD.size() << "/" << dlD.capacity() << endl;
|
<< " " << dlD.size() << "/" << dlD.capacity() << endl;
|
||||||
|
|
||||||
DynamicList<label,10> dlE1(10);
|
DynamicList<label,10> dlE1(10);
|
||||||
DynamicList<label> dlE2(dlE1);
|
DynamicList<label> dlE2(dlE1); // construct dissimilar
|
||||||
|
|
||||||
Info<< "<dlE1>" << dlE1 << "</dlE1>" << nl << "sizes: "
|
Info<< "<dlE1>" << dlE1 << "</dlE1>" << nl << "sizes: "
|
||||||
<< " " << dlE1.size() << "/" << dlE1.capacity() << endl;
|
<< " " << dlE1.size() << "/" << dlE1.capacity() << endl;
|
||||||
Info<< "<dlE2>" << dlE2 << "</dlE2>" << nl << "sizes: "
|
Info<< "<dlE2>" << dlE2 << "</dlE2>" << nl << "sizes: "
|
||||||
<< " " << dlE2.size() << "/" << dlE2.capacity() << endl;
|
<< " " << dlE2.size() << "/" << dlE2.capacity() << endl;
|
||||||
|
|
||||||
dlE2.append(100);
|
for (label elemI=0; elemI < 5; ++elemI)
|
||||||
|
{
|
||||||
|
dlE1.append(4 - elemI);
|
||||||
|
dlE2.append(elemI);
|
||||||
|
}
|
||||||
|
|
||||||
Info<< "<dlE2>" << dlE2 << "</dlE2>" << endl;
|
Info<< "<dlE2>" << dlE2 << "</dlE2>" << endl;
|
||||||
|
|
||||||
|
DynamicList<label> dlE3(dlE2); // construct identical
|
||||||
|
Info<< "<dlE3>" << dlE3 << "</dlE3>" << endl;
|
||||||
|
|
||||||
|
dlE3 = dlE1; // assign dissimilar
|
||||||
|
Info<< "<dlE3>" << dlE3 << "</dlE3>" << endl;
|
||||||
|
|
||||||
|
dlE3 = dlE2; // assign identical
|
||||||
|
Info<< "<dlE3>" << dlE3 << "</dlE3>" << endl;
|
||||||
|
|
||||||
|
|
||||||
Info<< "\nEnd\n";
|
Info<< "\nEnd\n";
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
@ -39,7 +39,7 @@ using namespace Foam;
|
|||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
HASHTABLE_CLASS<double> table1(100);
|
HASHTABLE_CLASS<double> table1(13);
|
||||||
|
|
||||||
table1.insert("aaa", 1.0);
|
table1.insert("aaa", 1.0);
|
||||||
table1.insert("aba", 2.0);
|
table1.insert("aba", 2.0);
|
||||||
@ -56,7 +56,8 @@ int main()
|
|||||||
table1.erase("abs");
|
table1.erase("abs");
|
||||||
|
|
||||||
Info<< "\ntable1 toc: " << table1.toc() << endl;
|
Info<< "\ntable1 toc: " << table1.toc() << endl;
|
||||||
Info<< "\ntable1 [" << table1.size() << "] " << endl;
|
table1.printInfo(Info)
|
||||||
|
<< "table1 [" << table1.size() << "] " << endl;
|
||||||
forAllIter(HASHTABLE_CLASS<double>, table1, iter)
|
forAllIter(HASHTABLE_CLASS<double>, table1, iter)
|
||||||
{
|
{
|
||||||
Info<< iter.key() << " => " << iter() << nl;
|
Info<< iter.key() << " => " << iter() << nl;
|
||||||
@ -97,7 +98,7 @@ int main()
|
|||||||
<< "transfer table1 -> table3 via the xfer() method" << nl;
|
<< "transfer table1 -> table3 via the xfer() method" << nl;
|
||||||
|
|
||||||
Info<< "\ntable1" << table1 << nl
|
Info<< "\ntable1" << table1 << nl
|
||||||
<< "\ntable2" << table1 << nl
|
<< "\ntable2" << table2 << nl
|
||||||
<< "\ntable3" << table3 << nl;
|
<< "\ntable3" << table3 << nl;
|
||||||
|
|
||||||
Info<< "\nerase table2 by iterator" << nl;
|
Info<< "\nerase table2 by iterator" << nl;
|
||||||
@ -113,10 +114,14 @@ int main()
|
|||||||
<< "\ntable3" << table3 << nl;
|
<< "\ntable3" << table3 << nl;
|
||||||
|
|
||||||
table3.resize(1);
|
table3.resize(1);
|
||||||
Info<< "\nresize(1) table3" << table3 << nl;
|
Info<< "\nresize(1) table3" << nl;
|
||||||
|
table3.printInfo(Info)
|
||||||
|
<< table3 << nl;
|
||||||
|
|
||||||
table3.resize(10000);
|
table3.resize(10000);
|
||||||
Info<< "\nresize(10000) table3" << table3 << nl;
|
Info<< "\nresize(10000) table3" << nl;
|
||||||
|
table3.printInfo(Info)
|
||||||
|
<< table3 << nl;
|
||||||
|
|
||||||
HASHTABLE_CLASS<double> table4;
|
HASHTABLE_CLASS<double> table4;
|
||||||
|
|
||||||
@ -153,7 +158,8 @@ int main()
|
|||||||
<< "\ntable2" << table2 << nl;
|
<< "\ntable2" << table2 << nl;
|
||||||
|
|
||||||
|
|
||||||
Info<< "\nclearStorage table3 ... ";
|
Info<< "\ntable3" << table3
|
||||||
|
<< "\nclearStorage table3 ... ";
|
||||||
table3.clearStorage();
|
table3.clearStorage();
|
||||||
Info<< table3 << nl;
|
Info<< table3 << nl;
|
||||||
|
|
||||||
|
|||||||
@ -39,7 +39,7 @@ using namespace Foam;
|
|||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
HASHTABLE_CLASS<double> table1(100);
|
HASHTABLE_CLASS<double> table1(13);
|
||||||
|
|
||||||
table1.insert("aaa", 1.0);
|
table1.insert("aaa", 1.0);
|
||||||
table1.insert("aba", 2.0);
|
table1.insert("aba", 2.0);
|
||||||
@ -56,7 +56,8 @@ int main()
|
|||||||
table1.erase("abs");
|
table1.erase("abs");
|
||||||
|
|
||||||
Info<< "\ntable1 toc: " << table1.toc() << endl;
|
Info<< "\ntable1 toc: " << table1.toc() << endl;
|
||||||
Info<< "\ntable1 [" << table1.size() << "] " << endl;
|
table1.printInfo(Info)
|
||||||
|
<< "table1 [" << table1.size() << "] " << endl;
|
||||||
forAllIter(HASHTABLE_CLASS<double>, table1, iter)
|
forAllIter(HASHTABLE_CLASS<double>, table1, iter)
|
||||||
{
|
{
|
||||||
Info<< iter.key() << " => " << iter() << nl;
|
Info<< iter.key() << " => " << iter() << nl;
|
||||||
@ -97,7 +98,7 @@ int main()
|
|||||||
<< "transfer table1 -> table3 via the xfer() method" << nl;
|
<< "transfer table1 -> table3 via the xfer() method" << nl;
|
||||||
|
|
||||||
Info<< "\ntable1" << table1 << nl
|
Info<< "\ntable1" << table1 << nl
|
||||||
<< "\ntable2" << table1 << nl
|
<< "\ntable2" << table2 << nl
|
||||||
<< "\ntable3" << table3 << nl;
|
<< "\ntable3" << table3 << nl;
|
||||||
|
|
||||||
Info<< "\nerase table2 by iterator" << nl;
|
Info<< "\nerase table2 by iterator" << nl;
|
||||||
@ -113,10 +114,14 @@ int main()
|
|||||||
<< "\ntable3" << table3 << nl;
|
<< "\ntable3" << table3 << nl;
|
||||||
|
|
||||||
table3.resize(1);
|
table3.resize(1);
|
||||||
Info<< "\nresize(1) table3" << table3 << nl;
|
Info<< "\nresize(1) table3" << nl;
|
||||||
|
table3.printInfo(Info)
|
||||||
|
<< table3 << nl;
|
||||||
|
|
||||||
table3.resize(10000);
|
table3.resize(10000);
|
||||||
Info<< "\nresize(10000) table3" << table3 << nl;
|
Info<< "\nresize(10000) table3" << nl;
|
||||||
|
table3.printInfo(Info)
|
||||||
|
<< table3 << nl;
|
||||||
|
|
||||||
HASHTABLE_CLASS<double> table4;
|
HASHTABLE_CLASS<double> table4;
|
||||||
|
|
||||||
@ -153,7 +158,8 @@ int main()
|
|||||||
<< "\ntable2" << table2 << nl;
|
<< "\ntable2" << table2 << nl;
|
||||||
|
|
||||||
|
|
||||||
Info<< "\nclearStorage table3 ... ";
|
Info<< "\ntable3" << table3
|
||||||
|
<< "\nclearStorage table3 ... ";
|
||||||
table3.clearStorage();
|
table3.clearStorage();
|
||||||
Info<< table3 << nl;
|
Info<< table3 << nl;
|
||||||
|
|
||||||
@ -162,4 +168,5 @@ int main()
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// ************************************************************************* //
|
// ************************************************************************* //
|
||||||
|
|||||||
@ -27,6 +27,7 @@ Description
|
|||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#include "UIndirectList.H"
|
#include "UIndirectList.H"
|
||||||
|
#include "DynamicList.H"
|
||||||
#include "IOstreams.H"
|
#include "IOstreams.H"
|
||||||
#include "ListOps.H"
|
#include "ListOps.H"
|
||||||
#include "OFstream.H"
|
#include "OFstream.H"
|
||||||
@ -81,15 +82,24 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
Info<< "idl assigned from UList: " << idl << endl;
|
Info<< "idl assigned from UList: " << idl << endl;
|
||||||
|
|
||||||
List<double> realList = UIndirectList<double>(completeList, addresses);
|
// test List operations
|
||||||
|
|
||||||
Info<< "realList:" << realList << endl;
|
List<double> flatList = UIndirectList<double>(completeList, addresses);
|
||||||
|
Info<< "List assigned from UIndirectList: " << flatList << endl;
|
||||||
|
|
||||||
List<double> realList2(UIndirectList<double>(completeList, addresses));
|
List<double> flatList2(UIndirectList<double>(completeList, addresses));
|
||||||
|
Info<< "List constructed from UIndirectList: " << flatList2 << endl;
|
||||||
|
|
||||||
Info<< "realList2:" << realList2 << endl;
|
flatList.append(UIndirectList<double>(completeList, addresses));
|
||||||
|
Info<< "List::append(UIndirectList): " << flatList << endl;
|
||||||
|
|
||||||
|
|
||||||
|
DynamicList<double> dynList(UIndirectList<double>(completeList, addresses));
|
||||||
|
Info<< "DynamicList constructed from UIndirectList: " << dynList << endl;
|
||||||
|
|
||||||
|
dynList.append(UIndirectList<double>(completeList, addresses));
|
||||||
|
Info<< "DynamicList::append(UIndirectList): " << dynList << endl;
|
||||||
|
|
||||||
Info << "\nEnd\n" << endl;
|
Info << "\nEnd\n" << endl;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
@ -50,7 +50,7 @@ void Foam::HashPtrTable<T, Key, Hash>::read(Istream& is, const INew& inewt)
|
|||||||
label s = firstToken.labelToken();
|
label s = firstToken.labelToken();
|
||||||
|
|
||||||
// Read beginning of contents
|
// Read beginning of contents
|
||||||
char listDelimiter = is.readBeginList("HashPtrTable<T, Key, Hash>");
|
char delimiter = is.readBeginList("HashPtrTable<T, Key, Hash>");
|
||||||
|
|
||||||
if (s)
|
if (s)
|
||||||
{
|
{
|
||||||
@ -59,7 +59,7 @@ void Foam::HashPtrTable<T, Key, Hash>::read(Istream& is, const INew& inewt)
|
|||||||
this->resize(2*s);
|
this->resize(2*s);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (listDelimiter == token::BEGIN_LIST)
|
if (delimiter == token::BEGIN_LIST)
|
||||||
{
|
{
|
||||||
for (label i=0; i<s; i++)
|
for (label i=0; i<s; i++)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -28,6 +28,13 @@ Class
|
|||||||
Description
|
Description
|
||||||
An STL-conforming hash table.
|
An STL-conforming hash table.
|
||||||
|
|
||||||
|
Note
|
||||||
|
Hashing index collisions are handled via chaining using a singly-linked
|
||||||
|
list with the colliding entry being added to the head of the linked
|
||||||
|
list. Thus copying the hash table (or indeed even resizing it) will
|
||||||
|
often result in a different hash order. Use a sorted table-of-contents
|
||||||
|
when the hash order is important.
|
||||||
|
|
||||||
SourceFiles
|
SourceFiles
|
||||||
HashTableI.H
|
HashTableI.H
|
||||||
HashTable.C
|
HashTable.C
|
||||||
|
|||||||
@ -81,7 +81,7 @@ Foam::HashTable<T, Key, Hash>::printInfo(Ostream& os) const
|
|||||||
|
|
||||||
os << "HashTable<T,Key,Hash>"
|
os << "HashTable<T,Key,Hash>"
|
||||||
<< " elements:" << size() << " slots:" << used << "/" << tableSize_
|
<< " elements:" << size() << " slots:" << used << "/" << tableSize_
|
||||||
<< " chaining(avg/max):" << (used ? float(avgChain/used) : 0)
|
<< " chaining(avg/max):" << (used ? (float(avgChain)/used) : 0)
|
||||||
<< "/" << maxChain << endl;
|
<< "/" << maxChain << endl;
|
||||||
|
|
||||||
return os;
|
return os;
|
||||||
@ -91,7 +91,11 @@ Foam::HashTable<T, Key, Hash>::printInfo(Ostream& os) const
|
|||||||
// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
|
||||||
|
|
||||||
template<class T, class Key, class Hash>
|
template<class T, class Key, class Hash>
|
||||||
Foam::Istream& Foam::operator>>(Istream& is, HashTable<T, Key, Hash>& L)
|
Foam::Istream& Foam::operator>>
|
||||||
|
(
|
||||||
|
Istream& is,
|
||||||
|
HashTable<T, Key, Hash>& L
|
||||||
|
)
|
||||||
{
|
{
|
||||||
is.fatalCheck("operator>>(Istream&, HashTable<T, Key, Hash>&)");
|
is.fatalCheck("operator>>(Istream&, HashTable<T, Key, Hash>&)");
|
||||||
|
|
||||||
@ -113,7 +117,7 @@ Foam::Istream& Foam::operator>>(Istream& is, HashTable<T, Key, Hash>& L)
|
|||||||
label s = firstToken.labelToken();
|
label s = firstToken.labelToken();
|
||||||
|
|
||||||
// Read beginning of contents
|
// Read beginning of contents
|
||||||
char listDelimiter = is.readBeginList("HashTable<T, Key, Hash>");
|
char delimiter = is.readBeginList("HashTable<T, Key, Hash>");
|
||||||
|
|
||||||
if (s)
|
if (s)
|
||||||
{
|
{
|
||||||
@ -122,7 +126,7 @@ Foam::Istream& Foam::operator>>(Istream& is, HashTable<T, Key, Hash>& L)
|
|||||||
L.resize(2*s);
|
L.resize(2*s);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (listDelimiter == token::BEGIN_LIST)
|
if (delimiter == token::BEGIN_LIST)
|
||||||
{
|
{
|
||||||
for (label i=0; i<s; i++)
|
for (label i=0; i<s; i++)
|
||||||
{
|
{
|
||||||
@ -209,7 +213,11 @@ Foam::Istream& Foam::operator>>(Istream& is, HashTable<T, Key, Hash>& L)
|
|||||||
|
|
||||||
|
|
||||||
template<class T, class Key, class Hash>
|
template<class T, class Key, class Hash>
|
||||||
Foam::Ostream& Foam::operator<<(Ostream& os, const HashTable<T, Key, Hash>& L)
|
Foam::Ostream& Foam::operator<<
|
||||||
|
(
|
||||||
|
Ostream& os,
|
||||||
|
const HashTable<T, Key, Hash>& L
|
||||||
|
)
|
||||||
{
|
{
|
||||||
// Write size and start delimiter
|
// Write size and start delimiter
|
||||||
os << nl << L.size() << nl << token::BEGIN_LIST << nl;
|
os << nl << L.size() << nl << token::BEGIN_LIST << nl;
|
||||||
|
|||||||
@ -117,7 +117,7 @@ Foam::Istream& Foam::operator>>(Istream& is, StaticHashTable<T, Key, Hash>& L)
|
|||||||
label s = firstToken.labelToken();
|
label s = firstToken.labelToken();
|
||||||
|
|
||||||
// Read beginning of contents
|
// Read beginning of contents
|
||||||
char listDelimiter = is.readBeginList("StaticHashTable<T, Key, Hash>");
|
char delimiter = is.readBeginList("StaticHashTable<T, Key, Hash>");
|
||||||
|
|
||||||
if (s)
|
if (s)
|
||||||
{
|
{
|
||||||
@ -126,7 +126,7 @@ Foam::Istream& Foam::operator>>(Istream& is, StaticHashTable<T, Key, Hash>& L)
|
|||||||
L.resize(2*s);
|
L.resize(2*s);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (listDelimiter == token::BEGIN_LIST)
|
if (delimiter == token::BEGIN_LIST)
|
||||||
{
|
{
|
||||||
for (label i=0; i<s; i++)
|
for (label i=0; i<s; i++)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -50,11 +50,11 @@ void Foam::ILList<LListBase, T>::read(Istream& is, const INew& iNew)
|
|||||||
label s = firstToken.labelToken();
|
label s = firstToken.labelToken();
|
||||||
|
|
||||||
// Read beginning of contents
|
// Read beginning of contents
|
||||||
char listDelimiter = is.readBeginList("ILList<LListBase, T>");
|
char delimiter = is.readBeginList("ILList<LListBase, T>");
|
||||||
|
|
||||||
if (s)
|
if (s)
|
||||||
{
|
{
|
||||||
if (listDelimiter == token::BEGIN_LIST)
|
if (delimiter == token::BEGIN_LIST)
|
||||||
{
|
{
|
||||||
for (label i=0; i<s; i++)
|
for (label i=0; i<s; i++)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -61,11 +61,11 @@ Foam::Istream& Foam::operator>>(Istream& is, LList<LListBase, T>& L)
|
|||||||
label s = firstToken.labelToken();
|
label s = firstToken.labelToken();
|
||||||
|
|
||||||
// Read beginning of contents
|
// Read beginning of contents
|
||||||
char listDelimiter = is.readBeginList("LList<LListBase, T>");
|
char delimiter = is.readBeginList("LList<LListBase, T>");
|
||||||
|
|
||||||
if (s)
|
if (s)
|
||||||
{
|
{
|
||||||
if (listDelimiter == token::BEGIN_LIST)
|
if (delimiter == token::BEGIN_LIST)
|
||||||
{
|
{
|
||||||
for (register label i=0; i<s; i++)
|
for (register label i=0; i<s; i++)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -53,11 +53,11 @@ void Foam::LPtrList<LListBase, T>::read(Istream& is, const INew& iNew)
|
|||||||
label s = firstToken.labelToken();
|
label s = firstToken.labelToken();
|
||||||
|
|
||||||
// Read beginning of contents
|
// Read beginning of contents
|
||||||
char listDelimiter = is.readBeginList("LPtrList<LListBase, T>");
|
char delimiter = is.readBeginList("LPtrList<LListBase, T>");
|
||||||
|
|
||||||
if (s)
|
if (s)
|
||||||
{
|
{
|
||||||
if (listDelimiter == token::BEGIN_LIST)
|
if (delimiter == token::BEGIN_LIST)
|
||||||
{
|
{
|
||||||
for (label i=0; i<s; i++)
|
for (label i=0; i<s; i++)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -111,6 +111,9 @@ public:
|
|||||||
// Also constructs from DynamicList with different sizing parameters.
|
// Also constructs from DynamicList with different sizing parameters.
|
||||||
explicit inline DynamicList(const UList<T>&);
|
explicit inline DynamicList(const UList<T>&);
|
||||||
|
|
||||||
|
//- Construct from UIndirectList. Size set to UIndirectList size.
|
||||||
|
explicit inline DynamicList(const UIndirectList<T>&);
|
||||||
|
|
||||||
//- Construct by transferring the parameter contents
|
//- Construct by transferring the parameter contents
|
||||||
explicit inline DynamicList(const Xfer< List<T> >&);
|
explicit inline DynamicList(const Xfer< List<T> >&);
|
||||||
|
|
||||||
@ -178,11 +181,14 @@ public:
|
|||||||
// Member Operators
|
// Member Operators
|
||||||
|
|
||||||
//- Append an element at the end of the list
|
//- Append an element at the end of the list
|
||||||
inline void append(const T& e);
|
inline void append(const T&);
|
||||||
|
|
||||||
//- Append a List at the end of this list
|
//- Append a List at the end of this list
|
||||||
inline void append(const UList<T>&);
|
inline void append(const UList<T>&);
|
||||||
|
|
||||||
|
//- Append a UIndirectList at the end of this list
|
||||||
|
inline void append(const UIndirectList<T>&);
|
||||||
|
|
||||||
//- Remove and return the top element
|
//- Remove and return the top element
|
||||||
inline T remove();
|
inline T remove();
|
||||||
|
|
||||||
@ -198,7 +204,7 @@ public:
|
|||||||
const DynamicList<T, SizeInc, SizeMult, SizeDiv>&
|
const DynamicList<T, SizeInc, SizeMult, SizeDiv>&
|
||||||
);
|
);
|
||||||
|
|
||||||
//- Assignment from List<T>.
|
//- Assignment from UList
|
||||||
inline void operator=(const UList<T>&);
|
inline void operator=(const UList<T>&);
|
||||||
|
|
||||||
// IOstream operators
|
// IOstream operators
|
||||||
|
|||||||
@ -72,6 +72,17 @@ inline Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::DynamicList
|
|||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv>
|
||||||
|
inline Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::DynamicList
|
||||||
|
(
|
||||||
|
const UIndirectList<T>& lst
|
||||||
|
)
|
||||||
|
:
|
||||||
|
List<T>(lst),
|
||||||
|
capacity_(lst.size())
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv>
|
template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv>
|
||||||
inline Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::DynamicList
|
inline Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::DynamicList
|
||||||
(
|
(
|
||||||
@ -313,8 +324,6 @@ inline void Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::append
|
|||||||
const UList<T>& lst
|
const UList<T>& lst
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
label nextFree = List<T>::size();
|
|
||||||
|
|
||||||
if (this == &lst)
|
if (this == &lst)
|
||||||
{
|
{
|
||||||
FatalErrorIn
|
FatalErrorIn
|
||||||
@ -324,6 +333,23 @@ inline void Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::append
|
|||||||
) << "attempted appending to self" << abort(FatalError);
|
) << "attempted appending to self" << abort(FatalError);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
label nextFree = List<T>::size();
|
||||||
|
setSize(nextFree + lst.size());
|
||||||
|
|
||||||
|
forAll(lst, elemI)
|
||||||
|
{
|
||||||
|
this->operator[](nextFree++) = lst[elemI];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv>
|
||||||
|
inline void Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::append
|
||||||
|
(
|
||||||
|
const UIndirectList<T>& lst
|
||||||
|
)
|
||||||
|
{
|
||||||
|
label nextFree = List<T>::size();
|
||||||
setSize(nextFree + lst.size());
|
setSize(nextFree + lst.size());
|
||||||
|
|
||||||
forAll(lst, elemI)
|
forAll(lst, elemI)
|
||||||
|
|||||||
@ -82,9 +82,9 @@ Foam::Istream& Foam::operator>>(Foam::Istream& is, FixedList<T, Size>& L)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Read beginning of contents
|
// Read beginning of contents
|
||||||
char listDelimiter = is.readBeginList("FixedList");
|
char delimiter = is.readBeginList("FixedList");
|
||||||
|
|
||||||
if (listDelimiter == token::BEGIN_LIST)
|
if (delimiter == token::BEGIN_LIST)
|
||||||
{
|
{
|
||||||
for (register unsigned i=0; i<Size; i++)
|
for (register unsigned i=0; i<Size; i++)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -404,61 +404,6 @@ void Foam::List<T>::clear()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class T>
|
|
||||||
void Foam::List<T>::append(const UList<T>& lst)
|
|
||||||
{
|
|
||||||
if (this == &lst)
|
|
||||||
{
|
|
||||||
FatalErrorIn
|
|
||||||
(
|
|
||||||
"List<T>::append(const UList<T>&)"
|
|
||||||
) << "attempted appending to self" << abort(FatalError);
|
|
||||||
}
|
|
||||||
|
|
||||||
label nextFree = this->size_;
|
|
||||||
setSize(nextFree + lst.size());
|
|
||||||
|
|
||||||
forAll(lst, elemI)
|
|
||||||
{
|
|
||||||
this->operator[](nextFree++) = lst[elemI];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
template<class T>
|
|
||||||
void Foam::List<T>::append(const UIndirectList<T>& lst)
|
|
||||||
{
|
|
||||||
label nextFree = this->size_;
|
|
||||||
setSize(nextFree + lst.size());
|
|
||||||
|
|
||||||
forAll(lst, elemI)
|
|
||||||
{
|
|
||||||
this->operator[](nextFree++) = lst[elemI];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
template<class T>
|
|
||||||
void Foam::List<T>::append(const SLList<T>& lst)
|
|
||||||
{
|
|
||||||
if (lst.size())
|
|
||||||
{
|
|
||||||
label nextFree = this->size_;
|
|
||||||
setSize(nextFree + lst.size());
|
|
||||||
|
|
||||||
for
|
|
||||||
(
|
|
||||||
typename SLList<T>::const_iterator iter = lst.begin();
|
|
||||||
iter != lst.end();
|
|
||||||
++iter
|
|
||||||
)
|
|
||||||
{
|
|
||||||
this->operator[](nextFree++) = iter();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Transfer the contents of the argument List into this List
|
// Transfer the contents of the argument List into this List
|
||||||
// and anull the argument list
|
// and anull the argument list
|
||||||
template<class T>
|
template<class T>
|
||||||
|
|||||||
@ -182,24 +182,21 @@ public:
|
|||||||
void clear();
|
void clear();
|
||||||
|
|
||||||
//- Append a List at the end of this list
|
//- Append a List at the end of this list
|
||||||
void append(const UList<T>&);
|
inline void append(const UList<T>&);
|
||||||
|
|
||||||
//- Append a UIndirectList at the end of this list
|
//- Append a UIndirectList at the end of this list
|
||||||
void append(const UIndirectList<T>&);
|
inline void append(const UIndirectList<T>&);
|
||||||
|
|
||||||
//- Append a SLList at the end of this list
|
//- Transfer the contents of the argument List into this list
|
||||||
void append(const SLList<T>&);
|
|
||||||
|
|
||||||
//- Transfer the contents of the argument List into this List
|
|
||||||
// and annull the argument list.
|
// and annull the argument list.
|
||||||
void transfer(List<T>&);
|
void transfer(List<T>&);
|
||||||
|
|
||||||
//- Transfer the contents of the argument List into this List
|
//- Transfer the contents of the argument List into this list
|
||||||
// and annull the argument list.
|
// and annull the argument list.
|
||||||
template<unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv>
|
template<unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv>
|
||||||
void transfer(DynamicList<T, SizeInc, SizeMult, SizeDiv>&);
|
void transfer(DynamicList<T, SizeInc, SizeMult, SizeDiv>&);
|
||||||
|
|
||||||
//- Transfer the contents of the argument List into this List
|
//- Transfer the contents of the argument List into this list
|
||||||
// and annull the argument list.
|
// and annull the argument list.
|
||||||
void transfer(SortableList<T>&);
|
void transfer(SortableList<T>&);
|
||||||
|
|
||||||
|
|||||||
@ -94,6 +94,40 @@ inline Foam::Xfer<Foam::List<T> > Foam::List<T>::xfer()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
inline void Foam::List<T>::append(const UList<T>& lst)
|
||||||
|
{
|
||||||
|
if (this == &lst)
|
||||||
|
{
|
||||||
|
FatalErrorIn
|
||||||
|
(
|
||||||
|
"List<T>::append(const UList<T>&)"
|
||||||
|
) << "attempted appending to self" << abort(FatalError);
|
||||||
|
}
|
||||||
|
|
||||||
|
label nextFree = this->size();
|
||||||
|
setSize(nextFree + lst.size());
|
||||||
|
|
||||||
|
forAll(lst, elemI)
|
||||||
|
{
|
||||||
|
this->operator[](nextFree++) = lst[elemI];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
inline void Foam::List<T>::append(const UIndirectList<T>& lst)
|
||||||
|
{
|
||||||
|
label nextFree = this->size();
|
||||||
|
setSize(nextFree + lst.size());
|
||||||
|
|
||||||
|
forAll(lst, elemI)
|
||||||
|
{
|
||||||
|
this->operator[](nextFree++) = lst[elemI];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
|
|||||||
@ -76,11 +76,11 @@ Foam::Istream& Foam::operator>>(Istream& is, List<T>& L)
|
|||||||
if (is.format() == IOstream::ASCII || !contiguous<T>())
|
if (is.format() == IOstream::ASCII || !contiguous<T>())
|
||||||
{
|
{
|
||||||
// Read beginning of contents
|
// Read beginning of contents
|
||||||
char listDelimiter = is.readBeginList("List");
|
char delimiter = is.readBeginList("List");
|
||||||
|
|
||||||
if (s)
|
if (s)
|
||||||
{
|
{
|
||||||
if (listDelimiter == token::BEGIN_LIST)
|
if (delimiter == token::BEGIN_LIST)
|
||||||
{
|
{
|
||||||
for (register label i=0; i<s; i++)
|
for (register label i=0; i<s; i++)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -54,11 +54,11 @@ void Foam::PtrList<T>::read(Istream& is, const INew& inewt)
|
|||||||
setSize(s);
|
setSize(s);
|
||||||
|
|
||||||
// Read beginning of contents
|
// Read beginning of contents
|
||||||
char listDelimiter = is.readBeginList("PtrList");
|
char delimiter = is.readBeginList("PtrList");
|
||||||
|
|
||||||
if (s)
|
if (s)
|
||||||
{
|
{
|
||||||
if (listDelimiter == token::BEGIN_LIST)
|
if (delimiter == token::BEGIN_LIST)
|
||||||
{
|
{
|
||||||
forAll(*this, i)
|
forAll(*this, i)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -177,7 +177,7 @@ inline Cmpt det(const SphericalTensor<Cmpt>& st)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//- Return the inverse of a symmetric tensor
|
//- Return the inverse of a spherical tensor
|
||||||
template <class Cmpt>
|
template <class Cmpt>
|
||||||
inline SphericalTensor<Cmpt> inv(const SphericalTensor<Cmpt>& st)
|
inline SphericalTensor<Cmpt> inv(const SphericalTensor<Cmpt>& st)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -256,7 +256,7 @@ inline Cmpt magSqr(const SymmTensor<Cmpt>& st)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//- Return the strace of a symmetric tensor
|
//- Return the trace of a symmetric tensor
|
||||||
template <class Cmpt>
|
template <class Cmpt>
|
||||||
inline Cmpt tr(const SymmTensor<Cmpt>& st)
|
inline Cmpt tr(const SymmTensor<Cmpt>& st)
|
||||||
{
|
{
|
||||||
@ -280,7 +280,7 @@ inline const SymmTensor<Cmpt>& symm(const SymmTensor<Cmpt>& st)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//- Return the stwice the symmetric part of a symmetric tensor
|
//- Return twice the symmetric part of a symmetric tensor
|
||||||
template <class Cmpt>
|
template <class Cmpt>
|
||||||
inline SymmTensor<Cmpt> twoSymm(const SymmTensor<Cmpt>& st)
|
inline SymmTensor<Cmpt> twoSymm(const SymmTensor<Cmpt>& st)
|
||||||
{
|
{
|
||||||
@ -361,7 +361,7 @@ inline SymmTensor<Cmpt> inv(const SymmTensor<Cmpt>& st)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//- Return the 1spt invariant of a symmetric tensor
|
//- Return the 1st invariant of a symmetric tensor
|
||||||
template <class Cmpt>
|
template <class Cmpt>
|
||||||
inline Cmpt invariantI(const SymmTensor<Cmpt>& st)
|
inline Cmpt invariantI(const SymmTensor<Cmpt>& st)
|
||||||
{
|
{
|
||||||
@ -453,13 +453,8 @@ operator&(const SphericalTensor<Cmpt>& spt1, const SymmTensor<Cmpt>& st2)
|
|||||||
{
|
{
|
||||||
return SymmTensor<Cmpt>
|
return SymmTensor<Cmpt>
|
||||||
(
|
(
|
||||||
spt1.ii()*st2.xx(),
|
spt1.ii()*st2.xx(), spt1.ii()*st2.xy(), spt1.ii()*st2.xz(),
|
||||||
spt1.ii()*st2.xy(),
|
spt1.ii()*st2.yy(), spt1.ii()*st2.yz(),
|
||||||
spt1.ii()*st2.xz(),
|
|
||||||
|
|
||||||
spt1.ii()*st2.yy(),
|
|
||||||
spt1.ii()*st2.yz(),
|
|
||||||
|
|
||||||
spt1.ii()*st2.zz()
|
spt1.ii()*st2.zz()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -472,13 +467,8 @@ operator&(const SymmTensor<Cmpt>& st1, const SphericalTensor<Cmpt>& spt2)
|
|||||||
{
|
{
|
||||||
return SymmTensor<Cmpt>
|
return SymmTensor<Cmpt>
|
||||||
(
|
(
|
||||||
st1.xx()*spt2.ii(),
|
st1.xx()*spt2.ii(), st1.xy()*spt2.ii(), st1.xz()*spt2.ii(),
|
||||||
st1.xy()*spt2.ii(),
|
st1.yy()*spt2.ii(), st1.yz()*spt2.ii(),
|
||||||
st1.xz()*spt2.ii(),
|
|
||||||
|
|
||||||
st1.yy()*spt2.ii(),
|
|
||||||
st1.yz()*spt2.ii(),
|
|
||||||
|
|
||||||
st1.zz()*spt2.ii()
|
st1.zz()*spt2.ii()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -25,7 +25,6 @@ License
|
|||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#include "symmTensor.H"
|
#include "symmTensor.H"
|
||||||
#include "mathematicalConstants.H"
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
|||||||
@ -402,7 +402,7 @@ inline SymmTensor<Cmpt> symm(const Tensor<Cmpt>& t)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//- Return the twice the symmetric part of a tensor
|
//- Return twice the symmetric part of a tensor
|
||||||
template <class Cmpt>
|
template <class Cmpt>
|
||||||
inline SymmTensor<Cmpt> twoSymm(const Tensor<Cmpt>& t)
|
inline SymmTensor<Cmpt> twoSymm(const Tensor<Cmpt>& t)
|
||||||
{
|
{
|
||||||
@ -609,17 +609,9 @@ operator&(const SphericalTensor<Cmpt>& st1, const Tensor<Cmpt>& t2)
|
|||||||
{
|
{
|
||||||
return Tensor<Cmpt>
|
return Tensor<Cmpt>
|
||||||
(
|
(
|
||||||
st1.ii()*t2.xx(),
|
st1.ii()*t2.xx(), st1.ii()*t2.xy(), st1.ii()*t2.xz(),
|
||||||
st1.ii()*t2.xy(),
|
st1.ii()*t2.yx(), st1.ii()*t2.yy(), st1.ii()*t2.yz(),
|
||||||
st1.ii()*t2.xz(),
|
st1.ii()*t2.zx(), st1.ii()*t2.zy(), st1.ii()*t2.zz()
|
||||||
|
|
||||||
st1.ii()*t2.yx(),
|
|
||||||
st1.ii()*t2.yy(),
|
|
||||||
st1.ii()*t2.yz(),
|
|
||||||
|
|
||||||
st1.ii()*t2.zx(),
|
|
||||||
st1.ii()*t2.zy(),
|
|
||||||
st1.ii()*t2.zz()
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -631,17 +623,9 @@ operator&(const Tensor<Cmpt>& t1, const SphericalTensor<Cmpt>& st2)
|
|||||||
{
|
{
|
||||||
return Tensor<Cmpt>
|
return Tensor<Cmpt>
|
||||||
(
|
(
|
||||||
t1.xx()*st2.ii(),
|
t1.xx()*st2.ii(), t1.xy()*st2.ii(), t1.xz()*st2.ii(),
|
||||||
t1.xy()*st2.ii(),
|
t1.yx()*st2.ii(), t1.yy()*st2.ii(), t1.yz()*st2.ii(),
|
||||||
t1.xz()*st2.ii(),
|
t1.zx()*st2.ii(), t1.zy()*st2.ii(), t1.zz()*st2.ii()
|
||||||
|
|
||||||
t1.yx()*st2.ii(),
|
|
||||||
t1.yy()*st2.ii(),
|
|
||||||
t1.yz()*st2.ii(),
|
|
||||||
|
|
||||||
t1.zx()*st2.ii(),
|
|
||||||
t1.zy()*st2.ii(),
|
|
||||||
t1.zz()*st2.ii()
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -51,13 +51,13 @@ namespace Foam
|
|||||||
|
|
||||||
typedef Tensor<scalar> tensor;
|
typedef Tensor<scalar> tensor;
|
||||||
|
|
||||||
vector eigenValues(const tensor& t);
|
vector eigenValues(const tensor&);
|
||||||
vector eigenVector(const tensor& t, const scalar lambda);
|
vector eigenVector(const tensor&, const scalar lambda);
|
||||||
tensor eigenVectors(const tensor& t);
|
tensor eigenVectors(const tensor&);
|
||||||
|
|
||||||
vector eigenValues(const symmTensor& t);
|
vector eigenValues(const symmTensor&);
|
||||||
vector eigenVector(const symmTensor& t, const scalar lambda);
|
vector eigenVector(const symmTensor&, const scalar lambda);
|
||||||
tensor eigenVectors(const symmTensor& t);
|
tensor eigenVectors(const symmTensor&);
|
||||||
|
|
||||||
//- Data associated with tensor type are contiguous
|
//- Data associated with tensor type are contiguous
|
||||||
template<>
|
template<>
|
||||||
|
|||||||
Reference in New Issue
Block a user