Tpetra parallel linear algebra  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Tpetra_BlockCrsMatrix_decl.hpp
Go to the documentation of this file.
1 // @HEADER
2 // *****************************************************************************
3 // Tpetra: Templated Linear Algebra Services Package
4 //
5 // Copyright 2008 NTESS and the Tpetra contributors.
6 // SPDX-License-Identifier: BSD-3-Clause
7 // *****************************************************************************
8 // @HEADER
9 
10 // clang-format off
11 #ifndef TPETRA_BLOCKCRSMATRIX_DECL_HPP
12 #define TPETRA_BLOCKCRSMATRIX_DECL_HPP
13 
16 
17 #include "Tpetra_CrsGraph.hpp"
18 #include "Tpetra_RowMatrix.hpp"
19 #include "Tpetra_BlockMultiVector_decl.hpp"
21 
22 #include "KokkosSparse_BsrMatrix.hpp"
23 
24 #include "Tpetra_Details_MatrixApplyHelper.hpp"
25 
26 namespace Tpetra {
27 
28 template<class BlockCrsMatrixType>
29 Teuchos::RCP<BlockCrsMatrixType>
30 importAndFillCompleteBlockCrsMatrix (const Teuchos::RCP<const BlockCrsMatrixType>& sourceMatrix,
31  const Import<typename BlockCrsMatrixType::local_ordinal_type,
32  typename BlockCrsMatrixType::global_ordinal_type,
33  typename BlockCrsMatrixType::node_type>& importer);
34 template<class BlockCrsMatrixType>
35 Teuchos::RCP<BlockCrsMatrixType>
36 exportAndFillCompleteBlockCrsMatrix (const Teuchos::RCP<const BlockCrsMatrixType>& sourceMatrix,
37  const Export<typename BlockCrsMatrixType::local_ordinal_type,
38  typename BlockCrsMatrixType::global_ordinal_type,
39  typename BlockCrsMatrixType::node_type>& exporter);
40 
118 
119 namespace Impl {
121 #if defined(TPETRA_ENABLE_BLOCKCRS_LITTLEBLOCK_LAYOUTLEFT)
122  using BlockCrsMatrixLittleBlockArrayLayout = Kokkos::LayoutLeft;
123 #else
124  using BlockCrsMatrixLittleBlockArrayLayout = Kokkos::LayoutRight;
125 #endif
126 }
127 
128 template<class Scalar,
129  class LO,
130  class GO,
131  class Node>
133  virtual public ::Tpetra::RowMatrix<Scalar, LO, GO, Node>,
134  virtual public ::Tpetra::DistObject<char, LO, GO, Node>
135 {
136 private:
139  using STS = Teuchos::ScalarTraits<Scalar>;
140 
141 protected:
143  typedef char packet_type;
144 
145 public:
147 
148 
150  using scalar_type = Scalar;
151 
159 
161  typedef LO local_ordinal_type;
168  typedef Node node_type;
169 
171  typedef typename Node::device_type device_type;
173  typedef typename device_type::execution_space execution_space;
175  typedef typename device_type::memory_space memory_space;
176 
178  typedef ::Tpetra::Map<LO, GO, node_type> map_type;
180  typedef ::Tpetra::MultiVector<Scalar, LO, GO, node_type> mv_type;
182  typedef ::Tpetra::CrsGraph<LO, GO, node_type> crs_graph_type;
183 
185  typedef Kokkos::View<impl_scalar_type**,
187  device_type,
188  Kokkos::MemoryTraits<Kokkos::Unmanaged> >
190  typedef typename little_block_type::HostMirror little_block_host_type;
191 
193  typedef Kokkos::View<const impl_scalar_type**,
195  device_type,
196  Kokkos::MemoryTraits<Kokkos::Unmanaged> >
200  typedef typename BMV::little_host_vec_type little_host_vec_type;
201 
204  typedef typename BMV::const_little_host_vec_type const_host_little_vec_type;
205 
207  using local_inds_device_view_type =
208  typename row_matrix_type::local_inds_device_view_type;
209  using local_inds_host_view_type =
210  typename row_matrix_type::local_inds_host_view_type;
211  using nonconst_local_inds_host_view_type =
212  typename row_matrix_type::nonconst_local_inds_host_view_type;
213 
214  using global_inds_device_view_type =
215  typename row_matrix_type::global_inds_device_view_type;
216  using global_inds_host_view_type =
217  typename row_matrix_type::global_inds_host_view_type;
218  using nonconst_global_inds_host_view_type =
219  typename row_matrix_type::nonconst_global_inds_host_view_type;
220 
221  using values_device_view_type =
222  typename row_matrix_type::values_device_view_type;
223  using values_host_view_type =
224  typename row_matrix_type::values_host_view_type;
225  using nonconst_values_host_view_type =
226  typename row_matrix_type::nonconst_values_host_view_type;
227 
228  using local_graph_device_type = typename crs_graph_type::local_graph_device_type;
229 
230  using local_matrix_device_type =
231  KokkosSparse::Experimental::BsrMatrix<impl_scalar_type,
233  device_type,
234  void,
235  typename local_graph_device_type::size_type>;
236 
237 private:
238  // TODO: When KokkosKernels 4.4 is released, local_matrix_device_type can be permanently modified to use the default_size_type
239  // of KK. This is always a type that is enabled by KK's ETI (preferring int if both or neither int and size_t are enabled).
240  using local_matrix_int_rowptrs_device_type =
241  KokkosSparse::Experimental::BsrMatrix<impl_scalar_type,
243  device_type,
244  void,
245  int>;
246 
249  local_matrix_device_type,
250  local_matrix_int_rowptrs_device_type,
251  typename mv_type::device_view_type>;
252 
260  mutable std::shared_ptr<ApplyHelper> applyHelper;
261 
262 public:
263  std::shared_ptr<ApplyHelper> getApplyHelper() const {
264  if (!applyHelper) {
265  auto A_lcl = getLocalMatrixDevice();
266  applyHelper = std::make_shared<ApplyHelper>(A_lcl.nnz(), A_lcl.graph.row_map);
267  }
268  return applyHelper;
269  }
270 
271  using local_matrix_host_type =
272  typename local_matrix_device_type::HostMirror;
273 
275 
277 
279  BlockCrsMatrix ();
280 
290  BlockCrsMatrix (const crs_graph_type& graph, const LO blockSize);
291 
292  BlockCrsMatrix (const crs_graph_type& graph,
293  const typename local_matrix_device_type::values_type& values,
294  const LO blockSize);
295 
303  BlockCrsMatrix (const crs_graph_type& graph,
304  const map_type& domainPointMap,
305  const map_type& rangePointMap,
306  const LO blockSize);
307 
309  virtual ~BlockCrsMatrix () {}
310 
312 
314 
316  Teuchos::RCP<const map_type> getDomainMap () const override;
317 
319  Teuchos::RCP<const map_type> getRangeMap () const override;
320 
322  Teuchos::RCP<const map_type> getRowMap () const override;
323 
325  Teuchos::RCP<const map_type> getColMap () const override;
326 
328  global_size_t getGlobalNumRows() const override;
329 
331  size_t getLocalNumRows() const override;
332 
333  size_t getLocalMaxNumRowEntries() const override;
334 
344  void
345  apply (const mv_type& X,
346  mv_type& Y,
347  Teuchos::ETransp mode = Teuchos::NO_TRANS,
348  Scalar alpha = Teuchos::ScalarTraits<Scalar>::one (),
349  Scalar beta = Teuchos::ScalarTraits<Scalar>::zero ()) const override;
350 
353  bool hasTransposeApply () const override {
354  // FIXME (mfh 04 May 2014) Transpose and conjugate transpose modes
355  // are not implemented yet. Fill in applyBlockTrans() to fix this.
356  return false;
357  }
358 
360  void setAllToScalar (const Scalar& alpha);
361 
363 
365 
367  std::string description () const override;
368 
392  void
393  describe (Teuchos::FancyOStream& out,
394  const Teuchos::EVerbosityLevel verbLevel) const override;
395 
397 
399 
401  virtual LO getBlockSize () const override { return blockSize_; }
402 
404  virtual Teuchos::RCP<const ::Tpetra::RowGraph<LO,GO,Node> > getGraph () const override;
405 
406  const crs_graph_type & getCrsGraph () const { return graph_; }
407 
412  void
413  applyBlock (const BlockMultiVector<Scalar, LO, GO, Node>& X,
414  BlockMultiVector<Scalar, LO, GO, Node>& Y,
415  Teuchos::ETransp mode = Teuchos::NO_TRANS,
416  const Scalar alpha = Teuchos::ScalarTraits<Scalar>::one (),
417  const Scalar beta = Teuchos::ScalarTraits<Scalar>::zero ());
418 
421  void
422  importAndFillComplete (Teuchos::RCP<BlockCrsMatrix<Scalar, LO, GO, Node> >& destMatrix,
423  const Import<LO, GO, Node>& importer) const;
424 
427  void
428  exportAndFillComplete (Teuchos::RCP<BlockCrsMatrix<Scalar, LO, GO, Node> >& destMatrix,
429  const Export<LO, GO, Node>& exporter) const;
430 
431 
458  LO
459  replaceLocalValues (const LO localRowInd,
460  const LO colInds[],
461  const Scalar vals[],
462  const LO numColInds) const;
463 
490  LO
491  sumIntoLocalValues (const LO localRowInd,
492  const LO colInds[],
493  const Scalar vals[],
494  const LO numColInds) const;
495 
496 
529  void
530  getLocalRowView (LO LocalRow,
531  local_inds_host_view_type &indices,
532  values_host_view_type &values) const override;
533 
536  void
537  getLocalRowViewNonConst (LO LocalRow,
538  local_inds_host_view_type &indices,
539  nonconst_values_host_view_type &values) const;
540 
542  virtual void
543  getLocalRowCopy (LO LocalRow,
544  nonconst_local_inds_host_view_type &Indices,
545  nonconst_values_host_view_type &Values,
546  size_t& NumEntries) const override;
548  getLocalBlockDeviceNonConst (const LO localRowInd, const LO localColInd) const;
549 
550  little_block_host_type
551  getLocalBlockHostNonConst (const LO localRowInd, const LO localColInd) const;
552 
553 
577  LO
578  getLocalRowOffsets (const LO localRowInd,
579  ptrdiff_t offsets[],
580  const LO colInds[],
581  const LO numColInds) const;
582 
588  LO
589  replaceLocalValuesByOffsets (const LO localRowInd,
590  const ptrdiff_t offsets[],
591  const Scalar vals[],
592  const LO numOffsets) const;
593 
594  LO
595  absMaxLocalValuesByOffsets (const LO localRowInd,
596  const ptrdiff_t offsets[],
597  const Scalar vals[],
598  const LO numOffsets) const;
599 
605  LO
606  sumIntoLocalValuesByOffsets (const LO localRowInd,
607  const ptrdiff_t offsets[],
608  const Scalar vals[],
609  const LO numOffsets) const;
610 
617  size_t getNumEntriesInLocalRow (const LO localRowInd) const override;
618 
619 
622  local_matrix_device_type getLocalMatrixDevice () const;
623 
640  bool localError () const {
641  return *localError_;
642  }
643 
658  std::string errorMessages () const {
659  return (*errs_).is_null () ? std::string ("") : (*errs_)->str ();
660  }
661 
693  void
694  getLocalDiagOffsets (const Kokkos::View<size_t*, device_type,
695  Kokkos::MemoryUnmanaged>& offsets) const;
696 
697 
711  void
712  getLocalDiagCopy (const Kokkos::View<impl_scalar_type***, device_type,
713  Kokkos::MemoryUnmanaged>& diag,
714  const Kokkos::View<const size_t*, device_type,
715  Kokkos::MemoryUnmanaged>& offsets) const;
716 
730 protected:
732  LO
733  absMaxLocalValues (const LO localRowInd,
734  const LO colInds[],
735  const Scalar vals[],
736  const LO numColInds) const;
737 
743 
744 
749  using buffer_device_type = typename DistObject<Scalar, LO, GO,
751 
752  virtual bool checkSizes (const ::Tpetra::SrcDistObject& source) override;
753 
754  // clang-format on
755  using dist_object_type::
757  // clang-format off
759 
760  virtual void
762  (const SrcDistObject& sourceObj,
763  const size_t numSameIDs,
764  const Kokkos::DualView<const local_ordinal_type*,
765  buffer_device_type>& permuteToLIDs,
766  const Kokkos::DualView<const local_ordinal_type*,
767  buffer_device_type>& permuteFromLIDs,
768  const CombineMode CM) override;
769 
770  // clang-format on
772  // clang-format off
776 
777  virtual void
779  (const SrcDistObject& sourceObj,
780  const Kokkos::DualView<const local_ordinal_type*,
781  buffer_device_type>& exportLIDs,
782  Kokkos::DualView<packet_type*,
783  buffer_device_type>& exports,
784  Kokkos::DualView<size_t*,
785  buffer_device_type> numPacketsPerLID,
786  size_t& constantNumPackets) override;
787 
788  // clang-format on
790  // clang-format off
794 
795  virtual void
797  (const Kokkos::DualView<const local_ordinal_type*,
798  buffer_device_type>& importLIDs,
799  Kokkos::DualView<packet_type*,
800  buffer_device_type> imports,
801  Kokkos::DualView<size_t*,
802  buffer_device_type> numPacketsPerLID,
803  const size_t constantNumPackets,
804  const CombineMode combineMode) override;
806 
807 private:
809  crs_graph_type graph_;
810  Teuchos::RCP<crs_graph_type> graphRCP_;
819  map_type rowMeshMap_;
826  map_type domainPointMap_;
833  map_type rangePointMap_;
835  LO blockSize_;
836 
850  using graph_row_offset_host_type = typename crs_graph_type::local_graph_device_type::row_map_type::HostMirror;
851  graph_row_offset_host_type ptrHost_;
852 
858  using graph_column_indices_host_type = typename crs_graph_type::local_graph_device_type::entries_type::HostMirror;
859  graph_column_indices_host_type indHost_;
860 
866  using impl_scalar_type_dualview = Kokkos::DualView<impl_scalar_type*, device_type>;
869 
891  Teuchos::RCP<Teuchos::RCP<BMV> > X_colMap_;
895  Teuchos::RCP<Teuchos::RCP<BMV> > Y_rowMap_;
896 
904  Teuchos::RCP<Teuchos::RCP<typename crs_graph_type::import_type> > pointImporter_;
905 
907  LO offsetPerBlock_;
908 
920  Teuchos::RCP<bool> localError_;
921 
929  Teuchos::RCP<Teuchos::RCP<std::ostringstream> > errs_;
930 
932  std::ostream& markLocalErrorAndGetStream ();
933 
934  // //! Clear the local error state and stream.
935  // void clearLocalErrorStateAndStream ();
936 
937  template<class Device>
938  struct is_cuda {
939 #if defined(KOKKOS_ENABLE_CUDA)
940  // CudaHostPinnedSpace::execution_space ==
941  // HostSpace::execution_space. That's OK; it's host memory, that
942  // just happens to be Cuda accessible. But what if somebody gives
943  // us Device<Cuda, CudaHostPinnedSpace>? It looks like they mean
944  // to run on device then, so we should sync to device.
945  static constexpr bool value =
946  std::is_same<typename Device::execution_space, Kokkos::Cuda>::value;
947  // Gonna badly fake this here for other execspaces
948 #elif defined(KOKKOS_ENABLE_HIP)
949  static constexpr bool value =
950  std::is_same<typename Device::execution_space, Kokkos::HIP>::value;
951 #elif defined(KOKKOS_ENABLE_SYCL)
952  static constexpr bool value =
953  std::is_same<typename Device::execution_space, Kokkos::Experimental::SYCL>::value;
954 #else
955  static constexpr bool value = false;
956 #endif
957  };
958 
959 public:
960  typename impl_scalar_type_dualview::t_host::const_type
961  getValuesHost() const;
962 
963  typename impl_scalar_type_dualview::t_dev::const_type
964  getValuesDevice() const;
965 
984  typename impl_scalar_type_dualview::t_host
985  getValuesHostNonConst() const;
986 
987  typename impl_scalar_type_dualview::t_dev
988  getValuesDeviceNonConst() const;
989 
991  typename impl_scalar_type_dualview::t_host::const_type
992  getValuesHost (const LO& lclRow) const;
993 
995  typename impl_scalar_type_dualview::t_dev::const_type
996  getValuesDevice (const LO& lclRow) const;
997 
999  typename impl_scalar_type_dualview::t_host
1000  getValuesHostNonConst (const LO& lclRow);
1001 
1003  typename impl_scalar_type_dualview::t_dev
1004  getValuesDeviceNonConst (const LO& lclRow);
1006 
1007 private:
1008 
1018  void
1019  applyBlockTrans (const BlockMultiVector<Scalar, LO, GO, Node>& X,
1021  const Teuchos::ETransp mode,
1022  const Scalar alpha,
1023  const Scalar beta);
1024 
1032  void
1033  applyBlockNoTrans (const BlockMultiVector<Scalar, LO, GO, Node>& X,
1035  const Scalar alpha,
1036  const Scalar beta);
1037 
1045  void
1046  localApplyBlockNoTrans (const BlockMultiVector<Scalar, LO, GO, Node>& X,
1048  const Scalar alpha,
1049  const Scalar beta);
1050 
1090  LO
1091  findRelOffsetOfColumnIndex (const LO localRowIndex,
1092  const LO colIndexToFind,
1093  const LO hint = 0) const;
1094 
1097  LO offsetPerBlock () const;
1098 
1100  getConstLocalBlockFromInput (const impl_scalar_type* val, const size_t pointOffset) const;
1101 
1103  getNonConstLocalBlockFromInput (impl_scalar_type* val, const size_t pointOffset) const;
1104 
1105  little_block_host_type
1106  getNonConstLocalBlockFromInputHost (impl_scalar_type* val, const size_t pointOffset) const;
1107 
1108 
1109 
1110 public:
1111 
1113  virtual Teuchos::RCP<const Teuchos::Comm<int> > getComm() const override;
1114 
1115 
1117  virtual global_size_t getGlobalNumCols() const override;
1118 
1119  virtual size_t getLocalNumCols() const override;
1120 
1121  virtual GO getIndexBase() const override;
1122 
1124  virtual global_size_t getGlobalNumEntries() const override;
1125 
1127  virtual size_t getLocalNumEntries() const override;
1137  virtual size_t getNumEntriesInGlobalRow (GO globalRow) const override;
1138 
1141  virtual size_t getGlobalMaxNumRowEntries () const override;
1142 
1144  virtual bool hasColMap () const override;
1145 
1155  virtual bool isLocallyIndexed () const override;
1156 
1166  virtual bool isGloballyIndexed () const override;
1167 
1169  virtual bool isFillComplete () const override;
1170 
1172  virtual bool supportsRowViews () const override;
1173 
1174 
1176 
1178 
1199  virtual void
1200  getGlobalRowCopy (GO GlobalRow,
1201  nonconst_global_inds_host_view_type &Indices,
1202  nonconst_values_host_view_type &Values,
1203  size_t& NumEntries) const override;
1228  virtual void
1229  getGlobalRowView (GO GlobalRow,
1230  global_inds_host_view_type & indices,
1231  values_host_view_type & values) const override;
1232 
1244  virtual void getLocalDiagCopy (::Tpetra::Vector<Scalar,LO,GO,Node>& diag) const override;
1245 
1247 
1249 
1255  virtual void leftScale (const ::Tpetra::Vector<Scalar, LO, GO, Node>& x) override;
1256 
1262  virtual void rightScale (const ::Tpetra::Vector<Scalar, LO, GO, Node>& x) override;
1263 
1272  virtual typename ::Tpetra::RowMatrix<Scalar, LO, GO, Node>::mag_type
1273  getFrobeniusNorm () const override;
1275 
1276  // Friend declaration for nonmember function.
1277  template<class BlockCrsMatrixType>
1278  friend Teuchos::RCP<BlockCrsMatrixType>
1279  Tpetra::importAndFillCompleteBlockCrsMatrix (const Teuchos::RCP<const BlockCrsMatrixType>& sourceMatrix,
1280  const Import<typename BlockCrsMatrixType::local_ordinal_type,
1281  typename BlockCrsMatrixType::global_ordinal_type,
1282  typename BlockCrsMatrixType::node_type>& importer);
1283  // Friend declaration for nonmember function.
1284  template<class BlockCrsMatrixType>
1285  friend Teuchos::RCP<BlockCrsMatrixType>
1286  Tpetra::exportAndFillCompleteBlockCrsMatrix (const Teuchos::RCP<const BlockCrsMatrixType>& sourceMatrix,
1287  const Export<typename BlockCrsMatrixType::local_ordinal_type,
1288  typename BlockCrsMatrixType::global_ordinal_type,
1289  typename BlockCrsMatrixType::node_type>& exporter);
1290 
1291 };
1292 
1293 template<class BlockCrsMatrixType>
1294 Teuchos::RCP<BlockCrsMatrixType>
1295 importAndFillCompleteBlockCrsMatrix (const Teuchos::RCP<const BlockCrsMatrixType>& sourceMatrix,
1296  const Import<typename BlockCrsMatrixType::local_ordinal_type,
1297  typename BlockCrsMatrixType::global_ordinal_type,
1298  typename BlockCrsMatrixType::node_type>& importer)
1299 {
1300  Teuchos::RCP<BlockCrsMatrixType> destMatrix;
1301  sourceMatrix->importAndFillComplete (destMatrix, importer);
1302  return destMatrix;
1303 }
1304 
1305 
1306 template<class BlockCrsMatrixType>
1307 Teuchos::RCP<BlockCrsMatrixType>
1308 exportAndFillCompleteBlockCrsMatrix (const Teuchos::RCP<const BlockCrsMatrixType>& sourceMatrix,
1309  const Export<typename BlockCrsMatrixType::local_ordinal_type,
1310  typename BlockCrsMatrixType::global_ordinal_type,
1311  typename BlockCrsMatrixType::node_type>& exporter)
1312 {
1313  Teuchos::RCP<BlockCrsMatrixType> destMatrix;
1314  sourceMatrix->exportAndFillComplete (destMatrix, exporter);
1315  return destMatrix;
1316 }
1317 
1318 } // namespace Tpetra
1319 
1320 #endif // TPETRA_BLOCKCRSMATRIX_DECL_HPP
virtual void getLocalRowCopy(LO LocalRow, nonconst_local_inds_host_view_type &Indices, nonconst_values_host_view_type &Values, size_t &NumEntries) const override
Not implemented.
size_t getNumEntriesInLocalRow(const LO localRowInd) const override
Return the number of entries in the given row on the calling process.
Communication plan for data redistribution from a uniquely-owned to a (possibly) multiply-owned distr...
virtual size_t getLocalNumEntries() const override
The local number of stored (structurally nonzero) entries.
virtual global_size_t getGlobalNumCols() const override
The global number of columns of this matrix.
::Tpetra::MultiVector< Scalar, LO, GO, node_type > mv_type
The implementation of MultiVector that this class uses.
Kokkos::View< const impl_scalar_type *, device_type > const_little_vec_type
&quot;Const block view&quot; of all degrees of freedom at a mesh point, for a single column of the MultiVector...
typename BMV::impl_scalar_type impl_scalar_type
The implementation type of entries in the matrix.
KokkosSparse::StaticCrsGraph< local_ordinal_type, Kokkos::LayoutLeft, device_type, void, size_t > local_graph_device_type
The type of the part of the sparse graph on each MPI process.
void getLocalDiagCopy(const Kokkos::View< impl_scalar_type ***, device_type, Kokkos::MemoryUnmanaged > &diag, const Kokkos::View< const size_t *, device_type, Kokkos::MemoryUnmanaged > &offsets) const
Variant of getLocalDiagCopy() that uses precomputed offsets and puts diagonal blocks in a 3-D Kokkos:...
void describe(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel) const override
Print a description of this object to the given output stream.
Kokkos::View< impl_scalar_type **, Impl::BlockCrsMatrixLittleBlockArrayLayout, device_type, Kokkos::MemoryTraits< Kokkos::Unmanaged > > little_block_type
The type used to access nonconst matrix blocks.
virtual typename::Tpetra::RowMatrix< Scalar, LO, GO, Node >::mag_type getFrobeniusNorm() const override
The Frobenius norm of the matrix.
LO replaceLocalValues(const LO localRowInd, const LO colInds[], const Scalar vals[], const LO numColInds) const
Replace values at the given (mesh, i.e., block) column indices, in the given (mesh, i.e., block) row.
virtual void leftScale(const ::Tpetra::Vector< Scalar, LO, GO, Node > &x) override
Scale the RowMatrix on the left with the given Vector x.
virtual LO getBlockSize() const override
The number of degrees of freedom per mesh point.
LO replaceLocalValuesByOffsets(const LO localRowInd, const ptrdiff_t offsets[], const Scalar vals[], const LO numOffsets) const
Like replaceLocalValues, but avoids computing row offsets.
std::string description() const override
One-line description of this object.
Sparse matrix whose entries are small dense square blocks, all of the same dimensions.
typename DistObject< Scalar, LO, GO, Node >::buffer_device_type buffer_device_type
Kokkos::Device specialization for communication buffers.
void exportAndFillComplete(Teuchos::RCP< BlockCrsMatrix< Scalar, LO, GO, Node > > &destMatrix, const Export< LO, GO, Node > &exporter) const
Import from this to the given destination matrix, and make the result fill complete.
virtual bool hasColMap() const override
Whether this matrix has a well-defined column Map.
virtual void copyAndPermute(const SrcDistObject &source, const size_t numSameIDs, const Kokkos::DualView< const local_ordinal_type *, buffer_device_type > &permuteToLIDs, const Kokkos::DualView< const local_ordinal_type *, buffer_device_type > &permuteFromLIDs, const CombineMode CM)
Perform copies and permutations that are local to the calling (MPI) process.
virtual bool isLocallyIndexed() const override
Whether matrix indices are locally indexed.
bool hasTransposeApply() const override
Whether it is valid to apply the transpose or conjugate transpose of this matrix. ...
LO local_ordinal_type
The type of local indices.
void getLocalRowViewNonConst(LO LocalRow, local_inds_host_view_type &indices, nonconst_values_host_view_type &values) const
::Tpetra::CrsGraph< LO, GO, node_type > crs_graph_type
The implementation of CrsGraph that this class uses.
Kokkos::View< impl_scalar_type *, device_type > little_vec_type
&quot;Block view&quot; of all degrees of freedom at a mesh point, for a single column of the MultiVector...
void setAllToScalar(const Scalar &alpha)
Set all matrix entries equal to alpha.
bool localError() const
Whether this object had an error on the calling process.
Declaration of the Tpetra::CrsMatrix class.
Scalar scalar_type
The type of entries in the matrix (that is, of each entry in each block).
size_t getLocalNumRows() const override
get the local number of block rows
virtual void unpackAndCombine(const Kokkos::DualView< const local_ordinal_type *, buffer_device_type > &importLIDs, Kokkos::DualView< packet_type *, buffer_device_type > imports, Kokkos::DualView< size_t *, buffer_device_type > numPacketsPerLID, const size_t constantNumPackets, const CombineMode combineMode)
Perform any unpacking and combining after communication.
virtual Teuchos::RCP< const Teuchos::Comm< int > > getComm() const override
The communicator over which this matrix is distributed.
Kokkos::LayoutRight BlockCrsMatrixLittleBlockArrayLayout
give an option to use layoutleft
virtual void rightScale(const ::Tpetra::Vector< Scalar, LO, GO, Node > &x) override
Scale the RowMatrix on the right with the given Vector x.
::Tpetra::Map< LO, GO, node_type > map_type
The implementation of Map that this class uses.
void getLocalRowView(LO LocalRow, local_inds_host_view_type &indices, values_host_view_type &values) const override
Get a view of the (mesh, i.e., block) row, using local (mesh, i.e., block) indices.
virtual ~BlockCrsMatrix()
Destructor (declared virtual for memory safety).
MultiVector for multiple degrees of freedom per mesh point.
virtual void copyAndPermute(const SrcDistObject &sourceObj, const size_t numSameIDs, const Kokkos::DualView< const local_ordinal_type *, buffer_device_type > &permuteToLIDs, const Kokkos::DualView< const local_ordinal_type *, buffer_device_type > &permuteFromLIDs, const CombineMode CM) override
Teuchos::RCP< const map_type > getColMap() const override
get the (mesh) map for the columns of this block matrix.
GO global_ordinal_type
The type of global indices.
virtual size_t getGlobalMaxNumRowEntries() const override
The maximum number of entries in any row over all processes in the matrix&#39;s communicator.
size_t global_size_t
Global size_t object.
virtual void getGlobalRowView(GO GlobalRow, global_inds_host_view_type &indices, values_host_view_type &values) const override
Get a constant, nonpersisting, globally indexed view of the given row of the matrix.
BlockCrsMatrix()
Default constructor: Makes an empty block matrix.
LO absMaxLocalValues(const LO localRowInd, const LO colInds[], const Scalar vals[], const LO numColInds) const
Variant of getLocalDiagCopy() that uses precomputed offsets and puts diagonal blocks in a 3-D Kokkos:...
Teuchos::RCP< const map_type > getDomainMap() const override
Get the (point) domain Map of this matrix.
device_type::memory_space memory_space
The Kokkos memory space that this class uses.
Teuchos::RCP< const map_type > getRowMap() const override
get the (mesh) map for the rows of this block matrix.
std::string errorMessages() const
The current stream of error messages.
LO sumIntoLocalValuesByOffsets(const LO localRowInd, const ptrdiff_t offsets[], const Scalar vals[], const LO numOffsets) const
Like sumIntoLocalValues, but avoids computing row offsets.
global_size_t getGlobalNumRows() const override
get the global number of block rows
BMV::const_little_vec_type const_little_vec_type
The type used to access const vector blocks.
Communication plan for data redistribution from a (possibly) multiply-owned to a uniquely-owned distr...
virtual Teuchos::RCP< const ::Tpetra::RowGraph< LO, GO, Node > > getGraph() const override
Get the (mesh) graph.
virtual GO getIndexBase() const override
The index base for global indices in this matrix.
virtual void packAndPrepare(const SrcDistObject &source, const Kokkos::DualView< const local_ordinal_type *, buffer_device_type > &exportLIDs, Kokkos::DualView< packet_type *, buffer_device_type > &exports, Kokkos::DualView< size_t *, buffer_device_type > numPacketsPerLID, size_t &constantNumPackets)
Pack data and metadata for communication (sends).
Kokkos::View< const impl_scalar_type **, Impl::BlockCrsMatrixLittleBlockArrayLayout, device_type, Kokkos::MemoryTraits< Kokkos::Unmanaged > > const_little_block_type
The type used to access const matrix blocks.
void applyBlock(const BlockMultiVector< Scalar, LO, GO, Node > &X, BlockMultiVector< Scalar, LO, GO, Node > &Y, Teuchos::ETransp mode=Teuchos::NO_TRANS, const Scalar alpha=Teuchos::ScalarTraits< Scalar >::one(), const Scalar beta=Teuchos::ScalarTraits< Scalar >::zero())
Version of apply() that takes BlockMultiVector input and output.
CombineMode
Rule for combining data in an Import or Export.
virtual bool isGloballyIndexed() const override
Whether matrix indices are globally indexed.
LO getLocalRowOffsets(const LO localRowInd, ptrdiff_t offsets[], const LO colInds[], const LO numColInds) const
Get relative offsets corresponding to the given rows, given by local row index.
size_t getLocalMaxNumRowEntries() const override
Maximum number of entries in any row of the matrix, on this process.
virtual global_size_t getGlobalNumEntries() const override
The global number of stored (structurally nonzero) entries.
void apply(const mv_type &X, mv_type &Y, Teuchos::ETransp mode=Teuchos::NO_TRANS, Scalar alpha=Teuchos::ScalarTraits< Scalar >::one(), Scalar beta=Teuchos::ScalarTraits< Scalar >::zero()) const override
For this matrix A, compute Y := beta * Y + alpha * Op(A) * X.
Abstract base class for objects that can be the source of an Import or Export operation.
device_type::execution_space execution_space
The Kokkos execution space that this class uses.
Teuchos::RCP< const map_type > getRangeMap() const override
Get the (point) range Map of this matrix.
void getLocalDiagOffsets(const Kokkos::View< size_t *, device_type, Kokkos::MemoryUnmanaged > &offsets) const
Get offsets of the diagonal entries in the matrix.
char packet_type
Implementation detail; tells.
local_matrix_device_type getLocalMatrixDevice() const
A read-only, row-oriented interface to a sparse matrix.
A distributed dense vector.
virtual bool supportsRowViews() const override
Whether this object implements getLocalRowView() and getGlobalRowView().
virtual void packAndPrepare(const SrcDistObject &sourceObj, const Kokkos::DualView< const local_ordinal_type *, buffer_device_type > &exportLIDs, Kokkos::DualView< packet_type *, buffer_device_type > &exports, Kokkos::DualView< size_t *, buffer_device_type > numPacketsPerLID, size_t &constantNumPackets) override
BMV::little_vec_type little_vec_type
The type used to access nonconst vector blocks.
virtual void unpackAndCombine(const Kokkos::DualView< const local_ordinal_type *, buffer_device_type > &importLIDs, Kokkos::DualView< packet_type *, buffer_device_type > imports, Kokkos::DualView< size_t *, buffer_device_type > numPacketsPerLID, const size_t constantNumPackets, const CombineMode combineMode) override
virtual void getGlobalRowCopy(GO GlobalRow, nonconst_global_inds_host_view_type &Indices, nonconst_values_host_view_type &Values, size_t &NumEntries) const override
Get a copy of the given global row&#39;s entries.
Node::device_type device_type
The Kokkos::Device specialization that this class uses.
virtual bool isFillComplete() const override
Whether fillComplete() has been called.
impl_scalar_type_dualview::t_host getValuesHostNonConst() const
Get the host or device View of the matrix&#39;s values (val_).
Base class for distributed Tpetra objects that support data redistribution.
typename mv_type::impl_scalar_type impl_scalar_type
The implementation type of entries in the object.
LO sumIntoLocalValues(const LO localRowInd, const LO colInds[], const Scalar vals[], const LO numColInds) const
Sum into values at the given (mesh, i.e., block) column indices, in the given (mesh, i.e., block) row.
virtual size_t getLocalNumCols() const override
The number of columns needed to apply the forward operator on this node.
void importAndFillComplete(Teuchos::RCP< BlockCrsMatrix< Scalar, LO, GO, Node > > &destMatrix, const Import< LO, GO, Node > &importer) const
Import from this to the given destination matrix, and make the result fill complete.
virtual size_t getNumEntriesInGlobalRow(GO globalRow) const override
The current number of entries on the calling process in the specified global row. ...