Xpetra  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Xpetra::IO< Scalar, LocalOrdinal, GlobalOrdinal, Node > Class Template Reference

Xpetra utility class containing IO routines to read/write vectors, matrices etc... More...

#include <Xpetra_IO_decl.hpp>

Static Public Member Functions

static RCP< MultiVectorReadMultiVector (const std::string &fileName, const RCP< const Map > &map, const bool binary=false)
 Read a MultiVector from file in Matrix Matrix or binary format. More...
 
static RCP
< Xpetra::MultiVector
< LocalOrdinal, LocalOrdinal,
GlobalOrdinal, Node > > 
ReadMultiVectorLO (const std::string &fileName, const RCP< const Map > &map, const bool binary=false)
 Read a MultiVector with Scalar=LocalOrdinal from file in Matrix Matrix or binary format. More...
 
static RCP< const MapReadMap (const std::string &fileName, Xpetra::UnderlyingLib lib, const RCP< const Teuchos::Comm< int >> &comm, const bool binary=false)
 
static RCP< const
Xpetra::BlockedCrsMatrix
< Scalar, LocalOrdinal,
GlobalOrdinal, Node > > 
ReadBlockedCrsMatrix (const std::string &fileName, Xpetra::UnderlyingLib lib, const RCP< const Teuchos::Comm< int >> &comm)
 Read block matrix from one file per block in Matrix Market format. More...
 
template<class T >
static std::string toString (const T &what)
 Little helper function to convert non-string types to strings. More...
 
static const Epetra_Map & Map2EpetraMap (const Xpetra::Map< LocalOrdinal, GlobalOrdinal, Node > &map)
 Helper utility to pull out the underlying Epetra objects from an Xpetra object. More...
 
static const RCP< const
Tpetra::Map< LocalOrdinal,
GlobalOrdinal, Node > > 
Map2TpetraMap (const Xpetra::Map< LocalOrdinal, GlobalOrdinal, Node > &map)
 Helper utility to pull out the underlying Tpetra objects from an Xpetra object. More...
 
static void Write (const std::string &fileName, const Xpetra::Map< LocalOrdinal, GlobalOrdinal, Node > &M)
 Read/Write methods. More...
 
static void Write (const std::string &fileName, const Xpetra::MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &vec)
 Save multivector to file in Matrix Market format. More...
 
static void WriteLOMV (const std::string &fileName, const Xpetra::MultiVector< LocalOrdinal, LocalOrdinal, GlobalOrdinal, Node > &vec)
 Save multivector with Scalar=LocalOrdinal to file in Matrix Market format. More...
 
static void WriteGOMV (const std::string &fileName, const Xpetra::MultiVector< GlobalOrdinal, LocalOrdinal, GlobalOrdinal, Node > &vec)
 Save multivector with Scalar=GlobalOrdinal to file in Matrix Market format. More...
 
static void Write (const std::string &fileName, const Xpetra::Matrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > &Op, const bool &writeAllMaps=false)
 Save matrix to file in Matrix Market format. More...
 
static void WriteLocal (const std::string &fileName, const Xpetra::Matrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > &Op)
 Save local parts of matrix to files in Matrix Market format. More...
 
static void WriteBlockedCrsMatrix (const std::string &fileName, const Xpetra::BlockedCrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > &Op, const bool &writeAllMaps=false)
 Save block matrix to one file per block in Matrix Market format. More...
 
static Teuchos::RCP
< Xpetra::Matrix< Scalar,
LocalOrdinal, GlobalOrdinal,
Node > > 
Read (const std::string &fileName, Xpetra::UnderlyingLib lib, const RCP< const Teuchos::Comm< int >> &comm, bool binary=false)
 Read matrix from file in Matrix Market or binary format. More...
 
static Teuchos::RCP
< Xpetra::Matrix< Scalar,
LocalOrdinal, GlobalOrdinal,
Node > > 
Read (const std::string &filename, const RCP< const Xpetra::Map< LocalOrdinal, GlobalOrdinal, Node >> rowMap, RCP< const Xpetra::Map< LocalOrdinal, GlobalOrdinal, Node >> colMap=Teuchos::null, const RCP< const Xpetra::Map< LocalOrdinal, GlobalOrdinal, Node >> domainMap=Teuchos::null, const RCP< const Xpetra::Map< LocalOrdinal, GlobalOrdinal, Node >> rangeMap=Teuchos::null, const bool callFillComplete=true, const bool binary=false, const bool tolerant=false, const bool debug=false)
 Read matrix from file in Matrix Market or binary format. More...
 
