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

This commit is contained in:
mattijs
2017-05-31 09:00:16 +01:00
215 changed files with 2426 additions and 1722 deletions

View File

@ -138,9 +138,7 @@ public:
>> m.orientation_;
is.readEnd("magnet");
// Check state of Istream
is.check("operator>>(Istream&, magnet&)");
is.check(FUNCTION_NAME);
return is;
}

View File

@ -42,13 +42,44 @@ Description
using namespace Foam;
void infoHashString
(
unsigned modulus,
std::initializer_list<std::string> lst
)
{
if (modulus)
{
Info<< "basic string hashing (mod " << label(modulus) << ")" << endl;
for (const auto& str : lst)
{
Info<<"hash(" << str.c_str() << ")="
<< (Hash<string>()(str) % modulus) << nl;
}
}
else
{
Info<< "basic string hashing" << nl;
for (const auto& str : lst)
{
Info<<"hash(" << str.c_str() << ")="
<< Hash<string>()(str) << nl;
}
}
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Main program:
int main(int argc, char *argv[])
{
IFstream is("hashingTests");
infoHashString(8, {"asdathis1", "adsxf", "hij", "klmpq"});
IFstream is("hashingTests");
while (is.good())
{

View File

@ -26,6 +26,7 @@ Description
\*---------------------------------------------------------------------------*/
#include "NamedEnum.H"
#include "Enum.H"
#include "IOstreams.H"
using namespace Foam;
@ -34,15 +35,27 @@ class namedEnumTest
{
public:
enum option
enum class option
{
a,
b,
c,
d
A,
B,
C,
D
};
static const Foam::NamedEnum<option, 4> namedEnum;
enum class otherOption
{
A,
B,
C,
D
};
static const Foam::NamedEnum<option, 4> optionNamed;
static const Foam::Enum<otherOption> optionEnum;
static const Foam::Enum<option> optionEnum2;
};
@ -52,10 +65,25 @@ const char* Foam::NamedEnum<namedEnumTest::option, 4>::names[] =
"a",
"b",
"c",
"d"
"d",
};
const Foam::NamedEnum<namedEnumTest::option, 4> namedEnumTest::namedEnum;
const Foam::NamedEnum<namedEnumTest::option, 4> namedEnumTest::optionNamed;
const Foam::Enum<namedEnumTest::otherOption> namedEnumTest::optionEnum
{
{ namedEnumTest::otherOption::A, "a" },
{ namedEnumTest::otherOption::B, "b" },
{ namedEnumTest::otherOption::C, "c" },
{ namedEnumTest::otherOption::D, "d" },
};
const Foam::Enum<namedEnumTest::option> namedEnumTest::optionEnum2
(
namedEnumTest::option::C,
{ "c", "d" }
);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -63,35 +91,66 @@ const Foam::NamedEnum<namedEnumTest::option, 4> namedEnumTest::namedEnum;
int main(int argc, char *argv[])
{
const List<namedEnumTest::option> options
= namedEnumTest::namedEnum.enums();
Info<<"NamedEnum: " << namedEnumTest::optionNamed << nl;
Info<<"Enum: " << namedEnumTest::optionEnum << nl;
Info<<"Enum: " << namedEnumTest::optionEnum2 << nl;
Info<< "enums: " << options << nl;
Info<< "loop over enums (as list):" << nl;
forAll(options, i)
{
const namedEnumTest::option& opt = options[i];
Info<< "option[" << opt
<< "] = '" << namedEnumTest::namedEnum[opt] << "'" << nl;
}
Info<< "loop over enums (C++11 for range):" << nl;
for (const auto& opt : options)
{
Info<< "option[" << opt
<< "] = '" << namedEnumTest::namedEnum[opt] << "'" << nl;
}
dictionary testDict;
testDict.add("lookup1", "c");
Info<< nl
<< namedEnumTest::namedEnum["a"] << nl
<< namedEnumTest::namedEnum[namedEnumTest::a] << nl;
<< int(namedEnumTest::optionNamed["a"]) << nl
<< namedEnumTest::optionNamed[namedEnumTest::option::A] << nl;
Info<< "--- test read construction ---" << endl;
Info<< nl
<< int(namedEnumTest::optionEnum["a"]) << nl
<< namedEnumTest::optionEnum[namedEnumTest::otherOption::A] << nl;
namedEnumTest::option dummy(namedEnumTest::namedEnum.read(Sin));
Info<< namedEnumTest::namedEnum[dummy] << endl;
Info<< "--- test dictionary lookup ---" << endl;
{
Info<< "dict: " << testDict << endl;
Info<< "got: "
<< int
(
namedEnumTest::optionNamed.lookupOrDefault
(
"notFound",
testDict,
namedEnumTest::option::A
)
)
<< nl;
Info<< "got: "
<< int
(
namedEnumTest::optionNamed.lookupOrDefault
(
"lookup1",
testDict,
namedEnumTest::option::A
)
)
<< nl;
Info<< "got: "
<< int
(
namedEnumTest::optionEnum2.lookupOrDefault
(
"lookup1",
testDict,
namedEnumTest::option::A
)
)
<< nl;
}
Info<< "--- test read ---" << endl;
namedEnumTest::option dummy(namedEnumTest::optionNamed.read(Sin));
Info<< namedEnumTest::optionNamed[dummy] << endl;
Info<< "End\n" << endl;

View File

@ -84,6 +84,12 @@ int main(int argc, char *argv[])
packed.resize(n, 1);
}
Info<< "resize/shrink/resize:" << timer.cpuTimeIncrement() << " s\n\n";
Info<< "packed bool size=" << packed.size() << nl;
// Neither of these should affect the size
packed.unset(2*n-1);
packed.set(2*n-1, 0);
Info<< "packed bool size=" << packed.size() << nl;
// set every other bit on:
Info<< "set every other bit on and count\n";
@ -99,8 +105,8 @@ int main(int argc, char *argv[])
}
}
Info<< "Counting brute-force:" << timer.cpuTimeIncrement()
<< " s" << endl;
Info<< " sum " << sum << endl;
<< " s" << nl
<< " sum " << sum << endl;
// Count packed
@ -110,8 +116,8 @@ int main(int argc, char *argv[])
sum += packed.count();
}
Info<< "Counting via count():" << timer.cpuTimeIncrement()
<< " s" << endl;
Info<< " sum " << sum << endl;
<< " s" << nl
<< " sum " << sum << endl;
// Dummy addition
@ -123,8 +129,8 @@ int main(int argc, char *argv[])
sum += i + 1;
}
}
Info<< "Dummy loop:" << timer.cpuTimeIncrement() << " s" << endl;
Info<< " sum " << sum << endl;
Info<< "Dummy loop:" << timer.cpuTimeIncrement() << " s" << nl
<< " sum " << sum << " (sum is meaningless)" << endl;
//
// Read
@ -139,8 +145,8 @@ int main(int argc, char *argv[])
sum += stlVector[i];
}
}
Info<< "Reading stl:" << timer.cpuTimeIncrement() << " s" << endl;
Info<< " sum " << sum << endl;
Info<< "Reading stl:" << timer.cpuTimeIncrement() << " s" << nl
<< " sum " << sum << endl;
// Read unpacked
@ -152,8 +158,8 @@ int main(int argc, char *argv[])
sum += unpacked[i];
}
}
Info<< "Reading unpacked:" << timer.cpuTimeIncrement() << " s" << endl;
Info<< " sum " << sum << endl;
Info<< "Reading unpacked:" << timer.cpuTimeIncrement() << " s" << nl
<< " sum " << sum << endl;
// Read packed
@ -166,8 +172,8 @@ int main(int argc, char *argv[])
}
}
Info<< "Reading packed using get:" << timer.cpuTimeIncrement()
<< " s" << endl;
Info<< " sum " << sum << endl;
<< " s" << nl
<< " sum " << sum << endl;
// Read packed
@ -180,8 +186,8 @@ int main(int argc, char *argv[])
}
}
Info<< "Reading packed using reference:" << timer.cpuTimeIncrement()
<< " s" << endl;
Info<< " sum " << sum << endl;
<< " s" << nl
<< " sum " << sum << endl;
// Read via iterator
@ -194,8 +200,8 @@ int main(int argc, char *argv[])
}
}
Info<< "Reading packed using iterator:" << timer.cpuTimeIncrement()
<< " s" << endl;
Info<< " sum " << sum << endl;
<< " s" << nl
<< " sum " << sum << endl;
// Read via iterator
@ -208,8 +214,8 @@ int main(int argc, char *argv[])
}
}
Info<< "Reading packed using const_iterator():" << timer.cpuTimeIncrement()
<< " s" << endl;
Info<< " sum " << sum << endl;
<< " s" << nl
<< " sum " << sum << endl;
// Read empty hash
@ -222,8 +228,8 @@ int main(int argc, char *argv[])
}
}
Info<< "Reading empty labelHashSet:" << timer.cpuTimeIncrement()
<< " s" << endl;
Info<< " sum " << sum << endl;
<< " s" << nl
<< " sum " << sum << endl;
// Read full hash
@ -236,8 +242,8 @@ int main(int argc, char *argv[])
}
}
Info<< "Reading full labelHashSet:" << timer.cpuTimeIncrement()
<< " s" << endl;
Info<< " sum " << sum << endl;
<< " s" << nl
<< " sum " << sum << endl;
// Read empty static hash
@ -250,8 +256,8 @@ int main(int argc, char *argv[])
}
}
Info<< "Reading empty StaticHash:" << timer.cpuTimeIncrement()
<< " s" << endl;
Info<< " sum " << sum << endl;
<< " s" << nl
<< " sum " << sum << endl;
#if 0
// we can skip this test - it is usually quite slow
@ -265,8 +271,8 @@ int main(int argc, char *argv[])
}
}
Info<< "Reading full StaticHash:" << timer.cpuTimeIncrement()
<< " s" << endl;
Info<< " sum " << sum << endl;
<< " s" << nl
<< " sum " << sum << endl;
#endif
Info<< "Starting write tests" << endl;
@ -319,7 +325,6 @@ int main(int argc, char *argv[])
Info<< "Writing packed using set:" << timer.cpuTimeIncrement()
<< " s" << endl;
// Write packed
for (label iter = 0; iter < nIters; ++iter)
{

View File

@ -44,22 +44,9 @@ void Foam::DelaunayMeshTools::writeOBJ
OFstream str(fName);
Pout<< nl
<< "Writing points of types:" << nl;
forAllConstIter
(
HashTable<int>,
indexedVertexEnum::vertexTypeNames_,
iter
)
{
if (iter() >= startPointType && iter() <= endPointType)
{
Pout<< " " << iter.key() << nl;
}
}
Pout<< "to " << str.name() << endl;
<< "Writing points of types ("
<< int(startPointType) << "-" << int(endPointType)
<< ") to " << str.name() << endl;
for
(
@ -265,7 +252,7 @@ void Foam::DelaunayMeshTools::drawDelaunayCell
<< "f " << 1 + offset << " " << 4 + offset << " " << 3 + offset << nl
<< "f " << 1 + offset << " " << 2 + offset << " " << 4 + offset << endl;
// os << "# cicumcentre " << endl;
// os << "# circumcentre " << endl;
// meshTools::writeOBJ(os, c->dual());

View File

@ -900,12 +900,10 @@ void Foam::conformalVoronoiMesh::writeMesh
mesh.addFvPatches(patches);
// Add zones to the mesh
addZones(mesh, cellCentres);
Info<< indent << "Add pointZones" << endl;
{
label sz = mesh.pointZones().size();
@ -914,6 +912,9 @@ void Foam::conformalVoronoiMesh::writeMesh
forAll(dualMeshPointTypeNames_, typeI)
{
const word& znName =
dualMeshPointTypeNames_[dualMeshPointType(typeI)];
forAll(boundaryPts, ptI)
{
const label& bPtType = boundaryPts[ptI];
@ -928,14 +929,14 @@ void Foam::conformalVoronoiMesh::writeMesh
Info<< incrIndent << indent
<< "Adding " << bPts.size()
<< " points of type " << dualMeshPointTypeNames_.words()[typeI]
<< " points of type " << znName
<< decrIndent << endl;
mesh.pointZones().append
(
new pointZone
(
dualMeshPointTypeNames_.words()[typeI],
znName,
bPts,
sz + typeI,
mesh.pointZones()

View File

@ -229,7 +229,7 @@ int main(int argc, char *argv[])
word patchMapMethod;
if (meshToMesh::interpolationMethodNames_.found(mapMethod))
if (meshToMesh::interpolationMethodNames_.hasEnum(mapMethod))
{
// Lookup corresponding AMI method
meshToMesh::interpolationMethod method =

View File

@ -35,8 +35,7 @@ Foam::CLASSNAME::CLASSNAME(Istream& is)
member1(is),
member2(is)
{
// Check state of Istream
is.check("Foam::CLASSNAME::CLASSNAME(Foam::Istream&)");
is.check(FUNCTION_NAME);
}
@ -44,25 +43,14 @@ Foam::CLASSNAME::CLASSNAME(Istream& is)
Foam::Istream& Foam::operator>>(Istream& is, CLASSNAME&)
{
// Check state of Istream
is.check
(
"Foam::Istream& Foam::operator>>(Foam::Istream&, Foam::CLASSNAME&)"
);
is.check(FUNCTION_NAME);
return is;
}
Foam::Ostream& Foam::operator<<(Ostream& os, const CLASSNAME&)
{
// Check state of Ostream
os.check
(
"Foam::Ostream& Foam::operator<<(Foam::Ostream&, "
"const Foam::CLASSNAME&)"
);
os.check(FUNCTION_NAME);
return os;
}

View File

@ -36,8 +36,7 @@ Foam::CLASSNAME<TemplateArgument>::CLASSNAME(Istream& is)
member1(is),
member2(is)
{
// Check state of Istream
is.check("Foam::CLASSNAME<TemplateArgument>::CLASSNAME(Foam::Istream&)");
is.check(FUNCTION_NAME);
}
@ -50,13 +49,7 @@ Foam::Istream& Foam::operator>>
CLASSNAME<TemplateArgument>&
)
{
// Check state of Istream
is.check
(
"Foam::Istream& Foam::operator>>"
"(Foam::Istream&, Foam::CLASSNAME<TemplateArgument>&)"
);
is.check(FUNCTION_NAME);
return is;
}
@ -68,13 +61,7 @@ Foam::Ostream& Foam::operator<<
const CLASSNAME<TemplateArgument>&
)
{
// Check state of Ostream
os.check
(
"Foam::Ostream& Foam::operator<<"
"(Ostream&, const CLASSNAME<TemplateArgument>&)"
);
os.check(FUNCTION_NAME);
return os;
}

View File

@ -51,8 +51,8 @@
#------------------------------------------------------------------------------
# USER EDITABLE PART: Changes made here may be lost with the next upgrade
set boost_version=boost_1_62_0
set cgal_version=CGAL-4.9
set boost_version=boost_1_64_0
set cgal_version=CGAL-4.9.1
setenv BOOST_ARCH_PATH $WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER/$boost_version
setenv CGAL_ARCH_PATH $WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER/$cgal_version

View File

@ -66,6 +66,9 @@ case ThirdParty:
case Gcc63:
set gcc_version=gcc-6.3.0
breaksw
case Gcc71:
set gcc_version=gcc-7.1.0
breaksw
case Clang:
set clang_version=llvm-3.7.1
breaksw

View File

@ -50,8 +50,8 @@
#------------------------------------------------------------------------------
# USER EDITABLE PART: Changes made here may be lost with the next upgrade
boost_version=boost_1_62_0
cgal_version=CGAL-4.9
boost_version=boost_1_64_0
cgal_version=CGAL-4.9.1
export BOOST_ARCH_PATH=$WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER/$boost_version
export CGAL_ARCH_PATH=$WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER/$cgal_version

View File

@ -65,6 +65,9 @@ ThirdParty)
Gcc63)
gcc_version=gcc-6.3.0
;;
Gcc71)
gcc_version=gcc-7.1.0
;;
Clang)
clang_version=llvm-3.7.1
;;

View File

@ -770,7 +770,7 @@ bool Foam::cp(const fileName& src, const fileName& dest, const bool followLink)
// If dest is a directory, create the destination file name.
if (destFile.type() == fileName::DIRECTORY)
{
destFile = destFile/src.component(src.components().size() -1);
destFile = destFile/src.components().last();
}
// Make sure the destination directory exists.
@ -943,7 +943,7 @@ bool Foam::mvBak(const fileName& src, const std::string& ext)
}
}
// fall-through: nothing to do
// fallthrough: nothing to do
return false;
}

