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 1027 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 619 of file exodusII_io_helper.C.

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

621  : our_data(our_data_in),
622  single_precision(single_precision_in)
623 {
624  // Allocate temporary space to store enough floats/doubles, if required.
625  if (single_precision)
626  {
627  if (sizeof(Real) != sizeof(float))
628  float_vec.resize(our_data.size());
629  }
630  else if (sizeof(Real) != sizeof(double))
631  double_vec.resize(our_data.size());
632 }
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real

◆ ~MappedInputVector()

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

Definition at line 635 of file exodusII_io_helper.C.

References libMesh::Real.

636 {
637  if (single_precision)
638  {
639  if (sizeof(Real) != sizeof(float))
640  our_data.assign(float_vec.begin(), float_vec.end());
641  }
642  else if (sizeof(Real) != sizeof(double))
643  our_data.assign(double_vec.begin(), double_vec.end());
644 }
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 647 of file exodusII_io_helper.C.

References libMesh::Real.

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

648 {
649  if (single_precision)
650  {
651  if (sizeof(Real) != sizeof(float))
652  return static_cast<void*>(float_vec.data());
653  }
654 
655  else if (sizeof(Real) != sizeof(double))
656  return static_cast<void*>(double_vec.data());
657 
658  // Otherwise return a (suitably casted) pointer to the original underlying data.
659  return static_cast<void *>(our_data.data());
660 }
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 1040 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 1041 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 1038 of file exodusII_io_helper.h.

Referenced by MappedInputVector().

◆ single_precision

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

Definition at line 1039 of file exodusII_io_helper.h.

Referenced by MappedInputVector().


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