Block-Structured AMR Software Framework
amrex::RealDescriptor Class Reference

A Descriptor of the Real Type. More...

#include <AMReX_FabConv.H>

Public Member Functions

 RealDescriptor ()=default
 The default constructor. Does not build a proper RealDescriptor. This should only be used when you need to build a generic RealDescriptor in order to be able to read in a specific one from an istream. More...
 
 RealDescriptor (const Long *fr_, const int *ord_, int ordl_)
 Construct a specific RealDescriptor, passing in the format of the Real, the order of the Real, and the length of the array detailing the ordering. More...
 
const Long * format () const &
 Returns the format array as a const Long*. More...
 
const Long * format () &&=delete
 
const Vector< Long > & formatarray () const &
 Returns const Vector<Long> reference to the format array. More...
 
const Vector< Long > & formatarray () &&=delete
 
const intorder () const &
 Returns the order array as a const int*. More...
 
const intorder () &&=delete
 
const Vector< int > & orderarray () const &
 Returns const Vector<int> reference to the order array. More...
 
const Vector< int > & orderarray () &&=delete
 
int numBytes () const
 Returns the number of bytes in the Real. More...
 
bool operator== (const RealDescriptor &rd) const
 The equality operator. More...
 
bool operator!= (const RealDescriptor &rd) const
 The inequality operator. More...
 
RealDescriptorclone () const
 Returns a copy of this RealDescriptor on the heap. The user is responsible for deletion. More...
 

Static Public Member Functions

static void SetFixDenormals ()
 Set to always fix denormals when converting to native format. More...
 
static void SetReadBufferSize (int rbs)
 Set read and write buffer sizes. More...
 
static void SetWriteBufferSize (int wbs)
 
static RealDescriptornewRealDescriptor (int fmt, int prec, const char *systype, int ordering)
 Returns a RealDescriptor on the heap detailing requested floating-point type. Here format, precision, and ordering correspond to the enumerations in FABio. This is here to support reading "old" FABs. Do NOT use it in new code. More...
 
static void convertToNativeFormat (Real *out, Long nitems, void *in, const RealDescriptor &id)
 Convert nitems in RealDescriptor format to native Real format. The out array is assumed to be large enough to hold the resulting output. More...
 
static void convertToNativeFormat (Real *out, Long nitems, std::istream &is, const RealDescriptor &id)
 Read nitems from istream in RealDescriptor format and convert them to the native Real format. The out array is assumed to be large enough to hold the resulting output. More...
 
static void convertFromNativeFormat (std::ostream &os, Long nitems, const Real *in, const RealDescriptor &od)
 Convert nitems Reals in native format to RealDescriptor format and write them to the ostream. More...
 
static void convertFromNativeFormat (void *out, Long nitems, const void *in, const RealDescriptor &od)
 Convert nitems Reals in native format to RealDescriptor format. The out array is assumed to be large enough to hold the resulting output. More...
 
static void convertFromNativeFloatFormat (std::ostream &os, Long nitems, const float *in, const RealDescriptor &od)
 Convert nitems floats in native format to RealDescriptor format and write them to the ostream. More...
 
static void convertFromNativeDoubleFormat (std::ostream &os, Long nitems, const double *in, const RealDescriptor &od)
 Convert nitems doubles in native format to RealDescriptor format and write them to the ostream. More...
 
static void convertToNativeFloatFormat (float *out, Long nitems, std::istream &is, const RealDescriptor &id)
 Read nitems from istream in RealDescriptor format and convert them to the native float format. The out array is assumed to be large enough to hold the resulting output. More...
 
static void convertToNativeDoubleFormat (double *out, Long nitems, std::istream &is, const RealDescriptor &id)
 Read nitems from istream in RealDescriptor format and convert them to the native double format. The out array is assumed to be large enough to hold the resulting output. More...
 

Private Attributes

Vector< Long > fr
 
Vector< intord
 

Static Private Attributes

static bool bAlwaysFixDenormals
 
static int writeBufferSize
 
static int readBufferSize
 

Detailed Description

A Descriptor of the Real Type.

This class is meant to hold all information needed to completely describe the "Real" floating-point type on a machine. By "Real" here we mean either the "float" or "double" type that this version of AMReX was built with, which corresponds to whether BL_USE_FLOAT or BL_USE_DOUBLE was used to build the version of the library.

To describe a "Real" type two arrays are needed: one detailing the ordering of the bytes in the Real, relative to the canonical ordering 1 .. sizeof(Real) and the other detailing the format of the floating-point number.

The array detailing the format of a floating-point number is an eight-element array of longs containing the following information:

    format[0] = number of bits per number
    format[1] = number of bits in exponent
    format[2] = number of bits in mantissa
    format[3] = start bit of sign
    format[4] = start bit of exponent
    format[5] = start bit of mantissa
    format[6] = high order mantissa bit (CRAY needs this)
    format[7] = bias of exponent

This allows us to write out "Real"s in the native format on a machine, and then by also saving the IntDescriptor, we can read them back in on another machine and have enough information to construct the exact same "Real" values, provided the Reals have the same size on the two machines.

Constructor & Destructor Documentation

◆ RealDescriptor() [1/2]

amrex::RealDescriptor::RealDescriptor ( )
default

The default constructor. Does not build a proper RealDescriptor. This should only be used when you need to build a generic RealDescriptor in order to be able to read in a specific one from an istream.

◆ RealDescriptor() [2/2]

amrex::RealDescriptor::RealDescriptor ( const Long *  fr_,
const int ord_,
int  ordl_ 
)