View File

@ -123,9 +123,7 @@ Foam::Istream& Foam::operator>>(Istream& is, fileStat& fStat)
fStat.status_.st_mtime = stat[11];
fStat.status_.st_ctime = stat[12];
// Check state of Istream
is.check("Istream& operator>>(Istream&, fileStat&)");
is.check(FUNCTION_NAME);
return is;
}

View File

@ -118,12 +118,7 @@ Foam::Istream& Foam::operator>>(Istream& is, memInfo& m)
is.readEnd("memInfo");
// Check state of Istream
is.check
(
"Foam::Istream& Foam::operator>>(Foam::Istream&, Foam::memInfo&)"
);
is.check(FUNCTION_NAME);
return is;
}
@ -136,12 +131,7 @@ Foam::Ostream& Foam::operator<<(Ostream& os, const memInfo& m)
<< m.rss_
<< token::END_LIST;
// Check state of Ostream
os.check
(
"Foam::Ostream& Foam::operator<<(Foam::Ostream&, const Foam::memInfo&)"
);
os.check(FUNCTION_NAME);
return os;
}

View File

@ -61,9 +61,7 @@ Foam::Istream& Foam::operator>>(Istream& is, volumeType& vt)
// Read end of volumeType
is.readEnd("volumeType");
// Check state of Istream
is.check("operator>>(Istream&, volumeType&)");
is.check(FUNCTION_NAME);
return is;
}

View File

@ -29,7 +29,6 @@ License
#include "HashTable.H"
#include "List.H"
#include "FixedList.H"
#include "Tuple2.H"
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
@ -74,7 +73,7 @@ Foam::HashTable<T, Key, Hash>::HashTable(const label size)
{
table_ = new hashedEntry*[tableSize_];
for (label hashIdx = 0; hashIdx < tableSize_; hashIdx++)
for (label hashIdx = 0; hashIdx < tableSize_; ++hashIdx)
{
table_[hashIdx] = nullptr;
}
@ -112,14 +111,14 @@ Foam::HashTable<T, Key, Hash>::HashTable
template<class T, class Key, class Hash>
Foam::HashTable<T, Key, Hash>::HashTable
(
std::initializer_list<Tuple2<Key, T>> lst
std::initializer_list<std::pair<Key, T>> lst
)
:
HashTable<T, Key, Hash>(2*lst.size())
{
for (const Tuple2<Key, T>& pair : lst)
for (const auto& pair : lst)
{
insert(pair.first(), pair.second());
insert(pair.first, pair.second);
}
}
@ -203,6 +202,17 @@ Foam::HashTable<T, Key, Hash>::find
(
const Key& key
) const
{
return this->cfind(key);
}
template<class T, class Key, class Hash>
typename Foam::HashTable<T, Key, Hash>::const_iterator
Foam::HashTable<T, Key, Hash>::cfind
(
const Key& key
) const
{
if (nElmts_)
{
@ -878,7 +888,7 @@ void Foam::HashTable<T, Key, Hash>::operator=
template<class T, class Key, class Hash>
void Foam::HashTable<T, Key, Hash>::operator=
(
std::initializer_list<Tuple2<Key, T>> lst
std::initializer_list<std::pair<Key, T>> lst
)
{
// Could be zero-sized from a previous transfer()
@ -893,7 +903,7 @@ void Foam::HashTable<T, Key, Hash>::operator=
for (const auto& pair : lst)
{
insert(pair.first(), pair.second());
insert(pair.first, pair.second);
}
}
@ -912,7 +922,7 @@ bool Foam::HashTable<T, Key, Hash>::operator==
for (const_iterator iter = rhs.cbegin(); iter != rhs.cend(); ++iter)
{
const_iterator other = find(iter.key());
const_iterator other = this->cfind(iter.key());
if (!other.found() || other.object() != iter.object())
{

View File

@ -57,11 +57,13 @@ SourceFiles
#include "uLabel.H"
#include "word.H"
#include "Xfer.H"
#include "Hash.H"
#include "className.H"
#include "nullObject.H"
#include <initializer_list>
#include <iterator>
#include <utility>
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -73,7 +75,6 @@ namespace Foam
template<class T> class List;
template<class T> class UList;
template<class T, unsigned Size> class FixedList;
template<class T1, class T2> class Tuple2;
template<class T, class Key, class Hash> class HashTable;
template<class T, class Key, class Hash>
@ -212,7 +213,7 @@ private:
// Private data type for table entries
//- Structure to hold a hashed entry, with a SLList for collisions
//- Structure to hold a hashed entry, with a linked-list for collisions
struct hashedEntry
{
//- The lookup key
@ -224,7 +225,7 @@ private:
//- Pointer to next hashedEntry in sub-list
hashedEntry* next_;
//- Construct from key, next pointer and object
//- Construct from key, object, next pointer
inline hashedEntry(const Key& key, const T& obj, hashedEntry* next);
private:
@ -296,7 +297,7 @@ public:
HashTable(const Xfer<HashTable<T, Key, Hash>>& ht);
//- Construct from an initializer list
HashTable(std::initializer_list<Tuple2<Key, T>> lst);
HashTable(std::initializer_list<std::pair<Key, T>> lst);
//- Destructor
@ -327,6 +328,10 @@ public:
// If not found iterator = end()
const_iterator find(const Key& key) const;
//- Find and return an const_iterator set at the hashed entry
// If not found iterator = end()
const_iterator cfind(const Key& key) const;
//- Return hashed entry if it exists, or return the given default
inline const T& lookup(const Key& key, const T& deflt) const;
@ -554,7 +559,7 @@ public:
void operator=(const HashTable<T, Key, Hash>& rhs);
//- Assignment from an initializer list
void operator=(std::initializer_list<Tuple2<Key, T>> lst);
void operator=(std::initializer_list<std::pair<Key, T>> lst);
//- Equality. Hash tables are equal if the keys and values are equal.
// Independent of table storage size and table order.

View File

@ -129,9 +129,7 @@ Foam::Ostream& Foam::HashTable<T, Key, Hash>::writeKeys
os << token::END_LIST << nl; // End delimiter
}
// Check state of IOstream
os.check(FUNCTION_NAME);
return os;
}
@ -145,12 +143,12 @@ Foam::Istream& Foam::operator>>
HashTable<T, Key, Hash>& L
)
{
is.fatalCheck("operator>>(Istream&, HashTable<T, Key, Hash>&)");
is.fatalCheck(FUNCTION_NAME);
// Anull list
L.clear();
is.fatalCheck("operator>>(Istream&, HashTable<T, Key, Hash>&)");
is.fatalCheck(FUNCTION_NAME);
token firstToken(is);
@ -251,7 +249,7 @@ Foam::Istream& Foam::operator>>
<< exit(FatalIOError);
}
is.fatalCheck("operator>>(Istream&, HashTable<T, Key, Hash>&)");
is.fatalCheck(FUNCTION_NAME);
return is;
}
@ -278,9 +276,7 @@ Foam::Ostream& Foam::operator<<
// Write end delimiter
os << token::END_LIST;
// Check state of IOstream
os.check(FUNCTION_NAME);
return os;
}

View File

@ -96,7 +96,7 @@ public:
{}
//- Construct from an initializer list
Map(std::initializer_list<Tuple2<label, T>> map)
Map(std::initializer_list<std::pair<label, T>> map)
:
parent_type(map)
{}

View File

@ -158,6 +158,17 @@ Foam::StaticHashTable<T, Key, Hash>::find
(
const Key& key
) const
{
return this->cfind(key);
}
template<class T, class Key, class Hash>
typename Foam::StaticHashTable<T, Key, Hash>::const_iterator
Foam::StaticHashTable<T, Key, Hash>::cfind
(
const Key& key
) const
{
if (nElmts_)
{

View File

@ -203,6 +203,10 @@ public:
// If not found iterator = end()
const_iterator find(const Key& key) const;
//- Find and return an const_iterator set at the hashed entry
// If not found iterator = end()
const_iterator cfind(const Key& key) const;
//- Return the table of contents
List<Key> toc() const;

View File

@ -94,12 +94,12 @@ Foam::StaticHashTable<T, Key, Hash>::printInfo(Ostream& os) const
template<class T, class Key, class Hash>
Foam::Istream& Foam::operator>>(Istream& is, StaticHashTable<T, Key, Hash>& L)
{
is.fatalCheck("operator>>(Istream&, StaticHashTable<T, Key, Hash>&)");
is.fatalCheck(FUNCTION_NAME);
// Anull list
L.clear();
is.fatalCheck("operator>>(Istream&, StaticHashTable<T, Key, Hash>&)");
is.fatalCheck(FUNCTION_NAME);
token firstToken(is);
@ -200,7 +200,7 @@ Foam::Istream& Foam::operator>>(Istream& is, StaticHashTable<T, Key, Hash>& L)
<< exit(FatalIOError);
}
is.fatalCheck("operator>>(Istream&, StaticHashTable<T, Key, Hash>&)");
is.fatalCheck(FUNCTION_NAME);
return is;
}
@ -229,9 +229,7 @@ Foam::Ostream& Foam::operator<<
// Write end delimiter
os << token::END_LIST;
// Check state of IOstream
os.check("Ostream& operator<<(Ostream&, const StaticHashTable&)");
os.check(FUNCTION_NAME);
return os;
}

View File

@ -125,9 +125,7 @@ inline Foam::Istream& Foam::operator>>(Istream& is, Keyed<T>& item)
// Read end of Keyed item/key pair
is.readEnd("Keyed<T>");
// Check state of Ostream
is.check("Istream& operator>>(Istream&, Keyed&)");
is.check(FUNCTION_NAME);
return is;
}

View File

@ -33,7 +33,7 @@ template<class LListBase, class T>
template<class INew>
void Foam::ILList<LListBase, T>::read(Istream& is, const INew& iNew)
{
is.fatalCheck("operator>>(Istream&, ILList<LListBase, T>&)");
is.fatalCheck(FUNCTION_NAME);
token firstToken(is);
@ -97,7 +97,7 @@ void Foam::ILList<LListBase, T>::read(Istream& is, const INew& iNew)
}
token lastToken(is);
is.fatalCheck("operator>>(Istream&, ILList<LListBase, T>&)");
is.fatalCheck(FUNCTION_NAME);
while
(
@ -111,7 +111,7 @@ void Foam::ILList<LListBase, T>::read(Istream& is, const INew& iNew)
this->append(iNew(is).ptr());
is >> lastToken;
is.fatalCheck("operator>>(Istream&, ILList<LListBase, T>&)");
is.fatalCheck(FUNCTION_NAME);
}
}
else
@ -122,7 +122,7 @@ void Foam::ILList<LListBase, T>::read(Istream& is, const INew& iNew)
<< exit(FatalIOError);
}
is.fatalCheck("operator>>(Istream&, ILList<LListBase, T>&)");
is.fatalCheck(FUNCTION_NAME);
}

View File

@ -44,7 +44,7 @@ Foam::Istream& Foam::operator>>(Istream& is, LList<LListBase, T>& L)
// Anull list
L.clear();
is.fatalCheck(" operator>>(Istream&, LList<LListBase, T>&)");
is.fatalCheck(FUNCTION_NAME);
token firstToken(is);
@ -98,7 +98,7 @@ Foam::Istream& Foam::operator>>(Istream& is, LList<LListBase, T>& L)
}
token lastToken(is);
is.fatalCheck(" operator>>(Istream&, LList<LListBase, T>&)");
is.fatalCheck(FUNCTION_NAME);
while
(
@ -114,7 +114,7 @@ Foam::Istream& Foam::operator>>(Istream& is, LList<LListBase, T>& L)
L.append(element);
is >> lastToken;
is.fatalCheck(" operator>>(Istream&, LList<LListBase, T>&)");
is.fatalCheck(FUNCTION_NAME);
}
}
else
@ -126,7 +126,7 @@ Foam::Istream& Foam::operator>>(Istream& is, LList<LListBase, T>& L)
}
// Check state of IOstream
is.fatalCheck(" operator>>(Istream&, LList<LListBase,>&)");
is.fatalCheck(FUNCTION_NAME);
return is;
}
@ -152,9 +152,7 @@ Foam::Ostream& Foam::operator<<(Ostream& os, const LList<LListBase, T>& lst)
// Write end of contents
os << token::END_LIST;
// Check state of IOstream
os.check("Ostream& operator<<(Ostream&, const LList<LListBase, T>&)");
os.check(FUNCTION_NAME);
return os;
}

