45 #ifndef AMESOS2_TPETRACRSMATRIX_MATRIXADAPTER_DEF_HPP
46 #define AMESOS2_TPETRACRSMATRIX_MATRIXADAPTER_DEF_HPP
49 #include "Amesos2_TpetraRowMatrix_AbstractMatrixAdapter_def.hpp"
50 #include "Amesos2_MatrixAdapter_def.hpp"
54 template <
typename Scalar,
55 typename LocalOrdinal,
56 typename GlobalOrdinal,
58 ConcreteMatrixAdapter<
59 Tpetra::CrsMatrix<Scalar,
63 >::ConcreteMatrixAdapter(Teuchos::RCP<matrix_t> m)
64 : AbstractConcreteMatrixAdapter<Tpetra::RowMatrix<Scalar,
68 Tpetra::CrsMatrix<Scalar,
74 template <
typename Scalar,
75 typename LocalOrdinal,
76 typename GlobalOrdinal,
78 Teuchos::RCP<const MatrixAdapter<Tpetra::CrsMatrix<Scalar,LocalOrdinal,GlobalOrdinal,Node> > >
79 ConcreteMatrixAdapter<
80 Tpetra::CrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node>
81 >::get_impl(
const Teuchos::Ptr<
const Tpetra::Map<local_ordinal_t,global_ordinal_t,node_t> > map,
EDistribution distribution)
const
85 using Teuchos::rcpFromPtr;
86 typedef Tpetra::Import<local_ordinal_t, global_ordinal_t, node_t> import_t;
88 RCP<import_t> importer =
89 rcp (
new import_t (this->getRowMap(), rcpFromPtr (map)));
93 t_mat = Tpetra::importAndFillCompleteCrsMatrix<matrix_t>( (this->mat_), *importer );
96 if ( distribution == CONTIGUOUS_AND_ROOTED ) {
98 auto myRank = map->getComm()->getRank();
100 auto local_matrix = t_mat->getLocalMatrix();
101 const size_t global_num_contiguous_entries = t_mat->getGlobalNumRows();
102 const size_t local_num_contiguous_entries = (myRank == 0) ? t_mat->getGlobalNumRows() : 0;
105 typedef Tpetra::Map< local_ordinal_t, global_ordinal_t, node_t> contiguous_map_type;
106 RCP<const contiguous_map_type> contiguousRowMap = rcp(
new contiguous_map_type(global_num_contiguous_entries, local_num_contiguous_entries, 0, (t_mat->getComm() ) ) );
107 RCP<const contiguous_map_type> contiguousColMap = rcp(
new contiguous_map_type(global_num_contiguous_entries, local_num_contiguous_entries, 0, (t_mat->getComm() ) ) );
108 RCP<const contiguous_map_type> contiguousDomainMap = rcp(
new contiguous_map_type(global_num_contiguous_entries, local_num_contiguous_entries, 0, (t_mat->getComm() ) ) );
109 RCP<const contiguous_map_type> contiguousRangeMap = rcp(
new contiguous_map_type(global_num_contiguous_entries, local_num_contiguous_entries, 0, (t_mat->getComm() ) ) );
111 RCP<matrix_t> contiguous_t_mat = rcp(
new matrix_t(contiguousRowMap, contiguousColMap, local_matrix) );
112 contiguous_t_mat->resumeFill();
113 contiguous_t_mat->expertStaticFillComplete(contiguousDomainMap, contiguousRangeMap);
115 return rcp (
new ConcreteMatrixAdapter<matrix_t> (contiguous_t_mat));
118 return rcp (
new ConcreteMatrixAdapter<matrix_t> (t_mat));
123 #endif // AMESOS2_TPETRACRSMATRIX_MATRIXADAPTER_DEF_HPP
Specialization of the ConcreteMatrixAdapter for Tpetra::CrsMatrix. Inherits all its functionality fro...
EDistribution
Definition: Amesos2_TypeDecl.hpp:123