static Teuchos::RCP
< Xpetra::Matrix< Scalar,
LocalOrdinal, GlobalOrdinal,
Node > > 
ReadLocal (const std::string &filename, const RCP< const Xpetra::Map< LocalOrdinal, GlobalOrdinal, Node >> rowMap, RCP< const Xpetra::Map< LocalOrdinal, GlobalOrdinal, Node >> colMap, const RCP< const Xpetra::Map< LocalOrdinal, GlobalOrdinal, Node >> domainMap=Teuchos::null, const RCP< const Xpetra::Map< LocalOrdinal, GlobalOrdinal, Node >> rangeMap=Teuchos::null, const bool callFillComplete=true, const bool binary=false, const bool tolerant=false, const bool debug=false)
 Read matrix from local files in Matrix Market or binary format. More...
 

Detailed Description

template<class Scalar, class LocalOrdinal = int, class GlobalOrdinal = LocalOrdinal, class Node = Tpetra::KokkosClassic::DefaultNode::DefaultNodeType>
class Xpetra::IO< Scalar, LocalOrdinal, GlobalOrdinal, Node >

Xpetra utility class containing IO routines to read/write vectors, matrices etc...

Xpetra utility class containing IO routines to read/write vectors, matrices.

Specialization for LO=GO=int

TODO: do we need specialization for SC=double and std::complex<>??? TODO: need specialization for <int, long long>

Definition at line 124 of file Xpetra_IO_decl.hpp.

Member Function Documentation

template<class Scalar , class LocalOrdinal , class GlobalOrdinal , class Node >
const Epetra_Map & Xpetra::IO< Scalar, LocalOrdinal, GlobalOrdinal, Node >::Map2EpetraMap ( const Xpetra::Map< LocalOrdinal, GlobalOrdinal, Node > &  map)
static

Helper utility to pull out the underlying Epetra objects from an Xpetra object.

Definition at line 67 of file Xpetra_IO_def.hpp.

template<class Scalar , class LocalOrdinal , class GlobalOrdinal , class Node >
const RCP< const Tpetra::Map< LocalOrdinal, GlobalOrdinal, Node > > Xpetra::IO< Scalar, LocalOrdinal, GlobalOrdinal, Node >::Map2TpetraMap ( const Xpetra::Map< LocalOrdinal, GlobalOrdinal, Node > &  map)
static

Helper utility to pull out the underlying Tpetra objects from an Xpetra object.

Definition at line 77 of file Xpetra_IO_def.hpp.

template<class Scalar , class LocalOrdinal , class GlobalOrdinal , class Node >
void Xpetra::IO< Scalar, LocalOrdinal, GlobalOrdinal, Node >::Write ( const std::string &  fileName,
const Xpetra::Map< LocalOrdinal, GlobalOrdinal, Node > &  M 
)
static

Read/Write methods.

Save map to file.

Definition at line 86 of file Xpetra_IO_def.hpp.

template<class Scalar , class LocalOrdinal , class GlobalOrdinal , class Node >
void Xpetra::IO< Scalar, LocalOrdinal, GlobalOrdinal, Node >::Write ( const std::string &  fileName,
const Xpetra::MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &  vec 
)
static

Save multivector to file in Matrix Market format.

Definition at line 112 of file Xpetra_IO_def.hpp.

template<class Scalar , class LocalOrdinal , class GlobalOrdinal , class Node >
void Xpetra::IO< Scalar, LocalOrdinal, GlobalOrdinal, Node >::WriteLOMV ( const std::string &  fileName,
const Xpetra::MultiVector< LocalOrdinal, LocalOrdinal, GlobalOrdinal, Node > &  vec 
)
static

Save multivector with Scalar=LocalOrdinal to file in Matrix Market format.

Definition at line 141 of file Xpetra_IO_def.hpp.

