mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
Added and verified support for 64bit labels
To compile with 64bit labels set WM_LABEL_SIZE=64 in ~/OpenFOAM/dev/prefs.sh source ~/.bashrc then Allwmake in OpenFOAM-dev. This will build into for example OpenFOAM-dev/platforms/linux64ClangDPInt64Opt If WM_LABEL_SIZE is unset or set to 32: WM_LABEL_SIZE=32 the build would be placed into OpenFOAM-dev/platforms/linux64ClangDPInt32Opt Thus both 32bit and 64bit label builds can coexist without problem.
This commit is contained in:
@ -115,7 +115,7 @@ private:
|
||||
{
|
||||
typedef typename Triangulation::Geom_traits Gt;
|
||||
|
||||
typedef std::pair<const typename Triangulation::Point*, int>
|
||||
typedef std::pair<const typename Triangulation::Point*, label>
|
||||
Point_3;
|
||||
|
||||
struct Less_x_3
|
||||
|
||||
@ -450,7 +450,7 @@ Foam::DelaunayMesh<Triangulation>::createMesh
|
||||
}
|
||||
|
||||
label faceI = 0;
|
||||
labelList verticesOnTriFace(3, -1);
|
||||
labelList verticesOnTriFace(3, label(-1));
|
||||
face newFace(verticesOnTriFace);
|
||||
|
||||
for
|
||||
@ -461,7 +461,7 @@ Foam::DelaunayMesh<Triangulation>::createMesh
|
||||
)
|
||||
{
|
||||
const Cell_handle c1(fit->first);
|
||||
const int oppositeVertex = fit->second;
|
||||
const label oppositeVertex = fit->second;
|
||||
const Cell_handle c2(c1->neighbor(oppositeVertex));
|
||||
|
||||
// Do not output if face has neither opposite vertex as an internal
|
||||
|
||||
@ -287,7 +287,7 @@ void Foam::DistributedDelaunayMesh<Triangulation>::findProcessorBoundaryCells
|
||||
// Cell_handle cit = *vcit;
|
||||
//
|
||||
// // Index of infinite vertex in this cell.
|
||||
// int i = cit->index(Triangulation::infinite_vertex());
|
||||
// label i = cit->index(Triangulation::infinite_vertex());
|
||||
//
|
||||
// Cell_handle c = cit->neighbor(i);
|
||||
//
|
||||
@ -333,7 +333,7 @@ void Foam::DistributedDelaunayMesh<Triangulation>::findProcessorBoundaryCells
|
||||
if (Triangulation::is_infinite(cit))
|
||||
{
|
||||
// Index of infinite vertex in this cell.
|
||||
int i = cit->index(Triangulation::infinite_vertex());
|
||||
label i = cit->index(Triangulation::infinite_vertex());
|
||||
|
||||
Cell_handle c = cit->neighbor(i);
|
||||
|
||||
|
||||
@ -497,7 +497,7 @@ void Foam::searchableSurfaceControl::cellSizeFunctionVertices
|
||||
List<pointIndexHit> infoList(1, pointIndexHit());
|
||||
|
||||
vectorField normals(1);
|
||||
labelList region(1, -1);
|
||||
labelList region(1, label(-1));
|
||||
|
||||
forAll(points, pI)
|
||||
{
|
||||
|
||||
@ -43,7 +43,6 @@ SourceFiles
|
||||
|
||||
#include "CGALTriangulation3Ddefs.H"
|
||||
#include "uint.H"
|
||||
#include "ulong.H"
|
||||
#include "searchableSurfaces.H"
|
||||
#include "conformationSurfaces.H"
|
||||
#include "cellShapeControl.H"
|
||||
|
||||
@ -172,7 +172,7 @@ void Foam::conformalVoronoiMesh::calcTetMesh
|
||||
|
||||
label faceI = 0;
|
||||
|
||||
labelList verticesOnTriFace(3, -1);
|
||||
labelList verticesOnTriFace(3, label(-1));
|
||||
|
||||
face newFace(verticesOnTriFace);
|
||||
|
||||
@ -184,7 +184,7 @@ void Foam::conformalVoronoiMesh::calcTetMesh
|
||||
)
|
||||
{
|
||||
const Cell_handle c1(fit->first);
|
||||
const int oppositeVertex = fit->second;
|
||||
const label oppositeVertex = fit->second;
|
||||
const Cell_handle c2(c1->neighbor(oppositeVertex));
|
||||
|
||||
if (c1->hasFarPoint() && c2->hasFarPoint())
|
||||
@ -347,7 +347,7 @@ Foam::label Foam::conformalVoronoiMesh::mergeIdenticalDualVertices
|
||||
)
|
||||
{
|
||||
const Cell_handle c1(fit->first);
|
||||
const int oppositeVertex = fit->second;
|
||||
const label oppositeVertex = fit->second;
|
||||
const Cell_handle c2(c1->neighbor(oppositeVertex));
|
||||
|
||||
if (is_infinite(c1) || is_infinite(c2))
|
||||
@ -1070,7 +1070,7 @@ Foam::labelHashSet Foam::conformalVoronoiMesh::checkPolyMeshQuality
|
||||
|
||||
// Check for cells with one internal face only
|
||||
|
||||
labelList nInternalFaces(pMesh.nCells(), 0);
|
||||
labelList nInternalFaces(pMesh.nCells(), label(0));
|
||||
|
||||
for (label fI = 0; fI < pMesh.nInternalFaces(); fI++)
|
||||
{
|
||||
@ -1737,7 +1737,7 @@ void Foam::conformalVoronoiMesh::createFacesOwnerNeighbourAndPatches
|
||||
|
||||
const label nPatches = patchNames.size();
|
||||
|
||||
labelList procNeighbours(nPatches, -1);
|
||||
labelList procNeighbours(nPatches, label(-1));
|
||||
forAll(procNeighbours, patchI)
|
||||
{
|
||||
if (patchDicts[patchI].found("neighbProcNo"))
|
||||
@ -2580,7 +2580,7 @@ void Foam::conformalVoronoiMesh::removeUnusedPoints
|
||||
|
||||
label pointI = 0;
|
||||
|
||||
labelList oldToNew(pts.size(), -1);
|
||||
labelList oldToNew(pts.size(), label(-1));
|
||||
|
||||
// Move all of the used points to the start of the pointField and
|
||||
// truncate it
|
||||
@ -2637,7 +2637,7 @@ Foam::labelList Foam::conformalVoronoiMesh::removeUnusedCells
|
||||
|
||||
label cellI = 0;
|
||||
|
||||
labelList oldToNew(cellUsed.size(), -1);
|
||||
labelList oldToNew(cellUsed.size(), label(-1));
|
||||
|
||||
// Move all of the used cellCentres to the start of the pointField and
|
||||
// truncate it
|
||||
|
||||
@ -922,7 +922,7 @@ void Foam::conformalVoronoiMesh::createMultipleEdgePointGroup
|
||||
const List<extendedFeatureEdgeMesh::sideVolumeType>& normalVolumeTypes =
|
||||
feMesh.normalVolumeTypes();
|
||||
|
||||
labelList nNormalTypes(4, 0);
|
||||
labelList nNormalTypes(4, label(0));
|
||||
|
||||
forAll(edNormalIs, edgeNormalI)
|
||||
{
|
||||
|
||||
@ -90,7 +90,7 @@ inline Foam::scalar Foam::conformalVoronoiMesh::averageAnyCellSize
|
||||
label nProducts = 0;
|
||||
|
||||
const Cell_handle c(fit->first);
|
||||
const int oppositeVertex = fit->second;
|
||||
const label oppositeVertex = fit->second;
|
||||
|
||||
for (label i = 0; i < 3; i++)
|
||||
{
|
||||
@ -456,7 +456,7 @@ inline Foam::List<Foam::label> Foam::conformalVoronoiMesh::processorsAttached
|
||||
DynamicList<label> procsAttached(8);
|
||||
|
||||
const Cell_handle c1(fit->first);
|
||||
const int oppositeVertex = fit->second;
|
||||
const label oppositeVertex = fit->second;
|
||||
const Cell_handle c2(c1->neighbor(oppositeVertex));
|
||||
|
||||
FixedList<label, 4> c1Procs(CGAL::indexedCellOps::processorsAttached(c1));
|
||||
@ -486,7 +486,7 @@ inline bool Foam::conformalVoronoiMesh::isParallelDualEdge
|
||||
) const
|
||||
{
|
||||
const Cell_handle c1(fit->first);
|
||||
const int oppositeVertex = fit->second;
|
||||
const label oppositeVertex = fit->second;
|
||||
|
||||
return
|
||||
(
|
||||
|
||||
@ -542,7 +542,7 @@ void Foam::conformalVoronoiMesh::reorderPoints
|
||||
Info<< incrIndent << indent << "Reordering points into internal/external"
|
||||
<< endl;
|
||||
|
||||
labelList oldToNew(points.size(), 0);
|
||||
labelList oldToNew(points.size(), label(0));
|
||||
|
||||
// Find points that are internal
|
||||
for (label fI = nInternalFaces; fI < faces.size(); ++fI)
|
||||
@ -645,8 +645,8 @@ void Foam::conformalVoronoiMesh::reorderProcessorPatches
|
||||
// }
|
||||
|
||||
// Rotation on new faces.
|
||||
labelList rotation(faces.size(), 0);
|
||||
labelList faceMap(faces.size(), -1);
|
||||
labelList rotation(faces.size(), label(0));
|
||||
labelList faceMap(faces.size(), label(-1));
|
||||
|
||||
PstreamBuffers pBufs(Pstream::nonBlocking);
|
||||
|
||||
@ -692,8 +692,8 @@ void Foam::conformalVoronoiMesh::reorderProcessorPatches
|
||||
const label patchStartFace =
|
||||
readLabel(patchDicts[patchI].lookup("startFace"));
|
||||
|
||||
labelList patchFaceMap(nPatchFaces, -1);
|
||||
labelList patchFaceRotation(nPatchFaces, 0);
|
||||
labelList patchFaceMap(nPatchFaces, label(-1));
|
||||
labelList patchFaceRotation(nPatchFaces, label(0));
|
||||
|
||||
bool changed = refCast<const processorPolyPatch>(pp).order
|
||||
(
|
||||
|
||||
@ -83,7 +83,7 @@ bool Foam::conformalVoronoiMesh::distributeBackground(const Triangulation& mesh)
|
||||
|
||||
meshSearch cellSearch(bMesh, polyMesh::FACEPLANES);
|
||||
|
||||
labelList cellVertices(bMesh.nCells(), 0);
|
||||
labelList cellVertices(bMesh.nCells(), label(0));
|
||||
|
||||
for
|
||||
(
|
||||
|
||||
@ -218,7 +218,7 @@ Foam::labelList Foam::conformalVoronoiMesh::calcCellZones
|
||||
const pointField& cellCentres
|
||||
) const
|
||||
{
|
||||
labelList cellToSurface(cellCentres.size(), -1);
|
||||
labelList cellToSurface(cellCentres.size(), label(-1));
|
||||
|
||||
const PtrList<surfaceZonesInfo>& surfZones =
|
||||
geometryToConformTo().surfZones();
|
||||
@ -327,7 +327,7 @@ void Foam::conformalVoronoiMesh::calcFaceZones
|
||||
const labelList& faceOwner = mesh.faceOwner();
|
||||
const labelList& faceNeighbour = mesh.faceNeighbour();
|
||||
|
||||
labelList neiFaceOwner(mesh.nFaces() - mesh.nInternalFaces(), -1);
|
||||
labelList neiFaceOwner(mesh.nFaces() - mesh.nInternalFaces(), label(-1));
|
||||
|
||||
const polyBoundaryMesh& patches = mesh.boundaryMesh();
|
||||
|
||||
|
||||
@ -83,7 +83,7 @@ bool Foam::featurePointConformer::createSpecialisedFeaturePoint
|
||||
const labelListList& edgeNormals = feMesh.edgeNormals();
|
||||
|
||||
label concaveEdgeI = -1;
|
||||
labelList convexEdgesI(2, -1);
|
||||
labelList convexEdgesI(2, label(-1));
|
||||
label nConvex = 0;
|
||||
|
||||
forAll(pEds, i)
|
||||
@ -521,7 +521,7 @@ bool Foam::featurePointConformer::createSpecialisedFeaturePoint
|
||||
const labelListList& edgeNormals = feMesh.edgeNormals();
|
||||
|
||||
label convexEdgeI = -1;
|
||||
labelList concaveEdgesI(2, -1);
|
||||
labelList concaveEdgesI(2, label(-1));
|
||||
label nConcave = 0;
|
||||
|
||||
forAll(pEds, i)
|
||||
|
||||
@ -97,7 +97,7 @@ class indexedCell
|
||||
// < 0 && > ctFar : the (global) index of a dual point on a processor
|
||||
// face
|
||||
|
||||
int index_;
|
||||
Foam::label index_;
|
||||
|
||||
//- The number of times that this Delaunay cell has been limited
|
||||
// during filtering
|
||||
@ -154,9 +154,9 @@ public:
|
||||
|
||||
// Member Functions
|
||||
|
||||
inline int& cellIndex();
|
||||
inline Foam::label& cellIndex();
|
||||
|
||||
inline int cellIndex() const;
|
||||
inline Foam::label cellIndex() const;
|
||||
|
||||
#ifdef CGAL_INEXACT
|
||||
inline const Foam::point& dual();
|
||||
|
||||
@ -94,14 +94,14 @@ CGAL::indexedCell<Gt, Cb>::indexedCell
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class Gt, class Cb>
|
||||
int& CGAL::indexedCell<Gt, Cb>::cellIndex()
|
||||
Foam::label& CGAL::indexedCell<Gt, Cb>::cellIndex()
|
||||
{
|
||||
return index_;
|
||||
}
|
||||
|
||||
|
||||
template<class Gt, class Cb>
|
||||
int CGAL::indexedCell<Gt, Cb>::cellIndex() const
|
||||
Foam::label CGAL::indexedCell<Gt, Cb>::cellIndex() const
|
||||
{
|
||||
return index_;
|
||||
}
|
||||
|
||||
@ -112,7 +112,7 @@ class indexedVertex
|
||||
//- The index for this Delaunay vertex. For referred vertices, the
|
||||
// index is negative for vertices that are the outer (slave) of point
|
||||
// pairs
|
||||
int index_;
|
||||
Foam::label index_;
|
||||
|
||||
//- Number of the processor that owns this vertex
|
||||
int processor_;
|
||||
@ -154,7 +154,7 @@ public:
|
||||
inline indexedVertex
|
||||
(
|
||||
const Point& p,
|
||||
int index,
|
||||
Foam::label index,
|
||||
vertexType type,
|
||||
int processor
|
||||
);
|
||||
@ -162,7 +162,7 @@ public:
|
||||
inline indexedVertex
|
||||
(
|
||||
const Foam::point& p,
|
||||
int index,
|
||||
Foam::label index,
|
||||
vertexType type,
|
||||
int processor
|
||||
);
|
||||
@ -174,9 +174,9 @@ public:
|
||||
|
||||
// Member Functions
|
||||
|
||||
inline int& index();
|
||||
inline Foam::label& index();
|
||||
|
||||
inline int index() const;
|
||||
inline Foam::label index() const;
|
||||
|
||||
inline vertexType& type();
|
||||
|
||||
|
||||
@ -91,7 +91,7 @@ template<class Gt, class Vb>
|
||||
inline CGAL::indexedVertex<Gt, Vb>::indexedVertex
|
||||
(
|
||||
const Point& p,
|
||||
int index,
|
||||
Foam::label index,
|
||||
vertexType type,
|
||||
int processor
|
||||
)
|
||||
@ -110,7 +110,7 @@ template<class Gt, class Vb>
|
||||
inline CGAL::indexedVertex<Gt, Vb>::indexedVertex
|
||||
(
|
||||
const Foam::point& p,
|
||||
int index,
|
||||
Foam::label index,
|
||||
vertexType type,
|
||||
int processor
|
||||
)
|
||||
@ -154,14 +154,14 @@ inline CGAL::indexedVertex<Gt, Vb>::indexedVertex(Cell_handle f)
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class Gt, class Vb>
|
||||
inline int& CGAL::indexedVertex<Gt, Vb>::index()
|
||||
inline Foam::label& CGAL::indexedVertex<Gt, Vb>::index()
|
||||
{
|
||||
return index_;
|
||||
}
|
||||
|
||||
|
||||
template<class Gt, class Vb>
|
||||
inline int CGAL::indexedVertex<Gt, Vb>::index() const
|
||||
inline Foam::label CGAL::indexedVertex<Gt, Vb>::index() const
|
||||
{
|
||||
return index_;
|
||||
}
|
||||
|
||||
@ -299,7 +299,7 @@ bool Foam::autoDensity::fillBox
|
||||
{
|
||||
const conformationSurfaces& geometry = geometryToConformTo();
|
||||
|
||||
unsigned int initialSize = initialPoints.size();
|
||||
label initialSize = initialPoints.size();
|
||||
|
||||
scalar maxCellSize = -GREAT;
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2013 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2013-2014 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -113,7 +113,7 @@ Foam::searchableBoxFeatures::features() const
|
||||
surfacePoints[treeBoundBox::edges[eI].end()]
|
||||
- surfacePoints[treeBoundBox::edges[eI].start()];
|
||||
|
||||
normalDirections[eI] = labelList(2, 0);
|
||||
normalDirections[eI] = labelList(2, label(0));
|
||||
for (label j = 0; j < 2; ++j)
|
||||
{
|
||||
const vector cross =
|
||||
|
||||
@ -131,7 +131,7 @@ Foam::searchablePlateFeatures::features() const
|
||||
surface().points()()[edges[eI].end()]
|
||||
- surface().points()()[edges[eI].start()];
|
||||
|
||||
normalDirections[eI] = labelList(2, 0);
|
||||
normalDirections[eI] = labelList(2, label(0));
|
||||
for (label j = 0; j < 2; ++j)
|
||||
{
|
||||
const vector cross =
|
||||
|
||||
@ -28,7 +28,6 @@ License
|
||||
#include "transform.H"
|
||||
#include "IFstream.H"
|
||||
#include "uint.H"
|
||||
#include "ulong.H"
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -43,9 +43,9 @@ License
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
void Foam::writeFuns::swapWord(label& word32)
|
||||
void Foam::writeFuns::swapWord(int32_t& word32)
|
||||
{
|
||||
char* mem = reinterpret_cast<char*>(&word32);
|
||||
char* mem = reinterpret_cast<char*>(&word32);
|
||||
|
||||
char a = mem[0];
|
||||
mem[0] = mem[3];
|
||||
@ -57,9 +57,9 @@ void Foam::writeFuns::swapWord(label& word32)
|
||||
}
|
||||
|
||||
|
||||
void Foam::writeFuns::swapWords(const label nWords, label* words32)
|
||||
void Foam::writeFuns::swapWords(const label nWords, int32_t* words32)
|
||||
{
|
||||
for (label i = 0; i < nWords; i++)
|
||||
for (label i=0; i<nWords; i++)
|
||||
{
|
||||
swapWord(words32[i]);
|
||||
}
|
||||
@ -75,9 +75,9 @@ void Foam::writeFuns::write
|
||||
{
|
||||
if (binary)
|
||||
{
|
||||
# ifdef LITTLEENDIAN
|
||||
swapWords(fField.size(), reinterpret_cast<label*>(fField.begin()));
|
||||
# endif
|
||||
#ifdef LITTLEENDIAN
|
||||
swapWords(fField.size(), reinterpret_cast<int32_t*>(fField.begin()));
|
||||
#endif
|
||||
|
||||
os.write
|
||||
(
|
||||
@ -111,7 +111,6 @@ void Foam::writeFuns::write
|
||||
)
|
||||
{
|
||||
List<floatScalar>& fld = fField.shrink();
|
||||
|
||||
write(os, binary, fld);
|
||||
}
|
||||
|
||||
@ -125,9 +124,13 @@ void Foam::writeFuns::write
|
||||
{
|
||||
if (binary)
|
||||
{
|
||||
# ifdef LITTLEENDIAN
|
||||
swapWords(elems.size(), reinterpret_cast<label*>(elems.begin()));
|
||||
# endif
|
||||
#ifdef LITTLEENDIAN
|
||||
swapWords
|
||||
(
|
||||
(sizeof(label)/4)*elems.size(),
|
||||
reinterpret_cast<int32_t*>(elems.begin())
|
||||
);
|
||||
#endif
|
||||
os.write
|
||||
(
|
||||
reinterpret_cast<char*>(elems.begin()),
|
||||
@ -160,12 +163,10 @@ void Foam::writeFuns::write
|
||||
)
|
||||
{
|
||||
labelList& fld = elems.shrink();
|
||||
|
||||
write(os, binary, fld);
|
||||
}
|
||||
|
||||
|
||||
// Store vector in dest.
|
||||
void Foam::writeFuns::insert(const point& pt, DynamicList<floatScalar>& dest)
|
||||
{
|
||||
dest.append(float(pt.x()));
|
||||
@ -174,7 +175,6 @@ void Foam::writeFuns::insert(const point& pt, DynamicList<floatScalar>& dest)
|
||||
}
|
||||
|
||||
|
||||
// Store labelList in dest.
|
||||
void Foam::writeFuns::insert(const labelList& source, DynamicList<label>& dest)
|
||||
{
|
||||
forAll(source, i)
|
||||
@ -184,7 +184,6 @@ void Foam::writeFuns::insert(const labelList& source, DynamicList<label>& dest)
|
||||
}
|
||||
|
||||
|
||||
// Store scalarField in dest
|
||||
void Foam::writeFuns::insert
|
||||
(
|
||||
const List<scalar>& source,
|
||||
@ -198,7 +197,6 @@ void Foam::writeFuns::insert
|
||||
}
|
||||
|
||||
|
||||
// Store scalarField (indexed through map) in dest
|
||||
void Foam::writeFuns::insert
|
||||
(
|
||||
const labelList& map,
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -27,6 +27,12 @@ Class
|
||||
Description
|
||||
Various functions for collecting and writing binary data.
|
||||
|
||||
The LITTLE_ENDIAN is based on 32bit words.
|
||||
It is not clear how 64bit labels should be handled, currently they are
|
||||
split into two 32bit words and swapWord applied to these two.
|
||||
|
||||
writeFuns should be a namespace rather than a class.
|
||||
|
||||
SourceFiles
|
||||
writeFuns.C
|
||||
|
||||
@ -41,43 +47,54 @@ SourceFiles
|
||||
#include "DynamicList.H"
|
||||
#include "point.H"
|
||||
|
||||
using namespace Foam;
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class writeFuns Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class writeFuns
|
||||
{
|
||||
//- Swap halves of word.
|
||||
static void swapWord(label& word32);
|
||||
static void swapWords(const label nWords, label* words32);
|
||||
// Private member functions
|
||||
|
||||
//- Swap halves of word
|
||||
static void swapWord(int32_t& word32);
|
||||
|
||||
//- Swap halves of word
|
||||
static void swapWords(const label nWords, int32_t* words32);
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Write ascii or binary. If binary optionally in-place swaps argument
|
||||
//- Write floats ascii or binary.
|
||||
// If binary optionally in-place swaps argument
|
||||
static void write(std::ostream&, const bool, DynamicList<floatScalar>&);
|
||||
|
||||
//- Write labels ascii or binary.
|
||||
// If binary optionally in-place swaps argument
|
||||
static void write(std::ostream&, const bool, DynamicList<label>&);
|
||||
|
||||
//- Write ascii or binary. If binary optionally in-place swaps argument
|
||||
//- Write floats ascii or binary.
|
||||
// If binary optionally in-place swaps argument
|
||||
static void write(std::ostream&, const bool, List<floatScalar>&);
|
||||
|
||||
//- Write labels ascii or binary.
|
||||
// If binary optionally in-place swaps argument
|
||||
static void write(std::ostream&, const bool, labelList&);
|
||||
|
||||
//- Append point to DynamicList
|
||||
//- Append point to given DynamicList
|
||||
static void insert(const point&, DynamicList<floatScalar>& dest);
|
||||
|
||||
//- Append elements of labelList to DynamicList
|
||||
//- Append elements of labelList to given DynamicList
|
||||
static void insert(const labelList&, DynamicList<label>&);
|
||||
//- Append elements of scalarList to DynamicList
|
||||
|
||||
//- Append elements of scalarList to given DynamicList
|
||||
static void insert(const List<scalar>&, DynamicList<floatScalar>&);
|
||||
|
||||
//- Append elements of scalarList to DynamicList using map
|
||||
//- Append elements of scalarList to given DynamicList using map
|
||||
static void insert
|
||||
(
|
||||
const labelList& map,
|
||||
@ -85,16 +102,16 @@ public:
|
||||
DynamicList<floatScalar>&
|
||||
);
|
||||
|
||||
//- Append points to DynamicList of floats
|
||||
//- Append points to given DynamicList of floats
|
||||
static void insert(const List<point>& source, DynamicList<floatScalar>&);
|
||||
//- As above but using map
|
||||
|
||||
//- Append points to given DynamicList of floats using map
|
||||
static void insert
|
||||
(
|
||||
const labelList& map,
|
||||
const List<point>& source,
|
||||
DynamicList<floatScalar>&
|
||||
);
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -26,6 +26,7 @@ INCLUDE_DIRECTORIES(
|
||||
|
||||
ADD_DEFINITIONS(
|
||||
-DWM_$ENV{WM_PRECISION_OPTION}
|
||||
-DWM_LABEL_SIZE=$ENV{WM_LABEL_SIZE}
|
||||
)
|
||||
|
||||
# Set output library destination to plugin directory
|
||||
|
||||
@ -31,7 +31,6 @@ License
|
||||
#include "cellModeller.H"
|
||||
#include "vtkOpenFOAMPoints.H"
|
||||
#include "Swap.H"
|
||||
#include "longLong.H"
|
||||
|
||||
// VTK includes
|
||||
#include "vtkCellArray.h"
|
||||
|
||||
@ -26,6 +26,7 @@ INCLUDE_DIRECTORIES(
|
||||
|
||||
ADD_DEFINITIONS(
|
||||
-DWM_$ENV{WM_PRECISION_OPTION}
|
||||
-DWM_LABEL_SIZE=$ENV{WM_LABEL_SIZE}
|
||||
)
|
||||
|
||||
# Set output library destination to plugin directory
|
||||
|
||||
@ -26,6 +26,7 @@ INCLUDE_DIRECTORIES(
|
||||
|
||||
ADD_DEFINITIONS(
|
||||
-DWM_$ENV{WM_PRECISION_OPTION}
|
||||
-DWM_LABEL_SIZE=$ENV{WM_LABEL_SIZE}
|
||||
)
|
||||
|
||||
# Set output library destination to plugin directory
|
||||
|
||||
@ -31,7 +31,6 @@ License
|
||||
#include "cellModeller.H"
|
||||
#include "vtkOpenFOAMPoints.H"
|
||||
#include "Swap.H"
|
||||
#include "longLong.H"
|
||||
|
||||
// VTK includes
|
||||
#include "vtkCellArray.h"
|
||||
|
||||
@ -26,6 +26,7 @@ INCLUDE_DIRECTORIES(
|
||||
|
||||
ADD_DEFINITIONS(
|
||||
-DWM_$ENV{WM_PRECISION_OPTION}
|
||||
-DWM_LABEL_SIZE=$ENV{WM_LABEL_SIZE}
|
||||
)
|
||||
|
||||
# Set output library destination to plugin directory
|
||||
|
||||
@ -74,6 +74,10 @@ export WM_ARCH_OPTION=64
|
||||
# WM_PRECISION_OPTION = DP | SP
|
||||
export WM_PRECISION_OPTION=DP
|
||||
|
||||
#- Label size:
|
||||
# WM_LABEL_SIZE = 32 | 64
|
||||
export WM_LABEL_SIZE=32
|
||||
|
||||
#- Optimised, debug, profiling:
|
||||
# WM_COMPILE_OPTION = Opt | Debug | Prof
|
||||
export WM_COMPILE_OPTION=Opt
|
||||
|
||||
@ -30,7 +30,7 @@
|
||||
##------------------------------------------------------------------------------
|
||||
|
||||
set boost_version=boost-system
|
||||
set cgal_version=CGAL-4.3
|
||||
set cgal_version=CGAL-4.5.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
|
||||
|
||||
@ -30,7 +30,7 @@
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
boost_version=boost-system
|
||||
cgal_version=CGAL-4.3
|
||||
cgal_version=CGAL-4.5.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
|
||||
|
||||
@ -34,6 +34,6 @@
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
export SCOTCH_VERSION=scotch_6.0.0
|
||||
export SCOTCH_ARCH_PATH=$WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER/$SCOTCH_VERSION
|
||||
export SCOTCH_ARCH_PATH=$WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER$WM_LABEL_OPTION/$SCOTCH_VERSION
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
|
||||
@ -142,7 +142,8 @@ setenv FOAM_JOB_DIR $WM_PROJECT_INST_DIR/jobControl
|
||||
# wmake configuration
|
||||
setenv WM_DIR $WM_PROJECT_DIR/wmake
|
||||
setenv WM_LINK_LANGUAGE c++
|
||||
setenv WM_OPTIONS $WM_ARCH$WM_COMPILER$WM_PRECISION_OPTION$WM_COMPILE_OPTION
|
||||
setenv WM_LABEL_OPTION Int$WM_LABEL_SIZE
|
||||
setenv WM_OPTIONS $WM_ARCH$WM_COMPILER$WM_PRECISION_OPTION$WM_LABEL_OPTION$WM_COMPILE_OPTION
|
||||
|
||||
# base executables/libraries
|
||||
setenv FOAM_APPBIN $WM_PROJECT_DIR/platforms/$WM_OPTIONS/bin
|
||||
|
||||
@ -170,7 +170,8 @@ export FOAM_JOB_DIR=$WM_PROJECT_INST_DIR/jobControl
|
||||
# wmake configuration
|
||||
export WM_DIR=$WM_PROJECT_DIR/wmake
|
||||
export WM_LINK_LANGUAGE=c++
|
||||
export WM_OPTIONS=$WM_ARCH$WM_COMPILER$WM_PRECISION_OPTION$WM_COMPILE_OPTION
|
||||
export WM_LABEL_OPTION=Int$WM_LABEL_SIZE
|
||||
export WM_OPTIONS=$WM_ARCH$WM_COMPILER$WM_PRECISION_OPTION$WM_LABEL_OPTION$WM_COMPILE_OPTION
|
||||
|
||||
# base executables/libraries
|
||||
export FOAM_APPBIN=$WM_PROJECT_DIR/platforms/$WM_OPTIONS/bin
|
||||
|
||||
@ -74,6 +74,10 @@ setenv WM_ARCH_OPTION 64
|
||||
# WM_PRECISION_OPTION = DP | SP
|
||||
setenv WM_PRECISION_OPTION DP
|
||||
|
||||
#- Label size:
|
||||
# WM_LABEL_SIZE = 32 | 64
|
||||
setenv WM_LABEL_SIZE 32
|
||||
|
||||
#- Optimised, debug, profiling:
|
||||
# WM_COMPILE_OPTION = Opt | Debug | Prof
|
||||
setenv WM_COMPILE_OPTION Opt
|
||||
|
||||
@ -327,7 +327,7 @@ void Foam::fileMonitor::checkFiles() const
|
||||
else if (FD_ISSET(watcher_->inotifyFd_, &fdSet))
|
||||
{
|
||||
// Read events
|
||||
ssize_t nBytes = read
|
||||
ssize_t nBytes = ::read
|
||||
(
|
||||
watcher_->inotifyFd_,
|
||||
buffer,
|
||||
|
||||
@ -16,11 +16,16 @@ $(chars)/char/charIO.C
|
||||
$(chars)/wchar/wcharIO.C
|
||||
|
||||
ints = primitives/ints
|
||||
$(ints)/int/intIO.C
|
||||
$(ints)/uint32/uint32.C
|
||||
$(ints)/uint32/uint32IO.C
|
||||
$(ints)/uint64/uint64.C
|
||||
$(ints)/uint64/uint64IO.C
|
||||
$(ints)/uint/uintIO.C
|
||||
$(ints)/long/longIO.C
|
||||
$(ints)/longLong/longLongIO.C
|
||||
$(ints)/ulong/ulongIO.C
|
||||
$(ints)/int32/int32.C
|
||||
$(ints)/int32/int32IO.C
|
||||
$(ints)/int64/int64.C
|
||||
$(ints)/int64/int64IO.C
|
||||
$(ints)/int/intIO.C
|
||||
$(ints)/label/label.C
|
||||
$(ints)/uLabel/uLabel.C
|
||||
$(ints)/lists/labelIOList.C
|
||||
|
||||
@ -27,7 +27,6 @@ License
|
||||
|
||||
#include "DLListBase.H"
|
||||
#include "IOstreams.H"
|
||||
#include "long.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
|
||||
@ -122,8 +122,11 @@ public:
|
||||
const bool quoted=true
|
||||
) = 0;
|
||||
|
||||
//- Write label
|
||||
virtual Ostream& write(const label) = 0;
|
||||
//- Write int32_t
|
||||
virtual Ostream& write(const int32_t) = 0;
|
||||
|
||||
//- Write int64_t
|
||||
virtual Ostream& write(const int64_t) = 0;
|
||||
|
||||
//- Write floatScalar
|
||||
virtual Ostream& write(const floatScalar) = 0;
|
||||
|
||||
@ -254,7 +254,15 @@ Foam::Ostream& Foam::UOPstream::writeQuoted
|
||||
}
|
||||
|
||||
|
||||
Foam::Ostream& Foam::UOPstream::write(const label val)
|
||||
Foam::Ostream& Foam::UOPstream::write(const int32_t val)
|
||||
{
|
||||
write(char(token::LABEL));
|
||||
writeToBuffer(val);
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
Foam::Ostream& Foam::UOPstream::write(const int64_t val)
|
||||
{
|
||||
write(char(token::LABEL));
|
||||
writeToBuffer(val);
|
||||
|
||||
@ -156,8 +156,11 @@ public:
|
||||
const bool quoted=true
|
||||
);
|
||||
|
||||
//- Write label
|
||||
Ostream& write(const label);
|
||||
//- Write int32_t
|
||||
virtual Ostream& write(const int32_t);
|
||||
|
||||
//- Write int64_t
|
||||
Ostream& write(const int64_t);
|
||||
|
||||
//- Write floatScalar
|
||||
Ostream& write(const floatScalar);
|
||||
|
||||
@ -409,7 +409,12 @@ Foam::UPstream::treeCommunication_(10);
|
||||
|
||||
// Allocate a serial communicator. This gets overwritten in parallel mode
|
||||
// (by UPstream::setParRun())
|
||||
Foam::UPstream::communicator serialComm(-1, Foam::labelList(1, 0), false);
|
||||
Foam::UPstream::communicator serialComm
|
||||
(
|
||||
-1,
|
||||
Foam::labelList(1, Foam::label(0)),
|
||||
false
|
||||
);
|
||||
|
||||
|
||||
|
||||
|
||||
@ -413,7 +413,7 @@ public:
|
||||
}
|
||||
|
||||
//- Process ID of given process index
|
||||
static List<int>& procID(int communicator)
|
||||
static List<int>& procID(label communicator)
|
||||
{
|
||||
return procIDs_[communicator];
|
||||
}
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -31,16 +31,10 @@ Description
|
||||
#include "PstreamCombineReduceOps.H"
|
||||
#include "UPstream.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
//template<template<class> class ListType, class T>
|
||||
template<class Container, class T>
|
||||
void Pstream::exchange
|
||||
void Foam::Pstream::exchange
|
||||
(
|
||||
const List<Container>& sendBufs,
|
||||
List<Container>& recvBufs,
|
||||
@ -55,7 +49,7 @@ void Pstream::exchange
|
||||
FatalErrorIn
|
||||
(
|
||||
"Pstream::exchange(..)"
|
||||
) << "Continuous data only." << Foam::abort(FatalError);
|
||||
) << "Continuous data only." << sizeof(T) << Foam::abort(FatalError);
|
||||
}
|
||||
|
||||
if (sendBufs.size() != UPstream::nProcs(comm))
|
||||
@ -153,8 +147,4 @@ void Pstream::exchange
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -350,8 +350,8 @@ Foam::Istream& Foam::ISstream::read(token& t)
|
||||
{
|
||||
if (asLabel)
|
||||
{
|
||||
label labelVal;
|
||||
if (readLabel(buf, labelVal))
|
||||
label labelVal = 0;
|
||||
if (Foam::read(buf, labelVal))
|
||||
{
|
||||
t = labelVal;
|
||||
}
|
||||
@ -367,21 +367,6 @@ Foam::Istream& Foam::ISstream::read(token& t)
|
||||
{
|
||||
t.setBad();
|
||||
}
|
||||
// ---------------------------------------
|
||||
// this would also be possible if desired:
|
||||
// ---------------------------------------
|
||||
// // return as a label when possible
|
||||
// // eg, 1E6 -> 1000000
|
||||
// if (scalarVal <= labelMax && scalarVal >= labelMin)
|
||||
// {
|
||||
// label labelVal(scalarVal);
|
||||
//
|
||||
// if (labelVal == scalarVal)
|
||||
// {
|
||||
// t = labelVal;
|
||||
// }
|
||||
// }
|
||||
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
@ -183,7 +183,15 @@ Foam::Ostream& Foam::OSstream::writeQuoted
|
||||
}
|
||||
|
||||
|
||||
Foam::Ostream& Foam::OSstream::write(const label val)
|
||||
Foam::Ostream& Foam::OSstream::write(const int32_t val)
|
||||
{
|
||||
os_ << val;
|
||||
setState(os_.rdstate());
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
Foam::Ostream& Foam::OSstream::write(const int64_t val)
|
||||
{
|
||||
os_ << val;
|
||||
setState(os_.rdstate());
|
||||
|
||||
@ -130,8 +130,11 @@ public:
|
||||
const bool quoted=true
|
||||
);
|
||||
|
||||
//- Write label
|
||||
virtual Ostream& write(const label);
|
||||
//- Write int32_t
|
||||
virtual Ostream& write(const int32_t);
|
||||
|
||||
//- Write int64_t
|
||||
virtual Ostream& write(const int64_t);
|
||||
|
||||
//- Write floatScalar
|
||||
virtual Ostream& write(const floatScalar);
|
||||
|
||||
@ -137,7 +137,14 @@ Foam::Ostream& Foam::prefixOSstream::writeQuoted
|
||||
}
|
||||
|
||||
|
||||
Foam::Ostream& Foam::prefixOSstream::write(const label val)
|
||||
Foam::Ostream& Foam::prefixOSstream::write(const int32_t val)
|
||||
{
|
||||
checkWritePrefix();
|
||||
return OSstream::write(val);
|
||||
}
|
||||
|
||||
|
||||
Foam::Ostream& Foam::prefixOSstream::write(const int64_t val)
|
||||
{
|
||||
checkWritePrefix();
|
||||
return OSstream::write(val);
|
||||
|
||||
@ -121,8 +121,11 @@ public:
|
||||
const bool quoted=true
|
||||
);
|
||||
|
||||
//- Write label
|
||||
virtual Ostream& write(const label);
|
||||
//- Write int32_t
|
||||
virtual Ostream& write(const int32_t);
|
||||
|
||||
//- Write int64_t
|
||||
virtual Ostream& write(const int64_t);
|
||||
|
||||
//- Write floatScalar
|
||||
virtual Ostream& write(const floatScalar);
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -25,13 +25,13 @@ License
|
||||
|
||||
#include "dlLibraryTable.H"
|
||||
#include "OSspecific.H"
|
||||
#include "long.H"
|
||||
#include "int.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
defineTypeNameAndDebug(dlLibraryTable, 0);
|
||||
defineTypeNameAndDebug(dlLibraryTable, 0);
|
||||
}
|
||||
|
||||
|
||||
@ -63,7 +63,7 @@ Foam::dlLibraryTable::~dlLibraryTable()
|
||||
{
|
||||
Info<< "dlLibraryTable::~dlLibraryTable() : closing "
|
||||
<< libNames_[i]
|
||||
<< " with handle " << long(libPtrs_[i]) << endl;
|
||||
<< " with handle " << uintptr_t(libPtrs_[i]) << endl;
|
||||
}
|
||||
dlClose(libPtrs_[i]);
|
||||
}
|
||||
@ -86,7 +86,7 @@ bool Foam::dlLibraryTable::open
|
||||
if (debug)
|
||||
{
|
||||
Info<< "dlLibraryTable::open : opened " << functionLibName
|
||||
<< " resulting in handle " << long(functionLibPtr) << endl;
|
||||
<< " resulting in handle " << uintptr_t(functionLibPtr) << endl;
|
||||
}
|
||||
|
||||
if (!functionLibPtr)
|
||||
@ -137,7 +137,7 @@ bool Foam::dlLibraryTable::close
|
||||
if (debug)
|
||||
{
|
||||
Info<< "dlLibraryTable::close : closing " << functionLibName
|
||||
<< " with handle " << long(libPtrs_[index]) << endl;
|
||||
<< " with handle " << uintptr_t(libPtrs_[index]) << endl;
|
||||
}
|
||||
|
||||
bool ok = dlClose(libPtrs_[index]);
|
||||
|
||||
@ -530,7 +530,7 @@ TMP_UNARY_FUNCTION(Type, average)
|
||||
#define G_UNARY_FUNCTION(ReturnType, gFunc, Func, rFunc) \
|
||||
\
|
||||
template<class Type> \
|
||||
ReturnType gFunc(const UList<Type>& f, const int comm) \
|
||||
ReturnType gFunc(const UList<Type>& f, const label comm) \
|
||||
{ \
|
||||
ReturnType res = Func(f); \
|
||||
reduce(res, rFunc##Op<Type>(), Pstream::msgType(), comm); \
|
||||
@ -554,7 +554,7 @@ scalar gSumProd
|
||||
(
|
||||
const UList<Type>& f1,
|
||||
const UList<Type>& f2,
|
||||
const int comm
|
||||
const label comm
|
||||
)
|
||||
{
|
||||
scalar SumProd = sumProd(f1, f2);
|
||||
@ -567,7 +567,7 @@ Type gSumCmptProd
|
||||
(
|
||||
const UList<Type>& f1,
|
||||
const UList<Type>& f2,
|
||||
const int comm
|
||||
const label comm
|
||||
)
|
||||
{
|
||||
Type SumProd = sumCmptProd(f1, f2);
|
||||
@ -579,7 +579,7 @@ template<class Type>
|
||||
Type gAverage
|
||||
(
|
||||
const UList<Type>& f,
|
||||
const int comm
|
||||
const label comm
|
||||
)
|
||||
{
|
||||
label n = f.size();
|
||||
|
||||
@ -212,7 +212,7 @@ TMP_UNARY_FUNCTION(Type, average)
|
||||
#define G_UNARY_FUNCTION(ReturnType, gFunc, Func, rFunc) \
|
||||
\
|
||||
template<class Type> \
|
||||
ReturnType gFunc(const UList<Type>& f, const int comm = UPstream::worldComm); \
|
||||
ReturnType gFunc(const UList<Type>& f, const label comm = UPstream::worldComm);\
|
||||
TMP_UNARY_FUNCTION(ReturnType, gFunc)
|
||||
|
||||
G_UNARY_FUNCTION(Type, gMax, max, max)
|
||||
@ -231,7 +231,7 @@ scalar gSumProd
|
||||
(
|
||||
const UList<Type>& f1,
|
||||
const UList<Type>& f2,
|
||||
const int comm = UPstream::worldComm
|
||||
const label comm = UPstream::worldComm
|
||||
);
|
||||
|
||||
template<class Type>
|
||||
@ -239,14 +239,14 @@ Type gSumCmptProd
|
||||
(
|
||||
const UList<Type>& f1,
|
||||
const UList<Type>& f2,
|
||||
const int comm = UPstream::worldComm
|
||||
const label comm = UPstream::worldComm
|
||||
);
|
||||
|
||||
template<class Type>
|
||||
Type gAverage
|
||||
(
|
||||
const UList<Type>& f,
|
||||
const int comm = UPstream::worldComm
|
||||
const label comm = UPstream::worldComm
|
||||
);
|
||||
|
||||
TMP_UNARY_FUNCTION(Type, gAverage)
|
||||
|
||||
@ -37,7 +37,6 @@ SourceFiles
|
||||
#define OSspecific_H
|
||||
|
||||
#include "fileNameList.H"
|
||||
#include "long.H"
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
|
||||
@ -85,7 +85,7 @@ public:
|
||||
// Access
|
||||
|
||||
//- Return communicator used for parallel communication
|
||||
virtual int comm() const = 0;
|
||||
virtual label comm() const = 0;
|
||||
|
||||
//- Return processor number (rank in communicator)
|
||||
virtual int myProcNo() const = 0;
|
||||
|
||||
@ -72,7 +72,7 @@ public:
|
||||
// Access
|
||||
|
||||
//- Return communicator used for comms
|
||||
virtual int comm() const = 0;
|
||||
virtual label comm() const = 0;
|
||||
|
||||
//- Return processor number
|
||||
virtual int myProcNo() const = 0;
|
||||
|
||||
@ -677,7 +677,7 @@ void Foam::GAMGAgglomeration::calculateRegionMaster
|
||||
const label comm,
|
||||
const labelList& procAgglomMap,
|
||||
labelList& masterProcs,
|
||||
List<int>& agglomProcIDs
|
||||
List<label>& agglomProcIDs
|
||||
)
|
||||
{
|
||||
// Determine the master processors
|
||||
|
||||
@ -435,7 +435,7 @@ public:
|
||||
const label comm,
|
||||
const labelList& procAgglomMap,
|
||||
labelList& masterProcs,
|
||||
List<int>& agglomProcIDs
|
||||
List<label>& agglomProcIDs
|
||||
);
|
||||
|
||||
//- Whether to agglomerate across processors
|
||||
|
||||
@ -34,7 +34,6 @@ void Foam::GAMGAgglomeration::gatherList
|
||||
(
|
||||
const label comm,
|
||||
const labelList& procIDs,
|
||||
|
||||
const Type& myVal,
|
||||
List<Type>& allVals,
|
||||
const int tag
|
||||
@ -123,7 +122,7 @@ void Foam::GAMGAgglomeration::restrictField
|
||||
{
|
||||
label fineComm = UPstream::parent(procCommunicator_[coarseLevelIndex]);
|
||||
|
||||
const List<int>& procIDs = agglomProcIDs(coarseLevelIndex);
|
||||
const List<label>& procIDs = agglomProcIDs(coarseLevelIndex);
|
||||
const labelList& offsets = cellOffsets(coarseLevelIndex);
|
||||
|
||||
globalIndex::gather
|
||||
@ -196,7 +195,7 @@ void Foam::GAMGAgglomeration::prolongField
|
||||
procCommunicator_[coarseLevelIndex]
|
||||
);
|
||||
|
||||
const List<int>& procIDs = agglomProcIDs(coarseLevelIndex);
|
||||
const List<label>& procIDs = agglomProcIDs(coarseLevelIndex);
|
||||
const labelList& offsets = cellOffsets(coarseLevelIndex);
|
||||
|
||||
label localSize = nCells_[levelIndex];
|
||||
|
||||
@ -266,7 +266,7 @@ bool Foam::GAMGProcAgglomeration::agglomerate
|
||||
const label fineLevelIndex,
|
||||
const labelList& procAgglomMap,
|
||||
const labelList& masterProcs,
|
||||
const List<int>& agglomProcIDs,
|
||||
const List<label>& agglomProcIDs,
|
||||
const label procAgglomComm
|
||||
)
|
||||
{
|
||||
|
||||
@ -71,7 +71,7 @@ protected:
|
||||
const label fineLevelIndex,
|
||||
const labelList& procAgglomMap,
|
||||
const labelList& masterProcs,
|
||||
const List<int>& agglomProcIDs,
|
||||
const List<label>& agglomProcIDs,
|
||||
const label procAgglomComm
|
||||
);
|
||||
|
||||
|
||||
@ -116,7 +116,7 @@ bool Foam::eagerGAMGProcAgglomeration::agglomerate()
|
||||
labelList masterProcs;
|
||||
// Local processors that agglomerate. agglomProcIDs[0]
|
||||
// is in masterProc.
|
||||
List<int> agglomProcIDs;
|
||||
List<label> agglomProcIDs;
|
||||
GAMGAgglomeration::calculateRegionMaster
|
||||
(
|
||||
levelComm,
|
||||
|
||||
@ -104,7 +104,7 @@ bool Foam::masterCoarsestGAMGProcAgglomeration::agglomerate()
|
||||
labelList masterProcs;
|
||||
// Local processors that agglomerate. agglomProcIDs[0] is in
|
||||
// masterProc.
|
||||
List<int> agglomProcIDs;
|
||||
List<label> agglomProcIDs;
|
||||
GAMGAgglomeration::calculateRegionMaster
|
||||
(
|
||||
levelComm,
|
||||
|
||||
@ -151,7 +151,7 @@ Foam::procFacesGAMGProcAgglomeration::processorAgglomeration
|
||||
label singleCellMeshComm = UPstream::allocateCommunicator
|
||||
(
|
||||
mesh.comm(),
|
||||
labelList(1, 0) // only processor 0
|
||||
labelList(1, label(0)) // only processor 0
|
||||
);
|
||||
|
||||
scalarField faceWeights;
|
||||
@ -283,7 +283,7 @@ bool Foam::procFacesGAMGProcAgglomeration::agglomerate()
|
||||
labelList masterProcs;
|
||||
// Local processors that agglomerate. agglomProcIDs[0] is in
|
||||
// masterProc.
|
||||
List<int> agglomProcIDs;
|
||||
List<label> agglomProcIDs;
|
||||
GAMGAgglomeration::calculateRegionMaster
|
||||
(
|
||||
levelComm,
|
||||
|
||||
@ -164,7 +164,7 @@ Foam::GAMGSolver::GAMGSolver
|
||||
|
||||
const labelList& procAgglomMap =
|
||||
agglomeration_.procAgglomMap(fineLevelIndex+1);
|
||||
const List<int>& procIDs =
|
||||
const List<label>& procIDs =
|
||||
agglomeration_.agglomProcIDs(fineLevelIndex+1);
|
||||
|
||||
procAgglomerateMatrix
|
||||
|
||||
@ -194,7 +194,7 @@ class GAMGSolver
|
||||
PtrList<FieldField<Field, scalar> >& otherBouCoeffs,
|
||||
PtrList<FieldField<Field, scalar> >& otherIntCoeffs,
|
||||
List<boolList>& otherTransforms,
|
||||
List<List<int> >& otherRanks
|
||||
List<List<label> >& otherRanks
|
||||
) const;
|
||||
|
||||
//- Agglomerate processor matrices
|
||||
@ -202,7 +202,7 @@ class GAMGSolver
|
||||
(
|
||||
// Agglomeration information
|
||||
const labelList& procAgglomMap,
|
||||
const List<int>& agglomProcIDs,
|
||||
const List<label>& agglomProcIDs,
|
||||
|
||||
const label levelI,
|
||||
|
||||
@ -218,7 +218,7 @@ class GAMGSolver
|
||||
void procAgglomerateMatrix
|
||||
(
|
||||
const labelList& procAgglomMap,
|
||||
const List<int>& agglomProcIDs,
|
||||
const List<label>& agglomProcIDs,
|
||||
const label levelI
|
||||
);
|
||||
|
||||
|
||||
@ -296,7 +296,7 @@ void Foam::GAMGSolver::gatherMatrices
|
||||
PtrList<FieldField<Field, scalar> >& otherBouCoeffs,
|
||||
PtrList<FieldField<Field, scalar> >& otherIntCoeffs,
|
||||
List<boolList>& otherTransforms,
|
||||
List<List<int> >& otherRanks
|
||||
List<List<label> >& otherRanks
|
||||
) const
|
||||
{
|
||||
if (debug)
|
||||
@ -332,7 +332,7 @@ void Foam::GAMGSolver::gatherMatrices
|
||||
|
||||
// Receive number of/valid interfaces
|
||||
boolList& procTransforms = otherTransforms[otherI];
|
||||
List<int>& procRanks = otherRanks[otherI];
|
||||
List<label>& procRanks = otherRanks[otherI];
|
||||
|
||||
fromSlave >> procTransforms;
|
||||
fromSlave >> procRanks;
|
||||
@ -372,7 +372,7 @@ void Foam::GAMGSolver::gatherMatrices
|
||||
|
||||
// Count valid interfaces
|
||||
boolList procTransforms(interfaceBouCoeffs.size(), false);
|
||||
List<int> procRanks(interfaceBouCoeffs.size(), -1);
|
||||
List<label> procRanks(interfaceBouCoeffs.size(), -1);
|
||||
forAll(interfaces, intI)
|
||||
{
|
||||
if (interfaces.set(intI))
|
||||
@ -415,7 +415,7 @@ void Foam::GAMGSolver::procAgglomerateMatrix
|
||||
(
|
||||
// Agglomeration information
|
||||
const labelList& procAgglomMap,
|
||||
const List<int>& agglomProcIDs,
|
||||
const List<label>& agglomProcIDs,
|
||||
|
||||
const label levelI,
|
||||
|
||||
@ -451,7 +451,7 @@ void Foam::GAMGSolver::procAgglomerateMatrix
|
||||
PtrList<FieldField<Field, scalar> > otherBouCoeffs;
|
||||
PtrList<FieldField<Field, scalar> > otherIntCoeffs;
|
||||
List<boolList> otherTransforms;
|
||||
List<List<int> > otherRanks;
|
||||
List<List<label> > otherRanks;
|
||||
gatherMatrices
|
||||
(
|
||||
agglomProcIDs,
|
||||
@ -745,7 +745,7 @@ void Foam::GAMGSolver::procAgglomerateMatrix
|
||||
void Foam::GAMGSolver::procAgglomerateMatrix
|
||||
(
|
||||
const labelList& procAgglomMap,
|
||||
const List<int>& agglomProcIDs,
|
||||
const List<label>& agglomProcIDs,
|
||||
|
||||
const label levelI
|
||||
)
|
||||
|
||||
@ -155,7 +155,7 @@ public:
|
||||
//- Processor interface functions
|
||||
|
||||
//- Return communicator used for comms
|
||||
virtual int comm() const
|
||||
virtual label comm() const
|
||||
{
|
||||
return procInterface_.comm();
|
||||
}
|
||||
|
||||
@ -148,7 +148,7 @@ public:
|
||||
//- Processor interface functions
|
||||
|
||||
//- Return communicator used for sending
|
||||
virtual int comm() const
|
||||
virtual label comm() const
|
||||
{
|
||||
return comm_;
|
||||
}
|
||||
|
||||
@ -80,7 +80,7 @@ public:
|
||||
virtual lduInterfacePtrsList interfaces() const = 0;
|
||||
|
||||
//- Return communicator used for parallel communication
|
||||
virtual int comm() const = 0;
|
||||
virtual label comm() const = 0;
|
||||
|
||||
//- Helper: reduce with current communicator
|
||||
template<class T, class BinaryOp>
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -35,6 +35,8 @@ Description
|
||||
#ifndef contiguous_H
|
||||
#define contiguous_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
@ -70,67 +72,60 @@ template<>
|
||||
inline bool contiguous<Pair<char> >() {return true;}
|
||||
|
||||
template<>
|
||||
inline bool contiguous<unsigned char>() {return true;}
|
||||
inline bool contiguous<int8_t>() {return true;}
|
||||
template<>
|
||||
inline bool contiguous<FixedList<unsigned char, 2> >() {return true;}
|
||||
inline bool contiguous<FixedList<int8_t, 2> >() {return true;}
|
||||
template<>
|
||||
inline bool contiguous<Pair<unsigned char> >() {return true;}
|
||||
inline bool contiguous<Pair<int8_t> >() {return true;}
|
||||
|
||||
template<>
|
||||
inline bool contiguous<short>() {return true;}
|
||||
inline bool contiguous<uint8_t>() {return true;}
|
||||
template<>
|
||||
inline bool contiguous<FixedList<short, 2> >() {return true;}
|
||||
inline bool contiguous<FixedList<uint8_t, 2> >() {return true;}
|
||||
template<>
|
||||
inline bool contiguous<Pair<short> >() {return true;}
|
||||
inline bool contiguous<Pair<uint8_t> >() {return true;}
|
||||
|
||||
template<>
|
||||
inline bool contiguous<unsigned short>() {return true;}
|
||||
inline bool contiguous<int16_t>() {return true;}
|
||||
template<>
|
||||
inline bool contiguous<FixedList<unsigned short, 2> >() {return true;}
|
||||
inline bool contiguous<FixedList<int16_t, 2> >() {return true;}
|
||||
template<>
|
||||
inline bool contiguous<Pair<unsigned short> >() {return true;}
|
||||
inline bool contiguous<Pair<int16_t> >() {return true;}
|
||||
|
||||
template<>
|
||||
inline bool contiguous<int>() {return true;}
|
||||
inline bool contiguous<uint16_t>() {return true;}
|
||||
template<>
|
||||
inline bool contiguous<FixedList<int, 2> >() {return true;}
|
||||
inline bool contiguous<FixedList<uint16_t, 2> >() {return true;}
|
||||
template<>
|
||||
inline bool contiguous<Pair<int> >() {return true;}
|
||||
inline bool contiguous<Pair<uint16_t> >() {return true;}
|
||||
|
||||
template<>
|
||||
inline bool contiguous<unsigned int>() {return true;}
|
||||
inline bool contiguous<int32_t>() {return true;}
|
||||
template<>
|
||||
inline bool contiguous<FixedList<unsigned int, 2> >() {return true;}
|
||||
inline bool contiguous<FixedList<int32_t, 2> >() {return true;}
|
||||
template<>
|
||||
inline bool contiguous<Pair<unsigned int> >() {return true;}
|
||||
inline bool contiguous<Pair<int32_t> >() {return true;}
|
||||
|
||||
template<>
|
||||
inline bool contiguous<long>() {return true;}
|
||||
inline bool contiguous<uint32_t>() {return true;}
|
||||
template<>
|
||||
inline bool contiguous<FixedList<long, 2> >() {return true;}
|
||||
inline bool contiguous<FixedList<uint32_t, 2> >() {return true;}
|
||||
template<>
|
||||
inline bool contiguous<Pair<long> >() {return true;}
|
||||
inline bool contiguous<Pair<uint32_t> >() {return true;}
|
||||
|
||||
template<>
|
||||
inline bool contiguous<unsigned long>() {return true;}
|
||||
inline bool contiguous<int64_t>() {return true;}
|
||||
template<>
|
||||
inline bool contiguous<FixedList<unsigned long, 2> >() {return true;}
|
||||
inline bool contiguous<FixedList<int64_t, 2> >() {return true;}
|
||||
template<>
|
||||
inline bool contiguous<Pair<unsigned long> >() {return true;}
|
||||
inline bool contiguous<Pair<int64_t> >() {return true;}
|
||||
|
||||
template<>
|
||||
inline bool contiguous<long long>() {return true;}
|
||||
inline bool contiguous<uint64_t>() {return true;}
|
||||
template<>
|
||||
inline bool contiguous<FixedList<long long, 2> >() {return true;}
|
||||
inline bool contiguous<FixedList<uint64_t, 2> >() {return true;}
|
||||
template<>
|
||||
inline bool contiguous<Pair<long long> >() {return true;}
|
||||
|
||||
template<>
|
||||
inline bool contiguous<unsigned long long>() {return true;}
|
||||
template<>
|
||||
inline bool contiguous<FixedList<unsigned long long, 2> >() {return true;}
|
||||
template<>
|
||||
inline bool contiguous<Pair<unsigned long long> >() {return true;}
|
||||
inline bool contiguous<Pair<uint64_t> >() {return true;}
|
||||
|
||||
template<>
|
||||
inline bool contiguous<float>() {return true;}
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -28,7 +28,6 @@ Description
|
||||
System integer
|
||||
|
||||
SourceFiles
|
||||
int.C
|
||||
intIO.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
@ -36,27 +35,40 @@ SourceFiles
|
||||
#ifndef int_H
|
||||
#define int_H
|
||||
|
||||
#include "word.H"
|
||||
#include "int32.H"
|
||||
#include "int64.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
class Istream;
|
||||
class Ostream;
|
||||
#define MAXMIN(retType, type1, type2) \
|
||||
\
|
||||
inline retType max(const type1 s1, const type2 s2) \
|
||||
{ \
|
||||
return (s1 > s2)? s1: s2; \
|
||||
} \
|
||||
\
|
||||
inline retType min(const type1 s1, const type2 s2) \
|
||||
{ \
|
||||
return (s1 < s2)? s1: s2; \
|
||||
}
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
//- Return a word representation of an int
|
||||
word name(const int);
|
||||
MAXMIN(int8_t, int8_t, int8_t)
|
||||
MAXMIN(int16_t, int16_t, int16_t)
|
||||
|
||||
MAXMIN(int32_t, int32_t, int32_t)
|
||||
MAXMIN(int64_t, int64_t, int32_t)
|
||||
MAXMIN(int64_t, int32_t, int64_t)
|
||||
MAXMIN(int64_t, int64_t, int64_t)
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
|
||||
|
||||
int readInt(Istream&);
|
||||
bool readInt(const char*, int&);
|
||||
Istream& operator>>(Istream&, int&);
|
||||
Ostream& operator<<(Ostream&, const int);
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -21,64 +21,13 @@ License
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Description
|
||||
Reads an int from an input stream, for a given version
|
||||
number and File format. If an ascii File is being read,
|
||||
then the line numbers are counted and an erroneous read
|
||||
ised.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "error.H"
|
||||
|
||||
#include "int.H"
|
||||
#include "IOstreams.H"
|
||||
|
||||
#include <sstream>
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::word Foam::name(const int val)
|
||||
{
|
||||
std::ostringstream buf;
|
||||
buf << val;
|
||||
return buf.str();
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
|
||||
|
||||
Foam::Istream& Foam::operator>>(Istream& is, int& i)
|
||||
{
|
||||
token t(is);
|
||||
|
||||
if (!t.good())
|
||||
{
|
||||
is.setBad();
|
||||
return is;
|
||||
}
|
||||
|
||||
if (t.isLabel())
|
||||
{
|
||||
i = int(t.labelToken());
|
||||
}
|
||||
else
|
||||
{
|
||||
is.setBad();
|
||||
FatalIOErrorIn("operator>>(Istream&, int&)", is)
|
||||
<< "wrong token type - expected int, found " << t.info()
|
||||
<< exit(FatalIOError);
|
||||
|
||||
return is;
|
||||
}
|
||||
|
||||
// Check state of Istream
|
||||
is.check("Istream& operator>>(Istream&, int&)");
|
||||
|
||||
return is;
|
||||
}
|
||||
|
||||
|
||||
int Foam::readInt(Istream& is)
|
||||
{
|
||||
int val;
|
||||
@ -88,21 +37,4 @@ int Foam::readInt(Istream& is)
|
||||
}
|
||||
|
||||
|
||||
bool Foam::readInt(const char* buf, int& s)
|
||||
{
|
||||
char *endptr = NULL;
|
||||
long l = strtol(buf, &endptr, 10);
|
||||
s = int(l);
|
||||
return (*endptr == 0);
|
||||
}
|
||||
|
||||
|
||||
Foam::Ostream& Foam::operator<<(Ostream& os, const int i)
|
||||
{
|
||||
os.write(label(i));
|
||||
os.check("Ostream& operator<<(Ostream&, const int)");
|
||||
return os;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
50
src/OpenFOAM/primitives/ints/int32/int32.C
Normal file
50
src/OpenFOAM/primitives/ints/int32/int32.C
Normal file
@ -0,0 +1,50 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2014 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 "int32.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
const int32_t Foam::pTraits<int32_t>::zero = 0;
|
||||
const int32_t Foam::pTraits<int32_t>::one = 1;
|
||||
const int32_t Foam::pTraits<int32_t>::min = INT32_MIN;
|
||||
const int32_t Foam::pTraits<int32_t>::max = INT32_MAX;
|
||||
const int32_t Foam::pTraits<int32_t>::rootMin = pTraits<int32_t>::min;
|
||||
const int32_t Foam::pTraits<int32_t>::rootMax = pTraits<int32_t>::max;
|
||||
|
||||
const char* Foam::pTraits<int32_t>::componentNames[] = { "x" };
|
||||
|
||||
Foam::pTraits<int32_t>::pTraits(const int32_t& p)
|
||||
:
|
||||
p_(p)
|
||||
{}
|
||||
|
||||
Foam::pTraits<int32_t>::pTraits(Istream& is)
|
||||
{
|
||||
is >> p_;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
137
src/OpenFOAM/primitives/ints/int32/int32.H
Normal file
137
src/OpenFOAM/primitives/ints/int32/int32.H
Normal file
@ -0,0 +1,137 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2014 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/>.
|
||||
|
||||
Primitive
|
||||
int32
|
||||
|
||||
Description
|
||||
32bit integer
|
||||
|
||||
SourceFiles
|
||||
int32.C
|
||||
int32IO.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef int32_H
|
||||
#define int32_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <climits>
|
||||
#include <cstdlib>
|
||||
|
||||
#include "word.H"
|
||||
#include "pTraits.H"
|
||||
#include "direction.H"
|
||||
|
||||
#ifndef UINT32_MIN
|
||||
#define UINT32_MIN 0
|
||||
#endif
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
class Istream;
|
||||
class Ostream;
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
//- Return a word representation of an int32
|
||||
word name(const int32_t);
|
||||
|
||||
// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
|
||||
|
||||
int32_t readInt32(Istream&);
|
||||
bool read(const char*, int32_t&);
|
||||
Istream& operator>>(Istream&, int32_t&);
|
||||
Ostream& operator<<(Ostream&, const int32_t);
|
||||
|
||||
//- template specialization for pTraits<int32_t>
|
||||
template<>
|
||||
class pTraits<int32_t>
|
||||
{
|
||||
int32_t p_;
|
||||
|
||||
public:
|
||||
|
||||
//- Component type
|
||||
typedef int32_t cmptType;
|
||||
|
||||
// Member constants
|
||||
|
||||
enum
|
||||
{
|
||||
dim = 3, //!< Dimensionality of space
|
||||
rank = 0, //!< Rank of int32_t is 0
|
||||
nComponents = 1 //!< Number of components in int32_t is 1
|
||||
};
|
||||
|
||||
|
||||
// Static data members
|
||||
|
||||
static const char* const typeName;
|
||||
static const char* componentNames[];
|
||||
static const int32_t zero;
|
||||
static const int32_t one;
|
||||
static const int32_t min;
|
||||
static const int32_t max;
|
||||
static const int32_t rootMax;
|
||||
static const int32_t rootMin;
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from primitive
|
||||
explicit pTraits(const int32_t&);
|
||||
|
||||
//- Construct from Istream
|
||||
pTraits(Istream&);
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Access to the int32_t value
|
||||
operator int32_t() const
|
||||
{
|
||||
return p_;
|
||||
}
|
||||
|
||||
//- Access to the int value
|
||||
operator int32_t&()
|
||||
{
|
||||
return p_;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2014 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -21,30 +21,28 @@ License
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Description
|
||||
Reads a ulong from an input stream.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "error.H"
|
||||
|
||||
#include "ulong.H"
|
||||
#include "int32.H"
|
||||
#include "IOstreams.H"
|
||||
|
||||
#include <sstream>
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::word Foam::name(const unsigned long val)
|
||||
Foam::word Foam::name(const int32_t val)
|
||||
{
|
||||
std::ostringstream buf;
|
||||
buf << val;
|
||||
return buf.str();
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
|
||||
|
||||
Foam::Istream& Foam::operator>>(Istream& is, unsigned long& val)
|
||||
Foam::Istream& Foam::operator>>(Istream& is, int32_t& i)
|
||||
{
|
||||
token t(is);
|
||||
|
||||
@ -56,38 +54,47 @@ Foam::Istream& Foam::operator>>(Istream& is, unsigned long& val)
|
||||
|
||||
if (t.isLabel())
|
||||
{
|
||||
val = static_cast<unsigned long>(t.labelToken());
|
||||
i = int32_t(t.labelToken());
|
||||
}
|
||||
else
|
||||
{
|
||||
is.setBad();
|
||||
FatalIOErrorIn("operator>>(Istream&, unsigned long&)", is)
|
||||
<< "wrong token type - expected unsigned long, found " << t.info()
|
||||
FatalIOErrorIn("operator>>(Istream&, int32_t&)", is)
|
||||
<< "wrong token type - expected int32_t, found " << t.info()
|
||||
<< exit(FatalIOError);
|
||||
|
||||
return is;
|
||||
}
|
||||
|
||||
// Check state of Istream
|
||||
is.check("Istream& operator>>(Istream&, unsigned long&)");
|
||||
is.check("Istream& operator>>(Istream&, int32_t&)");
|
||||
|
||||
return is;
|
||||
}
|
||||
|
||||
|
||||
unsigned long Foam::readUlong(Istream& is)
|
||||
int32_t Foam::readInt32(Istream& is)
|
||||
{
|
||||
unsigned long val;
|
||||
int32_t val;
|
||||
is >> val;
|
||||
|
||||
return val;
|
||||
}
|
||||
|
||||
|
||||
Foam::Ostream& Foam::operator<<(Ostream& os, const unsigned long val)
|
||||
bool Foam::read(const char* buf, int32_t& s)
|
||||
{
|
||||
os.write(label(val));
|
||||
os.check("Ostream& operator<<(Ostream&, const unsigned long)");
|
||||
char *endptr = NULL;
|
||||
long l = strtol(buf, &endptr, 10);
|
||||
s = int32_t(l);
|
||||
return (*endptr == 0);
|
||||
}
|
||||
|
||||
|
||||
Foam::Ostream& Foam::operator<<(Ostream& os, const int32_t i)
|
||||
{
|
||||
os.write(label(i));
|
||||
os.check("Ostream& operator<<(Ostream&, const int32_t)");
|
||||
return os;
|
||||
}
|
||||
|
||||
50
src/OpenFOAM/primitives/ints/int64/int64.C
Normal file
50
src/OpenFOAM/primitives/ints/int64/int64.C
Normal file
@ -0,0 +1,50 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2014 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 "int64.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
const int64_t Foam::pTraits<int64_t>::zero = 0;
|
||||
const int64_t Foam::pTraits<int64_t>::one = 1;
|
||||
const int64_t Foam::pTraits<int64_t>::min = INT64_MIN;
|
||||
const int64_t Foam::pTraits<int64_t>::max = INT64_MAX;
|
||||
const int64_t Foam::pTraits<int64_t>::rootMin = pTraits<int64_t>::min;
|
||||
const int64_t Foam::pTraits<int64_t>::rootMax = pTraits<int64_t>::max;
|
||||
|
||||
const char* Foam::pTraits<int64_t>::componentNames[] = { "x" };
|
||||
|
||||
Foam::pTraits<int64_t>::pTraits(const int64_t& p)
|
||||
:
|
||||
p_(p)
|
||||
{}
|
||||
|
||||
Foam::pTraits<int64_t>::pTraits(Istream& is)
|
||||
{
|
||||
is >> p_;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
137
src/OpenFOAM/primitives/ints/int64/int64.H
Normal file
137
src/OpenFOAM/primitives/ints/int64/int64.H
Normal file
@ -0,0 +1,137 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2014 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/>.
|
||||
|
||||
Primitive
|
||||
int64
|
||||
|
||||
Description
|
||||
64bit integer
|
||||
|
||||
SourceFiles
|
||||
int64.C
|
||||
int64IO.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef int64_H
|
||||
#define int64_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <climits>
|
||||
#include <cstdlib>
|
||||
|
||||
#include "word.H"
|
||||
#include "pTraits.H"
|
||||
#include "direction.H"
|
||||
|
||||
#ifndef UINT64_MIN
|
||||
#define UINT64_MIN 0
|
||||
#endif
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
class Istream;
|
||||
class Ostream;
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
//- Return a word representation of an int64
|
||||
word name(const int64_t);
|
||||
|
||||
// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
|
||||
|
||||
int64_t readInt64(Istream&);
|
||||
bool read(const char*, int64_t&);
|
||||
Istream& operator>>(Istream&, int64_t&);
|
||||
Ostream& operator<<(Ostream&, const int64_t);
|
||||
|
||||
//- template specialization for pTraits<int64_t>
|
||||
template<>
|
||||
class pTraits<int64_t>
|
||||
{
|
||||
int64_t p_;
|
||||
|
||||
public:
|
||||
|
||||
//- Component type
|
||||
typedef int64_t cmptType;
|
||||
|
||||
// Member constants
|
||||
|
||||
enum
|
||||
{
|
||||
dim = 3, //!< Dimensionality of space
|
||||
rank = 0, //!< Rank of int64_t is 0
|
||||
nComponents = 1 //!< Number of components in int64_t is 1
|
||||
};
|
||||
|
||||
|
||||
// Static data members
|
||||
|
||||
static const char* const typeName;
|
||||
static const char* componentNames[];
|
||||
static const int64_t zero;
|
||||
static const int64_t one;
|
||||
static const int64_t min;
|
||||
static const int64_t max;
|
||||
static const int64_t rootMax;
|
||||
static const int64_t rootMin;
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from primitive
|
||||
explicit pTraits(const int64_t&);
|
||||
|
||||
//- Construct from Istream
|
||||
pTraits(Istream&);
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Access to the int64_t value
|
||||
operator int64_t() const
|
||||
{
|
||||
return p_;
|
||||
}
|
||||
|
||||
//- Access to the int value
|
||||
operator int64_t&()
|
||||
{
|
||||
return p_;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2014 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -21,32 +21,28 @@ License
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Description
|
||||
Reads a long from an input stream, for a given version
|
||||
number and File format. If an ascii File is being read, then the line
|
||||
numbers are counted and an erroneous read ised.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "error.H"
|
||||
|
||||
#include "long.H"
|
||||
#include "int64.H"
|
||||
#include "IOstreams.H"
|
||||
|
||||
#include <sstream>
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::word Foam::name(const long val)
|
||||
Foam::word Foam::name(const int64_t val)
|
||||
{
|
||||
std::ostringstream buf;
|
||||
buf << val;
|
||||
return buf.str();
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
|
||||
|
||||
Foam::Istream& Foam::operator>>(Istream& is, long& l)
|
||||
Foam::Istream& Foam::operator>>(Istream& is, int64_t& i)
|
||||
{
|
||||
token t(is);
|
||||
|
||||
@ -58,45 +54,47 @@ Foam::Istream& Foam::operator>>(Istream& is, long& l)
|
||||
|
||||
if (t.isLabel())
|
||||
{
|
||||
l = long(t.labelToken());
|
||||
i = int64_t(t.labelToken());
|
||||
}
|
||||
else
|
||||
{
|
||||
is.setBad();
|
||||
FatalIOErrorIn("operator>>(Istream&, long&)", is)
|
||||
<< "wrong token type - expected long, found " << t.info()
|
||||
FatalIOErrorIn("operator>>(Istream&, int64_t&)", is)
|
||||
<< "wrong token type - expected int64_t, found " << t.info()
|
||||
<< exit(FatalIOError);
|
||||
|
||||
return is;
|
||||
}
|
||||
|
||||
// Check state of Istream
|
||||
is.check("Istream& operator>>(Istream&, long&)");
|
||||
is.check("Istream& operator>>(Istream&, int64_t&)");
|
||||
|
||||
return is;
|
||||
}
|
||||
|
||||
|
||||
long Foam::readLong(Istream& is)
|
||||
int64_t Foam::readInt64(Istream& is)
|
||||
{
|
||||
long val;
|
||||
int64_t val;
|
||||
is >> val;
|
||||
|
||||
return val;
|
||||
}
|
||||
|
||||
bool Foam::readLong(const char* buf, long& s)
|
||||
|
||||
bool Foam::read(const char* buf, int64_t& s)
|
||||
{
|
||||
char *endptr = NULL;
|
||||
s = strtol(buf, &endptr, 10);
|
||||
long l = strtol(buf, &endptr, 10);
|
||||
s = int64_t(l);
|
||||
return (*endptr == 0);
|
||||
}
|
||||
|
||||
|
||||
Foam::Ostream& Foam::operator<<(Ostream& os, const long l)
|
||||
Foam::Ostream& Foam::operator<<(Ostream& os, const int64_t i)
|
||||
{
|
||||
os.write(label(l));
|
||||
os.check("Ostream& operator<<(Ostream&, const long)");
|
||||
os.write(label(i));
|
||||
os.check("Ostream& operator<<(Ostream&, const int64_t)");
|
||||
return os;
|
||||
}
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -28,63 +28,18 @@ License
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
const char* const pTraits<label>::typeName = "label";
|
||||
const label pTraits<label>::zero = 0;
|
||||
const label pTraits<label>::one = 1;
|
||||
const label pTraits<label>::min = labelMin;
|
||||
const label pTraits<label>::max = labelMax;
|
||||
const label pTraits<label>::rootMin = pTraits<label>::min;
|
||||
const label pTraits<label>::rootMax = pTraits<label>::max;
|
||||
|
||||
const char* pTraits<label>::componentNames[] = { "x" };
|
||||
|
||||
pTraits<label>::pTraits(const label& p)
|
||||
:
|
||||
p_(p)
|
||||
{}
|
||||
|
||||
|
||||
pTraits<label>::pTraits(Istream& is)
|
||||
{
|
||||
is >> p_;
|
||||
}
|
||||
|
||||
|
||||
#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 int pTraits<int>::min = INT_MIN;
|
||||
const int pTraits<int>::max = INT_MAX;
|
||||
const int pTraits<int>::rootMin = pTraits<int>::min;
|
||||
const int pTraits<int>::rootMax = pTraits<int>::max;
|
||||
|
||||
const char* pTraits<int>::componentNames[] = { "x" };
|
||||
|
||||
pTraits<int>::pTraits(const int& p)
|
||||
:
|
||||
p_(p)
|
||||
{}
|
||||
|
||||
|
||||
pTraits<int>::pTraits(Istream& is)
|
||||
{
|
||||
is >> p_;
|
||||
}
|
||||
#if WM_LABEL_SIZE == 32
|
||||
const char* const Foam::pTraits<int64_t>::typeName = "int64";
|
||||
const char* const Foam::pTraits<int32_t>::typeName = "label";
|
||||
#elif WM_LABEL_SIZE == 64
|
||||
const char* const Foam::pTraits<int64_t>::typeName = "label";
|
||||
const char* const Foam::pTraits<int32_t>::typeName = "int32";
|
||||
#endif
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
// Raise one label to the power of another (overloaded function call)
|
||||
label pow(label a, label b)
|
||||
Foam::label Foam::pow(label a, label b)
|
||||
{
|
||||
register label ans = 1;
|
||||
for (register label i=0; i<b; i++)
|
||||
@ -92,21 +47,20 @@ label pow(label a, label b)
|
||||
ans *= a;
|
||||
}
|
||||
|
||||
# ifdef FULLDEBUG
|
||||
#ifdef FULLDEBUG
|
||||
if (b < 0)
|
||||
{
|
||||
FatalErrorIn("pow(label a, label b)")
|
||||
<< "negative value for b is not supported"
|
||||
<< abort(FatalError);
|
||||
}
|
||||
# endif
|
||||
#endif
|
||||
|
||||
return ans;
|
||||
}
|
||||
|
||||
|
||||
//- Return factorial(n) : 0 <= n <= 12
|
||||
label factorial(label n)
|
||||
Foam::label Foam::factorial(label n)
|
||||
{
|
||||
static label factTable[13] =
|
||||
{
|
||||
@ -114,21 +68,17 @@ label factorial(label n)
|
||||
362880, 3628800, 39916800, 479001600
|
||||
};
|
||||
|
||||
# ifdef FULLDEBUG
|
||||
#ifdef FULLDEBUG
|
||||
if (n > 12 && n < 0)
|
||||
{
|
||||
FatalErrorIn("factorial(label n)")
|
||||
<< "n value out of range"
|
||||
<< abort(FatalError);
|
||||
}
|
||||
# endif
|
||||
#endif
|
||||
|
||||
return factTable[n];
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -25,7 +25,8 @@ Typedef
|
||||
Foam::label
|
||||
|
||||
Description
|
||||
A label is an int/long/long long depending on the range desired.
|
||||
A label is an int32_t or int64_t as specified by the pre-processor macro
|
||||
WM_LABEL_SIZE.
|
||||
|
||||
A readLabel function is defined so that label can be constructed from
|
||||
Istream.
|
||||
@ -35,239 +36,35 @@ Description
|
||||
#ifndef label_H
|
||||
#define label_H
|
||||
|
||||
#include <climits>
|
||||
#include <cstdlib>
|
||||
#include "int.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#define INT_ADD_SIZE(x,s,y) x ## s ## y
|
||||
#define INT_ADD_DEF_SIZE(x,s,y) INT_ADD_SIZE(x,s,y)
|
||||
#define INT_SIZE(x,y) INT_ADD_DEF_SIZE(x,WM_LABEL_SIZE,y)
|
||||
|
||||
#if FOAM_LABEL64
|
||||
# define FOAM_LABEL_MAX 9000000000000000000
|
||||
#else
|
||||
# define FOAM_LABEL_MAX 2000000000
|
||||
#endif
|
||||
|
||||
#include "pTraits.H"
|
||||
#include "direction.H"
|
||||
|
||||
|
||||
#if INT_MAX > FOAM_LABEL_MAX
|
||||
|
||||
// Define label as an int
|
||||
|
||||
# undef FOAM_LABEL_MAX
|
||||
# define FOAM_LABEL_MAX INT_MAX
|
||||
|
||||
# include "int.H"
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
typedef int label;
|
||||
|
||||
static const label labelMin = INT_MIN;
|
||||
static const label labelMax = INT_MAX;
|
||||
|
||||
inline label readLabel(Istream& is)
|
||||
{
|
||||
return readInt(is);
|
||||
}
|
||||
|
||||
inline bool readLabel(const char* buf, label& s)
|
||||
{
|
||||
return readInt(buf, s);
|
||||
}
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
|
||||
#elif LONG_MAX > FOAM_LABEL_MAX
|
||||
// Define label as a long
|
||||
|
||||
# undef FOAM_LABEL_MAX
|
||||
# define FOAM_LABEL_MAX LONG_MAX
|
||||
|
||||
# include "int.H"
|
||||
# include "long.H"
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
typedef long label;
|
||||
|
||||
static const label labelMin = LONG_MIN;
|
||||
static const label labelMax = LONG_MAX;
|
||||
|
||||
inline label readLabel(Istream& is)
|
||||
{
|
||||
return readLong(is);
|
||||
}
|
||||
|
||||
inline bool readLabel(const char* buf, label& s)
|
||||
{
|
||||
return readLong(buf, s);
|
||||
}
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
|
||||
#elif LLONG_MAX > FOAM_LABEL_MAX
|
||||
|
||||
// Define label as a long long
|
||||
|
||||
# undef FOAM_LABEL_MAX
|
||||
# define FOAM_LABEL_MAX LLONG_MAX
|
||||
|
||||
# include "int.H"
|
||||
# include "long.H"
|
||||
# include "longLong.H"
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
typedef long long label;
|
||||
|
||||
static const label labelMin = LLONG_MIN;
|
||||
static const label labelMax = LLONG_MAX;
|
||||
|
||||
inline label readLabel(Istream& is)
|
||||
{
|
||||
return readLongLong(is);
|
||||
}
|
||||
|
||||
inline bool readLabel(const char* buf, label& s)
|
||||
{
|
||||
return readLongLong(buf, s);
|
||||
}
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
#if WM_LABEL_SIZE != 32 && WM_LABEL_SIZE != 64
|
||||
#error "label.H: WM_LABEL_SIZE must be set to either 32 or 64"
|
||||
#endif
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
//#include "pTraits.H"
|
||||
//#include "direction.H"
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
//- template specialization for pTraits<label>
|
||||
template<>
|
||||
class pTraits<label>
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
typedef INT_SIZE(int, _t) label;
|
||||
|
||||
static const label labelMin = INT_SIZE(INT, _MIN);
|
||||
static const label labelMax = INT_SIZE(INT, _MAX);
|
||||
|
||||
inline label readLabel(Istream& is)
|
||||
{
|
||||
label p_;
|
||||
|
||||
public:
|
||||
|
||||
//- Component type
|
||||
typedef label cmptType;
|
||||
|
||||
// Member constants
|
||||
|
||||
enum
|
||||
{
|
||||
dim = 3, //!< Dimensionality of space
|
||||
rank = 0, //!< Rank of label is 0
|
||||
nComponents = 1 //!< Number of components in label is 1
|
||||
};
|
||||
|
||||
|
||||
// Static data members
|
||||
|
||||
static const char* const typeName;
|
||||
static const char* componentNames[];
|
||||
static const label zero;
|
||||
static const label one;
|
||||
static const label min;
|
||||
static const label max;
|
||||
static const label rootMin;
|
||||
static const label rootMax;
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from primitive
|
||||
explicit pTraits(const label&);
|
||||
|
||||
//- Construct from Istream
|
||||
pTraits(Istream&);
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Access to the label value
|
||||
operator label() const
|
||||
{
|
||||
return p_;
|
||||
}
|
||||
|
||||
//- Access to the label value
|
||||
operator label&()
|
||||
{
|
||||
return p_;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// 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;
|
||||
static const int rootMax;
|
||||
static const int rootMin;
|
||||
|
||||
|
||||
// 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
|
||||
|
||||
return INT_SIZE(readInt,) (is);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
@ -275,40 +72,10 @@ public:
|
||||
//- Raise one label to the power of another
|
||||
label pow(label a, label b);
|
||||
|
||||
//- Evaluate n! : n <= 12
|
||||
//- Evaluate n! : 0 < n <= 12
|
||||
label factorial(label n);
|
||||
|
||||
|
||||
#define MAXMIN(retType, type1, type2) \
|
||||
\
|
||||
inline retType max(const type1 s1, const type2 s2) \
|
||||
{ \
|
||||
return (s1 > s2)? s1: s2; \
|
||||
} \
|
||||
\
|
||||
inline retType min(const type1 s1, const type2 s2) \
|
||||
{ \
|
||||
return (s1 < s2)? s1: s2; \
|
||||
}
|
||||
|
||||
|
||||
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)
|
||||
MAXMIN(unsigned short, unsigned short, unsigned short)
|
||||
MAXMIN(unsigned int, unsigned int, unsigned int)
|
||||
MAXMIN(unsigned long, unsigned long, unsigned long)
|
||||
MAXMIN(unsigned long long, unsigned long long, unsigned long long)
|
||||
|
||||
MAXMIN(long, int, long)
|
||||
MAXMIN(long long, int, long long)
|
||||
MAXMIN(long long, long long, int)
|
||||
|
||||
inline label& setComponent(label& l, const direction)
|
||||
{
|
||||
return l;
|
||||
@ -319,33 +86,18 @@ inline label component(const label l, const direction)
|
||||
return l;
|
||||
}
|
||||
|
||||
inline label mag(const label l)
|
||||
{
|
||||
return ::abs(l);
|
||||
}
|
||||
|
||||
inline label sign(const label s)
|
||||
{
|
||||
return (s >= 0)? 1: -1;
|
||||
}
|
||||
|
||||
inline label pos(const label s)
|
||||
{
|
||||
return (s >= 0)? 1: 0;
|
||||
}
|
||||
|
||||
inline label neg(const label s)
|
||||
{
|
||||
return (s < 0)? 1: 0;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#include "labelSpecific.H"
|
||||
|
||||
#undef INT_ADD_SIZE
|
||||
#undef INT_ADD_DEF_SIZE
|
||||
#undef INT_SIZE
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2014 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -21,48 +21,47 @@ License
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Primitive
|
||||
long
|
||||
Typedef
|
||||
Foam::label
|
||||
|
||||
Description
|
||||
A long integer
|
||||
|
||||
SourceFiles
|
||||
longIO.C
|
||||
label specific functions for which there is no uLabel equivalent
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef long_H
|
||||
#define long_H
|
||||
|
||||
#include "word.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
class Istream;
|
||||
class Ostream;
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
//- Return a string representation of a long
|
||||
word name(const long);
|
||||
inline label mag(const label l)
|
||||
{
|
||||
#if WM_LABEL_SIZE == 32
|
||||
return ::abs(l);
|
||||
#elif WM_LABEL_SIZE == 64
|
||||
return ::labs(l);
|
||||
#endif
|
||||
}
|
||||
|
||||
// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
|
||||
inline label sign(const label s)
|
||||
{
|
||||
return (s >= 0)? 1: -1;
|
||||
}
|
||||
|
||||
long readLong(Istream&);
|
||||
bool readLong(const char*, long&);
|
||||
Istream& operator>>(Istream&, long&);
|
||||
Ostream& operator<<(Ostream&, const long);
|
||||
inline label pos(const label s)
|
||||
{
|
||||
return (s >= 0)? 1: 0;
|
||||
}
|
||||
|
||||
inline label neg(const label s)
|
||||
{
|
||||
return (s < 0)? 1: 0;
|
||||
}
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,131 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2013 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/>.
|
||||
|
||||
Description
|
||||
Reads a long long from an input stream, for a given version
|
||||
number and File format. If an ascii File is being read, then the line
|
||||
numbers are counted and an erroneous read ised.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "error.H"
|
||||
|
||||
#include "longLong.H"
|
||||
#include "IOstreams.H"
|
||||
|
||||
#include <sstream>
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::word Foam::name(long long val)
|
||||
{
|
||||
std::ostringstream buf;
|
||||
buf << val;
|
||||
return buf.str();
|
||||
}
|
||||
|
||||
// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
|
||||
|
||||
Foam::Istream& Foam::operator>>(Istream& is, long long& l)
|
||||
{
|
||||
l = readLongLong(is);
|
||||
|
||||
// Check state of Istream
|
||||
is.check("Istream& operator>>(Istream&, long long&)");
|
||||
|
||||
return is;
|
||||
}
|
||||
|
||||
|
||||
long long Foam::readLongLong(Istream& is)
|
||||
{
|
||||
register long long result = 0;
|
||||
|
||||
char c = 0;
|
||||
|
||||
static const label zeroOffset = int('0');
|
||||
|
||||
// Get next non-whitespace character
|
||||
while (is.read(c) && isspace(c))
|
||||
{}
|
||||
|
||||
do
|
||||
{
|
||||
if (isspace(c) || c == 0) break;
|
||||
|
||||
if (!isdigit(c))
|
||||
{
|
||||
FatalIOErrorIn("readLongLong(ISstream& is)", is)
|
||||
<< "Illegal digit: \"" << c << "\""
|
||||
<< exit(FatalIOError);
|
||||
}
|
||||
|
||||
result *= 10 + int(c) - zeroOffset;
|
||||
} while (is.read(c));
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
bool Foam::readLongLong(const char* buf, long long& s)
|
||||
{
|
||||
char *endptr = NULL;
|
||||
s = strtoll(buf, &endptr, 10);
|
||||
return (*endptr == 0);
|
||||
}
|
||||
|
||||
|
||||
Foam::Ostream& Foam::operator<<(Ostream& os, const long long l)
|
||||
{
|
||||
long long val = l;
|
||||
|
||||
long long mask = 1000000000000000000LL;
|
||||
|
||||
bool printZeroes = false;
|
||||
|
||||
while (mask > 0)
|
||||
{
|
||||
int d = int(val/mask);
|
||||
|
||||
if (d == 0)
|
||||
{
|
||||
if (printZeroes)
|
||||
{
|
||||
os.write('0');
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
printZeroes = true;
|
||||
os.write(char(d+'0'));
|
||||
}
|
||||
|
||||
val = val % mask;
|
||||
mask /= 10;
|
||||
}
|
||||
os.check("Ostream& operator<<(Ostream&, const long long)");
|
||||
return os;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -23,40 +23,62 @@ License
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "uLabel.H"
|
||||
#include "error.H"
|
||||
#include "uLabel.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
#if WM_LABEL_SIZE == 32
|
||||
const char* const Foam::pTraits<uint64_t>::typeName = "uint64";
|
||||
const char* const Foam::pTraits<uint32_t>::typeName = "uLabel";
|
||||
#elif WM_LABEL_SIZE == 64
|
||||
const char* const Foam::pTraits<uint64_t>::typeName = "uLabel";
|
||||
const char* const Foam::pTraits<uint32_t>::typeName = "uint32";
|
||||
#endif
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
const char* const pTraits<uLabel>::typeName = "uLabel";
|
||||
const uLabel pTraits<uLabel>::zero = 0;
|
||||
const uLabel pTraits<uLabel>::one = 1;
|
||||
const uLabel pTraits<uLabel>::min = uLabelMin;
|
||||
const uLabel pTraits<uLabel>::max = uLabelMax;
|
||||
const uLabel pTraits<uLabel>::rootMin = pTraits<uLabel>::min;
|
||||
const uLabel pTraits<uLabel>::rootMax = pTraits<uLabel>::max;
|
||||
|
||||
const char* pTraits<uLabel>::componentNames[] = { "x" };
|
||||
|
||||
pTraits<uLabel>::pTraits(const uLabel& p)
|
||||
:
|
||||
p_(p)
|
||||
{}
|
||||
|
||||
|
||||
pTraits<uLabel>::pTraits(Istream& is)
|
||||
Foam::uLabel Foam::pow(uLabel a, uLabel b)
|
||||
{
|
||||
is >> p_;
|
||||
register uLabel ans = 1;
|
||||
for (register uLabel i=0; i<b; i++)
|
||||
{
|
||||
ans *= a;
|
||||
}
|
||||
|
||||
#ifdef FULLDEBUG
|
||||
if (b < 0)
|
||||
{
|
||||
FatalErrorIn("pow(uLabel a, uLabel b)")
|
||||
<< "negative value for b is not supported"
|
||||
<< abort(FatalError);
|
||||
}
|
||||
#endif
|
||||
|
||||
return ans;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
Foam::uLabel Foam::factorial(uLabel n)
|
||||
{
|
||||
static uLabel factTable[13] =
|
||||
{
|
||||
1, 1, 2, 6, 24, 120, 720, 5040, 40320,
|
||||
362880, 3628800, 39916800, 479001600
|
||||
};
|
||||
|
||||
#ifdef FULLDEBUG
|
||||
if (n > 12 && n < 0)
|
||||
{
|
||||
FatalErrorIn("factorial(uLabel n)")
|
||||
<< "n value out of range"
|
||||
<< abort(FatalError);
|
||||
}
|
||||
#endif
|
||||
|
||||
return factTable[n];
|
||||
}
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -25,157 +25,57 @@ Typedef
|
||||
Foam::uLabel
|
||||
|
||||
Description
|
||||
A uLabel is an unsigned label.
|
||||
A uLabel is an uint32_t or uint64_t as specified by the pre-processor macro
|
||||
WM_LABEL_SIZE.
|
||||
|
||||
SeeAlso
|
||||
label.H
|
||||
A readLabel function is defined so that uLabel can be constructed from
|
||||
Istream.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef uLabel_H
|
||||
#define uLabel_H
|
||||
|
||||
#include <climits>
|
||||
#include <cstdlib>
|
||||
#include "uint.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#define UINT_ADD_SIZE(x,s,y) x ## s ## y
|
||||
#define UINT_ADD_DEF_SIZE(x,s,y) UINT_ADD_SIZE(x,s,y)
|
||||
#define UINT_SIZE(x,y) UINT_ADD_DEF_SIZE(x,WM_LABEL_SIZE,y)
|
||||
|
||||
#if FOAM_LABEL64
|
||||
# define FOAM_ULABEL_MAX 18000000000000000000u
|
||||
#else
|
||||
# define FOAM_ULABEL_MAX 4000000000u
|
||||
#endif
|
||||
|
||||
|
||||
#if UINT_MAX > FOAM_ULABEL_MAX
|
||||
|
||||
// Define uLabel as an unsigned int
|
||||
|
||||
# undef FOAM_ULABEL_MAX
|
||||
# define FOAM_ULABEL_MAX UINT_MAX
|
||||
|
||||
# include "uint.H"
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
typedef unsigned int uLabel;
|
||||
|
||||
static const uLabel uLabelMin = 0;
|
||||
static const uLabel uLabelMax = UINT_MAX;
|
||||
|
||||
inline uLabel readULabel(Istream& is)
|
||||
{
|
||||
return readUint(is);
|
||||
}
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
|
||||
#elif ULONG_MAX > FOAM_ULABEL_MAX
|
||||
|
||||
// Define uLabel as an unsigned long
|
||||
|
||||
# undef FOAM_ULABEL_MAX
|
||||
# define FOAM_ULABEL_MAX ULONG_MAX
|
||||
|
||||
# include "uint.H"
|
||||
# include "ulong.H"
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
typedef unsigned long uLabel;
|
||||
|
||||
static const uLabel uLabelMin = 0;
|
||||
static const uLabel uLabelMax = ULONG_MAX;
|
||||
|
||||
inline uLabel readULabel(Istream& is)
|
||||
{
|
||||
return readUlong(is);
|
||||
}
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
|
||||
#elif ULLONG_MAX > FOAM_ULABEL_MAX
|
||||
|
||||
// Define uLabel as an unsigned long long
|
||||
|
||||
# undef FOAM_ULABEL_MAX
|
||||
|
||||
# error "Not implemented yet"
|
||||
|
||||
#if WM_LABEL_SIZE != 32 && WM_LABEL_SIZE != 64
|
||||
#error "uLabel.H: WM_LABEL_SIZE must be set to either 32 or 64"
|
||||
#endif
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#include "pTraits.H"
|
||||
#include "direction.H"
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
//- template specialization for pTraits<uLabel>
|
||||
template<>
|
||||
class pTraits<uLabel>
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
typedef UINT_SIZE(uint, _t) uLabel;
|
||||
|
||||
static const uLabel uLabelMin = UINT_SIZE(UINT, _MIN);
|
||||
static const uLabel uLabelMax = UINT_SIZE(UINT, _MAX);
|
||||
|
||||
inline uLabel readULabel(Istream& is)
|
||||
{
|
||||
uLabel p_;
|
||||
|
||||
public:
|
||||
|
||||
//- Component type
|
||||
typedef uLabel cmptType;
|
||||
|
||||
// Member constants
|
||||
|
||||
enum
|
||||
{
|
||||
dim = 3, //!< Dimensionality of space
|
||||
rank = 0, //!< Rank of uLabel is 0
|
||||
nComponents = 1 //!< Number of components in uLabel is 1
|
||||
};
|
||||
|
||||
|
||||
// Static data members
|
||||
|
||||
static const char* const typeName;
|
||||
static const char* componentNames[];
|
||||
static const uLabel zero;
|
||||
static const uLabel one;
|
||||
static const uLabel max;
|
||||
static const uLabel min;
|
||||
static const uLabel rootMax;
|
||||
static const uLabel rootMin;
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from primitive
|
||||
explicit pTraits(const uLabel&);
|
||||
|
||||
//- Construct from Istream
|
||||
pTraits(Istream&);
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Access to the uLabel value
|
||||
operator uLabel() const
|
||||
{
|
||||
return p_;
|
||||
}
|
||||
|
||||
//- Access to the uLabel value
|
||||
operator uLabel&()
|
||||
{
|
||||
return p_;
|
||||
}
|
||||
};
|
||||
return UINT_SIZE(readUint,) (is);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
//- Raise one uLabel to the power of another
|
||||
uLabel pow(uLabel a, uLabel b);
|
||||
|
||||
//- Evaluate n! : 0 < n <= 12
|
||||
uLabel factorial(uLabel n);
|
||||
|
||||
|
||||
inline uLabel& setComponent(uLabel& l, const direction)
|
||||
{
|
||||
return l;
|
||||
@ -186,13 +86,18 @@ inline uLabel component(const uLabel l, const direction)
|
||||
return l;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#include "uLabelSpecific.H"
|
||||
|
||||
#undef UINT_ADD_SIZE
|
||||
#undef UINT_ADD_DEF_SIZE
|
||||
#undef UINT_SIZE
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -25,7 +25,7 @@ Primitive
|
||||
uint
|
||||
|
||||
Description
|
||||
System unsigned integer
|
||||
System uinteger
|
||||
|
||||
SourceFiles
|
||||
uintIO.C
|
||||
@ -35,26 +35,40 @@ SourceFiles
|
||||
#ifndef uint_H
|
||||
#define uint_H
|
||||
|
||||
#include "word.H"
|
||||
#include "uint32.H"
|
||||
#include "uint64.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
class Istream;
|
||||
class Ostream;
|
||||
#define MAXMIN(retType, type1, type2) \
|
||||
\
|
||||
inline retType max(const type1 s1, const type2 s2) \
|
||||
{ \
|
||||
return (s1 > s2)? s1: s2; \
|
||||
} \
|
||||
\
|
||||
inline retType min(const type1 s1, const type2 s2) \
|
||||
{ \
|
||||
return (s1 < s2)? s1: s2; \
|
||||
}
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
//- Return a string representation of an uint
|
||||
word name(const unsigned int);
|
||||
MAXMIN(uint8_t, uint8_t, uint8_t)
|
||||
MAXMIN(uint16_t, uint16_t, uint16_t)
|
||||
|
||||
MAXMIN(uint32_t, uint32_t, uint32_t)
|
||||
MAXMIN(uint64_t, uint64_t, uint32_t)
|
||||
MAXMIN(uint64_t, uint32_t, uint64_t)
|
||||
MAXMIN(uint64_t, uint64_t, uint64_t)
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
|
||||
|
||||
unsigned int readUint(Istream&);
|
||||
Istream& operator>>(Istream&, unsigned int&);
|
||||
Ostream& operator<<(Ostream&, const unsigned int);
|
||||
uint readUint(Istream&);
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -21,78 +21,20 @@ License
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Description
|
||||
Reads an uint from an input stream, for a given version
|
||||
number and File format. If an ascii File is being read,
|
||||
then the line numbers are counted and an erroneous read
|
||||
ised.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "error.H"
|
||||
|
||||
#include "uint.H"
|
||||
#include "IOstreams.H"
|
||||
|
||||
#include <sstream>
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::word Foam::name(const unsigned int val)
|
||||
{
|
||||
std::ostringstream buf;
|
||||
buf << val;
|
||||
return buf.str();
|
||||
}
|
||||
|
||||
// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
|
||||
|
||||
Foam::Istream& Foam::operator>>(Istream& is, unsigned int& i)
|
||||
uint Foam::readUint(Istream& is)
|
||||
{
|
||||
token t(is);
|
||||
|
||||
if (!t.good())
|
||||
{
|
||||
is.setBad();
|
||||
return is;
|
||||
}
|
||||
|
||||
if (t.isLabel())
|
||||
{
|
||||
i = static_cast<unsigned int>(t.labelToken());
|
||||
}
|
||||
else
|
||||
{
|
||||
is.setBad();
|
||||
FatalIOErrorIn("operator>>(Istream&, unsigned int&)", is)
|
||||
<< "wrong token type - expected unsigned int, found " << t.info()
|
||||
<< exit(FatalIOError);
|
||||
|
||||
return is;
|
||||
}
|
||||
|
||||
// Check state of Istream
|
||||
is.check("Istream& operator>>(Istream&, unsigned int&)");
|
||||
|
||||
return is;
|
||||
}
|
||||
|
||||
|
||||
unsigned int Foam::readUint(Istream& is)
|
||||
{
|
||||
unsigned int val;
|
||||
uint val;
|
||||
is >> val;
|
||||
|
||||
return val;
|
||||
}
|
||||
|
||||
|
||||
Foam::Ostream& Foam::operator<<(Ostream& os, const unsigned int i)
|
||||
{
|
||||
os.write(label(i));
|
||||
os.check("Ostream& operator<<(Ostream&, const unsigned int)");
|
||||
return os;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2014 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -21,47 +21,30 @@ License
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Primitive
|
||||
ulong
|
||||
|
||||
Description
|
||||
System unsigned long
|
||||
|
||||
SourceFiles
|
||||
ulongIO.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef ulong_H
|
||||
#define ulong_H
|
||||
|
||||
#include "word.H"
|
||||
#include "uint32.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
const uint32_t Foam::pTraits<uint32_t>::zero = 0;
|
||||
const uint32_t Foam::pTraits<uint32_t>::one = 1;
|
||||
const uint32_t Foam::pTraits<uint32_t>::min = INT32_MIN;
|
||||
const uint32_t Foam::pTraits<uint32_t>::max = INT32_MAX;
|
||||
const uint32_t Foam::pTraits<uint32_t>::rootMin = pTraits<uint32_t>::min;
|
||||
const uint32_t Foam::pTraits<uint32_t>::rootMax = pTraits<uint32_t>::max;
|
||||
|
||||
const char* Foam::pTraits<uint32_t>::componentNames[] = { "x" };
|
||||
|
||||
Foam::pTraits<uint32_t>::pTraits(const uint32_t& p)
|
||||
:
|
||||
p_(p)
|
||||
{}
|
||||
|
||||
Foam::pTraits<uint32_t>::pTraits(Istream& is)
|
||||
{
|
||||
is >> p_;
|
||||
}
|
||||
|
||||
class Istream;
|
||||
class Ostream;
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
//- Return a string representation of a ulong
|
||||
word name(const unsigned long);
|
||||
|
||||
// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
|
||||
|
||||
unsigned long readUlong(Istream&);
|
||||
Istream& operator>>(Istream&, unsigned long&);
|
||||
Ostream& operator<<(Ostream&, const unsigned long);
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
137
src/OpenFOAM/primitives/ints/uint32/uint32.H
Normal file
137
src/OpenFOAM/primitives/ints/uint32/uint32.H
Normal file
@ -0,0 +1,137 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2014 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/>.
|
||||
|
||||
Primitive
|
||||
uint32
|
||||
|
||||
Description
|
||||
32bit uinteger
|
||||
|
||||
SourceFiles
|
||||
uint32.C
|
||||
uint32IO.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef uint32_H
|
||||
#define uint32_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <climits>
|
||||
#include <cstdlib>
|
||||
|
||||
#include "word.H"
|
||||
#include "pTraits.H"
|
||||
#include "direction.H"
|
||||
|
||||
#ifndef UINT32_MIN
|
||||
#define UINT32_MIN 0
|
||||
#endif
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
class Istream;
|
||||
class Ostream;
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
//- Return a word representation of an uint32
|
||||
word name(const uint32_t);
|
||||
|
||||
// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
|
||||
|
||||
uint32_t readUint32(Istream&);
|
||||
bool read(const char*, uint32_t&);
|
||||
Istream& operator>>(Istream&, uint32_t&);
|
||||
Ostream& operator<<(Ostream&, const uint32_t);
|
||||
|
||||
//- template specialization for pTraits<uint32_t>
|
||||
template<>
|
||||
class pTraits<uint32_t>
|
||||
{
|
||||
uint32_t p_;
|
||||
|
||||
public:
|
||||
|
||||
//- Component type
|
||||
typedef uint32_t cmptType;
|
||||
|
||||
// Member constants
|
||||
|
||||
enum
|
||||
{
|
||||
dim = 3, //!< Dimensionality of space
|
||||
rank = 0, //!< Rank of uint32_t is 0
|
||||
nComponents = 1 //!< Number of components in uint32_t is 1
|
||||
};
|
||||
|
||||
|
||||
// Static data members
|
||||
|
||||
static const char* const typeName;
|
||||
static const char* componentNames[];
|
||||
static const uint32_t zero;
|
||||
static const uint32_t one;
|
||||
static const uint32_t min;
|
||||
static const uint32_t max;
|
||||
static const uint32_t rootMax;
|
||||
static const uint32_t rootMin;
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from primitive
|
||||
explicit pTraits(const uint32_t&);
|
||||
|
||||
//- Construct from Istream
|
||||
pTraits(Istream&);
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Access to the uint32_t value
|
||||
operator uint32_t() const
|
||||
{
|
||||
return p_;
|
||||
}
|
||||
|
||||
//- Access to the uint value
|
||||
operator uint32_t&()
|
||||
{
|
||||
return p_;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
102
src/OpenFOAM/primitives/ints/uint32/uint32IO.C
Normal file
102
src/OpenFOAM/primitives/ints/uint32/uint32IO.C
Normal file
@ -0,0 +1,102 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2014 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 "error.H"
|
||||
|
||||
#include "uint32.H"
|
||||
#include "IOstreams.H"
|
||||
|
||||
#include <sstream>
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::word Foam::name(const uint32_t val)
|
||||
{
|
||||
std::ostringstream buf;
|
||||
buf << val;
|
||||
return buf.str();
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
|
||||
|
||||
Foam::Istream& Foam::operator>>(Istream& is, uint32_t& i)
|
||||
{
|
||||
token t(is);
|
||||
|
||||
if (!t.good())
|
||||
{
|
||||
is.setBad();
|
||||
return is;
|
||||
}
|
||||
|
||||
if (t.isLabel())
|
||||
{
|
||||
i = uint32_t(t.labelToken());
|
||||
}
|
||||
else
|
||||
{
|
||||
is.setBad();
|
||||
FatalIOErrorIn("operator>>(Istream&, uint32_t&)", is)
|
||||
<< "wrong token type - expected uint32_t, found " << t.info()
|
||||
<< exit(FatalIOError);
|
||||
|
||||
return is;
|
||||
}
|
||||
|
||||
// Check state of Istream
|
||||
is.check("Istream& operator>>(Istream&, uint32_t&)");
|
||||
|
||||
return is;
|
||||
}
|
||||
|
||||
|
||||
uint32_t Foam::readUint32(Istream& is)
|
||||
{
|
||||
uint32_t val;
|
||||
is >> val;
|
||||
|
||||
return val;
|
||||
}
|
||||
|
||||
|
||||
bool Foam::read(const char* buf, uint32_t& s)
|
||||
{
|
||||
char *endptr = NULL;
|
||||
long l = strtol(buf, &endptr, 10);
|
||||
s = uint32_t(l);
|
||||
return (*endptr == 0);
|
||||
}
|
||||
|
||||
|
||||
Foam::Ostream& Foam::operator<<(Ostream& os, const uint32_t i)
|
||||
{
|
||||
os.write(label(i));
|
||||
os.check("Ostream& operator<<(Ostream&, const uint32_t)");
|
||||
return os;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2014 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -21,48 +21,30 @@ License
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Primitive
|
||||
long long
|
||||
|
||||
Description
|
||||
A long long (64 bits on many systems)
|
||||
|
||||
SourceFiles
|
||||
longLongIO.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef longLong_H
|
||||
#define longLong_H
|
||||
|
||||
#include "word.H"
|
||||
#include "uint64.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
const uint64_t Foam::pTraits<uint64_t>::zero = 0;
|
||||
const uint64_t Foam::pTraits<uint64_t>::one = 1;
|
||||
const uint64_t Foam::pTraits<uint64_t>::min = INT64_MIN;
|
||||
const uint64_t Foam::pTraits<uint64_t>::max = INT64_MAX;
|
||||
const uint64_t Foam::pTraits<uint64_t>::rootMin = pTraits<uint64_t>::min;
|
||||
const uint64_t Foam::pTraits<uint64_t>::rootMax = pTraits<uint64_t>::max;
|
||||
|
||||
const char* Foam::pTraits<uint64_t>::componentNames[] = { "x" };
|
||||
|
||||
Foam::pTraits<uint64_t>::pTraits(const uint64_t& p)
|
||||
:
|
||||
p_(p)
|
||||
{}
|
||||
|
||||
Foam::pTraits<uint64_t>::pTraits(Istream& is)
|
||||
{
|
||||
is >> p_;
|
||||
}
|
||||
|
||||
class Istream;
|
||||
class Ostream;
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
//- Return a string representation of a long long
|
||||
word name(long long);
|
||||
|
||||
// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
|
||||
|
||||
long long readLongLong(Istream&);
|
||||
bool readLongLong(const char*, long long&);
|
||||
Istream& operator>>(Istream&, long long&);
|
||||
Ostream& operator<<(Ostream&, const long long);
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
137
src/OpenFOAM/primitives/ints/uint64/uint64.H
Normal file
137
src/OpenFOAM/primitives/ints/uint64/uint64.H
Normal file
@ -0,0 +1,137 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2014 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/>.
|
||||
|
||||
Primitive
|
||||
uint64
|
||||
|
||||
Description
|
||||
64bit uinteger
|
||||
|
||||
SourceFiles
|
||||
uint64.C
|
||||
uint64IO.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef uint64_H
|
||||
#define uint64_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <climits>
|
||||
#include <cstdlib>
|
||||
|
||||
#include "word.H"
|
||||
#include "pTraits.H"
|
||||
#include "direction.H"
|
||||
|
||||
#ifndef UINT64_MIN
|
||||
#define UINT64_MIN 0
|
||||
#endif
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
class Istream;
|
||||
class Ostream;
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
//- Return a word representation of an uint64
|
||||
word name(const uint64_t);
|
||||
|
||||
// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
|
||||
|
||||
uint64_t readUint64(Istream&);
|
||||
bool read(const char*, uint64_t&);
|
||||
Istream& operator>>(Istream&, uint64_t&);
|
||||
Ostream& operator<<(Ostream&, const uint64_t);
|
||||
|
||||
//- template specialization for pTraits<uint64_t>
|
||||
template<>
|
||||
class pTraits<uint64_t>
|
||||
{
|
||||
uint64_t p_;
|
||||
|
||||
public:
|
||||
|
||||
//- Component type
|
||||
typedef uint64_t cmptType;
|
||||
|
||||
// Member constants
|
||||
|
||||
enum
|
||||
{
|
||||
dim = 3, //!< Dimensionality of space
|
||||
rank = 0, //!< Rank of uint64_t is 0
|
||||
nComponents = 1 //!< Number of components in uint64_t is 1
|
||||
};
|
||||
|
||||
|
||||
// Static data members
|
||||
|
||||
static const char* const typeName;
|
||||
static const char* componentNames[];
|
||||
static const uint64_t zero;
|
||||
static const uint64_t one;
|
||||
static const uint64_t min;
|
||||
static const uint64_t max;
|
||||
static const uint64_t rootMax;
|
||||
static const uint64_t rootMin;
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from primitive
|
||||
explicit pTraits(const uint64_t&);
|
||||
|
||||
//- Construct from Istream
|
||||
pTraits(Istream&);
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Access to the uint64_t value
|
||||
operator uint64_t() const
|
||||
{
|
||||
return p_;
|
||||
}
|
||||
|
||||
//- Access to the uint value
|
||||
operator uint64_t&()
|
||||
{
|
||||
return p_;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
102
src/OpenFOAM/primitives/ints/uint64/uint64IO.C
Normal file
102
src/OpenFOAM/primitives/ints/uint64/uint64IO.C
Normal file
@ -0,0 +1,102 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2014 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 "error.H"
|
||||
|
||||
#include "uint64.H"
|
||||
#include "IOstreams.H"
|
||||
|
||||
#include <sstream>
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::word Foam::name(const uint64_t val)
|
||||
{
|
||||
std::ostringstream buf;
|
||||
buf << val;
|
||||
return buf.str();
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
|
||||
|
||||
Foam::Istream& Foam::operator>>(Istream& is, uint64_t& i)
|
||||
{
|
||||
token t(is);
|
||||
|
||||
if (!t.good())
|
||||
{
|
||||
is.setBad();
|
||||
return is;
|
||||
}
|
||||
|
||||
if (t.isLabel())
|
||||
{
|
||||
i = uint64_t(t.labelToken());
|
||||
}
|
||||
else
|
||||
{
|
||||
is.setBad();
|
||||
FatalIOErrorIn("operator>>(Istream&, uint64_t&)", is)
|
||||
<< "wrong token type - expected uint64_t, found " << t.info()
|
||||
<< exit(FatalIOError);
|
||||
|
||||
return is;
|
||||
}
|
||||
|
||||
// Check state of Istream
|
||||
is.check("Istream& operator>>(Istream&, uint64_t&)");
|
||||
|
||||
return is;
|
||||
}
|
||||
|
||||
|
||||
uint64_t Foam::readUint64(Istream& is)
|
||||
{
|
||||
uint64_t val;
|
||||
is >> val;
|
||||
|
||||
return val;
|
||||
}
|
||||
|
||||
|
||||
bool Foam::read(const char* buf, uint64_t& s)
|
||||
{
|
||||
char *endptr = NULL;
|
||||
long l = strtol(buf, &endptr, 10);
|
||||
s = uint64_t(l);
|
||||
return (*endptr == 0);
|
||||
}
|
||||
|
||||
|
||||
Foam::Ostream& Foam::operator<<(Ostream& os, const uint64_t i)
|
||||
{
|
||||
os.write(label(i));
|
||||
os.check("Ostream& operator<<(Ostream&, const uint64_t)");
|
||||
return os;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -27,12 +27,11 @@ Description
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "IPstream.H"
|
||||
#include "long.H"
|
||||
#include "PstreamGlobals.H"
|
||||
|
||||
extern "C"
|
||||
{
|
||||
# include <linux/gamma/libgamma.h>
|
||||
#include <linux/gamma/libgamma.h>
|
||||
}
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -27,13 +27,11 @@ Description
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "OPstream.H"
|
||||
#include "long.H"
|
||||
#include "PstreamGlobals.H"
|
||||
|
||||
extern "C" {
|
||||
|
||||
#include <linux/gamma/libgamma.h>
|
||||
|
||||
extern "C"
|
||||
{
|
||||
#include <linux/gamma/libgamma.h>
|
||||
}
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -351,7 +351,13 @@ void Foam::UPstream::allocatePstreamCommunicator
|
||||
// Set the number of processes to the actual number
|
||||
int numProcs;
|
||||
MPI_Comm_size(PstreamGlobals::MPICommunicators_[index], &numProcs);
|
||||
procIDs_[index] = identity(numProcs);
|
||||
|
||||
//procIDs_[index] = identity(numProcs);
|
||||
procIDs_[index].setSize(numProcs);
|
||||
forAll(procIDs_[index], i)
|
||||
{
|
||||
procIDs_[index][i] = i;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@ -53,7 +53,7 @@ void allReduce
|
||||
MPI_Op op,
|
||||
const BinaryOp& bop,
|
||||
const int tag,
|
||||
const int communicator
|
||||
const label communicator
|
||||
);
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2012-2013 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2012-2014 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
|
||||
@ -57,20 +57,20 @@ namespace Foam
|
||||
|
||||
Foam::label Foam::metisDecomp::decompose
|
||||
(
|
||||
const List<int>& adjncy,
|
||||
const List<int>& xadj,
|
||||
const List<label>& adjncy,
|
||||
const List<label>& xadj,
|
||||
const scalarField& cellWeights,
|
||||
List<int>& finalDecomp
|
||||
List<label>& finalDecomp
|
||||
)
|
||||
{
|
||||
FatalErrorIn
|
||||
(
|
||||
"labelList metisDecomp::decompose"
|
||||
"("
|
||||
"const List<int>&, "
|
||||
"const List<int>&, "
|
||||
"const List<label>&, "
|
||||
"const List<label>&, "
|
||||
"const scalarField&, "
|
||||
"List<int>&"
|
||||
"List<label>&"
|
||||
")"
|
||||
) << notImplementedMessage << exit(FatalError);
|
||||
|
||||
|
||||
@ -61,11 +61,11 @@ void Foam::ptscotchDecomp::check(const int retVal, const char* str)
|
||||
Foam::label Foam::ptscotchDecomp::decompose
|
||||
(
|
||||
const fileName& meshPath,
|
||||
const List<int>& initxadj,
|
||||
const List<int>& initadjncy,
|
||||
const List<label>& initxadj,
|
||||
const List<label>& initadjncy,
|
||||
const scalarField& initcWeights,
|
||||
|
||||
List<int>& finalDecomp
|
||||
List<label>& finalDecomp
|
||||
) const
|
||||
{
|
||||
FatalErrorIn
|
||||
@ -73,24 +73,26 @@ Foam::label Foam::ptscotchDecomp::decompose
|
||||
"label ptscotchDecomp::decompose"
|
||||
"("
|
||||
"onst fileName&,"
|
||||
"const List<int>&, "
|
||||
"const List<int>&, "
|
||||
"const List<label>&, "
|
||||
"const List<label>&, "
|
||||
"const scalarField&, "
|
||||
"List<int>&"
|
||||
"List<label>&"
|
||||
")"
|
||||
) << notImplementedMessage << exit(FatalError);
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
Foam::label Foam::ptscotchDecomp::decompose
|
||||
(
|
||||
const fileName& meshPath,
|
||||
const int adjncySize,
|
||||
const int adjncy[],
|
||||
const int xadjSize,
|
||||
const int xadj[],
|
||||
const label adjncySize,
|
||||
const label adjncy[],
|
||||
const label xadjSize,
|
||||
const label xadj[],
|
||||
const scalarField& cWeights,
|
||||
List<int>& finalDecomp
|
||||
List<label>& finalDecomp
|
||||
) const
|
||||
{
|
||||
FatalErrorIn
|
||||
@ -103,7 +105,7 @@ Foam::label Foam::ptscotchDecomp::decompose
|
||||
"const int,"
|
||||
"const int,"
|
||||
"const scalarField&,"
|
||||
"List<int>&"
|
||||
"List<label>&"
|
||||
")"
|
||||
) << notImplementedMessage << exit(FatalError);
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user