MueLu  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MueLu_TpetraOperatorAsRowMatrix.hpp
Go to the documentation of this file.
1 // @HEADER
2 // *****************************************************************************
3 // MueLu: A package for multigrid based preconditioning
4 //
5 // Copyright 2012 NTESS and the MueLu contributors.
6 // SPDX-License-Identifier: BSD-3-Clause
7 // *****************************************************************************
8 // @HEADER
9 
10 #include <Tpetra_RowMatrix.hpp>
11 
12 namespace MueLu {
13 
14 template <class Scalar = Tpetra::Operator<>::scalar_type,
18 class TpetraOperatorAsRowMatrix : public Tpetra::RowMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node> {
19  public:
22 
25 
27  using mag_type = typename Kokkos::ArithTraits<impl_scalar_type>::mag_type;
28 
30  typename row_matrix_type::local_inds_device_view_type;
32  typename row_matrix_type::local_inds_host_view_type;
34  typename row_matrix_type::nonconst_local_inds_host_view_type;
35 
37  typename row_matrix_type::global_inds_device_view_type;
39  typename row_matrix_type::global_inds_host_view_type;
41  typename row_matrix_type::nonconst_global_inds_host_view_type;
42 
44  typename row_matrix_type::values_device_view_type;
45  using values_host_view_type =
46  typename row_matrix_type::values_host_view_type;
48  typename row_matrix_type::nonconst_values_host_view_type;
49 
51 
52 
55  : op_(op)
56  , diag_(Teuchos::null) {}
57 
59  const RCP<vec_type>& diag)
60  : op_(op)
61  , diag_(diag) {}
62 
65  return op_->getDomainMap();
66  }
67 
70  return op_->getRangeMap();
71  }
72 
74 
83  op_->apply(X, Y, mode, alpha, beta);
84  }
85 
86  // Fake RowMatrix interface
88  return op_->getRangeMap();
89  }
90 
92  throw MueLu::Exceptions::RuntimeError("Not implemented.");
93  }
94 
96  throw MueLu::Exceptions::RuntimeError("Not implemented.");
97  }
98 
100  return op_->getDomainMap()->getComm();
101  }
102 
104  throw MueLu::Exceptions::RuntimeError("Not implemented.");
105  }
106 
108  return getRowMap()->getGlobalNumElements();
109  }
110 
112  return getDomainMap()->getGlobalNumElements();
113  }
114 
115  size_t getLocalNumRows() const {
116  return getRowMap()->getLocalNumElements();
117  }
118 
119  size_t getLocalNumCols() const {
120  throw MueLu::Exceptions::RuntimeError("Not implemented.");
121  }
122 
124  throw MueLu::Exceptions::RuntimeError("Not implemented.");
125  }
126 
128  return 0;
129  }
130 
131  size_t getLocalNumEntries() const {
132  throw MueLu::Exceptions::RuntimeError("Not implemented.");
133  }
134 
135  size_t getNumEntriesInGlobalRow(GlobalOrdinal globalRow) const {
136  throw MueLu::Exceptions::RuntimeError("Not implemented.");
137  }
138 
139  size_t getNumEntriesInLocalRow(LocalOrdinal localRow) const {
140  throw MueLu::Exceptions::RuntimeError("Not implemented.");
141  }
142 
143  size_t getGlobalMaxNumRowEntries() const {
144  throw MueLu::Exceptions::RuntimeError("Not implemented.");
145  }
146 
147  size_t getLocalMaxNumRowEntries() const {
148  throw MueLu::Exceptions::RuntimeError("Not implemented.");
149  }
150 
151  bool hasColMap() const {
152  return false;
153  }
154 
155  bool isLocallyIndexed() const {
156  return true;
157  }
158 
159  bool isGloballyIndexed() const {
160  return true;
161  }
162 
163  bool isFillComplete() const {
164  return true;
165  }
166 
167  bool supportsRowViews() const {
168  return false;
169  }
170 
171  void
175  size_t& NumEntries) const {
176  throw MueLu::Exceptions::RuntimeError("Not implemented.");
177  }
178 
179  void
183  size_t& NumEntries) const {
184  throw MueLu::Exceptions::RuntimeError("Not implemented.");
185  }
186 
187  void
190  values_host_view_type& values) const {
191  throw MueLu::Exceptions::RuntimeError("Not implemented.");
192  }
193 
194  void
196  local_inds_host_view_type& indices,
197  values_host_view_type& values) const {
198  throw MueLu::Exceptions::RuntimeError("Not implemented.");
199  }
200 
202  if (diag_.is_null())
203  throw MueLu::Exceptions::RuntimeError("No diagonal available.");
204  else
205  diag = *diag_;
206  }
207 
209  throw MueLu::Exceptions::RuntimeError("Not implemented.");
210  }
211 
213  throw MueLu::Exceptions::RuntimeError("Not implemented.");
214  }
215 
217  return 0.;
218  }
219 
220  // void describe(Teuchos::FancyOStream& out, const Teuchos::EVerbosityLevel verbLevel) const {
221  // using std::setw;
222  // using std::endl;
223  // const size_t numRows = nearField_->getRowMap()->getGlobalNumElements();
224  // const size_t nnzNearField = nearField_->getGlobalNumEntries();
225  // const double nnzNearPerRow = Teuchos::as<double>(nnzNearField)/numRows;
226  // const size_t nnzKernelApprox = kernelApproximations_->pointA_->getGlobalNumEntries();
227  // const size_t numClusterPairs = kernelApproximations_->blockA_->getGlobalNumEntries();
228  // const size_t nnzBasis = basisMatrix_->getGlobalNumEntries();
229  // size_t nnzTransfer = 0;
230  // for (size_t i = 0; i<transferMatrices_.size(); i++)
231  // nnzTransfer += transferMatrices_[i]->pointA_->getGlobalNumEntries();
232  // const size_t nnzTotal = nnzNearField+nnzKernelApprox+nnzBasis+nnzTransfer;
233  // const double nnzTotalPerRow = Teuchos::as<double>(nnzTotal)/numRows;
234  // std::ostringstream oss;
235  // oss << std::left;
236  // oss << setw(9) << "rows" << setw(12) << "nnz(near)" << setw(14) << "nnz(near)/row" << setw(12) << "nnz(basis)" << setw(15) << "#cluster pairs" << setw(12)<< "nnz(kernel)" << setw(14) << "nnz(transfer)" << setw(12) << "nnz(total)" << setw(14) << "nnz(total)/row" << endl;
237  // oss << setw(9) << numRows << setw(12) << nnzNearField << setw(14) << nnzNearPerRow << setw(12) << nnzBasis << setw(15) << numClusterPairs << setw(12) << nnzKernelApprox << setw(14) << nnzTransfer << setw(12) << nnzTotal << setw(14) << nnzTotalPerRow << endl;
238  // out << oss.str();
239  // }
240 
241  private:
244 };
245 
246 } // namespace MueLu
void leftScale(const Tpetra::Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &x)
MueLu::DefaultLocalOrdinal LocalOrdinal
TpetraOperatorAsRowMatrix(const RCP< op_type > &op, const RCP< vec_type > &diag)
Teuchos::RCP< const Tpetra::Map< LocalOrdinal, GlobalOrdinal, Node > > getDomainMap() const
Returns the Tpetra::Map object associated with the domain of this operator.
void getGlobalRowCopy(GlobalOrdinal GlobalRow, nonconst_global_inds_host_view_type &Indices, nonconst_values_host_view_type &Values, size_t &NumEntries) const
row_matrix_type::local_ordinal_type getBlockSize() const
typename row_matrix_type::values_device_view_type values_device_view_type
LocalOrdinal local_ordinal_type
size_t getNumEntriesInGlobalRow(GlobalOrdinal globalRow) const
void rightScale(const Tpetra::Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &x)
typename row_matrix_type::local_inds_host_view_type local_inds_host_view_type
MueLu::DefaultNode Node
void getLocalRowCopy(LocalOrdinal LocalRow, nonconst_local_inds_host_view_type &Indices, nonconst_values_host_view_type &Values, size_t &NumEntries) const
void getLocalDiagCopy(Tpetra::Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &diag) const
typename Kokkos::ArithTraits< Scalar >::val_type impl_scalar_type
size_t global_size_t
typename row_matrix_type::nonconst_local_inds_host_view_type nonconst_local_inds_host_view_type
MueLu::DefaultScalar Scalar
MueLu::DefaultGlobalOrdinal GlobalOrdinal
typename Kokkos::ArithTraits< Scalar >::mag_type mag_type
size_t getNumEntriesInLocalRow(LocalOrdinal localRow) const
void apply(const Tpetra::MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &X, Tpetra::MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &Y, Teuchos::ETransp mode=Teuchos::NO_TRANS, Scalar alpha=Teuchos::ScalarTraits< Scalar >::one(), Scalar beta=Teuchos::ScalarTraits< Scalar >::zero()) const
Returns in Y the result of a Tpetra::Operator applied to a Tpetra::MultiVector X. ...
typename row_matrix_type::values_host_view_type values_host_view_type
Tpetra::global_size_t getGlobalNumEntries() const
typename row_matrix_type::nonconst_global_inds_host_view_type nonconst_global_inds_host_view_type
Teuchos::RCP< const Teuchos::Comm< int > > getComm() const
Teuchos::RCP< const Tpetra::RowGraph< LocalOrdinal, GlobalOrdinal, Node > > getGraph() const
typename row_matrix_type::local_inds_device_view_type local_inds_device_view_type
Teuchos::RCP< const Tpetra::Map< LocalOrdinal, GlobalOrdinal, Node > > getColMap() const
typename row_matrix_type::global_inds_host_view_type global_inds_host_view_type
typename row_matrix_type::global_inds_device_view_type global_inds_device_view_type
typename row_matrix_type::nonconst_values_host_view_type nonconst_values_host_view_type
Teuchos::RCP< const Tpetra::Map< LocalOrdinal, GlobalOrdinal, Node > > getRangeMap() const
Returns the Tpetra::Map object associated with the range of this operator.
Exception throws to report errors in the internal logical of the program.
void getLocalRowView(LocalOrdinal LocalRow, local_inds_host_view_type &indices, values_host_view_type &values) const
TpetraOperatorAsRowMatrix(const RCP< op_type > &op)
Constructor.
void getGlobalRowView(GlobalOrdinal GlobalRow, global_inds_host_view_type &indices, values_host_view_type &values) const
Teuchos::RCP< const Tpetra::Map< LocalOrdinal, GlobalOrdinal, Node > > getRowMap() const
bool is_null() const