template<class Scalar , class LocalOrdinal , class GlobalOrdinal , class Node >
void Xpetra::IO< Scalar, LocalOrdinal, GlobalOrdinal, Node >::WriteGOMV ( const std::string &  fileName,
const Xpetra::MultiVector< GlobalOrdinal, LocalOrdinal, GlobalOrdinal, Node > &  vec 
)
static

Save multivector with Scalar=GlobalOrdinal to file in Matrix Market format.

Definition at line 163 of file Xpetra_IO_def.hpp.

template<class Scalar , class LocalOrdinal , class GlobalOrdinal , class Node >
void Xpetra::IO< Scalar, LocalOrdinal, GlobalOrdinal, Node >::Write ( const std::string &  fileName,
const Xpetra::Matrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > &  Op,
const bool &  writeAllMaps = false 
)
static

Save matrix to file in Matrix Market format.

Definition at line 185 of file Xpetra_IO_def.hpp.

template<class Scalar , class LocalOrdinal , class GlobalOrdinal , class Node >
void Xpetra::IO< Scalar, LocalOrdinal, GlobalOrdinal, Node >::WriteLocal ( const std::string &  fileName,
const Xpetra::Matrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > &  Op 
)
static

Save local parts of matrix to files in Matrix Market format.

Definition at line 231 of file Xpetra_IO_def.hpp.

template<class Scalar , class LocalOrdinal , class GlobalOrdinal , class Node >
void Xpetra::IO< Scalar, LocalOrdinal, GlobalOrdinal, Node >::WriteBlockedCrsMatrix ( const std::string &  fileName,
const Xpetra::BlockedCrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > &  Op,
const bool &  writeAllMaps = false 
)
static

Save block matrix to one file per block in Matrix Market format.

We write one MatrixMarket file for each block of the given BlockedCrsMatrix. The block (row,col) indicators are included into the file name, such that filename02.m indicates the block in row = 0 and col = 2, for example.

While the user can enable/disable the output of all maps of each matrix block, we always write the range and domain maps of each block as well of the full blocked operator in order to enable reconstruction of the MapExtractor objects for range and domain maps.

Parameters
fileNameString to indicate file name of files to be written
OpBlockedCrsMatrix to be written
writeAllMapsFlag to control output of maps to separate files (defaults to false )

Definition at line 258 of file Xpetra_IO_def.hpp.

template<class Scalar , class LocalOrdinal , class GlobalOrdinal , class Node >
Teuchos::RCP< Xpetra::Matrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > > Xpetra::IO< Scalar, LocalOrdinal, GlobalOrdinal, Node >::Read ( const std::string &  fileName,
Xpetra::UnderlyingLib  lib,
const RCP< const Teuchos::Comm< int >> &  comm,
bool  binary = false 
)
static

Read matrix from file in Matrix Market or binary format.

Definition at line 289 of file Xpetra_IO_def.hpp.

template<class Scalar , class LocalOrdinal , class GlobalOrdinal , class Node >
Teuchos::RCP< Xpetra::Matrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > > Xpetra::IO< Scalar, LocalOrdinal, GlobalOrdinal, Node >::Read ( const std::string &  filename,
const RCP< const Xpetra::Map< LocalOrdinal, GlobalOrdinal, Node >>  rowMap,
RCP< const Xpetra::Map< LocalOrdinal, GlobalOrdinal, Node >>  colMap = Teuchos::null,
const RCP< const Xpetra::Map< LocalOrdinal, GlobalOrdinal, Node >>  domainMap = Teuchos::null,
const RCP< const Xpetra::Map< LocalOrdinal, GlobalOrdinal, Node >>  rangeMap = Teuchos::null,
const bool  callFillComplete = true,
const bool  binary = false,
const bool  tolerant = false,
const bool  debug = false 
)
static

Read matrix from file in Matrix Market or binary format.

If only rowMap is specified, then it is used for the domainMap and rangeMap, as well.

Definition at line 410 of file Xpetra_IO_def.hpp.

