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

This class facilitates reading in vectors from Exodus file that may be of a different floating point type than Real. More...

#include <exodusII_io_helper.h>

Public Member Functions

 MappedInputVector (std::vector< Real > &vec_in, bool single_precision_in)
 
 ~MappedInputVector ()
 
void * data ()
 

Private Attributes

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

Detailed Description

This class facilitates reading in vectors from Exodus file that may be of a different floating point type than Real.

It employs basically the same approach as the MappedOutputVector, just going in the opposite direction. For more information, see the MappedOutputVector class docs.

Definition at line 1079 of file exodusII_io_helper.h.

Constructor & Destructor Documentation

◆ MappedInputVector()

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

Definition at line 626 of file exodusII_io_helper.C.

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

628  : our_data(our_data_in),
629  single_precision(single_precision_in)
630 {
631  // Allocate temporary space to store enough floats/doubles, if required.
632  if (single_precision)
633  {
634  if (sizeof(Real) != sizeof(float))
635  float_vec.resize(our_data.size());
636  }
637  else if (sizeof(Real) != sizeof(double))
638  double_vec.resize(our_data.size());
639 }
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real

◆ ~MappedInputVector()

libMesh::ExodusII_IO_Helper::MappedInputVector::~MappedInputVector ( )

Definition at line 642 of file exodusII_io_helper.C.

References libMesh::Real.

643 {
644  if (single_precision)
645  {
646  if (sizeof(Real) != sizeof(float))
647  our_data.assign(float_vec.begin(), float_vec.end());
648  }
649  else if (sizeof(Real) != sizeof(double))
650  our_data.assign(double_vec.begin(), double_vec.end());
651 }
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real

Member Function Documentation

◆ data()

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

Definition at line 654 of file exodusII_io_helper.C.

References libMesh::Real.

Referenced by libMesh::ExodusII_IO_Helper::read_all_nodesets().

655 {
656  if (single_precision)
657  {
658  if (sizeof(Real) != sizeof(float))
659  return static_cast<void*>(float_vec.data());
660  }
661 
662  else if (sizeof(Real) != sizeof(double))
663  return static_cast<void*>(double_vec.data());
664 
665  // Otherwise return a (suitably casted) pointer to the original underlying data.
666  return static_cast<void *>(our_data.data());
667 }
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real

Member Data Documentation

◆ double_vec

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

Definition at line 1092 of file exodusII_io_helper.h.

Referenced by MappedInputVector().

◆ float_vec

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

Definition at line 1093 of file exodusII_io_helper.h.

Referenced by MappedInputVector().

◆ our_data

std::vector<Real>& libMesh::ExodusII_IO_Helper::MappedInputVector::our_data
private

Definition at line 1090 of file exodusII_io_helper.h.

Referenced by MappedInputVector().

◆ single_precision

bool libMesh::ExodusII_IO_Helper::MappedInputVector::single_precision
private

Definition at line 1091 of file exodusII_io_helper.h.

Referenced by MappedInputVector().


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