|
Tpetra Matrix/Vector Services Version of the Day
|
00001 #ifndef TPETRA_EPETRAROWMATRIX_HPP 00002 #define TPETRA_EPETRAROWMATRIX_HPP 00003 00004 #include <Tpetra_ConfigDefs.hpp> 00005 00006 #if defined(HAVE_TPETRA_EPETRA) 00007 00008 #include <Epetra_Comm.h> 00009 #include <Epetra_BasicRowMatrix.h> 00010 #include <Tpetra_CrsMatrix.hpp> 00011 00012 namespace Tpetra 00013 { 00014 00016 template<class TpetraMatrixType> 00017 class EpetraRowMatrix : public Epetra_BasicRowMatrix { 00018 public: 00019 EpetraRowMatrix(const Teuchos::RCP<TpetraMatrixType> &mat, const Epetra_Comm &comm); 00020 virtual ~EpetraRowMatrix(); 00021 00022 int ExtractMyRowCopy(int MyRow, int Length, int & NumEntries, double *Values, int * Indices) const; 00023 00024 //not implemented 00025 int ExtractMyEntryView(int CurEntry, double * & Value, int & RowIndex, int & ColIndex); 00026 00027 //not implemented 00028 int ExtractMyEntryView(int CurEntry, double const * & Value, int & RowIndex, int & ColIndex) const; 00029 00030 int NumMyRowEntries(int MyRow, int & NumEntries) const; 00031 00032 private: 00033 Teuchos::RCP<TpetraMatrixType> tpetra_matrix_; 00034 };//class EpetraRowMatrix 00035 00036 template<class TpetraMatrixType> 00037 EpetraRowMatrix<TpetraMatrixType>::EpetraRowMatrix( 00038 const Teuchos::RCP<TpetraMatrixType> &mat, const Epetra_Comm &comm 00039 ) 00040 : Epetra_BasicRowMatrix(comm), 00041 tpetra_matrix_(mat) 00042 { 00043 int globalNumRows = tpetra_matrix_->getRowMap()->getGlobalNumElements(); 00044 int globalNumCols = tpetra_matrix_->getColMap()->getGlobalNumElements(); 00045 Teuchos::ArrayView<const int> row_elem_list = tpetra_matrix_->getRowMap()->getNodeElementList(); 00046 Teuchos::ArrayView<const int> col_elem_list = tpetra_matrix_->getColMap()->getNodeElementList(); 00047 Epetra_Map rowmap(globalNumRows, row_elem_list.size(), row_elem_list.getRawPtr(), 0, comm); 00048 Epetra_Map colmap(globalNumCols, col_elem_list.size(), col_elem_list.getRawPtr(), 0, comm); 00049 SetMaps(rowmap, colmap); 00050 } 00051 00052 template<class TpetraMatrixType> 00053 EpetraRowMatrix<TpetraMatrixType>::~EpetraRowMatrix() 00054 { 00055 } 00056 00057 template<class TpetraMatrixType> 00058 int EpetraRowMatrix<TpetraMatrixType>::ExtractMyRowCopy(int MyRow, int Length, int & NumEntries, double *Values, int * Indices) const 00059 { 00060 Teuchos::ArrayView<int> inds(Indices, Length); 00061 Teuchos::ArrayView<double> vals(Values, Length); 00062 size_t num_entries = NumEntries; 00063 tpetra_matrix_->getLocalRowCopy(MyRow, inds, vals, num_entries); 00064 NumEntries = num_entries; 00065 return 0; 00066 } 00067 00068 template<class TpetraMatrixType> 00069 int EpetraRowMatrix<TpetraMatrixType>::ExtractMyEntryView(int CurEntry, double * & Value, int & RowIndex, int & ColIndex) 00070 { 00071 //not implemented 00072 return -1; 00073 } 00074 00075 template<class TpetraMatrixType> 00076 int EpetraRowMatrix<TpetraMatrixType>::ExtractMyEntryView(int CurEntry, double const * & Value, int & RowIndex, int & ColIndex) const 00077 { 00078 //not implemented 00079 return -1; 00080 } 00081 00082 template<class TpetraMatrixType> 00083 int EpetraRowMatrix<TpetraMatrixType>::NumMyRowEntries(int MyRow, int & NumEntries) const 00084 { 00085 NumEntries = tpetra_matrix_->getNumEntriesInLocalRow(MyRow); 00086 return 0; 00087 } 00088 00089 }//namespace Tpetra 00090 00091 #endif // defined(HAVE_TPETRA_EPETRA) 00092 00093 //here is the include-guard #endif: 00094 00095 #endif
1.7.4