template<class Scalar , class LocalOrdinal , class GlobalOrdinal , class Node >
Teuchos::RCP< Xpetra::Matrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > > Xpetra::IO< Scalar, LocalOrdinal, GlobalOrdinal, Node >::ReadLocal ( const std::string &  filename,
const RCP< const Xpetra::Map< LocalOrdinal, GlobalOrdinal, Node >>  rowMap,
RCP< const Xpetra::Map< LocalOrdinal, GlobalOrdinal, Node >>  colMap,
const RCP< const Xpetra::Map< LocalOrdinal, GlobalOrdinal, Node >>  domainMap = Teuchos::null,
const RCP< const Xpetra::Map< LocalOrdinal, GlobalOrdinal, Node >>  rangeMap = Teuchos::null,
const bool  callFillComplete = true,
const bool  binary = false,
const bool  tolerant = false,
const bool  debug = false 
)
static

Read matrix from local files in Matrix Market or binary format.

The file name format is filename.SIZE.RANK, where SIZE is the size of the communicator of the rowMap and RANK is the MPI ranks of the calling process.

If only rowMap is specified, then it is used for the domainMap and rangeMap, as well.

Definition at line 497 of file Xpetra_IO_def.hpp.

template<class Scalar , class LocalOrdinal = int, class GlobalOrdinal = LocalOrdinal, class Node = Tpetra::KokkosClassic::DefaultNode::DefaultNodeType>
RCP< Xpetra::MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > > Xpetra::IO< Scalar, LocalOrdinal, GlobalOrdinal, Node >::ReadMultiVector ( const std::string &  fileName,
const RCP< const Map > &  map,
const bool  binary = false 
)
static

Read a MultiVector from file in Matrix Matrix or binary format.

Definition at line 638 of file Xpetra_IO_def.hpp.

template<class Scalar , class LocalOrdinal = int, class GlobalOrdinal = LocalOrdinal, class Node = Tpetra::KokkosClassic::DefaultNode::DefaultNodeType>
RCP< Xpetra::MultiVector< LocalOrdinal, LocalOrdinal, GlobalOrdinal, Node > > Xpetra::IO< Scalar, LocalOrdinal, GlobalOrdinal, Node >::ReadMultiVectorLO ( const std::string &  fileName,
const RCP< const Map > &  map,
const bool  binary = false 
)
static

Read a MultiVector with Scalar=LocalOrdinal from file in Matrix Matrix or binary format.

Definition at line 668 of file Xpetra_IO_def.hpp.

template<class Scalar , class LocalOrdinal , class GlobalOrdinal , class Node >
RCP< const Xpetra::Map< LocalOrdinal, GlobalOrdinal, Node > > Xpetra::IO< Scalar, LocalOrdinal, GlobalOrdinal, Node >::ReadMap ( const std::string &  fileName,
Xpetra::UnderlyingLib  lib,
const RCP< const Teuchos::Comm< int >> &  comm,
const bool  binary = false 
)
static

Definition at line 695 of file Xpetra_IO_def.hpp.

template<class Scalar , class LocalOrdinal , class GlobalOrdinal , class Node >
RCP< const Xpetra::BlockedCrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > > Xpetra::IO< Scalar, LocalOrdinal, GlobalOrdinal, Node >::ReadBlockedCrsMatrix ( const std::string &  fileName,
Xpetra::UnderlyingLib  lib,
const RCP< const Teuchos::Comm< int >> &  comm 
)
static

Read block matrix from one file per block in Matrix Market format.

We read one MatrixMarket file for each block of the desired BlockedCrsMatrix. The block (row,col) indicators are included into the file name, such that filename02.m indicates the block in row = 0 and col = 2, for example.

We also read the range and domain maps of each block as well of the full blocked operator in order to enable reconstruction of the MapExtractor objects for range and domain maps.

Parameters
fileNameString to indicate file name of files to be written
libUnderlying type of linear algebra package
commCommunicator

Definition at line 722 of file Xpetra_IO_def.hpp.

template<class Scalar , class LocalOrdinal , class GlobalOrdinal , class Node >
template<class T >
std::string Xpetra::IO< Scalar, LocalOrdinal, GlobalOrdinal, Node >::toString ( const T &  what)
static

Little helper function to convert non-string types to strings.

Definition at line 795 of file Xpetra_IO_def.hpp.


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