CEPS  24.01
Cardiac ElectroPhysiology Simulator
CoeffReader Class Reference

Detailed Description

Reader used to import point or cell data from files.

  • Compatible files formats are .vtk (legacy) or .msh.
  • Data can have between 1 and 9 components. The number of components is determined automatically from the file (either through vtk methods, or the number of scalars given on the first read line for .msh and .cdf)

Usage:

r = ceps::getNew<CoeffReader>(fileName,geomPtr); r.getData(v,label,component); (component optional if data is scalar)

The ptr used at instanciation is a ptr to a Geometry, (geom nodes, geom cells) Finite Element nodes are not compatible with this reader. Coefficients are usually defined following the geometry, not the discretization or partitioning...

Definition at line 62 of file CoeffReader.hpp.

#include <CoeffReader.hpp>

Inheritance diagram for CoeffReader:
[legend]

Public Member Functions

 CoeffReader (const CepsString &fileName, const CepsLocationFlag &loc, Geometry *geom)
 Constructor from file name, and location flag, linked to geometry. More...
 
 ~CoeffReader () override
 Destructor. More...
 
CepsBool isValidExtension (CepsString ext)
 Tells if extension is compatible with reader. More...
 
void getData (const CepsString &label, DistributedInfos< CepsMathScalar > &dest)
 Extract a distributed data structure of scalars with given label. More...
 
void getData (const CepsString &label, DistributedInfos< CepsMathVertex > &dest)
 Extract a distributed data structure of vertex with given label. More...
 
void getData (const CepsString &label, DistributedInfos< CepsMathTensor > &dest)
 Extract a distributed data structure of tensors with given label. More...
 
CepsBool hasArray (const CepsString &label, CepsInt dim=-1) const
 Tells if file has data array, dim = 0 for scalars, 1 for vector, 2 for tensor. More...
 
- Public Member Functions inherited from FileReader
 FileReader ()
 Alternative constructor. More...
 
 FileReader (const CepsString &fileName)
 Default constructor. More...
 
 FileReader (const FileReader &that)
 Copy constructor. More...
 
FileReaderoperator= (const FileReader &that)
 Copy constructor. More...
 
virtual ~FileReader ()
 Destructor. Calls FileReader::close. More...
 
void setFileName (const CepsString &fileName)
 Set file to read. More...
 
virtual CepsBool open ()
 Opens the designated file in read mode. More...
 
virtual void close ()
 Close the file. More...
 
virtual CepsBool good ()
 true if stream is still readable More...
 
void reset ()
 Set file stream to the beginning of the file. More...
 
CepsUInt find (const CepsString &pattern)
 Advance stream until pattern is found. More...
 
CepsBool findNext (const CepsString &pattern)
 Advance stream until pattern is found. More...
 
CepsUInt findNextOf (const CepsVector< CepsString > &patterns)
 Advance stream until one of patterns is found. More...
 
CepsString getFileName ()
 Name of parsed file. More...
 
CepsUInt skipLines (CepsUInt nbLines)
 Skip given number of lines. More...
 
void oneLine (CepsString &line)
 Get one line from the stream. More...
 
template<typename T >
FileReaderoperator>> (T &var)
 Reading operator. More...
 
CepsInt lineIndex (const CepsString &word)
 Index of first line starting with word, search starting from the current stream position. More...
 
CepsUInt checkEOF ()
 Checks if the reader reached end of file. More...
 

Protected Member Functions

void buildArrayNamesList ()
 Stores the names of the arrays for easier access afterwards. More...
 
template<typename _Result >
void read (const CepsString &label, DistributedInfos< _Result > &dest)
 Read the array and stores the data into instance. The label is needed for vtk format. More...
 
template<typename _Result >
void readVtk (const CepsString &label, DistributedInfos< _Result > &dest)
 Read the array with given label in file, stores the data into instance. More...
 
template<typename _Result >
void readMsh (const CepsString &label, DistributedInfos< _Result > &dest)
 Read the array with given label in file, stores the data into instance. More...
 

Protected Attributes

Geometrym_geom
 Link to geometry. More...
 
CepsLocationFlag m_loc
 Used to choose between point or cell data. More...
 
CepsArray< CepsVector< CepsString >, 3 > m_cellArrayNames
 Names of data arrays defined on cells (array index: scalar, vector, tensor) More...
 
