libMesh
Public Member Functions | Private Attributes | List of all members
libMesh::ExodusII_IO_Helper::MappedOutputVector Struct Reference

This class facilitates inline conversion of an input data vector to a different precision level, depending on the underlying type of Real and whether or not the single_precision flag is set. More...

#include <exodusII_io_helper.h>

Public Member Functions

 MappedOutputVector (const std::vector< Real > &vec_in, bool single_precision_in)
 
 ~MappedOutputVector ()=default
 
void * data ()
 

Private Attributes

const std::vector< Real > & our_data
 
bool single_precision
 
std::vector< double > double_vec
 
std::vector< float > float_vec
 

Detailed Description

This class facilitates inline conversion of an input data vector to a different precision level, depending on the underlying type of Real and whether or not the single_precision flag is set.

This should be used whenever floating point data is being written to the Exodus file. Note that if no precision conversion has to take place, there should be very little overhead involved in using this object.

Definition at line 751 of file exodusII_io_helper.h.

Constructor & Destructor Documentation

◆ MappedOutputVector()

libMesh::ExodusII_IO_Helper::MappedOutputVector::MappedOutputVector ( const std::vector< Real > &  vec_in,
bool  single_precision_in 
)

Definition at line 417 of file exodusII_io_helper.C.

419  : our_data(our_data_in),
420  single_precision(single_precision_in)
421 {
422  if (single_precision)
423  {
424  if (sizeof(Real) != sizeof(float))
425  float_vec.assign(our_data.begin(), our_data.end());
426  }
427 
428  else if (sizeof(Real) != sizeof(double))
429  double_vec.assign(our_data.begin(), our_data.end());
430 }

References double_vec, float_vec, our_data, libMesh::Real, and single_precision.

◆ ~MappedOutputVector()

libMesh::ExodusII_IO_Helper::MappedOutputVector::~MappedOutputVector ( )
default

Member Function Documentation

◆ data()

void * libMesh::ExodusII_IO_Helper::MappedOutputVector::data ( )

Definition at line 433 of file exodusII_io_helper.C.

434 {
435  if (single_precision)
436  {
437  if (sizeof(Real) != sizeof(float))
438  return static_cast<void*>(float_vec.data());
439  }
440 
441  else if (sizeof(Real) != sizeof(double))
442  return static_cast<void*>(double_vec.data());
443 
444  // Otherwise return a (suitably casted) pointer to the original underlying data.
445  return const_cast<void *>(static_cast<const void *>(our_data.data()));
446 }

References libMesh::Real.

Referenced by libMesh::ExodusII_IO_Helper::write_element_values_element_major(), and libMesh::ExodusII_IO_Helper::write_nodal_coordinates().

Member Data Documentation

◆ double_vec

std::vector<double> libMesh::ExodusII_IO_Helper::MappedOutputVector::double_vec
private

Definition at line 767 of file exodusII_io_helper.h.

Referenced by MappedOutputVector().

◆ float_vec

std::vector<float> libMesh::ExodusII_IO_Helper::MappedOutputVector::float_vec
private

Definition at line 768 of file exodusII_io_helper.h.

Referenced by MappedOutputVector().

◆ our_data

const std::vector<Real>& libMesh::ExodusII_IO_Helper::MappedOutputVector::our_data
private

Definition at line 765 of file exodusII_io_helper.h.

Referenced by MappedOutputVector().

◆ single_precision

bool libMesh::ExodusII_IO_Helper::MappedOutputVector::single_precision
private

Definition at line 766 of file exodusII_io_helper.h.

Referenced by MappedOutputVector().


The documentation for this struct was generated from the following files:
libMesh::ExodusII_IO_Helper::MappedOutputVector::float_vec
std::vector< float > float_vec
Definition: exodusII_io_helper.h:768
libMesh::ExodusII_IO_Helper::MappedOutputVector::double_vec
std::vector< double > double_vec
Definition: exodusII_io_helper.h:767
libMesh::ExodusII_IO_Helper::MappedOutputVector::single_precision
bool single_precision
Definition: exodusII_io_helper.h:766
libMesh::ExodusII_IO_Helper::MappedOutputVector::our_data
const std::vector< Real > & our_data
Definition: exodusII_io_helper.h:765
libMesh::Real
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
Definition: libmesh_common.h:121