ABACUS develop
Atomic-orbital Based Ab-initio Computation at UStc
Loading...
Searching...
No Matches
ModuleIO::csrFileReader< T > Class Template Reference

Class to read CSR file. More...

#include <csr_reader.h>

Inheritance diagram for ModuleIO::csrFileReader< T >:
Collaboration diagram for ModuleIO::csrFileReader< T >:

Public Member Functions

 csrFileReader (const std::string &filename)
void parseFile ()
int getNumberOfR () const
SparseMatrix< T > getMatrix (int Rx, int Ry, int Rz) const
SparseMatrix< T > getMatrix (int index) const
std::vector< int > getRCoordinate (int index) const
int getStep () const
int getMatrixDimension () const
Public Member Functions inherited from ModuleIO::FileReader
 FileReader (std::string filename)
 ~FileReader ()
bool isOpen () const
void readLine ()
void read_ucell ()

Private Member Functions

void parseCompactHeader ()
void parseCellHeader ()
void readBlocks ()
void validateFrameEnd ()
void nextDataLine ()
void nextDataToken ()

Private Attributes

std::vector< std::vector< int > > RCoordinates
std::vector< SparseMatrix< T > > sparse_matrices
int step = 0
int matrixDimension = 0
int numberOfR = 0

Additional Inherited Members

Public Attributes inherited from ModuleIO::FileReader
std::stringstream ss
Protected Member Functions inherited from ModuleIO::FileReader
bool peekLine (std::string &line)

Detailed Description

template<typename T>
class ModuleIO::csrFileReader< T >

Class to read CSR file.

This class is used to read CSR file Both save_sparse's compact three-line header (STEP, Matrix Dimension, Matrix number) and the cell-aware format below are accepted. Compact CSR blocks contain an R coordinate/nnz line, values, zero-based column indices, and dimension+1 row pointers. Invalid dimensions, indices and truncated data are rejected for both formats rather than producing an empty matrix. The cell-aware format is like:

Ionic_Step 1
# print density matrix in real space DM(R)
26 # number of localized basis
13 # number of Bravais lattice vector R
unitcell_information
#--------------------------------------------------------#
# CSR format #
# Outer loop is the number of Bravais lattice vectors. #
# First line is Bravais lattice vector index Rx, Ry, Rz, #
# followed by the number of non-zero elements. #
# Next are three blocks of data. #
#--------------------------------------------------------#
-1 0 0 507
# CSR values
6.73361941e-04 -3.97537783e-05 7.92408228e-04 ...
# CSR column indices
0 1 2 ...
# CSR row pointers
0 26 52 ...
...

It will store the R coordinates and sparse matrices as two vectors. One can use getter functions to get the R coordinates and sparse matrices, and related info including step, matrix dimension, number of R.

Constructor & Destructor Documentation

◆ csrFileReader()

template<typename T>
ModuleIO::csrFileReader< T >::csrFileReader ( const std::string & filename)
Here is the call graph for this function:

Member Function Documentation

◆ getMatrix() [1/2]

template<typename T>
SparseMatrix< T > ModuleIO::csrFileReader< T >::getMatrix ( int index) const
Here is the call graph for this function:

◆ getMatrix() [2/2]

template<typename T>
SparseMatrix< T > ModuleIO::csrFileReader< T >::getMatrix ( int Rx,
int Ry,
int Rz ) const
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getMatrixDimension()

template<typename T>
int ModuleIO::csrFileReader< T >::getMatrixDimension ( ) const
Here is the caller graph for this function:

◆ getNumberOfR()

template<typename T>
int ModuleIO::csrFileReader< T >::getNumberOfR ( ) const
Here is the caller graph for this function:

◆ getRCoordinate()

template<typename T>
std::vector< int > ModuleIO::csrFileReader< T >::getRCoordinate ( int index) const
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getStep()

template<typename T>
int ModuleIO::csrFileReader< T >::getStep ( ) const
Here is the caller graph for this function:

◆ nextDataLine()

template<typename T>
void ModuleIO::csrFileReader< T >::nextDataLine ( )
private
Here is the call graph for this function:
Here is the caller graph for this function:

◆ nextDataToken()

template<typename T>
void ModuleIO::csrFileReader< T >::nextDataToken ( )
private
Here is the call graph for this function:
Here is the caller graph for this function:

◆ parseCellHeader()

template<typename T>
void ModuleIO::csrFileReader< T >::parseCellHeader ( )
private
Here is the call graph for this function:
Here is the caller graph for this function:

◆ parseCompactHeader()

template<typename T>
void ModuleIO::csrFileReader< T >::parseCompactHeader ( )
private
Here is the call graph for this function:
Here is the caller graph for this function:

◆ parseFile()

template<typename T>
void ModuleIO::csrFileReader< T >::parseFile ( )
Here is the call graph for this function:
Here is the caller graph for this function:

◆ readBlocks()

template<typename T>
void ModuleIO::csrFileReader< T >::readBlocks ( )
private
Here is the call graph for this function:
Here is the caller graph for this function:

◆ validateFrameEnd()

template<typename T>
void ModuleIO::csrFileReader< T >::validateFrameEnd ( )
private
Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ matrixDimension

template<typename T>
int ModuleIO::csrFileReader< T >::matrixDimension = 0
private

◆ numberOfR

template<typename T>
int ModuleIO::csrFileReader< T >::numberOfR = 0
private

◆ RCoordinates

template<typename T>
std::vector<std::vector<int> > ModuleIO::csrFileReader< T >::RCoordinates
private

◆ sparse_matrices

template<typename T>
std::vector<SparseMatrix<T> > ModuleIO::csrFileReader< T >::sparse_matrices
private

◆ step

template<typename T>
int ModuleIO::csrFileReader< T >::step = 0
private

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