CepsArray< CepsVector< CepsString >, 3 > m_nodeArrayNames
 Names of data arrays defined on nodes (array index: scalar, vector, tensor) More...
 
vtkSmartPointer< vtkDataSet > m_vtkData
 Array in the vtk format. More...
 
- Protected Attributes inherited from FileReader
CepsString m_fileName
 file to open More...
 
std::ifstream m_file
 stream More...
 

Constructor & Destructor Documentation

◆ CoeffReader()

CoeffReader::CoeffReader ( const CepsString fileName,
const CepsLocationFlag loc,
Geometry geom 
)

Constructor from file name, and location flag, linked to geometry.

Definition at line 33 of file CoeffReader.cpp.

◆ ~CoeffReader()

CoeffReader::~CoeffReader ( )
override

Destructor.

Definition at line 70 of file CoeffReader.cpp.

Member Function Documentation

◆ buildArrayNamesList()

void CoeffReader::buildArrayNamesList ( )
protected

Stores the names of the arrays for easier access afterwards.

Definition at line 131 of file CoeffReader.cpp.

◆ getData() [1/3]

void CoeffReader::getData ( const CepsString label,
DistributedInfos< CepsMathScalar > &  dest 
)

Extract a distributed data structure of scalars with given label.

Definition at line 81 of file CoeffReader.cpp.

◆ getData() [2/3]

void CoeffReader::getData ( const CepsString label,
DistributedInfos< CepsMathTensor > &  dest 
)

Extract a distributed data structure of tensors with given label.

Definition at line 101 of file CoeffReader.cpp.

◆ getData() [3/3]

void CoeffReader::getData ( const CepsString label,
DistributedInfos< CepsMathVertex > &  dest 
)

Extract a distributed data structure of vertex with given label.

Definition at line 91 of file CoeffReader.cpp.

◆ hasArray()

CepsBool CoeffReader::hasArray ( const CepsString label,
CepsInt  dim = -1 
) const

Tells if file has data array, dim = 0 for scalars, 1 for vector, 2 for tensor.

Definition at line 111 of file CoeffReader.cpp.

◆ isValidExtension()

CepsBool CoeffReader::isValidExtension ( CepsString  ext)

Tells if extension is compatible with reader.

Definition at line 75 of file CoeffReader.cpp.

◆ read()

template<typename _Result >
void CoeffReader::read ( const CepsString label,
DistributedInfos< _Result > &  dest 
)
protected

Read the array and stores the data into instance. The label is needed for vtk format.

.msh, other extensions caused abort at instanciation

Definition at line 133 of file CoeffReader.hpp.

◆ readMsh()

template<typename _Result >
void CoeffReader::readMsh ( const CepsString label,
DistributedInfos< _Result > &  dest 
)
protected

Read the array with given label in file, stores the data into instance.

Definition at line 195 of file CoeffReader.hpp.

◆ readVtk()

template<typename _Result >
void CoeffReader::readVtk ( const CepsString label,
DistributedInfos< _Result > &  dest 
)
protected

Read the array with given label in file, stores the data into instance.

Definition at line 147 of file CoeffReader.hpp.

Field Documentation

◆ m_cellArrayNames

CepsArray<CepsVector<CepsString>,3> CoeffReader::m_cellArrayNames
protected

Names of data arrays defined on cells (array index: scalar, vector, tensor)

Definition at line 124 of file CoeffReader.hpp.

◆ m_geom

Geometry* CoeffReader::m_geom
protected

Link to geometry.

Definition at line 120 of file CoeffReader.hpp.

◆ m_loc

CepsLocationFlag CoeffReader::m_loc
protected

Used to choose between point or cell data.

Definition at line 121 of file CoeffReader.hpp.

◆ m_nodeArrayNames

CepsArray<CepsVector<CepsString>,3> CoeffReader::m_nodeArrayNames
protected

Names of data arrays defined on nodes (array index: scalar, vector, tensor)

Definition at line 126 of file CoeffReader.hpp.

◆ m_vtkData

vtkSmartPointer<vtkDataSet> CoeffReader::m_vtkData
protected

Array in the vtk format.

Definition at line 128 of file CoeffReader.hpp.


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