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 MappedOuputVector, just going in the opposite direction. For more information, see the MappedOutputVector class docs.

Definition at line 778 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 449 of file exodusII_io_helper.C.

451  : our_data(our_data_in),
452  single_precision(single_precision_in)
453 {
454  // Allocate temporary space to store enough floats/doubles, if required.
455  if (single_precision)
456  {
457  if (sizeof(Real) != sizeof(float))
458  float_vec.resize(our_data.size());
459  }
460  else if (sizeof(Real) != sizeof(double))
461  double_vec.resize(our_data.size());
462 }

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

◆ ~MappedInputVector()

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

Definition at line 465 of file exodusII_io_helper.C.

466 {
467  if (single_precision)
468  {
469  if (sizeof(Real) != sizeof(float))
470  our_data.assign(float_vec.begin(), float_vec.end());
471  }
472  else if (sizeof(Real) != sizeof(double))
473  our_data.assign(double_vec.begin(), double_vec.end());
474 }

References libMesh::Real.

Member Function Documentation

◆ data()

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

Definition at line 477 of file exodusII_io_helper.C.

478 {
479  if (single_precision)
480  {
481  if (sizeof(Real) != sizeof(float))
482  return static_cast<void*>(float_vec.data());
483  }
484 
485  else if (sizeof(Real) != sizeof(double))
486  return static_cast<void*>(double_vec.data());
487 
488  // Otherwise return a (suitably casted) pointer to the original underlying data.
489  return static_cast<void *>(our_data.data());
490 }

References libMesh::Real.

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

Member Data Documentation

◆ double_vec

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

Definition at line 791 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 792 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 789 of file exodusII_io_helper.h.

Referenced by MappedInputVector().

◆ single_precision

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

Definition at line 790 of file exodusII_io_helper.h.

Referenced by MappedInputVector().


The documentation for this struct was generated from the following files:
libMesh::ExodusII_IO_Helper::MappedInputVector::single_precision
bool single_precision
Definition: exodusII_io_helper.h:790
libMesh::ExodusII_IO_Helper::MappedInputVector::double_vec
std::vector< double > double_vec
Definition: exodusII_io_helper.h:791
libMesh::Real
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
Definition: libmesh_common.h:121
libMesh::ExodusII_IO_Helper::MappedInputVector::our_data
std::vector< Real > & our_data
Definition: exodusII_io_helper.h:789
libMesh::ExodusII_IO_Helper::MappedInputVector::float_vec
std::vector< float > float_vec
Definition: exodusII_io_helper.h:792