Commit 7a77ef7e authored by mark's avatar mark

ENH: support more types in adiosTraits

parent 183f89e6
......@@ -32,47 +32,30 @@ License
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
#if WM_LABEL_SIZE == 32
const enum ADIOS_DATATYPES
Foam::adiosTraits<Foam::label>::adiosType = adios_integer;
Foam::adiosTraits<int>::adiosType = adios_integer;
const size_t
Foam::adiosTraits<Foam::label>::adiosSize = 4;
#elif WM_LABEL_SIZE == 64
Foam::adiosTraits<int>::adiosSize = 4;
const enum ADIOS_DATATYPES
Foam::adiosTraits<Foam::label>::adiosType = adios_long;
Foam::adiosTraits<long>::adiosType = adios_long;
const size_t
Foam::adiosTraits<Foam::label>::adiosSize = 8;
#else
#error "WM_LABEL_SIZE not defined in adiosTypes"
#endif
Foam::adiosTraits<long>::adiosSize = 8;
#if defined(WM_SP)
const enum ADIOS_DATATYPES
Foam::adiosTraits<Foam::scalar>::adiosType = adios_real;
Foam::adiosTraits<float>::adiosType = adios_real;
const size_t
Foam::adiosTraits<Foam::scalar>::adiosSize = 4;
#elif defined(WM_DP)
Foam::adiosTraits<float>::adiosSize = 4;
const enum ADIOS_DATATYPES
Foam::adiosTraits<Foam::scalar>::adiosType = adios_double;
Foam::adiosTraits<double>::adiosType = adios_double;
const size_t
Foam::adiosTraits<Foam::scalar>::adiosSize = 8;
#else
# error "(WM_SP | WM_DP) not defined in adiosTypes"
#endif
Foam::adiosTraits<double>::adiosSize = 8;
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
......@@ -90,7 +73,8 @@ bool Foam::adiosTraits<Foam::label>::ok()
else
{
FatalErrorInFunction
<< "Incorrect adios type/size for " << pTraits<label>::typeName
<< "Incorrect adios type/size for "
<< pTraits<label>::typeName
<< exit(FatalError);
return false;
......@@ -111,7 +95,8 @@ bool Foam::adiosTraits<Foam::scalar>::ok()
else
{
FatalErrorInFunction
<< "Incorrect adios type/size for " << pTraits<scalar>::typeName
<< "Incorrect adios type/size for "
<< pTraits<scalar>::typeName
<< exit(FatalError);
return false;
......
......@@ -47,16 +47,58 @@ namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
//- Template specialization for adiosTraits<label>
//- Template specialization for adiosTraits<int>
template<>
class adiosTraits<label>
class adiosTraits<int>
{
label p_;
int p_;
public:
//- ADIOS type
static const enum ADIOS_DATATYPES adiosType;
//- Size of ADIOS type
static const size_t adiosSize;
//- Verify ADIOS type-size
static bool ok();
// Constructors
//- Construct from primitive
explicit adiosTraits(const int&);
// Member Functions
//- Access to the primitive value
operator int() const
{
return p_;
}
//- Access to the primitive value
operator int&()
{
return p_;
}
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
//- Template specialization for adiosTraits<int>
template<>
class adiosTraits<long>
{
long p_;
public:
//- Component type
typedef label cmptType;
// typedef label cmptType;
//- ADIOS type
static const enum ADIOS_DATATYPES adiosType;
......@@ -71,19 +113,19 @@ public:
// Constructors
//- Construct from primitive
explicit adiosTraits(const label&);
explicit adiosTraits(const long&);
// Member Functions
//- Access to the primitive value
operator label() const
operator long() const
{
return p_;
}
//- Access to the primitive value
operator label&()
operator long&()
{
return p_;
}
......@@ -92,16 +134,58 @@ public:
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
//- Template specialization for adiosTraits<scalar>
//- Template specialization for adiosTraits<float>
template<>
class adiosTraits<scalar>
class adiosTraits<float>
{
scalar p_;
float p_;
public:
//- Component type
typedef scalar cmptType;
// typedef scalar cmptType;
//- ADIOS type
static const enum ADIOS_DATATYPES adiosType;
//- Size of ADIOS type
static const size_t adiosSize;
//- Verify ADIOS type-size
static bool ok();
// Constructors
//- Construct from primitive
explicit adiosTraits(const float&);
// Member Functions
//- Access to the primitive value
operator float() const
{
return p_;
}
//- Access to the primitive value
operator float&()
{
return p_;
}
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
//- Template specialization for adiosTraits<double>
template<>
class adiosTraits<double>
{
double p_;
public:
//- ADIOS type
static const enum ADIOS_DATATYPES adiosType;
......@@ -116,19 +200,19 @@ public:
// Constructors
//- Construct from primitive
explicit adiosTraits(const scalar&);
explicit adiosTraits(const double&);
// Member Functions
//- Access to the primitive value
operator scalar() const
operator double() const
{
return p_;
}
//- Access to the primitive value
operator scalar&()
operator double&()
{
return p_;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment