2 #include "RBGen_MatrixMarketFileIOHandler.h"
3 #include "RBGen_ConfigDefs.h"
5 #include "Epetra_BLAS.h"
6 #include "Epetra_Export.h"
7 #include "Epetra_Import.h"
8 #include "Epetra_Map.h"
9 #include "Epetra_MultiVector.h"
11 #include "EpetraExt_mmio.h"
12 #include "EpetraExt_MultiVectorIn.h"
13 #include "EpetraExt_MultiVectorOut.h"
16 #include "Teuchos_Assert.hpp"
19 #include "Epetra_MpiComm.h"
21 #include "Epetra_SerialComm.h"
28 : num_nodes(0), isInit(false)
39 if ( fileio_params.
isParameter(
"Data Input Path" ) ) {
40 in_path = Teuchos::getParameter<std::string>( fileio_params,
"Data Input Path" );
45 if ( fileio_params.
isParameter(
"Data Output Path" ) ) {
46 out_path = Teuchos::getParameter<std::string>( fileio_params,
"Data Output Path" );
68 int num_files = filenames.size();
69 std::vector<int> cols(num_files,0);
71 for (i=0; i<num_files; ++i) {
72 int info = 0, rows_i = 0;
75 std::string temp_filename = in_path + filenames[i];
76 handle = fopen(temp_filename.c_str(),
"r");
77 TEUCHOS_TEST_FOR_EXCEPTION(handle==0, std::invalid_argument,
"File named '"+temp_filename+
"' does not exist or is not readable!");
80 info = EpetraExt::mm_read_mtx_array_size( handle, &rows_i, &cols[i] );
81 TEUCHOS_TEST_FOR_EXCEPTION(info!=0, std::runtime_error,
"Error reading file with name '"+temp_filename+
"'!");
88 TEUCHOS_TEST_FOR_EXCEPTION(rows_i!=rows, std::logic_error,
"Error reading file '"+temp_filename+
"', does not have same number of rows!");
105 for ( i=0; i<num_files; i++ ) {
109 std::string curr_filename = in_path + filenames[i];
110 int info = EpetraExt::MatrixMarketFileToMultiVector( curr_filename.c_str(), Map, fileMV );
119 subMV.Update( 1.0, *fileMV, 0.0 );
127 if (fileMV) {
delete fileMV; fileMV=0; }
142 std::string temp_filename = out_path + filename;
143 EpetraExt::MultiVectorToMatrixMarketFile( temp_filename.c_str(), *MV );
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
void Initialize(const Teuchos::RCP< Teuchos::ParameterList > ¶ms)
Initialize file reader using.
Teuchos::RCP< Epetra_MultiVector > Read(const std::vector< std::string > &filenames)
Method for reading multiple files and putting them into an Epetra_MultiVector.
bool isParameter(const std::string &name) const
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
MatrixMarketFileIOHandler()
Default constructor.
void Write(const Teuchos::RCP< const Epetra_MultiVector > &MV, const std::string &filename)
Method for writing one Epetra_MultiVector into a file.
ParameterList & sublist(const std::string &name, bool mustAlreadyExist=false, const std::string &docString="")