mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-12-28 03:37:59 +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:
@ -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>&
|
||||
);
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user