Construct a specific RealDescriptor, passing in the format of the Real, the order of the Real, and the length of the array detailing the ordering.

Member Function Documentation

◆ clone()

RealDescriptor * amrex::RealDescriptor::clone ( ) const

Returns a copy of this RealDescriptor on the heap. The user is responsible for deletion.

◆ convertFromNativeDoubleFormat()

void amrex::RealDescriptor::convertFromNativeDoubleFormat ( std::ostream &  os,
Long  nitems,
const double *  in,
const RealDescriptor od 
)
static

Convert nitems doubles in native format to RealDescriptor format and write them to the ostream.

◆ convertFromNativeFloatFormat()

void amrex::RealDescriptor::convertFromNativeFloatFormat ( std::ostream &  os,
Long  nitems,
const float *  in,
const RealDescriptor od 
)
static

Convert nitems floats in native format to RealDescriptor format and write them to the ostream.

◆ convertFromNativeFormat() [1/2]

void amrex::RealDescriptor::convertFromNativeFormat ( std::ostream &  os,
Long  nitems,
const Real *  in,
const RealDescriptor od 
)
static

Convert nitems Reals in native format to RealDescriptor format and write them to the ostream.

◆ convertFromNativeFormat() [2/2]

void amrex::RealDescriptor::convertFromNativeFormat ( void *  out,
Long  nitems,
const void *  in,
const RealDescriptor od 
)
static

Convert nitems Reals in native format to RealDescriptor format. The out array is assumed to be large enough to hold the resulting output.

◆ convertToNativeDoubleFormat()

void amrex::RealDescriptor::convertToNativeDoubleFormat ( double *  out,
Long  nitems,
std::istream &  is,
const RealDescriptor id 
)
static

Read nitems from istream in RealDescriptor format and convert them to the native double format. The out array is assumed to be large enough to hold the resulting output.

◆ convertToNativeFloatFormat()

void amrex::RealDescriptor::convertToNativeFloatFormat ( float *  out,
Long  nitems,
std::istream &  is,
const RealDescriptor id 
)
static

Read nitems from istream in RealDescriptor format and convert them to the native float format. The out array is assumed to be large enough to hold the resulting output.

◆ convertToNativeFormat() [1/2]

void amrex::RealDescriptor::convertToNativeFormat ( Real *  out,
Long  nitems,
std::istream &  is,
const RealDescriptor id 
)
static

Read nitems from istream in RealDescriptor format and convert them to the native Real format. The out array is assumed to be large enough to hold the resulting output.

◆ convertToNativeFormat() [2/2]

void amrex::RealDescriptor::convertToNativeFormat ( Real *  out,
Long  nitems,
void *  in,
const RealDescriptor id 
)
static

Convert nitems in RealDescriptor format to native Real format. The out array is assumed to be large enough to hold the resulting output.

◆ format() [1/2]

const Long* amrex::RealDescriptor::format ( ) &&
delete

◆ format() [2/2]

const Long * amrex::RealDescriptor::format ( ) const &

Returns the format array as a const Long*.

◆ formatarray() [1/2]

const Vector<Long>& amrex::RealDescriptor::formatarray ( ) &&
delete

◆ formatarray() [2/2]

const Vector< Long > & amrex::RealDescriptor::formatarray ( ) const &

Returns const Vector<Long> reference to the format array.

◆ newRealDescriptor()

RealDescriptor * amrex::RealDescriptor::newRealDescriptor ( int  fmt,
int  prec,
const char *  systype,
int  ordering 
)
static

Returns a RealDescriptor on the heap detailing requested floating-point type. Here format, precision, and ordering correspond to the enumerations in FABio. This is here to support reading "old" FABs. Do NOT use it in new code.

◆ numBytes()

int amrex::RealDescriptor::numBytes ( ) const

Returns the number of bytes in the Real.

◆ operator!=()

bool amrex::RealDescriptor::operator!= ( const RealDescriptor rd) const

The inequality operator.

◆ operator==()

bool amrex::RealDescriptor::operator== ( const RealDescriptor rd) const

The equality operator.

◆ order() [1/2]

const int* amrex::RealDescriptor::order ( ) &&
delete

◆ order() [2/2]

const int * amrex::RealDescriptor::order ( ) const &

Returns the order array as a const int*.

◆ orderarray() [1/2]

const Vector<int>& amrex::RealDescriptor::orderarray ( ) &&
delete

◆ orderarray() [2/2]

const Vector< int > & amrex::RealDescriptor::orderarray ( ) const &

Returns const Vector<int> reference to the order array.

◆ SetFixDenormals()

void amrex::RealDescriptor::SetFixDenormals ( )
static

Set to always fix denormals when converting to native format.

◆ SetReadBufferSize()

void amrex::RealDescriptor::SetReadBufferSize ( int  rbs)
static

Set read and write buffer sizes.

◆ SetWriteBufferSize()

void amrex::RealDescriptor::SetWriteBufferSize ( int  wbs)
static

Member Data Documentation

◆ bAlwaysFixDenormals

bool amrex::RealDescriptor::bAlwaysFixDenormals
staticprivate

◆ fr

Vector<Long> amrex::RealDescriptor::fr
private

◆ ord

Vector<int> amrex::RealDescriptor::ord
private

◆ readBufferSize

int amrex::RealDescriptor::readBufferSize
staticprivate

◆ writeBufferSize

int amrex::RealDescriptor::writeBufferSize
staticprivate

The documentation for this class was generated from the following files: