11 #ifndef AMESOS2_TPETRACRSMATRIX_MATRIXADAPTER_DEF_HPP
12 #define AMESOS2_TPETRACRSMATRIX_MATRIXADAPTER_DEF_HPP
15 #include "Amesos2_TpetraRowMatrix_AbstractMatrixAdapter_def.hpp"
16 #include "Amesos2_MatrixAdapter_def.hpp"
20 template <
typename Scalar,
21 typename LocalOrdinal,
22 typename GlobalOrdinal,
24 ConcreteMatrixAdapter<
25 Tpetra::CrsMatrix<Scalar,
29 >::ConcreteMatrixAdapter(Teuchos::RCP<matrix_t> m)
30 : AbstractConcreteMatrixAdapter<Tpetra::RowMatrix<Scalar,
34 Tpetra::CrsMatrix<Scalar,
40 template <
typename Scalar,
41 typename LocalOrdinal,
42 typename GlobalOrdinal,
44 Teuchos::RCP<const MatrixAdapter<Tpetra::CrsMatrix<Scalar,LocalOrdinal,GlobalOrdinal,Node> > >
45 ConcreteMatrixAdapter<
46 Tpetra::CrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node>
47 >::get_impl(
const Teuchos::Ptr<
const Tpetra::Map<local_ordinal_t,global_ordinal_t,node_t> > map,
EDistribution distribution)
const
51 using Teuchos::rcpFromPtr;
52 typedef Tpetra::Import<local_ordinal_t, global_ordinal_t, node_t> import_t;
54 RCP<import_t> importer =
55 rcp (
new import_t (this->getRowMap(), rcpFromPtr (map)));
59 t_mat = Tpetra::importAndFillCompleteCrsMatrix<matrix_t>( (this->mat_), *importer );
62 if ( distribution == CONTIGUOUS_AND_ROOTED ) {
64 auto myRank = map->getComm()->getRank();
66 auto local_matrix = t_mat->getLocalMatrixDevice();
67 const size_t global_num_contiguous_entries = t_mat->getGlobalNumRows();
68 const size_t local_num_contiguous_entries = (myRank == 0) ? t_mat->getGlobalNumRows() : 0;
71 typedef Tpetra::Map< local_ordinal_t, global_ordinal_t, node_t> contiguous_map_type;
72 RCP<const contiguous_map_type> contiguousRowMap = rcp(
new contiguous_map_type(global_num_contiguous_entries, local_num_contiguous_entries, 0, (t_mat->getComm() ) ) );
73 RCP<const contiguous_map_type> contiguousColMap = rcp(
new contiguous_map_type(global_num_contiguous_entries, local_num_contiguous_entries, 0, (t_mat->getComm() ) ) );
74 RCP<const contiguous_map_type> contiguousDomainMap = rcp(
new contiguous_map_type(global_num_contiguous_entries, local_num_contiguous_entries, 0, (t_mat->getComm() ) ) );
75 RCP<const contiguous_map_type> contiguousRangeMap = rcp(
new contiguous_map_type(global_num_contiguous_entries, local_num_contiguous_entries, 0, (t_mat->getComm() ) ) );
77 RCP<matrix_t> contiguous_t_mat = rcp(
new matrix_t(contiguousRowMap, contiguousColMap, local_matrix) );
78 contiguous_t_mat->resumeFill();
79 contiguous_t_mat->expertStaticFillComplete(contiguousDomainMap, contiguousRangeMap);
81 return rcp (
new ConcreteMatrixAdapter<matrix_t> (contiguous_t_mat));
84 return rcp (
new ConcreteMatrixAdapter<matrix_t> (t_mat));
89 #endif // AMESOS2_TPETRACRSMATRIX_MATRIXADAPTER_DEF_HPP
Specialization of the ConcreteMatrixAdapter for Tpetra::CrsMatrix. Inherits all its functionality fro...
EDistribution
Definition: Amesos2_TypeDecl.hpp:89