Amesos2 - Direct Sparse Solver Interfaces Version of the Day
Amesos2_TpetraRowMatrix_AbstractMatrixAdapter_decl.hpp
1// @HEADER
2// *****************************************************************************
3// Amesos2: Templated Direct Sparse Solver Package
4//
5// Copyright 2011 NTESS and the Amesos2 contributors.
6// SPDX-License-Identifier: BSD-3-Clause
7// *****************************************************************************
8// @HEADER
9
10
11#ifndef AMESOS2_TPETRAROWMATRIX_MATRIXADAPTER_DECL_HPP
12#define AMESOS2_TPETRAROWMATRIX_MATRIXADAPTER_DECL_HPP
13
14#include "Amesos2_config.h"
15
16#include <Teuchos_ArrayView.hpp>
17#include <Tpetra_CrsMatrix.hpp>
18
19#include "Amesos2_AbstractConcreteMatrixAdapter.hpp"
20#include "Amesos2_Util.hpp"
22
23namespace Amesos2 {
24
25 template <class Matrix> class MatrixAdapter;
26
27 using Teuchos::RCP;
28
43 template <typename Scalar,
44 typename LocalOrdinal,
45 typename GlobalOrdinal,
46 typename Node,
47 class DerivedMat >
48 class AbstractConcreteMatrixAdapter< Tpetra::RowMatrix<Scalar,
49 LocalOrdinal,
50 GlobalOrdinal,
51 Node >,
52 DerivedMat >
53 : public MatrixAdapter< DerivedMat > {
54 public:
55 // Give our base class access to our private implementation functions
56 friend class MatrixAdapter< DerivedMat >;
57
58 typedef Tpetra::RowMatrix<Scalar,
59 LocalOrdinal,
60 GlobalOrdinal,
61 Node > matrix_t;
62
63 typedef Scalar scalar_t;
64 typedef LocalOrdinal local_ordinal_t;
65 typedef GlobalOrdinal global_ordinal_t;
66 typedef Node node_t;
67
68 private:
70
71 public:
72 typedef typename super_t::global_size_t global_size_t;
73
74 typedef AbstractConcreteMatrixAdapter<matrix_t,
75 DerivedMat> type;
76
80
81 AbstractConcreteMatrixAdapter(RCP<matrix_t> m);
82
83 public: // these functions should technically be private
84
85 // implementation functions
86 template<typename KV_GO, typename KV_S>
87 void getGlobalRowCopy_kokkos_view_impl(global_ordinal_t row,
88 KV_GO & indices,
89 KV_S & vals,
90 size_t& nnz) const;
91
92 void getGlobalRowCopy_impl(global_ordinal_t row,
93 const Teuchos::ArrayView<global_ordinal_t>& indices,
94 const Teuchos::ArrayView<scalar_t>& vals,
95 size_t& nnz) const;
96
97 void getGlobalColCopy_impl(global_ordinal_t col,
98 const Teuchos::ArrayView<global_ordinal_t>& indices,
99 const Teuchos::ArrayView<scalar_t>& vals,
100 size_t& nnz) const;
101
102 global_size_t getGlobalNNZ_impl() const;
103
104 size_t getLocalNNZ_impl() const;
105
106 size_t getMaxRowNNZ_impl() const;
107
108 size_t getMaxColNNZ_impl() const;
109
110 size_t getGlobalRowNNZ_impl(global_ordinal_t row) const;
111
112 size_t getLocalRowNNZ_impl(local_ordinal_t row) const;
113
114 size_t getGlobalColNNZ_impl(global_ordinal_t col) const;
115
116 size_t getLocalColNNZ_impl(local_ordinal_t col) const;
117
118 global_size_t getGlobalNumRows_impl() const;
119
120 global_size_t getGlobalNumCols_impl() const;
121
122 // Brunt of the work is put on the implementation for converting
123 // their maps to a Tpetra::Map
124 const RCP<const Tpetra::Map<local_ordinal_t,
125 global_ordinal_t,
126 node_t> >
127 getMap_impl() const;
128
129 const RCP<const Tpetra::Map<local_ordinal_t,
130 global_ordinal_t,
131 node_t> >
132 getRowMap_impl() const;
133
134 const RCP<const Tpetra::Map<local_ordinal_t,
135 global_ordinal_t,
136 node_t> >
137 getColMap_impl() const;
138
139 const RCP<const Teuchos::Comm<int> > getComm_impl() const;
140
141 bool isLocallyIndexed_impl() const;
142
143 bool isGloballyIndexed_impl() const;
144
145 // Because instantiation of the subclasses could be wildly
146 // different (cf subclasses of Tpetra::CrsMatrix), this method
147 // hands off implementation to the adapter for the subclass
148 RCP<const super_t> get_impl(const Teuchos::Ptr<const Tpetra::Map<local_ordinal_t,global_ordinal_t,node_t> > map, EDistribution distribution = ROOTED) const;
149 RCP<const super_t> reindex_impl(Teuchos::RCP<const Tpetra::Map<local_ordinal_t, global_ordinal_t, node_t>> &contigRowMap, Teuchos::RCP<const Tpetra::Map<local_ordinal_t, global_ordinal_t, node_t>> &contigColMap, const EPhase current_phase) const;
150
151 template<typename KV_S, typename KV_GO, typename KV_GS, typename host_ordinal_type_array, typename host_scalar_type_array>
152 local_ordinal_t gather_impl(KV_S& nzvals, KV_GO& indices, KV_GS& pointers,
153 host_ordinal_type_array &perm_g2l,
154 host_ordinal_type_array &recvCountRows, host_ordinal_type_array &recvDisplRows,
155 host_ordinal_type_array &recvCounts, host_ordinal_type_array &recvDispls,
156 host_ordinal_type_array &transpose_map, host_scalar_type_array &nzvals_t,
157 bool column_major, EPhase current_phase) const;
158
159 template<class KV>
160 void getSparseRowPtr_kokkos_view(KV & view) const {
161 deep_copy_or_assign_view(view, this->mat_->getLocalMatrixDevice().graph.row_map);
162 }
163
164 template<class KV>
165 void getSparseColInd_kokkos_view(KV & view) const {
166 deep_copy_or_assign_view(view, this->mat_->getLocalMatrixDevice().graph.entries);
167 }
168
169 template<class KV>
170 void getSparseValues_kokkos_view(KV & view) const {
171 deep_copy_or_assign_view(view, this->mat_->getLocalMatrixDevice().values);
172 }
173
174 };
175
176} // end namespace Amesos2
177
178#endif // AMESOS2_TPETRAROWMATRIX_MATRIXADAPTER_DECL_HPP
Copy or assign views based on memory spaces.
EDistribution
Definition Amesos2_TypeDecl.hpp:89
@ ROOTED
Definition Amesos2_TypeDecl.hpp:93
Utility functions for Amesos2.
Definition Amesos2_AbstractConcreteMatrixAdapter.hpp:55
A Matrix adapter interface for Amesos2.
Definition Amesos2_MatrixAdapter_decl.hpp:42
EPhase
Used to indicate a phase in the direct solution.
Definition Amesos2_TypeDecl.hpp:31
Indicates that the concrete class can use the generic getC{c|r}s methods implemented in MatrixAdapter...
Definition Amesos2_TypeDecl.hpp:57
Indicates that the object of an adapter provides row access to its data.
Definition Amesos2_TypeDecl.hpp:66