View File

@ -34,10 +34,7 @@ template<class LListBase, class T>
template<class INew>
void Foam::LPtrList<LListBase, T>::read(Istream& is, const INew& iNew)
{
is.fatalCheck
(
"LPtrList<LListBase, T>::read(Istream&, const INew&)"
);
is.fatalCheck(FUNCTION_NAME);
token firstToken(is);
@ -102,7 +99,7 @@ void Foam::LPtrList<LListBase, T>::read(Istream& is, const INew& iNew)
}
token lastToken(is);
is.fatalCheck("LPtrList<LListBase, T>::read(Istream&, const INew&)");
is.fatalCheck(FUNCTION_NAME);
while
(
@ -116,10 +113,7 @@ void Foam::LPtrList<LListBase, T>::read(Istream& is, const INew& iNew)
this->append(iNew(is).ptr());
is >> lastToken;
is.fatalCheck
(
"LPtrList<LListBase, T>::read(Istream&, const INew&)"
);
is.fatalCheck(FUNCTION_NAME);
}
}
else
@ -132,7 +126,7 @@ void Foam::LPtrList<LListBase, T>::read(Istream& is, const INew& iNew)
<< exit(FatalIOError);
}
is.fatalCheck("LPtrList<LListBase, T>::read(Istream&, const INew&)");
is.fatalCheck(FUNCTION_NAME);
}
@ -190,9 +184,7 @@ Foam::Ostream& Foam::operator<<(Ostream& os, const LPtrList<LListBase, T>& lst)
// Write end of contents
os << token::END_LIST;
// Check state of IOstream
os.check("Ostream& operator<<(Ostream&, const LPtrList<LListBase, T>&)");
os.check(FUNCTION_NAME);
return os;
}

View File

@ -52,9 +52,7 @@ Foam::Ostream& Foam::operator<<(Ostream& os, const UILList<LListBase, T>& lst)
// Write end of contents
os << token::END_LIST;
// Check state of IOstream
os.check("Ostream& operator<<(Ostream&, const UILList<LListBase, T>&)");
os.check(FUNCTION_NAME);
return os;
}

View File

@ -591,9 +591,7 @@ Foam::Istream& Foam::operator>>
>> d.binWidth_
>> d.listStarts_;
// Check state of Istream
is.check("Istream& operator>>(Istream&, Distribution<Type>&)");
is.check(FUNCTION_NAME);
return is;
}
@ -609,9 +607,7 @@ Foam::Ostream& Foam::operator<<
<< d.binWidth_ << token::SPACE
<< d.listStarts_;
// Check state of Ostream
os.check("Ostream& operator<<(Ostream&, " "const Distribution&)");
os.check(FUNCTION_NAME);
return os;
}

View File

