Commit 8558af2c authored by mattijs's avatar mattijs
Browse files

COMP: 64bit label changes

parent ea52a8bc
......@@ -230,7 +230,7 @@ void sammMesh::readCells()
{
IFstream cellsFile(cellsFileName);
labelList labels(24, -1);
labelList labels(24, label(-1));
label lineLabel, sammLabel, regionLabel, typeFlag;
for (label cellI = 0; cellI < nCells; cellI++)
......
......@@ -47,7 +47,7 @@ void starMesh::readBoundary()
labelList pointLabels(4);
labelList pointLabelsTri(3);
labelList patchLabels(1000, -1);
labelList patchLabels(1000, label(-1));
word patchType;
patchTypes_.setSize(1000);
......
......@@ -244,8 +244,8 @@ void Foam::domainDecomposition::decomposeMesh()
{
label nInterfaces = interPatchFaces[procI].size();
subPatchIDs[procI].setSize(nInterfaces, labelList(1, -1));
subPatchStarts[procI].setSize(nInterfaces, labelList(1, 0));
subPatchIDs[procI].setSize(nInterfaces, labelList(1, label(-1)));
subPatchStarts[procI].setSize(nInterfaces, labelList(1, label(0)));
}
// Processor boundaries from split cyclics
......@@ -319,7 +319,7 @@ void Foam::domainDecomposition::decomposeMesh()
{
label nIntfcs = interPatchFaces[procI].size();
subPatchIDs[procI].setSize(nIntfcs, labelList(1, patchi));
subPatchStarts[procI].setSize(nIntfcs, labelList(1, 0));
subPatchStarts[procI].setSize(nIntfcs, labelList(1, label(0)));
}
}
}
......
......@@ -24,6 +24,7 @@ License
\*---------------------------------------------------------------------------*/
#include "HashTable.H"
#include "uLabel.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
......@@ -47,7 +48,7 @@ Foam::label Foam::HashTableCore::canonicalSize(const label size)
}
// enforce power of two
unsigned int goodSize = size;
uLabel goodSize = size;
if (goodSize & (goodSize - 1))
{
......
......@@ -68,7 +68,7 @@ class UIPstream
const bool clearAtEnd_;
label messageSize_;
int messageSize_;
// Private Member Functions
......
......@@ -222,7 +222,7 @@ int Foam::UPstream::myProcNo_(0);
bool Foam::UPstream::parRun_(false);
// List of process IDs
Foam::List<int> Foam::UPstream::procIDs_(1, 0);
Foam::List<int> Foam::UPstream::procIDs_(label(1), 0);
// Standard transfer message type
int Foam::UPstream::msgType_(1);
......
......@@ -278,7 +278,7 @@ Foam::Time::Time
writeControl_(wcTimeStep),
writeInterval_(GREAT),
secondaryWriteControl_(wcTimeStep),
secondaryWriteInterval_(labelMax),
secondaryWriteInterval_(labelMax/10.0), // bit less to allow calculations
purgeWrite_(0),
writeOnce_(false),
subCycling_(false),
......@@ -370,7 +370,7 @@ Foam::Time::Time
writeControl_(wcTimeStep),
writeInterval_(GREAT),
secondaryWriteControl_(wcTimeStep),
secondaryWriteInterval_(labelMax),
secondaryWriteInterval_(labelMax/10.0),
purgeWrite_(0),
writeOnce_(false),
subCycling_(false),
......@@ -465,7 +465,7 @@ Foam::Time::Time
writeControl_(wcTimeStep),
writeInterval_(GREAT),
secondaryWriteControl_(wcTimeStep),
secondaryWriteInterval_(labelMax),
secondaryWriteInterval_(labelMax/10.0),
purgeWrite_(0),
writeOnce_(false),
subCycling_(false),
......@@ -562,7 +562,7 @@ Foam::Time::Time
writeControl_(wcTimeStep),
writeInterval_(GREAT),
secondaryWriteControl_(wcTimeStep),
secondaryWriteInterval_(labelMax),
secondaryWriteInterval_(labelMax/10.0),
purgeWrite_(0),
writeOnce_(false),
subCycling_(false),
......
......@@ -75,6 +75,28 @@ template<class T>
void transformList(const tensorField&, EdgeMap<T>&);
// Specialisations for bool
template<>
inline void transformList(const tensor&, UList<bool>&)
{}
template<>
inline void transformList(const tensorField&, UList<bool>&)
{}
template<>
inline void transformList(const tensor&, Map<bool>&)
{}
template<>
inline void transformList(const tensorField&, Map<bool>&)
{}
template<>
inline void transformList(const tensor&, EdgeMap<bool>&)
{}
template<>
inline void transformList(const tensorField&, EdgeMap<bool>&)
{}
// Specialisations for label
template<>
inline void transformList(const tensor&, labelUList&)
{}
......@@ -95,6 +117,7 @@ inline void transformList(const tensorField&, EdgeMap<label>&)
{}
// Specialisations for scalar
template<>
inline void transformList(const tensor&, UList<scalar>&)
{}
......
......@@ -137,7 +137,7 @@ void Foam::pointMapper::calcAddressing() const
if (addr[pointI].empty())
{
// Mapped from a dummy point. Take point 0 with weight 1.
addr[pointI] = labelList(1, 0);
addr[pointI] = labelList(1, label(0));
w[pointI] = scalarList(1, 1.0);
insertedPoints[nInsertedPoints] = pointI;
......
......@@ -88,7 +88,7 @@ void Foam::pointPatchMapper::calcAddressing() const
else
{
// Inserted point. Map from point0 (arbitrary choice)
addr[i] = labelList(1, 0);
addr[i] = labelList(1, label(0));
w[i] = scalarList(1, 1.0);
}
}
......
......@@ -202,7 +202,7 @@ void Foam::cellMapper::calcAddressing() const
if (addr[cellI].empty())
{
// Mapped from a dummy cell
addr[cellI] = labelList(1, 0);
addr[cellI] = labelList(1, label(0));
w[cellI] = scalarList(1, 1.0);
insertedCells[nInsertedCells] = cellI;
......
......@@ -180,7 +180,7 @@ void Foam::faceMapper::calcAddressing() const
if (addr[faceI].empty())
{
// Mapped from a dummy face
addr[faceI] = labelList(1, 0);
addr[faceI] = labelList(1, label(0));
w[faceI] = scalarList(1, 1.0);
insertedFaces[nInsertedFaces] = faceI;
......
......@@ -147,7 +147,7 @@ bool Foam::pointZone::checkParallelSync(const bool report) const
maxZone[pointI] = index();
minZone[pointI] = index();
}
syncTools::syncPointList(mesh, maxZone, maxEqOp<label>(), -1);
syncTools::syncPointList(mesh, maxZone, maxEqOp<label>(), label(-1));
syncTools::syncPointList(mesh, minZone, minEqOp<label>(), labelMax);
bool error = false;
......
......@@ -318,7 +318,7 @@ void Foam::globalIndexAndTransform::determineTransforms()
void Foam::globalIndexAndTransform::determineTransformPermutations()
{
label nTransformPermutations = pow(3, transforms_.size());
label nTransformPermutations = pow(label(3), transforms_.size());
transformPermutations_.setSize(nTransformPermutations);
......
......@@ -151,7 +151,7 @@ Foam::globalIndexAndTransform::decodeTransformIndex
const label transformIndex
) const
{
FixedList<label, 3> permutation(0);
FixedList<label, 3> permutation(label(0));
label t = transformIndex;
if (nIndependentTransforms() > 0)
......@@ -520,7 +520,7 @@ Foam::labelList Foam::globalIndexAndTransform::transformIndicesForPatches
}
// Number of selected transformations
label nSelTrans = pow(2, nUsedTrans) - 1;
label nSelTrans = pow(label(2), nUsedTrans) - 1;
// Pout<< nl << permutation << nl << endl;
......
......@@ -42,6 +42,8 @@ Description
namespace Foam
{
//template<class Type> class Hash;
//template<> class Hash<label>;
/*---------------------------------------------------------------------------*\
Class Hash Declaration
......@@ -70,54 +72,54 @@ public:
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
//- Hash specialization for hashing pointer addresses.
// Treat a pointer like a long.
// This should work for both 32-bit and 64-bit pointers.
//- Hash specialization for hashing labels
template<>
class Hash<void*>
class Hash<Foam::label>
{
public:
Hash()
{}
unsigned operator()(const void* const& p, unsigned seed) const
//- Incrementally hash a label.
// This will necessarily return a different value than the
// non-incremental version.
unsigned operator()(const label p, unsigned seed) const
{
return Hash<long>()(long(p), seed);
return Hasher(&p, sizeof(label), seed);
}
unsigned operator()(const void* const& p) const
//- Return the unsigned representation of a label.
// This helps if people have relied on the hash value corresponding to
// the natural order.
unsigned operator()(const label p) const
{
return Hash<long>()(long(p));
return p;
}
};
//- Hash specialization for hashing labels
//- Hash specialization for hashing pointer addresses.
// Treat a pointer like a long.
// This should work for both 32-bit and 64-bit pointers.
template<>
class Hash<Foam::label>
class Hash<void*>
{
public:
Hash()
{}
//- Incrementally hash a label.
// This will necessarily return a different value than the
// non-incremental version.
unsigned operator()(const label p, unsigned seed) const
unsigned operator()(const void* const& p, unsigned seed) const
{
return Hasher(&p, sizeof(label), seed);
return Hash<long>()(long(p), seed);
}
//- Return the unsigned representation of a label.
// This helps if people have relied on the hash value corresponding to
// the natural order.
unsigned operator()(const label p) const
unsigned operator()(const void* const& p) const
{
return p;
return Hash<long>()(long(p));
}
};
......
......@@ -53,6 +53,28 @@ pTraits<label>::pTraits(Istream& is)
}
#if (FOAM_LABEL_MAX != INT_MAX)
const char* const pTraits<int>::typeName = "int";
const int pTraits<int>::zero = 0;
const int pTraits<int>::one = 1;
const int pTraits<int>::min = INT_MIN;
const int pTraits<int>::max = INT_MAX;
const char* pTraits<int>::componentNames[] = { "x" };
pTraits<int>::pTraits(const int& p)
:
p_(p)
{}
pTraits<int>::pTraits(Istream& is)
{
is >> p_;
}
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Raise one label to the power of another (overloaded function call)
......
......@@ -47,6 +47,9 @@ Description
# define FOAM_LABEL_MAX 2000000000
#endif
#include "pTraits.H"
#include "direction.H"
#if INT_MAX > FOAM_LABEL_MAX
......@@ -126,8 +129,8 @@ namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#include "pTraits.H"
#include "direction.H"
//#include "pTraits.H"
//#include "direction.H"
namespace Foam
{
......@@ -188,6 +191,66 @@ public:
};
// For convenience's sake always define pTraits<int> (so even if label != int)
#if (FOAM_LABEL_MAX != INT_MAX)
//- template specialization for pTraits<int>
template<>
class pTraits<int>
{
int p_;
public:
//- Component type
typedef int cmptType;
// Member constants
enum
{
dim = 3, //!< Dimensionality of space
rank = 0, //!< Rank of int is 0
nComponents = 1 //!< Number of components in int is 1
};
// Static data members
static const char* const typeName;
static const char* componentNames[];
static const int zero;
static const int one;
static const int min;
static const int max;
// Constructors
//- Construct from primitive
explicit pTraits(const int&);
//- Construct from Istream
pTraits(Istream&);
// Member Functions
//- Access to the int value
operator int() const
{
return p_;
}
//- Access to the int value
operator int&()
{
return p_;
}
};
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
//- Raise one label to the power of another
......@@ -214,6 +277,7 @@ MAXMIN(char, char, char)
MAXMIN(short, short, short)
MAXMIN(int, int, int)
MAXMIN(long, long, long)
MAXMIN(long, long, int)
MAXMIN(long long, long long, long long)
MAXMIN(unsigned char, unsigned char, unsigned char)
......
......@@ -48,7 +48,7 @@ class Ostream;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
//- Return a string representation of a long
word name(long);
word name(const long);
// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
......
......@@ -37,7 +37,7 @@ Description
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
Foam::word Foam::name(long val)
Foam::word Foam::name(const long val)
{
std::ostringstream buf;
buf << val;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment