Commit 240e304b authored by sergio's avatar sergio
Browse files

Merge branch 'develop' of develop.openfoam.com:Development/OpenFOAM-plus into develop

parents 543ac077 32a854d2
...@@ -62,15 +62,8 @@ public: ...@@ -62,15 +62,8 @@ public:
{ {
public: public:
class hash struct hash
:
public Hash<interfacePair>
{ {
public:
hash()
{}
label operator()(const interfacePair& key) const label operator()(const interfacePair& key) const
{ {
return word::hash()(key.first()) + word::hash()(key.second()); return word::hash()(key.first()) + word::hash()(key.second());
...@@ -80,8 +73,7 @@ public: ...@@ -80,8 +73,7 @@ public:
// Constructors // Constructors
interfacePair() interfacePair() {} // = default
{}
interfacePair(const word& alpha1Name, const word& alpha2Name) interfacePair(const word& alpha1Name, const word& alpha2Name)
: :
......
...@@ -74,30 +74,16 @@ public: ...@@ -74,30 +74,16 @@ public:
{ {
public: public:
class symmHash struct symmHash
:
public Hash<interfacePair>
{ {
public:
symmHash()
{}
label operator()(const interfacePair& key) const label operator()(const interfacePair& key) const
{ {
return word::hash()(key.first()) + word::hash()(key.second()); return word::hash()(key.first()) + word::hash()(key.second());
} }
}; };
class hash struct hash
:
public Hash<interfacePair>
{ {
public:
hash()
{}
label operator()(const interfacePair& key) const label operator()(const interfacePair& key) const
{ {
return word::hash()(key.first(), word::hash()(key.second())); return word::hash()(key.first(), word::hash()(key.second()));
...@@ -107,8 +93,7 @@ public: ...@@ -107,8 +93,7 @@ public:
// Constructors // Constructors
interfacePair() interfacePair() {} // = default
{}
interfacePair(const word& alpha1Name, const word& alpha2Name) interfacePair(const word& alpha1Name, const word& alpha2Name)
: :
...@@ -233,8 +218,7 @@ public: ...@@ -233,8 +218,7 @@ public:
//- Destructor //- Destructor
virtual ~multiphaseSystem() virtual ~multiphaseSystem() = default;
{}
// Member Functions // Member Functions
......
...@@ -71,15 +71,8 @@ public: ...@@ -71,15 +71,8 @@ public:
{ {
public: public:
class hash struct hash
:
public Hash<interfacePair>
{ {
public:
hash()
{}
label operator()(const interfacePair& key) const label operator()(const interfacePair& key) const
{ {
return word::hash()(key.first()) + word::hash()(key.second()); return word::hash()(key.first()) + word::hash()(key.second());
...@@ -89,8 +82,7 @@ public: ...@@ -89,8 +82,7 @@ public:
// Constructors // Constructors
interfacePair() interfacePair() {} // = default
{}
interfacePair(const word& alpha1Name, const word& alpha2Name) interfacePair(const word& alpha1Name, const word& alpha2Name)
: :
...@@ -196,8 +188,7 @@ public: ...@@ -196,8 +188,7 @@ public:
//- Destructor //- Destructor
virtual ~multiphaseMixture() virtual ~multiphaseMixture() = default;
{}
// Member Functions // Member Functions
......
...@@ -27,14 +27,6 @@ License ...@@ -27,14 +27,6 @@ License
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::phasePairKey::hash::hash()
{}
Foam::phasePairKey::phasePairKey()
{}
Foam::phasePairKey::phasePairKey Foam::phasePairKey::phasePairKey
( (
const word& name1, const word& name1,
...@@ -47,12 +39,6 @@ Foam::phasePairKey::phasePairKey ...@@ -47,12 +39,6 @@ Foam::phasePairKey::phasePairKey
{} {}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::phasePairKey::~phasePairKey()
{}
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
bool Foam::phasePairKey::ordered() const bool Foam::phasePairKey::ordered() const
...@@ -94,13 +80,13 @@ bool Foam::operator== ...@@ -94,13 +80,13 @@ bool Foam::operator==
const phasePairKey& b const phasePairKey& b
) )
{ {
const label c = Pair<word>::compare(a,b); const label cmp = Pair<word>::compare(a,b);
return return
(a.ordered_ == b.ordered_) (a.ordered_ == b.ordered_)
&& ( && (
(a.ordered_ && (c == 1)) (a.ordered_ && (cmp == 1))
|| (!a.ordered_ && (c != 0)) || (!a.ordered_ && (cmp != 0))
); );
} }
...@@ -127,7 +113,7 @@ Foam::Istream& Foam::operator>>(Istream& is, phasePairKey& key) ...@@ -127,7 +113,7 @@ Foam::Istream& Foam::operator>>(Istream& is, phasePairKey& key)
{ {
key.ordered_ = false; key.ordered_ = false;
} }
else if(temp[1] == "in") else if (temp[1] == "in")
{ {
key.ordered_ = true; key.ordered_ = true;
} }
......
...@@ -40,7 +40,7 @@ SourceFiles ...@@ -40,7 +40,7 @@ SourceFiles
namespace Foam namespace Foam
{ {
// Forward declaration of friend functions and operators // Forward declarations
class phasePairKey; class phasePairKey;
...@@ -59,41 +59,24 @@ class phasePairKey ...@@ -59,41 +59,24 @@ class phasePairKey
: :
public Pair<word> public Pair<word>
{ {
public:
class hash
:
public Hash<phasePairKey>
{
public:
// Constructors
// Construct null
hash();
// Member operators
// Generate a hash from a phase pair key
label operator()(const phasePairKey& key) const;
};
private:
// Private data // Private data
//- Flag to indicate whether ordering is important //- Flag to indicate whether ordering is important
bool ordered_; bool ordered_;
public: public:
struct hash
{
// Generate a hash from a phase pair key
label operator()(const phasePairKey& key) const;
};
// Constructors // Constructors
//- Construct null //- Construct null
phasePairKey(); phasePairKey() {} // = default
//- Construct from names and the ordering flag //- Construct from names and the ordering flag
phasePairKey phasePairKey
...@@ -105,7 +88,7 @@ public: ...@@ -105,7 +88,7 @@ public:
// Destructor // Destructor
virtual ~phasePairKey(); virtual ~phasePairKey() = default;
// Access // Access
......
...@@ -27,14 +27,6 @@ License ...@@ -27,14 +27,6 @@ License
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::phasePairKey::hash::hash()
{}
Foam::phasePairKey::phasePairKey()
{}
Foam::phasePairKey::phasePairKey Foam::phasePairKey::phasePairKey
( (
const word& name1, const word& name1,
...@@ -47,12 +39,6 @@ Foam::phasePairKey::phasePairKey ...@@ -47,12 +39,6 @@ Foam::phasePairKey::phasePairKey
{} {}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::phasePairKey::~phasePairKey()
{}
// * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * * //
Foam::label Foam::phasePairKey::hash::operator() Foam::label Foam::phasePairKey::hash::operator()
...@@ -86,13 +72,13 @@ bool Foam::operator== ...@@ -86,13 +72,13 @@ bool Foam::operator==
const phasePairKey& b const phasePairKey& b
) )
{ {
const label c = Pair<word>::compare(a,b); const label cmp = Pair<word>::compare(a,b);
return return
(a.ordered_ == b.ordered_) (a.ordered_ == b.ordered_)
&& ( && (
(a.ordered_ && (c == 1)) (a.ordered_ && (cmp == 1))
|| (!a.ordered_ && (c != 0)) || (!a.ordered_ && (cmp != 0))
); );
} }
...@@ -119,7 +105,7 @@ Foam::Istream& Foam::operator>>(Istream& is, phasePairKey& key) ...@@ -119,7 +105,7 @@ Foam::Istream& Foam::operator>>(Istream& is, phasePairKey& key)
{ {
key.ordered_ = false; key.ordered_ = false;
} }
else if(temp[1] == "in") else if (temp[1] == "in")
{ {
key.ordered_ = true; key.ordered_ = true;
} }
......
...@@ -40,7 +40,7 @@ SourceFiles ...@@ -40,7 +40,7 @@ SourceFiles
namespace Foam namespace Foam
{ {
// Forward declaration of friend functions and operators // Forward declarations
class phasePairKey; class phasePairKey;
...@@ -59,48 +59,36 @@ class phasePairKey ...@@ -59,48 +59,36 @@ class phasePairKey
: :
public Pair<word> public Pair<word>
{ {
public:
class hash
:
public Hash<phasePairKey>
{
public:
// Constructors
// Construct null
hash();
// Member operators
// Generate a hash from a phase pair key
label operator()(const phasePairKey& key) const;
};
private:
// Private data // Private data
//- Flag to indicate whether ordering is important //- Flag to indicate whether ordering is important
bool ordered_; bool ordered_;
public: public:
struct hash
{
// Generate a hash from a phase pair key
label operator()(const phasePairKey& key) const;
};
// Constructors // Constructors
//- Construct null //- Construct null
phasePairKey(); phasePairKey() {} // = default
//- Construct from names and the ordering flag //- Construct from names and the ordering flag
phasePairKey(const word& name1, const word& name2, const bool ordered); phasePairKey
(
const word& name1,
const word& name2,
const bool ordered
);
// Destructor // Destructor
virtual ~phasePairKey(); virtual ~phasePairKey() = default;
// Friend Operators // Friend Operators
......
...@@ -56,7 +56,7 @@ int main(int argc, char *argv[]) ...@@ -56,7 +56,7 @@ int main(int argc, char *argv[])
setA = { "kjhk", "kjhk2", "abced" }; setA = { "kjhk", "kjhk2", "abced" };
HashTable<label, word> tableA HashTable<label> tableA
{ {
{ "value1", 1 }, { "value1", 1 },
{ "value2", 2 }, { "value2", 2 },
......
...@@ -48,6 +48,23 @@ See also ...@@ -48,6 +48,23 @@ See also
#include <list> #include <list>
#include <numeric> #include <numeric>
#include <functional>
namespace Foam
{
// Verify inheritance
class MyStrings
:
public List<string>
{
public:
using List<string>::List;
};
} // end namespace Foam
using namespace Foam; using namespace Foam;
...@@ -66,6 +83,14 @@ void testFind(const T& val, const ListType& lst) ...@@ -66,6 +83,14 @@ void testFind(const T& val, const ListType& lst)
} }
void printMyString(const UList<string>& lst)
{
MyStrings slist2(lst);
Info<<slist2 << nl;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Main program: // Main program:
...@@ -76,6 +101,7 @@ int main(int argc, char *argv[]) ...@@ -76,6 +101,7 @@ int main(int argc, char *argv[])
argList::addOption("wordList", "wordList"); argList::addOption("wordList", "wordList");
argList::addOption("stringList", "stringList"); argList::addOption("stringList", "stringList");
argList::addOption("float", "xx"); argList::addOption("float", "xx");
argList::addBoolOption("transform", "Test List::createList functionality");
argList::addBoolOption("flag"); argList::addBoolOption("flag");
#include "setRootCase.H" #include "setRootCase.H"
...@@ -336,6 +362,85 @@ int main(int argc, char *argv[]) ...@@ -336,6 +362,85 @@ int main(int argc, char *argv[])
Info<<"-flag:" << args["flag"] << endl; Info<<"-flag:" << args["flag"] << endl;
} }
if (args.found("transform"))
{
Info<< nl << "Test List::createList functionality" << nl;
const auto labels = identity(15);
Info<< "labels: " << flatOutput(labels) << endl;
{
auto scalars = List<scalar>::createList
(
labels,
[](const label& val){ return scalar(1.5*val); }