@ -139,9 +139,7 @@ Foam::Ostream& Foam::FixedList<T, Size>::writeList
os.write(reinterpret_cast<const char*>(L.cdata()), Size*sizeof(T));
}
// Check state of IOstream
os.check("const FixedList::writeList(Ostream&)");
os.check(FUNCTION_NAME);
return os;
}
@ -158,7 +156,7 @@ Foam::FixedList<T, Size>::FixedList(Istream& is)
template<class T, unsigned Size>
Foam::Istream& Foam::operator>>(Foam::Istream& is, FixedList<T, Size>& L)
{
is.fatalCheck("operator>>(Istream&, FixedList<T, Size>&)");
is.fatalCheck(FUNCTION_NAME);
if (is.format() == IOstream::ASCII || !contiguous<T>())
{

View File

@ -46,11 +46,11 @@ Foam::Istream& Foam::operator>>(Istream& is, List<T>& L)
// Anull list
L.setSize(0);
is.fatalCheck("operator>>(Istream&, List<T>&)");
is.fatalCheck(FUNCTION_NAME);
token firstToken(is);
is.fatalCheck("operator>>(Istream&, List<T>&) : reading first token");
is.fatalCheck(FUNCTION_NAME);
if (firstToken.isCompound())
{

View File

@ -286,7 +286,7 @@ Foam::Xfer<Foam::labelList> Foam::PackedBoolList::used() const
// * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * * //
void Foam::PackedBoolList::operator=(const Foam::UList<bool>& lst)
void Foam::PackedBoolList::operator=(const UList<bool>& lst)
{
this->setSize(lst.size());

View File

@ -94,7 +94,7 @@ public:
inline PackedBoolList();
//- Construct from Istream
PackedBoolList(Istream&);
PackedBoolList(Istream& is);
//- Construct with given size, initializes list to 0
explicit inline PackedBoolList(const label size);
@ -103,19 +103,19 @@ public:
inline PackedBoolList(const label size, const bool val);
//- Copy constructor
inline PackedBoolList(const PackedBoolList&);
inline PackedBoolList(const PackedBoolList& lst);
//- Copy constructor
explicit inline PackedBoolList(const PackedList<1>&);
explicit inline PackedBoolList(const PackedList<1>& lst);
//- Construct by transferring the parameter contents
inline PackedBoolList(const Xfer<PackedBoolList>&);
inline PackedBoolList(const Xfer<PackedBoolList>& lst);
//- Construct by transferring the parameter contents
inline PackedBoolList(const Xfer<PackedList<1>>&);
inline PackedBoolList(const Xfer<PackedList<1>>& lst);
//- Construct from a list of bools
explicit inline PackedBoolList(const Foam::UList<bool>&);
explicit inline PackedBoolList(const UList<bool>& lst);
//- Construct from a list of labels
// using the labels as indices to indicate which bits are set
@ -131,132 +131,132 @@ public:
// Member Functions
// Access
// Access
using PackedList<1>::set;
using PackedList<1>::unset;
using PackedList<1>::set;
using PackedList<1>::unset;
//- Set specified bits.
void set(const PackedList<1>&);
//- Set specified bits.
void set(const PackedList<1>& lst);
//- Set the listed indices. Return number of elements changed.
// Does auto-vivify for non-existent entries.
label set(const labelUList& indices);
//- Set the listed indices. Return number of elements changed.
// Does auto-vivify for non-existent entries.
label set(const labelUList& indices);
//- Set the listed indices. Return number of elements changed.
// Does auto-vivify for non-existent entries.
label set(const UIndirectList<label>& indices);
//- Set the listed indices. Return number of elements changed.
// Does auto-vivify for non-existent entries.
label set(const UIndirectList<label>& indices);
//- Unset specified bits.
void unset(const PackedList<1>&);
//- Unset specified bits.
void unset(const PackedList<1>& lst);
//- Unset the listed indices. Return number of elements changed.
// Never auto-vivify entries.
label unset(const labelUList& indices);
//- Unset the listed indices. Return number of elements changed.
// Never auto-vivify entries.
label unset(const labelUList& indices);
//- Unset the listed indices. Return number of elements changed.
// Never auto-vivify entries.
label unset(const UIndirectList<label>& indices);
//- Unset the listed indices. Return number of elements changed.
// Never auto-vivify entries.
label unset(const UIndirectList<label>& indices);
//- Subset with the specified list.
void subset(const PackedList<1>&);
//- Subset with the specified list.
void subset(const PackedList<1>& lst);
//- Subset with the listed indices.
// Return number of elements subsetted.
label subset(const labelUList& indices);
//- Subset with the listed indices.
// Return number of elements subsetted.
label subset(const labelUList& indices);
//- Subset with the listed indices.
// Return number of elements subsetted.
label subset(const UIndirectList<label>& indices);
//- Subset with the listed indices.
// Return number of elements subsetted.
label subset(const UIndirectList<label>& indices);
//- Return indices of the used (true) elements as a list of labels
Xfer<labelList> used() const;
//- Return indices of the used (true) elements as a list of labels
Xfer<labelList> used() const;
// Edit
// Edit
//- Transfer the contents of the argument list into this list
// and annul the argument list.
inline void transfer(PackedBoolList&);
//- Transfer the contents of the argument list into this list
// and annul the argument list.
inline void transfer(PackedBoolList& lst);
//- Transfer the contents of the argument list into this list
// and annul the argument list.
inline void transfer(PackedList<1>&);
//- Transfer the contents of the argument list into this list
// and annul the argument list.
inline void transfer(PackedList<1>& lst);
//- Transfer contents to the Xfer container
inline Xfer<PackedBoolList> xfer();
//- Transfer contents to the Xfer container
inline Xfer<PackedBoolList> xfer();
// Member Operators
//- Assignment of all entries to the given value.
inline void operator=(const bool val);
//- Assignment of all entries to the given value.
inline void operator=(const bool val);
//- Assignment operator.
inline void operator=(const PackedBoolList&);
//- Assignment operator.
inline void operator=(const PackedBoolList& lst);
//- Assignment operator.
inline void operator=(const PackedList<1>&);
//- Assignment operator.
inline void operator=(const PackedList<1>& lst);
//- Assignment operator.
void operator=(const Foam::UList<bool>&);
//- Assignment operator.
void operator=(const UList<bool>& lst);
//- Assignment operator,
// using the labels as indices to indicate which bits are set
inline void operator=(const labelUList& indices);
//- Assignment operator,
// using the labels as indices to indicate which bits are set
inline void operator=(const labelUList& indices);
//- Assignment operator,
// using the labels as indices to indicate which bits are set
inline void operator=(const UIndirectList<label>&);
//- Assignment operator,
// using the labels as indices to indicate which bits are set
inline void operator=(const UIndirectList<label>& indices);
//- Complement operator
inline PackedBoolList operator~() const;
//- Complement operator
inline PackedBoolList operator~() const;
//- And operator (lists may be dissimilar sizes)
inline PackedBoolList& operator&=(const PackedList<1>&);
//- And operator (lists may be dissimilar sizes)
inline PackedBoolList& operator&=(const PackedList<1>& lst);
//- And operator (lists may be dissimilar sizes)
// using the labels as indices to indicate which bits are set
inline PackedBoolList& operator&=(const labelUList& indices);
//- And operator (lists may be dissimilar sizes)
// using the labels as indices to indicate which bits are set
inline PackedBoolList& operator&=(const labelUList& indices);
//- And operator (lists may be dissimilar sizes)
// using the labels as indices to indicate which bits are set
inline PackedBoolList& operator&=(const UIndirectList<label>&);
//- And operator (lists may be dissimilar sizes)
// using the labels as indices to indicate which bits are set
inline PackedBoolList& operator&=(const UIndirectList<label>& indices);
//- Xor operator (lists may be dissimilar sizes)
// Retains unique entries
PackedBoolList& operator^=(const PackedList<1>&);
//- Xor operator (lists may be dissimilar sizes)
// Retains unique entries
PackedBoolList& operator^=(const PackedList<1>& lst);
//- Or operator (lists may be dissimilar sizes)
inline PackedBoolList& operator|=(const PackedList<1>&);
//- Or operator (lists may be dissimilar sizes)
inline PackedBoolList& operator|=(const PackedList<1>& lst);
//- Or operator (lists may be dissimilar sizes),
// using the labels as indices to indicate which bits are set
inline PackedBoolList& operator|=(const labelUList& indices);
//- Or operator (lists may be dissimilar sizes),
// using the labels as indices to indicate which bits are set
inline PackedBoolList& operator|=(const labelUList& indices);
//- Or operator (lists may be dissimilar sizes),
// using the labels as indices to indicate which bits are set
inline PackedBoolList& operator|=(const UIndirectList<label>&);
//- Or operator (lists may be dissimilar sizes),
// using the labels as indices to indicate which bits are set
inline PackedBoolList& operator|=(const UIndirectList<label>& indices);
//- Add entries to this list, synonymous with the or operator
inline PackedBoolList& operator+=(const PackedList<1>&);
//- Add entries to this list, synonymous with the or operator
inline PackedBoolList& operator+=(const PackedList<1>& lst);
//- Add entries to this list, synonymous with the or operator
inline PackedBoolList& operator+=(const labelUList& indices);
//- Add entries to this list, synonymous with the or operator
inline PackedBoolList& operator+=(const labelUList& indices);
//- Add entries to this list, synonymous with the or operator
inline PackedBoolList& operator+=(const UIndirectList<label>&);
//- Add entries to this list, synonymous with the or operator
inline PackedBoolList& operator+=(const UIndirectList<label>& indices);
//- Remove entries from this list - unset the specified bits
inline PackedBoolList& operator-=(const PackedList<1>&);
//- Remove entries from this list - unset the specified bits
inline PackedBoolList& operator-=(const PackedList<1>& lst);
//- Remove entries from this list - unset the specified bits
inline PackedBoolList& operator-=(const labelUList& indices);
//- Remove entries from this list - unset the specified bits
inline PackedBoolList& operator-=(const labelUList& indices);
//- Remove entries from this list - unset the specified bits
inline PackedBoolList& operator-=(const UIndirectList<label>&);
//- Remove entries from this list - unset the specified bits
inline PackedBoolList& operator-=(const UIndirectList<label>& indices);
};

View File

@ -73,7 +73,7 @@ inline Foam::PackedBoolList::PackedBoolList(const Xfer<PackedList<1>>& lst)
{}
inline Foam::PackedBoolList::PackedBoolList(const Foam::UList<bool>& lst)
inline Foam::PackedBoolList::PackedBoolList(const UList<bool>& lst)
:
PackedList<1>()
{

View File

@ -266,7 +266,7 @@ Foam::Istream& Foam::PackedList<nBits>::read(Istream& is)
PackedList<nBits>& lst = *this;
lst.clear();
is.fatalCheck("PackedList<nBits>::read(Istream&)");
is.fatalCheck(FUNCTION_NAME);
token firstTok(is);
is.fatalCheck
@ -349,7 +349,7 @@ Foam::Istream& Foam::PackedList<nBits>::read(Istream& is)
if (firstTok.pToken() == token::BEGIN_LIST)
{
token nextTok(is);
is.fatalCheck("PackedList<nBits>::read(Istream&)");
is.fatalCheck(FUNCTION_NAME);
while
(
@ -362,13 +362,13 @@ Foam::Istream& Foam::PackedList<nBits>::read(Istream& is)
lst.append(lst.readValue(is));
is >> nextTok;
is.fatalCheck("PackedList<nBits>::read(Istream&)");
is.fatalCheck(FUNCTION_NAME);
}
}
else if (firstTok.pToken() == token::BEGIN_BLOCK)
{
token nextTok(is);
is.fatalCheck("PackedList<nBits>::read(Istream&)");
is.fatalCheck(FUNCTION_NAME);
while
(
@ -381,7 +381,7 @@ Foam::Istream& Foam::PackedList<nBits>::read(Istream& is)
lst.setPair(is);
is >> nextTok;
is.fatalCheck("PackedList<nBits>::read(Istream&)");
is.fatalCheck(FUNCTION_NAME);
}
}
else

View File

@ -118,9 +118,9 @@ class Ostream;
template<unsigned nBits> class PackedList;
template<unsigned nBits>
Istream& operator>>(Istream&, PackedList<nBits>&);
Istream& operator>>(Istream& is, PackedList<nBits>& lst);
template<unsigned nBits>
Ostream& operator<<(Ostream&, const PackedList<nBits>&);
Ostream& operator<<(Ostream& os, const PackedList<nBits>& lst);
/*---------------------------------------------------------------------------*\
@ -160,11 +160,11 @@ protected:
inline static label packedLength(const label);
//- Read a list entry (allows for specialization)
inline static unsigned int readValue(Istream&);
inline static unsigned int readValue(Istream& is);
//- Read an index/value pair and set accordingly.
// For bool specialization, read a single index value
inline void setPair(Istream&);
inline void setPair(Istream& is);
private:
@ -252,167 +252,167 @@ public:
// Member Functions
// Access
// Access
//- The number of elements that can be stored before reallocating
inline label capacity() const;
//- The number of elements that can be stored before reallocating
inline label capacity() const;
//- Number of entries.
inline label size() const;
//- Number of entries.
inline label size() const;
//- Return true if the list is empty (ie, size() is zero).
inline bool empty() const;
//- Return true if the list is empty (ie, size() is zero).
inline bool empty() const;
//- Get value at index I.
// Never auto-vivify entries.
inline unsigned int get(const label i) const;
//- Get value at index I.
// Never auto-vivify entries.
inline unsigned int get(const label i) const;
//- Set value at index I. Return true if value changed.
// Does auto-vivify for non-existent entries.
// Default value set is the max_value.
inline bool set(const label i, const unsigned int val = ~0u);
//- Set value at index I. Return true if value changed.
// Does auto-vivify for non-existent, non-zero entries.
// Default value set is the max_value.
inline bool set(const label i, const unsigned int val = ~0u);
//- Unset the entry at index I. Return true if value changed.
// Never auto-vivify entries.
inline bool unset(const label i);
//- Unset the entry at index I. Return true if value changed.
// Never auto-vivify entries.
inline bool unset(const label i);
//- Return the underlying packed storage
// Manipulate with utmost caution
inline List<unsigned int>& storage();
//- Return the underlying packed storage
// Manipulate with utmost caution
inline List<unsigned int>& storage();
//- Return the underlying packed storage
inline const List<unsigned int>& storage() const;
//- Return the underlying packed storage
inline const List<unsigned int>& storage() const;
//- The list length when packed
inline label packedLength() const;
//- The list length when packed
inline label packedLength() const;
//- Return the binary size in number of characters
// used in the underlying storage
inline std::streamsize byteSize() const;
//- Return the binary size in number of characters
// used in the underlying storage
inline std::streamsize byteSize() const;
//- Count number of bits set, O(log(n))
// Uses the Hamming weight (population count) method
// http://en.wikipedia.org/wiki/Hamming_weight
unsigned int count() const;
//- Count number of bits set, O(log(n))
// Uses the Hamming weight (population count) method
// http://en.wikipedia.org/wiki/Hamming_weight
unsigned int count() const;
//- Return the values as a list of labels
Xfer<labelList> values() const;
//- Return the values as a list of labels
Xfer<labelList> values() const;
//- Print bit patterns, optionally output unused elements
//
// addressable bits:
// on: '1', off: '-'
//
// non-addressable bits:
// on: '!', off: '.'
//
Ostream& printBits(Ostream&, const bool fullOutput=false) const;
//- Print bit patterns, optionally output unused elements
//
// addressable bits:
// on: '1', off: '-'
//
// non-addressable bits:
// on: '!', off: '.'
//
Ostream& printBits(Ostream& os, const bool fullOutput=false) const;
//- Print information and bit patterns (with printBits)
Ostream& printInfo(Ostream&, const bool fullOutput=false) const;
//- Print information and bit patterns (with printBits)
Ostream& printInfo(Ostream& os, const bool fullOutput=false) const;
// Edit
// Edit
//- Trim any trailing zero elements
bool trim();
//- Trim any trailing zero elements
bool trim();
//- Invert the bits in the addressable region
void flip();
//- Invert the bits in the addressable region
void flip();
//- Clear all bits
inline void reset();
//- Clear all bits
inline void reset();
//- Alter the size of the underlying storage.
// The addressed size will be truncated if needed to fit, but will
// remain otherwise untouched.
inline void setCapacity(const label);
//- Alter the size of the underlying storage.
// The addressed size will be truncated if needed to fit, but will
// remain otherwise untouched.
inline void setCapacity(const label nElem);
//- Reset addressable list size, does not shrink the allocated size.
// Optionally specify a value for new elements.
inline void resize(const label, const unsigned int val = 0u);
//- Reset addressable list size, does not shrink the allocated size.
// Optionally specify a value for new elements.
inline void resize(const label nElem, const unsigned int val = 0u);
//- Alias for resize()
inline void setSize(const label, const unsigned int val = 0u);
//- Alias for resize()
inline void setSize(const label nElem, const unsigned int val = 0u);
//- Reserve allocation space for at least this size.
// Never shrinks the allocated size.
// The list size is adjusted as per DynamicList with
// SizeInc=0, SizeMult=2, SizeDiv=1
inline void reserve(const label);
//- Reserve allocation space for at least this size.
// Never shrinks the allocated size.
// The list size is adjusted as per DynamicList with
// SizeInc=0, SizeMult=2, SizeDiv=1
inline void reserve(const label nElem);
//- Clear the list, i.e. set addressable size to zero.
// Does not adjust the underlying storage
inline void clear();
//- Clear the list, i.e. set addressable size to zero.
// Does not adjust the underlying storage
inline void clear();
//- Clear the list and delete storage.
inline void clearStorage();
//- Clear the list and delete storage.
inline void clearStorage();
//- Shrink the allocated space to what is actually used.
inline void shrink();
//- Shrink the allocated space to what is actually used.
inline void shrink();
//- Transfer the contents of the argument list into this list
// and annul the argument list.
inline void transfer(PackedList<nBits>&);
//- Transfer the contents of the argument list into this list
// and annul the argument list.
inline void transfer(PackedList<nBits>& lst);
//- Transfer contents to the Xfer container
inline Xfer<PackedList<nBits>> xfer();
//- Transfer contents to the Xfer container
inline Xfer<PackedList<nBits>> xfer();
// IO
// IO
//- Clear list and read from stream
Istream& read(Istream& is);
//- Clear list and read from stream
Istream& read(Istream& is);
//- Write the List, with line-breaks in ASCII if the list length
// exceeds shortListLen. Using '0' suppresses line-breaks entirely.
// A special indexed output (ASCII only) is triggered by specifying
// a negative value for shortListLen.
//
// The indexed output may be convenient in some situations.
// The general format is a group of index/value pairs:
// \verbatim
// { (index1 value1) (index2 value2) (index3 value3) }
// \endverbatim
// The bool specialization just uses the indices corresponding to
// non-zero entries instead of a index/value pair:
// \verbatim
// { index1 index2 index3 }
// \endverbatim
Ostream& writeList(Ostream& os, const label shortListLen=0) const;
//- Write the List, with line-breaks in ASCII if the list length
// exceeds shortListLen. Using '0' suppresses line-breaks entirely.
// A special indexed output (ASCII only) is triggered by specifying
// a negative value for shortListLen.
//
// The indexed output may be convenient in some situations.
// The general format is a group of index/value pairs:
// \verbatim
// { (index1 value1) (index2 value2) (index3 value3) }
// \endverbatim
// The bool specialization just uses the indices corresponding to
// non-zero entries instead of a index/value pair:
// \verbatim
// { index1 index2 index3 }
// \endverbatim
Ostream& writeList(Ostream& os, const label shortListLen=0) const;
//- Write as a dictionary entry with keyword
void writeEntry(const word& keyword, Ostream& os) const;
//- Write as a dictionary entry with keyword
void writeEntry(const word& keyword, Ostream& os) const;
// Member operators
// Member operators
//- Append a value at the end of the list
inline PackedList<nBits>& append(const unsigned int val);
//- Append a value at the end of the list
inline PackedList<nBits>& append(const unsigned int val);
//- Remove and return the last element
inline unsigned int remove();
//- Remove and return the last element
inline unsigned int remove();
//- Get value at index I
// Never auto-vivify entries.
inline unsigned int operator[](const label i) const;
//- Get value at index I
// Never auto-vivify entries.
inline unsigned int operator[](const label i) const;
//- Set value at index I.
// Returns iterator to perform the actual operation.
// Does not auto-vivify entries, but will when assigned to.
inline iteratorBase operator[](const label i);
//- Set value at index I.
// Returns iterator to perform the actual operation.
// Does not auto-vivify entries, but will when assigned to.
inline iteratorBase operator[](const label i);
//- Assignment of all entries to the given value. Takes linear time.
inline void operator=(const unsigned int val);
//- Assignment of all entries to the given value. Takes linear time.
inline void operator=(const unsigned int val);
//- Assignment operator.
void operator=(const PackedList<nBits>& lst);
//- Assignment operator.
void operator=(const PackedList<nBits>& lst);
//- Assignment operator.
void operator=(const labelUList& lst);
//- Assignment operator.
void operator=(const labelUList& lst);
//- Assignment operator.
void operator=(const UIndirectList<label>& lst);
//- Assignment operator.
void operator=(const UIndirectList<label>& lst);
// Iterators and helpers
@ -442,7 +442,7 @@ public:
inline unsigned int get() const;
//- Set value, returning true if changed, no range-checking
inline bool set(unsigned int);
inline bool set(unsigned int val);
// Constructors
@ -451,7 +451,7 @@ public:
inline iteratorBase();
//- Construct from base list and position index
inline iteratorBase(const PackedList*, const label);
inline iteratorBase(const PackedList* lst, const label i);
public:
@ -463,17 +463,17 @@ public:
//- Write index/value for a non-zero entry
// The bool specialization writes the index only
inline bool writeIfSet(Ostream&) const;
inline bool writeIfSet(Ostream& os) const;
// Member Operators
//- Compare values (not positions)
inline bool operator==(const iteratorBase&) const;
inline bool operator!=(const iteratorBase&) const;
inline bool operator==(const iteratorBase& iter) const;
inline bool operator!=(const iteratorBase& iter) const;
//- Assign value, not position.
// This allows packed[0] = packed[3] for assigning values
inline void operator=(const iteratorBase&);
inline void operator=(const iteratorBase& iter);
//- Assign value.
// A non-existent entry will be auto-vivified.
@ -484,7 +484,7 @@ public:
inline operator unsigned int () const;
//- Print information and values
Ostream& printInfo(Ostream&) const;
Ostream& printInfo(Ostream& os) const;
};
@ -496,11 +496,11 @@ public:
//- Disallow copy constructor from const_iterator
// This would violate const-ness!
iterator(const const_iterator&);
iterator(const const_iterator& iter);
//- Disallow assignment from const_iterator
// This would violate const-ness!
void operator=(const const_iterator&);
void operator=(const const_iterator& iter);
public:
@ -513,21 +513,21 @@ public:
//- Construct from iterator base, eg iter(packedlist[i])
// but also "iterator iter = packedlist[i];"
// An out-of-range iterator is assigned end()
inline iterator(const iteratorBase&);
inline iterator(const iteratorBase& iter);
//- Construct from base list and position index
inline iterator(const PackedList*, const label);
inline iterator(const PackedList* lst, const label i);
// Member Operators
//- Compare positions (not values)
inline bool operator==(const iteratorBase&) const;
inline bool operator!=(const iteratorBase&) const;
inline bool operator==(const iteratorBase& iter) const;
inline bool operator!=(const iteratorBase& iter) const;
//- Assign from iteratorBase, eg iter = packedlist[i]
// An out-of-range iterator is assigned end()
inline void operator=(const iteratorBase&);
inline void operator=(const iteratorBase& iter);
//- Return value
inline unsigned int operator*() const;
@ -571,24 +571,24 @@ public:
//- Construct from iterator base, eg iter(packedlist[i])
// but also "const_iterator iter = packedlist[i];"
// An out-of-range iterator is assigned cend()
inline const_iterator(const iteratorBase&);
inline const_iterator(const iteratorBase& iter);
//- Construct from base list and position index
inline const_iterator(const PackedList*, const label);
inline const_iterator(const PackedList* lst, const label i);
//- Construct from iterator
inline const_iterator(const iterator&);
inline const_iterator(const iterator& iter);
// Member operators
//- Compare positions (not values)
inline bool operator==(const iteratorBase&) const;
inline bool operator!=(const iteratorBase&) const;
inline bool operator==(const iteratorBase& iter) const;
inline bool operator!=(const iteratorBase& iter) const;
//- Assign from iteratorBase or derived
// eg, iter = packedlist[i] or even iter = list.begin()
inline void operator=(const iteratorBase&);
inline void operator=(const iteratorBase& iter);
//- Return referenced value directly
inline unsigned int operator*() const;
@ -621,14 +621,14 @@ public:
friend Istream& operator>> <nBits>
(
Istream&,
PackedList<nBits>&
Istream& is,
PackedList<nBits>& lst
);
friend Ostream& operator<< <nBits>
(
Ostream&,
const PackedList<nBits>&
Ostream& os,
const PackedList<nBits>& lst
);
};

View File

@ -137,8 +137,7 @@ inline void Foam::PackedList<nBits>::setPair(Istream& is)
set(ind, val);
// Check state of Istream
is.check("PackedList<nBits>::setPair(Istream&)");
is.check(FUNCTION_NAME);
}
@ -268,7 +267,7 @@ Foam::PackedList<nBits>::clone() const
template<unsigned nBits>
inline Foam::PackedList<nBits>::iteratorBase::iteratorBase()
:
list_(0),
list_(nullptr),
index_(0)
{}
@ -1003,6 +1002,12 @@ inline bool Foam::PackedList<nBits>::set
}
else if (i >= size_)
{
if (!val)
{
// Same as unset out-of-bounds = noop
return false;
}
// Lazy evaluation - increase size on assigment
resize(i + 1);
}
@ -1014,7 +1019,7 @@ inline bool Foam::PackedList<nBits>::set
template<unsigned nBits>
inline bool Foam::PackedList<nBits>::unset(const label i)
{
// lazy evaluation - ignore out-of-bounds
// Unset out-of-bounds = noop
if (i < 0 || i >= size_)
{
return false;

View File

@ -35,7 +35,7 @@ template<class T>
template<class INew>
void Foam::PtrList<T>::read(Istream& is, const INew& inewt)
{
is.fatalCheck("PtrList<T>::read(Istream&, const INew&)");
is.fatalCheck(FUNCTION_NAME);
token firstToken(is);

View File

@ -120,9 +120,7 @@ Foam::Ostream& Foam::UIndirectList<T>::writeList
}
}
// Check state of IOstream
os.check("UIndirectList::writeList(Ostream&)");
os.check(FUNCTION_NAME);
return os;
}

View File

@ -150,9 +150,7 @@ Foam::Ostream& Foam::UList<T>::writeList
}
}
// Check state of IOstream
os.check("UList<T>::writeList(Ostream&)");
os.check(FUNCTION_NAME);
return os;
}
@ -169,7 +167,7 @@ Foam::Ostream& Foam::operator<<(Foam::Ostream& os, const Foam::UList<T>& L)
template<class T>
Foam::Istream& Foam::operator>>(Istream& is, UList<T>& L)
{
is.fatalCheck("operator>>(Istream&, UList<T>&)");
is.fatalCheck(FUNCTION_NAME);
token firstToken(is);

View File

@ -44,9 +44,7 @@ Foam::Ostream& Foam::operator<<(Ostream& os, const UPtrList<T>& L)
// Write end delimiter
os << nl << decrIndent << indent << token::END_LIST << nl;
// Check state of IOstream
os.check("Ostream& operator<<(Ostream&, const UPtrList&)");
os.check(FUNCTION_NAME);
return os;
}

View File

@ -1,142 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
\\/ 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 3 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, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "NamedEnum.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class Enum, int nEnum>
Foam::NamedEnum<Enum, nEnum>::NamedEnum()
:
HashTable<int>(2*nEnum)
{
for (int enumI = 0; enumI < nEnum; ++enumI)
{
if (!names[enumI] || names[enumI][0] == '\0')
{
stringList goodNames(enumI);
for (int i = 0; i < enumI; ++i)
{
goodNames[i] = names[i];
}
FatalErrorInFunction
<< "Illegal enumeration name at position " << enumI << endl
<< "after entries " << goodNames << ".\n"
<< "Possibly your NamedEnum<Enum, nEnum>::names array"
<< " is not of size " << nEnum << endl
<< abort(FatalError);
}
insert(names[enumI], enumI);
}
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class Enum, int nEnum>
Enum Foam::NamedEnum<Enum, nEnum>::read(Istream& is) const
{
const word name(is);
HashTable<int>::const_iterator iter = find(name);
if (!iter.found())
{
FatalIOErrorInFunction(is)
<< name << " is not in enumeration: "
<< sortedToc() << exit(FatalIOError);
}
return Enum(iter.object());
}
template<class Enum, int nEnum>
void Foam::NamedEnum<Enum, nEnum>::write(const Enum e, Ostream& os) const
{
os << operator[](e);
}
template<class Enum, int nEnum>
Foam::stringList Foam::NamedEnum<Enum, nEnum>::strings()
{
stringList lst(nEnum);
label nElem = 0;
for (int enumI = 0; enumI < nEnum; ++enumI)
{
if (names[enumI] && names[enumI][0])
{
lst[nElem++] = names[enumI];
}
}
lst.setSize(nElem);
return lst;
}
template<class Enum, int nEnum>
Foam::wordList Foam::NamedEnum<Enum, nEnum>::words()
{
wordList lst(nEnum);
label nElem = 0;
for (int enumI = 0; enumI < nEnum; ++enumI)
{
if (names[enumI] && names[enumI][0])
{
lst[nElem++] = names[enumI];
}
}
lst.setSize(nElem);
return lst;
}
template<class Enum, int nEnum>
Foam::List<Enum> Foam::NamedEnum<Enum, nEnum>::enums()
{
List<Enum> lst(nEnum);
label nElem = 0;
for (int enumI = 0; enumI < nEnum; ++enumI)
{
if (names[enumI] && names[enumI][0])
{
lst[nElem++] = Enum(enumI);
}
}
lst.setSize(nElem);
return lst;
}
// ************************************************************************* //

View File

@ -117,11 +117,7 @@ Foam::Ostream& Foam::operator<<(Ostream& os, const UPstream::commsStruct& comm)
<< comm.allBelow_ << token::SPACE
<< comm.allNotBelow_;
os.check
(
"Ostream& operator<<(Ostream&, const commsStruct&)"
);
os.check(FUNCTION_NAME);
return os;
}

View File

@ -105,9 +105,7 @@ Foam::Ostream& Foam::operator<<(Ostream& os, const token& t)
<< endl;
}
// Check state of stream
os.check("Ostream& operator<<(Ostream&, const token&)");
os.check(FUNCTION_NAME);
return os;
}

View File

@ -38,11 +38,7 @@ Foam::dictionaryEntry::dictionaryEntry
entry(keyType(is)),
dictionary(parentDict, is)
{
is.fatalCheck
(
"dictionaryEntry::dictionaryEntry"
"(const dictionary& parentDict, Istream&)"
);
is.fatalCheck(FUNCTION_NAME);
}
@ -56,11 +52,7 @@ Foam::dictionaryEntry::dictionaryEntry
entry(key),
dictionary(key, parentDict, is)
{
is.fatalCheck
(
"dictionaryEntry::dictionaryEntry"
"(const keyType&, const dictionary& parentDict, Istream&)"
);
is.fatalCheck(FUNCTION_NAME);
}

View File

@ -115,8 +115,7 @@ void Foam::dictionaryListEntry::write(Ostream& os) const
// Write end delimiter
os << decrIndent << indent << token::END_LIST << nl;
// Check state of IOstream
os.check("Ostream& operator<<(Ostream&, const dictionaryListEntry&)");
os.check(FUNCTION_NAME);
}

View File

@ -84,11 +84,7 @@ bool Foam::functionEntry::execute
Istream& is
)
{
is.fatalCheck
(
"functionEntry::execute"
"(const word& functionName, dictionary& parentDict, Istream&)"
);
is.fatalCheck(FUNCTION_NAME);
if (!executedictionaryIstreamMemberFunctionTablePtr_)
{
@ -127,11 +123,7 @@ bool Foam::functionEntry::execute
Istream& is
)
{
is.fatalCheck
(
"functionEntry::execute"
"(const word&, const dictionary&, primitiveEntry&, Istream&)"
);
is.fatalCheck(FUNCTION_NAME);
if (!executeprimitiveEntryIstreamMemberFunctionTablePtr_)
{

View File

@ -91,10 +91,7 @@ bool Foam::primitiveEntry::expandFunction
bool Foam::primitiveEntry::read(const dictionary& dict, Istream& is)
{
is.fatalCheck
(
"primitiveEntry::readData(const dictionary&, Istream&)"
);
is.fatalCheck(FUNCTION_NAME);
label blockCount = 0;
token currToken;
@ -145,10 +142,7 @@ bool Foam::primitiveEntry::read(const dictionary& dict, Istream& is)
}
}
is.fatalCheck
(
"primitiveEntry::readData(const dictionary&, Istream&)"
);
is.fatalCheck(FUNCTION_NAME);
if (currToken.good())
{

View File

@ -477,9 +477,8 @@ Foam::Istream& Foam::dimensionSet::read
<< exit(FatalIOError);
}
}
// Check state of Istream
is.check("Istream& operator>>(Istream&, dimensionSet&)");
is.check(FUNCTION_NAME);
return is;
}
@ -617,9 +616,7 @@ Foam::Istream& Foam::dimensionSet::read
}
}
// Check state of Istream
is.check("Istream& operator>>(Istream&, dimensionSet&)");
is.check(FUNCTION_NAME);
return is;
}
@ -691,9 +688,7 @@ Foam::Ostream& Foam::dimensionSet::write
os << token::END_SQR;
// Check state of Ostream
os.check("Ostream& operator<<(Ostream&, const dimensionSet&)");
os.check(FUNCTION_NAME);
return os;
}
@ -722,9 +717,7 @@ Foam::Istream& Foam::operator>>(Istream& is, dimensionSet& dset)
<< exit(FatalIOError);
}
// Check state of Istream
is.check("Istream& operator>>(Istream&, dimensionSet&)");
is.check(FUNCTION_NAME);
return is;
}
@ -734,9 +727,7 @@ Foam::Ostream& Foam::operator<<(Ostream& os, const dimensionSet& dset)
scalar multiplier;
dset.write(os, multiplier);
// Check state of Ostream
os.check("Ostream& operator<<(Ostream&, const dimensionSet&)");
os.check(FUNCTION_NAME);
return os;
}

View File

@ -339,12 +339,7 @@ Foam::dimensioned<Type>::read(Istream& is, const dictionary& readSet)
is >> value_;
value_ *= mult;
// Check state of Istream
is.check
(
"Istream& dimensioned<Type>::read(Istream& is, const dictionary&)"
);
is.check(FUNCTION_NAME);
return is;
}
@ -367,13 +362,7 @@ Foam::Istream& Foam::dimensioned<Type>::read
is >> value_;
value_ *= mult;
// Check state of Istream
is.check
(
"Istream& dimensioned<Type>::read"
"(Istream& is, const HashTable<dimensionedScalar>&)"
);
is.check(FUNCTION_NAME);
return is;
}
@ -392,12 +381,7 @@ Foam::Istream& Foam::dimensioned<Type>::read(Istream& is)
is >> value_;
value_ *= mult;
// Check state of Istream
is.check
(
"Istream& dimensioned<Type>::read(Istream& is)"
);
is.check(FUNCTION_NAME);
return is;
}
@ -612,9 +596,7 @@ Foam::Istream& Foam::operator>>(Istream& is, dimensioned<Type>& dt)
is >> dt.value_;
dt.value_ *= multiplier;
// Check state of Istream
is.check("Istream& operator>>(Istream&, dimensioned<Type>&)");
is.check(FUNCTION_NAME);
return is;
}
@ -634,9 +616,7 @@ Foam::Ostream& Foam::operator<<(Ostream& os, const dimensioned<Type>& dt)
// Write the value
os << dt.value()/mult;
// Check state of Ostream
os.check("Ostream& operator<<(Ostream&, const dimensioned<Type>&)");
os.check(FUNCTION_NAME);
return os;
}

View File

@ -117,10 +117,8 @@ bool Foam::DimensionedField<Type, GeoMesh>::writeData
Field<Type>::writeEntry(fieldDictEntry, os);
// Check state of Ostream
os.check(FUNCTION_NAME);
return (os.good());
return os.good();
}

View File

@ -573,12 +573,7 @@ writeEntry(const word& keyword, Ostream& os) const
this->writeEntries(os);
os.endBlock() << flush;
// Check state of IOstream
os.check
(
"GeometricField<Type, PatchField, GeoMesh>::Boundary::"
"writeEntry(const word& keyword, Ostream& os) const"
);
os.check(FUNCTION_NAME);
}

View File

@ -1292,14 +1292,8 @@ Foam::Ostream& Foam::operator<<
os << nl;
gf.boundaryField().writeEntry("boundaryField", os);
// Check state of IOstream
os.check
(
"Ostream& operator<<(Ostream&, "
"const GeometricField<Type, PatchField, GeoMesh>&)"
);
return (os);
os.check(FUNCTION_NAME);
return os;
}

View File

@ -329,7 +329,7 @@ Foam::Ostream& Foam::operator<<
{
ptf.write(os);
os.check("Ostream& operator<<(Ostream&, const pointPatchField<Type>&)");
os.check(FUNCTION_NAME);
return os;
}

View File

@ -54,6 +54,7 @@ SourceFiles
#include "profilingTrigger.H"
#include "HashPtrTable.H"
#include "Tuple2.H"
#include "LIFOStack.H"
#include "Map.H"
#include "Time.H"

View File

@ -63,7 +63,7 @@ Foam::Ostream& Foam::operator<<(Ostream& os, const curve& c)
<< c.style_ << nl
<< static_cast<const scalarField&>(c);
os.check("Ostream& operator>>(Ostream&, const curve&)");
os.check(FUNCTION_NAME);
return os;
}

View File

@ -298,7 +298,7 @@ void Foam::graph::write
Foam::Ostream& Foam::operator<<(Ostream& os, const graph& g)
{
g.writeTable(os);
os.check("Ostream& operator<<(Ostream&, const graph&)");
os.check(FUNCTION_NAME);
return os;
}

View File

@ -123,10 +123,10 @@ Type Foam::interpolation2DTable<Type>::interpolateValue
const scalar lookupValue
) const
{
label n = data.size();
const label n = data.size();
scalar minLimit = data.first().first();
scalar maxLimit = data.last().first();
const scalar minLimit = data.first().first();
const scalar maxLimit = data.last().first();
if (lookupValue < minLimit)
{
@ -147,7 +147,9 @@ Type Foam::interpolation2DTable<Type>::interpolateValue
<< "bound (" << minLimit << ")" << nl
<< " Continuing with the first entry"
<< endl;
// fall-through to 'CLAMP'
// Behaviour as per 'CLAMP'
return data.first().second();
break;
}
case interpolation2DTable::CLAMP:
{
@ -175,7 +177,9 @@ Type Foam::interpolation2DTable<Type>::interpolateValue
<< "bound (" << maxLimit << ")" << nl
<< " Continuing with the last entry"
<< endl;
// fall-through to 'CLAMP'
// Behaviour as per 'CLAMP'
return data.last().second();
break;
}
case interpolation2DTable::CLAMP:
{
@ -251,16 +255,19 @@ Foam::label Foam::interpolation2DTable<Type>::Xi
WarningInFunction
<< "value (" << valueX << ") out of bounds"
<< endl;
// fall-through to 'CLAMP'
// Behaviour as per 'CLAMP'
return limitI;
break;
}
case interpolation2DTable::CLAMP:
{
return limitI;
break;
}
default:
{
FatalErrorInFunction
<< "Un-handled enumeration " << boundsHandling_
<< "Unhandled enumeration " << boundsHandling_
<< abort(FatalError);
}
}
@ -299,7 +306,7 @@ Type Foam::interpolation2DTable<Type>::operator()
) const
{
// Considers all of the list in Y being equal
label nX = this->size();
const label nX = this->size();
const table& t = *this;
@ -320,8 +327,8 @@ Type Foam::interpolation2DTable<Type>::operator()
// have 2-D data, interpolate
// find low and high indices in the X range that bound valueX
label x0i = Xi(lessOp<scalar>(), valueX, false);
label x1i = Xi(greaterOp<scalar>(), valueX, true);
const label x0i = Xi(lessOp<scalar>(), valueX, false);
const label x1i = Xi(greaterOp<scalar>(), valueX, true);
if (x0i == x1i)
{
@ -333,8 +340,8 @@ Type Foam::interpolation2DTable<Type>::operator()
Type y1(interpolateValue(t[x1i].second(), valueY));
// gradient in X
scalar x0 = t[x0i].first();
scalar x1 = t[x1i].first();
const scalar x0 = t[x0i].first();
const scalar x1 = t[x1i].first();
Type mX = (y1 - y0)/(x1 - x0);
// interpolate
@ -420,7 +427,7 @@ Foam::interpolation2DTable<Type>::outOfBounds
template<class Type>
void Foam::interpolation2DTable<Type>::checkOrder() const
{
label n = this->size();
const label n = this->size();
const table& t = *this;
scalar prevValue = t[0].first();
@ -445,10 +452,8 @@ void Foam::interpolation2DTable<Type>::checkOrder() const
template<class Type>
void Foam::interpolation2DTable<Type>::write(Ostream& os) const
{
os.writeKeyword("file")
<< fileName_ << token::END_STATEMENT << nl;
os.writeKeyword("outOfBounds")
<< boundsHandlingToWord(boundsHandling_) << token::END_STATEMENT << nl;
os.writeEntry("file", fileName_);
os.writeEntry("outOfBounds", boundsHandlingToWord(boundsHandling_));
os << *this;
}

View File

@ -66,7 +66,7 @@ public:
CLAMP //!< Clamp value to the start/end value
};
//- Cconvenience typedef
//- Convenience typedef
typedef List<Tuple2<scalar, List<Tuple2<scalar, Type>>>> table;
@ -156,7 +156,7 @@ public:
const List<Tuple2<scalar, Type>>& operator[](const label) const;
//- Return an interpolated value
Type operator()(const scalar, const scalar) const;
Type operator()(const scalar valueX, const scalar valueY) const;
};

View File

@ -205,8 +205,8 @@ Foam::interpolationTable<Type>::outOfBounds
template<class Type>
void Foam::interpolationTable<Type>::check() const
{
label n = this->size();
scalar prevValue = List<Tuple2<scalar, Type>>::operator[](0).first();
const label n = this->size();
scalar prevValue = this->first().first();
for (label i=1; i<n; ++i)
{
@ -229,10 +229,8 @@ void Foam::interpolationTable<Type>::check() const
template<class Type>
void Foam::interpolationTable<Type>::write(Ostream& os) const
{
os.writeKeyword("file")
<< fileName_ << token::END_STATEMENT << nl;
os.writeKeyword("outOfBounds")
<< boundsHandlingToWord(boundsHandling_) << token::END_STATEMENT << nl;
os.writeEntry("file", fileName_);
os.writeEntry("outOfBounds", boundsHandlingToWord(boundsHandling_));
if (reader_.valid())
{
reader_->write(os);
@ -251,8 +249,8 @@ Type Foam::interpolationTable<Type>::rateOfChange(const scalar value) const
return 0;
}
scalar minLimit = List<Tuple2<scalar, Type>>::operator[](0).first();
scalar maxLimit = List<Tuple2<scalar, Type>>::operator[](n-1).first();
const scalar minLimit = this->first().first();
const scalar maxLimit = this->last().first();
scalar lookupValue = value;
if (lookupValue < minLimit)
@ -272,7 +270,9 @@ Type Foam::interpolationTable<Type>::rateOfChange(const scalar value) const
<< "value (" << lookupValue << ") underflow" << nl
<< " Zero rate of change."
<< endl;
// fall-through to 'CLAMP'
// behaviour as per 'CLAMP'
return 0;
break;
}
case interpolationTable::CLAMP:
{
@ -305,7 +305,9 @@ Type Foam::interpolationTable<Type>::rateOfChange(const scalar value) const
<< "value (" << lookupValue << ") overflow" << nl
<< " Zero rate of change."
<< endl;
// fall-through to 'CLAMP'
// Behaviour as per 'CLAMP'
return 0;
break;
}
case interpolationTable::CLAMP:
{
@ -346,7 +348,7 @@ Type Foam::interpolationTable<Type>::rateOfChange(const scalar value) const
}
else if (hi == 0)
{
// this treatment should should only occur under these conditions:
// this treatment should only occur under these conditions:
// -> the 'REPEAT' treatment
// -> (0 <= value <= minLimit)
// -> minLimit > 0
@ -414,7 +416,9 @@ Foam::interpolationTable<Type>::operator[](const label i) const
<< "index (" << ii << ") underflow" << nl
<< " Continuing with the first entry"
<< endl;
// fall-through to 'CLAMP'
// Behaviour as per 'CLAMP'
ii = 0;
break;
}
case interpolationTable::CLAMP:
{
@ -448,7 +452,9 @@ Foam::interpolationTable<Type>::operator[](const label i) const
<< "index (" << ii << ") overflow" << nl
<< " Continuing with the last entry"
<< endl;
// fall-through to 'CLAMP'
// Behaviour as per 'CLAMP'
ii = n - 1;
break;
}
case interpolationTable::CLAMP:
{
@ -477,11 +483,11 @@ Type Foam::interpolationTable<Type>::operator()(const scalar value) const
if (n <= 1)
{
return List<Tuple2<scalar, Type>>::operator[](0).second();
return this->first().second();
}
scalar minLimit = List<Tuple2<scalar, Type>>::operator[](0).first();
scalar maxLimit = List<Tuple2<scalar, Type>>::operator[](n-1).first();
const scalar minLimit = this->first().first();
const scalar maxLimit = this->last().first();
scalar lookupValue = value;
if (lookupValue < minLimit)
@ -501,17 +507,19 @@ Type Foam::interpolationTable<Type>::operator()(const scalar value) const
<< "value (" << lookupValue << ") underflow" << nl
<< " Continuing with the first entry"
<< endl;
// fall-through to 'CLAMP'
// Behaviour as per 'CLAMP'
return this->first().second();
break;
}
case interpolationTable::CLAMP:
{
return List<Tuple2<scalar, Type>>::operator[](0).second();
return this->first().second();
break;
}
case interpolationTable::REPEAT:
{
// adjust lookupValue to >= minLimit
scalar span = maxLimit-minLimit;
const scalar span = maxLimit-minLimit;
lookupValue = fmod(lookupValue-minLimit, span) + minLimit;
break;
}
@ -534,17 +542,19 @@ Type Foam::interpolationTable<Type>::operator()(const scalar value) const
<< "value (" << lookupValue << ") overflow" << nl
<< " Continuing with the last entry"
<< endl;
// fall-through to 'CLAMP'
// Behaviour as per 'CLAMP'
return this->last().second();
break;
}
case interpolationTable::CLAMP:
{
return List<Tuple2<scalar, Type>>::operator[](n-1).second();
return this->last().second();
break;
}
case interpolationTable::REPEAT:
{
// adjust lookupValue <= maxLimit
scalar span = maxLimit-minLimit;
const scalar span = maxLimit-minLimit;
lookupValue = fmod(lookupValue-minLimit, span) + minLimit;
break;
}
@ -575,7 +585,7 @@ Type Foam::interpolationTable<Type>::operator()(const scalar value) const
}
else if (hi == 0)
{
// this treatment should should only occur under these conditions:
// this treatment should only occur under these conditions:
// -> the 'REPEAT' treatment
// -> (0 <= value <= minLimit)
// -> minLimit > 0

View File

@ -363,7 +363,7 @@ Foam::Ostream& Foam::operator<<
<< endl << endl;
}
os.check("Ostream& operator<<(Ostream&, const LduMatrix&");
os.check(FUNCTION_NAME);
return os;
}

View File

@ -48,7 +48,7 @@ Foam::Istream& Foam::operator>>(Istream& is, Matrix<Form, Type>& M)
// Anull matrix
M.clear();
is.fatalCheck("operator>>(Istream&, Matrix<Form, Type>&)");
is.fatalCheck(FUNCTION_NAME);
token firstToken(is);
@ -250,9 +250,7 @@ Foam::Ostream& Foam::operator<<(Ostream& os, const Matrix<Form, Type>& M)
}
}
// Check state of IOstream
os.check("Ostream& operator<<(Ostream&, const Matrix&)");
os.check(FUNCTION_NAME);
return os;
}

View File

@ -338,7 +338,7 @@ Foam::Ostream& Foam::operator<<(Ostream& os, const lduMatrix& ldum)
os << ldum.upper();
}
os.check("Ostream& operator<<(Ostream&, const lduMatrix&");
os.check(FUNCTION_NAME);
return os;
}
@ -398,7 +398,7 @@ Foam::Ostream& Foam::operator<<(Ostream& os, const InfoProxy<lduMatrix>& ip)
// os << endl;
//}
os.check("Ostream& operator<<(Ostream&, const lduMatrix&");
os.check(FUNCTION_NAME);
return os;
}

View File

@ -142,9 +142,7 @@ Ostream& operator<<(Ostream& os, const DynamicID<ObjectType>& dynId)
<< dynId.name() << token::SPACE << dynId.index()
<< token::END_LIST;
// Check state of Ostream
os.check("Ostream& operator<<(Ostream&, const DynamicID<ObjectType>&)");
os.check(FUNCTION_NAME);
return os;
}

View File

@ -82,7 +82,7 @@ Foam::patchIdentifier::~patchIdentifier()
bool Foam::patchIdentifier::inGroup(const word& name) const
{
return inGroups_.size() && findIndex(inGroups_, name) != -1;
return findIndex(inGroups_, name) != -1;
}

View File

@ -106,48 +106,39 @@ void Foam::surfZoneIdentifier::write(Ostream& os) const
}
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
// * * * * * * * * * * * * * * * Global Operators * * * * * * * * * * * * * //
// needed for list output
bool Foam::surfZoneIdentifier::operator!=
(
const surfZoneIdentifier& rhs
) const
{
return !(*this == rhs);
}
bool Foam::surfZoneIdentifier::operator==
(
const surfZoneIdentifier& rhs
) const
bool Foam::operator==(const surfZoneIdentifier& a, const surfZoneIdentifier& b)
{
return
(
(index() == rhs.index())
&& (name() == rhs.name())
&& (geometricType() == rhs.geometricType())
(a.index() == b.index())
&& (a.name() == b.name())
&& (a.geometricType() == b.geometricType())
);
}
bool Foam::operator!=(const surfZoneIdentifier& a, const surfZoneIdentifier& b)
{
return !(a == b);
}
// * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * //
Foam::Istream& Foam::operator>>(Istream& is, surfZoneIdentifier& obj)
{
is >> obj.name_ >> obj.geometricType_;
return is;
}
Foam::Ostream& Foam::operator<<(Ostream& os, const surfZoneIdentifier& obj)
{
// newlines to separate, since that is what triSurface currently expects
// Newlines to separate, since that is what triSurface currently expects
os << nl << obj.name_ << nl << obj.geometricType_;
os.check("Ostream& operator<<(Ostream&, const surfZoneIdentifier&)");
os.check(FUNCTION_NAME);
return os;
}

View File

@ -51,8 +51,8 @@ class dictionary;
// Forward declaration of friend functions and operators
class surfZoneIdentifier;
Istream& operator>>(Istream&, surfZoneIdentifier&);
Ostream& operator<<(Ostream&, const surfZoneIdentifier&);
Istream& operator>>(Istream& is, surfZoneIdentifier& p);
Ostream& operator<<(Ostream& os, const surfZoneIdentifier& p);
/*---------------------------------------------------------------------------*\
Class surfZoneIdentifier Declaration
@ -94,21 +94,20 @@ public:
const word& name,
const label index,
const word& geometricType = word::null
);
//- Construct from dictionary
surfZoneIdentifier
(
const word& name,
const dictionary&,
const dictionary& dict,
const label index
);
//- Construct from another zone identifier, resetting the index
//- Copy construct from another zone identifier, resetting the index
surfZoneIdentifier
(
const surfZoneIdentifier&,
const surfZoneIdentifier& p,
const label index
);
@ -156,14 +155,8 @@ public:
}
//- Write surfZoneIdentifier as a dictionary
void write(Ostream&) const;
// Member Operators
bool operator!=(const surfZoneIdentifier&) const;
bool operator==(const surfZoneIdentifier&) const;
//- Write identifier as a dictionary
void write(Ostream& os) const;
// Ostream Operator
@ -171,20 +164,29 @@ public:
//- Read name/type.
friend Istream& operator>>
(
Istream&,
surfZoneIdentifier&
Istream& is,
surfZoneIdentifier& ob
);
//- Write name/type.
friend Ostream& operator<<
(
Ostream&,
const surfZoneIdentifier&
Ostream& os,
const surfZoneIdentifier& obj
);
};
// Global Operators
//- Compare zone indentifiers for equality
bool operator==(const surfZoneIdentifier& a, const surfZoneIdentifier& b);
//- Compare zone indentifiers for inequality
bool operator!=(const surfZoneIdentifier& a, const surfZoneIdentifier& b);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam

View File

@ -259,8 +259,7 @@ Foam::Ostream& Foam::operator<<(Ostream& os, const boundBox& bb)
);
}
// Check state of Ostream
os.check("Ostream& operator<<(Ostream&, const boundBox&)");
os.check(FUNCTION_NAME);
return os;
}
@ -280,8 +279,7 @@ Foam::Istream& Foam::operator>>(Istream& is, boundBox& bb)
);
}
// Check state of Istream
is.check("Istream& operator>>(Istream&, boundBox&)");
is.check(FUNCTION_NAME);
return is;
}

View File

@ -139,7 +139,7 @@ Foam::Ostream& Foam::operator<<(Ostream& os, const InfoProxy<lduMesh>& ip)
}
}
os.check("Ostream& operator<<(Ostream&, const lduMesh&");
os.check(FUNCTION_NAME);
return os;
}

View File

@ -176,9 +176,7 @@ inline Foam::Istream& Foam::operator>>(Istream& is, face& f)
is >> static_cast<labelList&>(f);
}
// Check state of Ostream
is.check("Istream& operator>>(Istream&, face&)");
is.check(FUNCTION_NAME);
return is;
}

View File

@ -137,9 +137,7 @@ inline Foam::Istream& Foam::operator>>(Istream& is, labelledTri& t)
is.read(reinterpret_cast<char*>(&t), sizeof(labelledTri));
}
// Check state of Ostream
is.check("Istream& operator>>(Istream&, labelledTri&)");
is.check(FUNCTION_NAME);
return is;
}
@ -161,9 +159,7 @@ inline Foam::Ostream& Foam::operator<<(Ostream& os, const labelledTri& t)
);
}
// Check state of Ostream
os.check(FUNCTION_NAME);
return os;
}

View File

@ -545,7 +545,7 @@ void Foam::mapDistribute::operator=(const mapDistribute& rhs)
Foam::Istream& Foam::operator>>(Istream& is, mapDistribute& map)
{
is.fatalCheck("operator>>(Istream&, mapDistribute&)");
is.fatalCheck(FUNCTION_NAME);
is >> static_cast<mapDistributeBase&>(map)
>> map.transformElements_ >> map.transformStart_;

View File

@ -1248,7 +1248,7 @@ void Foam::mapDistributeBase::operator=(const mapDistributeBase& rhs)
Foam::Istream& Foam::operator>>(Istream& is, mapDistributeBase& map)
{
is.fatalCheck("operator>>(Istream&, mapDistributeBase&)");
is.fatalCheck(FUNCTION_NAME);
is >> map.constructSize_ >> map.subMap_ >> map.constructMap_
>> map.subHasFlip_ >> map.constructHasFlip_;

View File

@ -309,7 +309,7 @@ void Foam::mapDistributePolyMesh::operator=(const mapDistributePolyMesh& rhs)
Foam::Istream& Foam::operator>>(Istream& is, mapDistributePolyMesh& map)
{
is.fatalCheck("operator>>(Istream&, mapDistributePolyMesh&)");
is.fatalCheck(FUNCTION_NAME);
is >> map.nOldPoints_
>> map.nOldFaces_

View File

@ -58,8 +58,7 @@ inline objectMap::objectMap(Istream& is)
// Read master of objectMap
is.readEnd("objectMap");
// Check state of Istream
is.check("objectMap::objectMap(Istream&)");
is.check(FUNCTION_NAME);
}
@ -115,9 +114,7 @@ inline Ostream& operator<<(Ostream& os, const objectMap& a)
<< a.masterObjects_
<< token::END_LIST;
// Check state of Ostream
os.check("Ostream& operator<<(Ostream&, const objectMap&)");
os.check(FUNCTION_NAME);
return os;
}
@ -128,9 +125,7 @@ inline Istream& operator>>(Istream& is, objectMap& a)
is >> a.index_ >> a.masterObjects_;
is.readEnd("objectMap");
// Check state of Istream
is.check("Istream& operator>>(Istream&, objectMap&)");
is.check(FUNCTION_NAME);
return is;
}

View File

@ -86,12 +86,7 @@ Foam::polyBoundaryMesh::polyBoundaryMesh
);
}
// Check state of IOstream
is.check
(
"polyBoundaryMesh::polyBoundaryMesh"
"(const IOobject&, const polyMesh&)"
);
is.check(FUNCTION_NAME);
close();
}
@ -155,12 +150,7 @@ Foam::polyBoundaryMesh::polyBoundaryMesh
);
}
// Check state of IOstream
is.check
(
"polyBoundaryMesh::polyBoundaryMesh"
"(const IOobject&, const polyMesh&, const polyPatchList&)"
);
is.check(FUNCTION_NAME);
close();
}
@ -1121,9 +1111,7 @@ bool Foam::polyBoundaryMesh::writeData(Ostream& os) const
os << decrIndent << token::END_LIST;
// Check state of IOstream
os.check("polyBoundaryMesh::writeData(Ostream& os) const");
os.check(FUNCTION_NAME);
return os.good();
}

View File

@ -114,12 +114,7 @@ Foam::Istream& Foam::operator>>(Istream& is, tetIndices& tI)
>> tI.facePtB()
>> tI.tetPt();
// Check state of Istream
is.check
(
"Foam::Istream& Foam::operator>>(Foam::Istream&, Foam::tetIndices&)"
);
is.check(FUNCTION_NAME);
return is;
}
@ -134,13 +129,7 @@ Foam::Ostream& Foam::operator<<(Ostream& os, const tetIndices& tI)
<< tI.tetPt() << token::SPACE
<< endl;
// Check state of Ostream
os.check
(
"Foam::Ostream& Foam::operator<<(Foam::Ostream&, "
"const Foam::tetIndices&)"
);
os.check(FUNCTION_NAME);
return os;
}

View File

@ -421,7 +421,7 @@ void Foam::polyPatch::operator=(const polyPatch& p)
Foam::Ostream& Foam::operator<<(Ostream& os, const polyPatch& p)
{
p.write(os);
os.check("Ostream& operator<<(Ostream& os, const polyPatch& p");
os.check(FUNCTION_NAME);
return os;
}

View File

@ -173,7 +173,7 @@ void Foam::cellZone::operator=(const Xfer<labelList>& addr)
Foam::Ostream& Foam::operator<<(Ostream& os, const cellZone& zn)
{
zn.write(os);
os.check("Ostream& operator<<(Ostream&, const cellZone&");
os.check(FUNCTION_NAME);
return os;
}

View File

@ -544,7 +544,7 @@ void Foam::faceZone::writeDict(Ostream& os) const
Foam::Ostream& Foam::operator<<(Ostream& os, const faceZone& zn)
{
zn.write(os);
os.check("Ostream& operator<<(Ostream&, const faceZone&");
os.check(FUNCTION_NAME);
return os;
}

View File

@ -225,7 +225,7 @@ void Foam::pointZone::operator=(const Xfer<labelList>& addr)
Foam::Ostream& Foam::operator<<(Ostream& os, const pointZone& zn)
{
zn.write(os);
os.check("Ostream& operator<<(Ostream&, const pointZone&");
os.check(FUNCTION_NAME);
return os;
}

View File

@ -242,7 +242,7 @@ void Foam::zone::write(Ostream& os) const
Foam::Ostream& Foam::operator<<(Ostream& os, const zone& z)
{
z.write(os);
os.check("Ostream& operator<<(Ostream& f, const zone& z");
os.check(FUNCTION_NAME);
return os;
}

View File

@ -280,7 +280,7 @@ inline Foam::Istream& Foam::operator>>
is >> l.a_ >> l.b_;
is.readEnd("line");
is.check("Istream& operator>>(Istream&, line&)");
is.check(FUNCTION_NAME);
return is;
}

View File

@ -212,12 +212,11 @@ public:
);
}
// Check state of Ostream
os.check("Ostream& operator<<(Ostream&, const PointIndexHit&)");
os.check(FUNCTION_NAME);
return os;
}
friend Istream& operator>>(Istream& is, PointIndexHit& pHit)
{
if (is.format() == IOstream::ASCII)
@ -233,9 +232,7 @@ public:
);
}
// Check state of Istream
is.check("Istream& operator>>(Istream&, PointIndexHit&)");
is.check(FUNCTION_NAME);
return is;
}

View File

@ -45,7 +45,7 @@ template<class Point, class PointRef, class polygonRef>
inline Foam::pyramid<Point, PointRef, polygonRef>::pyramid(Istream& is)
{
is >> base_ >> apex_;
is.check("pyramid::pyramid(Istream&)");
is.check(FUNCTION_NAME);
}
@ -105,7 +105,7 @@ inline Foam::Istream& Foam::operator>>
)
{
is >> p.base_ >> p.apex_;
is.check("Istream& operator>>(Istream&, pyramid&)");
is.check(FUNCTION_NAME);
return is;
}

View File

@ -967,7 +967,7 @@ inline Foam::Istream& Foam::operator>>
is >> t.a_ >> t.b_ >> t.c_ >> t.d_;
is.readEnd("tetrahedron");
is.check("Istream& operator>>(Istream&, tetrahedron&)");
is.check(FUNCTION_NAME);
return is;
}

View File

@ -869,7 +869,7 @@ inline Foam::Istream& Foam::operator>>
is >> t.a_ >> t.b_ >> t.c_;
is.readEnd("triangle");
is.check("Istream& operator>>(Istream&, triangle&)");
is.check(FUNCTION_NAME);
return is;
}

View File

@ -111,9 +111,7 @@ Istream& operator>>(Istream& is, Scalar& s)
return is;
}
// Check state of Istream
is.check("Istream& operator>>(Istream&, Scalar&)");
is.check(FUNCTION_NAME);
return is;
}
@ -121,7 +119,7 @@ Istream& operator>>(Istream& is, Scalar& s)
Ostream& operator<<(Ostream& os, const Scalar s)
{
os.write(s);
os.check("Ostream& operator<<(Ostream&, const Scalar&)");
os.check(FUNCTION_NAME);
return os;
}

View File

@ -234,9 +234,7 @@ inline Istream& operator>>(Istream& is, Tuple2<Type1, Type2>& t2)
is >> t2.f_ >> t2.s_;
is.readEnd("Tuple2");
// Check state of Istream
is.check("operator>>(Istream&, Tuple2<Type1, Type2>&)");
is.check(FUNCTION_NAME);
return is;
}

View File

@ -48,7 +48,7 @@ Foam::VectorSpace<Form, Cmpt, Ncmpts>::VectorSpace
is.readEnd("VectorSpace<Form, Cmpt, Ncmpts>");
// Check state of Istream
is.check("VectorSpace<Form, Cmpt, Ncmpts>::VectorSpace(Istream&)");
is.check(FUNCTION_NAME);
}
@ -94,7 +94,7 @@ Foam::Istream& Foam::operator>>
is.readEnd("VectorSpace<Form, Cmpt, Ncmpts>");
// Check state of Istream
is.check("operator>>(Istream&, VectorSpace<Form, Cmpt, Ncmpts>&)");
is.check(FUNCTION_NAME);
return is;
}
@ -116,9 +116,7 @@ Foam::Ostream& Foam::operator<<
os << token::END_LIST;
// Check state of Ostream
os.check("operator<<(Ostream&, const VectorSpace<Form, Cmpt, Ncmpts>&)");
os.check(FUNCTION_NAME);
return os;
}

View File

@ -39,7 +39,7 @@ char Foam::readChar(Istream& is)
Foam::Istream& Foam::operator>>(Istream& is, char& c)
{
is.read(c);
is.check("Istream& operator>>(Istream&, char&)");
is.check(FUNCTION_NAME);
return is;
}
@ -47,7 +47,7 @@ Foam::Istream& Foam::operator>>(Istream& is, char& c)
Foam::Ostream& Foam::operator<<(Ostream& os, const char c)
{
os.write(c);
os.check("Ostream& operator<<(Ostream&, const char)");
os.check(FUNCTION_NAME);
return os;
}
@ -55,7 +55,7 @@ Foam::Ostream& Foam::operator<<(Ostream& os, const char c)
Foam::Ostream& Foam::operator<<(Ostream& os, const char* s)
{
os.write(s);
os.check("Ostream& operator<<(Ostream&, const char*)");
os.check(FUNCTION_NAME);
return os;
}

View File

@ -95,7 +95,7 @@ Foam::Ostream& Foam::operator<<(Ostream& os, const wchar_t wc)
os.write(char(0xBD));
}
os.check("Ostream& operator<<(Ostream&, const wchar_t)");
os.check(FUNCTION_NAME);
return os;
}

View File

@ -64,9 +64,7 @@ Foam::Istream& Foam::operator>>(Istream& is, complex& c)
// Read end of complex
is.readEnd("complex");
// Check state of Istream
is.check("operator>>(Istream&, complex&)");
is.check(FUNCTION_NAME);
return is;
}

View File

@ -0,0 +1,238 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2017 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 3 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, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "Enum.H"
#include "dictionary.H"
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
template<class EnumType>
Foam::label Foam::Enum<EnumType>::getIndex(const word& enumName) const
{
const label n = size();
for (label idx=0; idx < n; ++idx)
{
if (names_[idx] == enumName)
{
return idx;
}
}
return -1;
}
template<class EnumType>
Foam::label Foam::Enum<EnumType>::getIndex(const EnumType e) const
{
const int val = int(e);
const label n = size();
for (label idx=0; idx < n; ++idx)
{
if (values_[idx] == val)
{
return idx;
}
}
return -1;
}
template<class EnumType>
EnumType Foam::Enum<EnumType>::getEnum(const word& enumName) const
{
const label idx = getIndex(enumName);
if (idx < 0)
{
FatalErrorInFunction
<< enumName << " is not in enumeration: "
<< names_ << exit(FatalError);
}
return EnumType(values_[idx]);
}
template<class EnumType>
const Foam::word& Foam::Enum<EnumType>::getName(const EnumType e) const
{
const label idx = getIndex(e);
if (idx < 0)
{
return word::null;
}
else
{
return names_[idx];
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class EnumType>
Foam::Enum<EnumType>::Enum
(
std::initializer_list<std::pair<EnumType, word>> lst
)
:
names_(lst.size()),
values_(lst.size())
{
int idx = 0;
for (const auto& pair : lst)
{
names_[idx] = pair.second;
values_[idx] = int(pair.first);
++idx;
}
}
template<class EnumType>
Foam::Enum<EnumType>::Enum
(
const EnumType start,
std::initializer_list<word> lst
)
:
names_(lst.size()),
values_(lst.size())
{
int val = int(start);
int idx = 0;
for (const auto& key : lst)
{
names_[idx] = key;
values_[idx] = val;
++val;
++idx;
}
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class EnumType>
Foam::List<Foam::word> Foam::Enum<EnumType>::sortedToc() const
{
wordList lst(names_);
Foam::sort(lst);
return lst;
}
template<class EnumType>
EnumType Foam::Enum<EnumType>::read(Istream& is) const
{
const word enumName(is);
const label idx = getIndex(enumName);
if (idx < 0)
{
FatalIOErrorInFunction(is)
<< enumName << " is not in enumeration: "
<< names_ << nl
<< exit(FatalIOError);
}
return EnumType(values_[idx]);
}
template<class EnumType>
void Foam::Enum<EnumType>::write(const EnumType e, Ostream& os) const
{
const label idx = getIndex(e);
if (idx >= 0)
{
os << names_[idx];
}
}
template<class EnumType>
EnumType Foam::Enum<EnumType>::lookup
(
const word& key,
const dictionary& dict
) const
{
const word enumName(dict.lookup(key));
const label idx = getIndex(enumName);
if (idx < 0)
{
FatalIOErrorInFunction(dict)
<< enumName << " is not in enumeration: "
<< names_ << nl
<< exit(FatalIOError);
}
return EnumType(values_[idx]);
}
template<class EnumType>
EnumType Foam::Enum<EnumType>::lookupOrDefault
(
const word& key,
const dictionary& dict,
const EnumType deflt
) const
{
if (dict.found(key))
{
return lookup(key, dict);
}
else
{
return deflt;
}
}
// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
template<class EnumType>
Foam::Ostream& Foam::operator<<
(
Ostream& os,
const Enum<EnumType>& wrapped
)
{
return wrapped.names().writeList(os, 10);
}
// ************************************************************************* //

View File

@ -0,0 +1,220 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2017 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 3 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, see <http://www.gnu.org/licenses/>.
Class
Foam::Enum
Description
A Enum is a wrapper around a list of names/values that represent
particular enumeration values.
SourceFiles
Enum.C
\*---------------------------------------------------------------------------*/
#ifndef Enum_H
#define Enum_H
#include "wordList.H"
#include <initializer_list>
#include <utility>
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// Forward declarations
class dictionary;
template<class EnumType> class Enum;
template<class EnumType>
Ostream& operator<<(Ostream& os, const Enum<EnumType>& wrapped);
/*---------------------------------------------------------------------------*\
Class Enum Declaration
\*---------------------------------------------------------------------------*/
template<class EnumType>
class Enum
{
// Private Member Data
//- The names for the enum
List<word> names_;
//- The values for the enum
List<int> values_;
// Private Member Functions
//- The index for the given name. -1 if not found.
label getIndex(const word& enumName) const;
//- The index for the given enumeration. -1 if not found.
label getIndex(const EnumType e) const;
//- Lookup enumeration corresponding to the given name.
// FatalError if not found.
EnumType getEnum(const word& enumName) const;
//- Lookup name corresponding to the given enumeration.
// Return empty word if not found.
const word& getName(const EnumType e) const;
//- Disallow default bitwise copy construct
Enum(const Enum&) = delete;
//- Disallow default bitwise assignment
void operator=(const Enum&) = delete;
public:
//- The type of enumeration wrapped by Enum
typedef EnumType value_type;
// Constructors
//- Construct from a values/names list.
// Duplicate values are permitted (eg, for aliases).
// Duplicate names are permitted, but won't make much sense.
explicit Enum(std::initializer_list<std::pair<EnumType, word>> lst);
//- Construct from a list of names with values incremented from the
// specified start value.
Enum(const EnumType start, std::initializer_list<word> lst);
// Member Functions
// Access
//- The number of lookup names for the enumeration
inline label size() const;
//- The list of enum names, in construction order
inline const List<word>& names() const;
//- The list of enum names, in construction order
inline const List<word>& toc() const;
//- The sorted list of enum names
List<word> sortedToc() const;
//- The list of enum values, in construction order
inline const List<int>& values() const;
// Query
//- Test if there is an enumeration corresponding to the given name.
inline bool hasEnum(const word& enumName) const;
//- Test if there is a name corresponding to the given enumeration.
inline bool hasName(const EnumType e) const;
// Lookup
//- Lookup the key in the dictionary and return the corresponding
// enumeration element based on its name.
// Fatal if anything is incorrect.
EnumType lookup
(
const word& key,
const dictionary& dict
) const;
//- Find the key in the dictionary and return the corresponding
// enumeration element based on its name.
// Return the default value if the key was not found in the dictionary.
// Fatal if the enumerated name was incorrect.
EnumType lookupOrDefault
(
const word& key,
const dictionary& dict,
const EnumType deflt
) const;
// IO
//- Read a word from Istream and return the corresponding enumeration
EnumType read(Istream& is) const;
//- Write the name representation of the enumeration to an Ostream
// A noop if the enumeration wasn't found.
void write(const EnumType e, Ostream& os) const;
//- Write the names as a list to an Ostream
inline Ostream& writeList
(
Ostream& os,
const label shortListLen=0
) const;
// Member Operators
//- Return the enumeration corresponding to the given name
// Fatal if the name cannot be found.
inline const EnumType operator[](const word& name) const;
//- Return the first name corresponding to the given enumeration.
// Returns an empty word on failure.
inline const word& operator[](const EnumType e) const;
// IOstream operators
//- Write names to Ostream, as per writeList() with shortListLen=10
friend Ostream& operator<< <EnumType>
(
Ostream& os,
const Enum<EnumType>& wrapped
);
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#include "EnumI.H"
#ifdef NoRepository
#include "Enum.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,103 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2017 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 3 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, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class EnumType>
inline Foam::label Foam::Enum<EnumType>::size() const
{
return names_.size();
}
template<class EnumType>
inline const Foam::wordList& Foam::Enum<EnumType>::names() const
{
return names_;
}
template<class EnumType>
inline const Foam::wordList& Foam::Enum<EnumType>::toc() const
{
return names_;
}
template<class EnumType>
inline const Foam::List<int>& Foam::Enum<EnumType>::values() const
{
return values_;
}
template<class EnumType>
inline bool Foam::Enum<EnumType>::hasEnum(const word& enumName) const
{
return getIndex(enumName) >= 0;
}
template<class EnumType>
inline bool Foam::Enum<EnumType>::hasName(const EnumType e) const
{
return getIndex(e) >= 0;
}
template<class EnumType>
inline Foam::Ostream& Foam::Enum<EnumType>::writeList
(
Ostream& os,
const label shortListLen
) const
{
return names_.writeList(os, shortListLen);
}
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
template<class EnumType>
inline const EnumType Foam::Enum<EnumType>::operator[]
(
const word& name
) const
{
return getEnum(name);
}
template<class EnumType>
inline const Foam::word& Foam::Enum<EnumType>::operator[]
(
const EnumType e
) const
{
return getName(e);
}
// ************************************************************************* //

View File

@ -0,0 +1,212 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd.
-------------------------------------------------------------------------------
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 3 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, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "NamedEnum.H"
#include "dictionary.H"
#include "stdFoam.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class EnumType, int nEnum>
Foam::NamedEnum<EnumType, nEnum>::NamedEnum()
:
lookup_(2*nEnum)
{
for (int enumi=0; enumi < nEnum; ++enumi)
{
if (names[enumi] && names[enumi][0])
{
lookup_.insert(names[enumi], enumi);
}
else
{
// Bad name - generate error message
List<string> goodNames(enumi);
for (int i = 0; i < enumi; ++i)
{
goodNames[i] = names[i];
}
FatalErrorInFunction
<< "Illegal enumeration name at position " << enumi << nl
<< "after entries " << goodNames << nl
<< "Possibly your NamedEnum<EnumType, nEnum>::names array"
<< " is not of size " << nEnum << endl
<< abort(FatalError);
}
}
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class EnumType, int nEnum>
Foam::wordList Foam::NamedEnum<EnumType, nEnum>::words() const
{
List<word> lst(nEnum);
label count = 0;
for (int enumi=0; enumi < nEnum; ++enumi)
{
if (names[enumi] && names[enumi][0])
{
lst[count++] = names[enumi];
}
}
lst.setSize(count);
return lst;
}
template<class EnumType, int nEnum>
Foam::List<int> Foam::NamedEnum<EnumType, nEnum>::values() const
{
List<int> lst(nEnum);
label count = 0;
for (int enumi=0; enumi < nEnum; ++enumi)
{
if (names[enumi] && names[enumi][0])
{
auto iter = lookup_.cfind(names[enumi]);
if (iter.found())
{
lst[count++] = iter.object();
}
}
}
lst.setSize(count);
return lst;
}
template<class EnumType, int nEnum>
bool Foam::NamedEnum<EnumType, nEnum>::hasName(const EnumType e) const
{
const int enumValue(e);
forAllConstIters(lookup_, iter)
{
if (iter.object() == enumValue)
{
return true;
}
}
return false;
}
template<class EnumType, int nEnum>
EnumType Foam::NamedEnum<EnumType, nEnum>::lookup
(
const word& key,
const dictionary& dict
) const
{
const word enumName(dict.lookup(key));
auto iter = lookup_.cfind(enumName);
if (!iter.found())
{
FatalIOErrorInFunction(dict)
<< enumName << " is not in enumeration: "
<< lookup_.sortedToc() << nl
<< exit(FatalIOError);
}
return EnumType(iter.object());
}
template<class EnumType, int nEnum>
EnumType Foam::NamedEnum<EnumType, nEnum>::lookupOrDefault
(
const word& key,
const dictionary& dict,
const EnumType deflt
) const
{
if (dict.found(key))
{
return lookup(key, dict);
}
else
{
return deflt;
}
}
template<class EnumType, int nEnum>
EnumType Foam::NamedEnum<EnumType, nEnum>::read(Istream& is) const
{
const word enumName(is);
auto iter = lookup_.cfind(enumName);
if (!iter.found())
{
FatalIOErrorInFunction(is)
<< enumName << " is not in enumeration: "
<< lookup_.sortedToc() << nl
<< exit(FatalIOError);
}
return EnumType(iter.object());
}
template<class EnumType, int nEnum>
void Foam::NamedEnum<EnumType, nEnum>::write
(
const EnumType e,
Ostream& os
) const
{
const int idx = int(e);
if (idx >= 0 && idx < nEnum)
{
os << names[idx];
}
}
// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
template<class EnumType, int nEnum>
Foam::Ostream& Foam::operator<<
(
Ostream& os,
const NamedEnum<EnumType, nEnum>& wrapped
)
{
return wrapped.lookup_.writeKeys(os, 10);
}
// ************************************************************************* //

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
\\/ M anipulation |
\\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -25,7 +25,8 @@ Class
Foam::NamedEnum
Description
Initialise the NamedEnum HashTable from the static list of names.
A NamedEnum is a wrapper around a list of names that represent
particular enumeration values.
SourceFiles
NamedEnum.C
@ -36,7 +37,6 @@ SourceFiles
#define NamedEnum_H
#include "HashTable.H"
#include "stringList.H"
#include "wordList.H"
#include <type_traits>
@ -44,22 +44,30 @@ SourceFiles
namespace Foam
{
// Forward declarations
class dictionary;
template<class EnumType, int nEnum> class NamedEnum;
template<class EnumType, int nEnum>
Ostream& operator<<(Ostream& os, const NamedEnum<EnumType, nEnum>& wrapped);
// Forward declaration
template<class Enum, int> class NamedEnum;
/*---------------------------------------------------------------------------*\
Class NamedEnum Declaration
\*---------------------------------------------------------------------------*/
template<class Enum, int nEnum>
template<class EnumType, int nEnum>
class NamedEnum
:
public HashTable<int>
{
//- nEnum must be positive (non-zero)
//- The nEnum must be positive (non-zero)
static_assert(nEnum > 0, "nEnum must be positive (non-zero)");
// Private Member Data
//- The values for the enum
HashTable<int> lookup_;
// Private Member Functions
//- Disallow default bitwise copy construct
@ -71,9 +79,13 @@ class NamedEnum
public:
//- The type of enumeration wrapped by NamedEnum
typedef EnumType value_type;
// Static data members
//- The set of names corresponding to the enumeration Enum
//- The set of names corresponding to the enumeration EnumType
static const char* names[nEnum];
@ -85,42 +97,84 @@ public:
// Member Functions
//- Read a word from Istream and return the corresponding
// enumeration element
Enum read(Istream&) const;
// Access
//- The number of lookup names for the enumeration
inline label size() const;
//- The list of enum names
inline wordList toc() const;
//- The sorted list of enum names
inline wordList sortedToc() const;
//- The list of enum names, in construction order
wordList words() const;
//- The list of enum values, in construction order
List<int> values() const;
// Query
//- Test if there is an enumeration corresponding to the given name.
inline bool hasEnum(const word& enumName) const;
//- Test if there is a name corresponding to the given enumeration.
bool hasName(const EnumType e) const;
// Lookup
//- Lookup the key in the dictionary and return the corresponding
// enumeration element based on its name.
// Fatal if anything is incorrect.
EnumType lookup
(
const word& key,
const dictionary& dict
) const;
//- Find the key in the dictionary and return the corresponding
// enumeration element based on its name.
// Return the default value if the key was not found in the dictionary.
// Fatal if enumerated name was incorrect.
EnumType lookupOrDefault
(
const word& key,
const dictionary& dict,
const EnumType deflt
) const;
// IO
//- Read a word from Istream and return the corresponding enumeration
EnumType read(Istream& is) const;
//- Write the name representation of the enumeration to an Ostream
void write(const Enum e, Ostream&) const;
//- The set of names as a list of strings
static stringList strings();
//- The set of names as a list of words
static wordList words();
//- List of enumerations
static List<Enum> enums();
// A noop if the enumeration wasn't found.
void write(const EnumType e, Ostream& os) const;
// Member Operators
//- Return the enumeration element corresponding to the given name
const Enum operator[](const char* name) const
{
return Enum(HashTable<int>::operator[](name));
}
//- Return the enumeration element corresponding to the given name
const Enum operator[](const word& name) const
{
return Enum(HashTable<int>::operator[](name));
}
inline const EnumType operator[](const word& name) const;
//- Return the name of the given enumeration element
const char* operator[](const Enum e) const
{
return names[int(e)];
}
inline const char* operator[](const EnumType e) const;
// IOstream operators
//- Write names to Ostream, as per writeKeys() with shortListLen=10
friend Ostream& operator<< <EnumType, nEnum>
(
Ostream& os,
const NamedEnum<EnumType, nEnum>& wrapped
);
};
@ -130,6 +184,8 @@ public:
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#include "NamedEnumI.H"
#ifdef NoRepository
#include "NamedEnum.C"
#endif

View File

@ -0,0 +1,81 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2017 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 3 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, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class EnumType, int nEnum>
inline Foam::label Foam::NamedEnum<EnumType, nEnum>::size() const
{
return lookup_.size();
}
template<class EnumType, int nEnum>
inline Foam::wordList Foam::NamedEnum<EnumType, nEnum>::toc() const
{
return lookup_.toc();
}
template<class EnumType, int nEnum>
inline Foam::wordList Foam::NamedEnum<EnumType, nEnum>::sortedToc() const
{
return lookup_.sortedToc();
}
template<class EnumType, int nEnum>
inline bool Foam::NamedEnum<EnumType, nEnum>::hasEnum
(
const word& enumName
) const
{
return lookup_.found(enumName);
}
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
template<class EnumType, int nEnum>
inline const EnumType Foam::NamedEnum<EnumType, nEnum>::operator[]
(
const word& name
) const
{
return EnumType(lookup_[name]);
}
template<class EnumType, int nEnum>
inline const char* Foam::NamedEnum<EnumType, nEnum>::operator[]
(
const EnumType e
) const
{
return names[int(e)];
}
// ************************************************************************* //

Some files were not shown because too many files have changed in this diff Show More