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 //
4 // Tpetra: Templated Linear Algebra Services Package
5 // Copyright (2008) Sandia Corporation
6 //
7 // Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
8 // the U.S. Government retains certain rights in this software.
9 //
10 // Redistribution and use in source and binary forms, with or without
11 // modification, are permitted provided that the following conditions are
12 // met:
13 //
14 // 1. Redistributions of source code must retain the above copyright
15 // notice, this list of conditions and the following disclaimer.
16 //
17 // 2. Redistributions in binary form must reproduce the above copyright
18 // notice, this list of conditions and the following disclaimer in the
19 // documentation and/or other materials provided with the distribution.
20 //
21 // 3. Neither the name of the Corporation nor the names of the
22 // contributors may be used to endorse or promote products derived from
23 // this software without specific prior written permission.
24 //
25 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
26 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
29 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
30 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
31 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
32 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
33 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
34 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
35 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36 //
37 // ************************************************************************
38 // @HEADER
39 
40 // clang-format off
41 #ifndef TPETRA_BLOCKCRSMATRIX_DECL_HPP
42 #define TPETRA_BLOCKCRSMATRIX_DECL_HPP
43 
46 
47 #include "Tpetra_CrsGraph.hpp"
48 #include "Tpetra_RowMatrix.hpp"
49 #include "Tpetra_BlockMultiVector_decl.hpp"
51 
52 #include "KokkosSparse_BsrMatrix.hpp"
53 
54 namespace Tpetra {
55 
56 template<class BlockCrsMatrixType>
57 Teuchos::RCP<BlockCrsMatrixType>
58 importAndFillCompleteBlockCrsMatrix (const Teuchos::RCP<const BlockCrsMatrixType>& sourceMatrix,
59  const Import<typename BlockCrsMatrixType::local_ordinal_type,
60  typename BlockCrsMatrixType::global_ordinal_type,
61  typename BlockCrsMatrixType::node_type>& importer);
62 template<class BlockCrsMatrixType>
63 Teuchos::RCP<BlockCrsMatrixType>
64 exportAndFillCompleteBlockCrsMatrix (const Teuchos::RCP<const BlockCrsMatrixType>& sourceMatrix,
65  const Export<typename BlockCrsMatrixType::local_ordinal_type,
66  typename BlockCrsMatrixType::global_ordinal_type,
67  typename BlockCrsMatrixType::node_type>& exporter);
68 
146 
147 namespace Impl {
149 #if defined(TPETRA_ENABLE_BLOCKCRS_LITTLEBLOCK_LAYOUTLEFT)
150  using BlockCrsMatrixLittleBlockArrayLayout = Kokkos::LayoutLeft;
151 #else
152  using BlockCrsMatrixLittleBlockArrayLayout = Kokkos::LayoutRight;
153 #endif
154 }
155 
156 template<class Scalar,
157  class LO,
158  class GO,
159  class Node>
161  virtual public ::Tpetra::RowMatrix<Scalar, LO, GO, Node>,
162  virtual public ::Tpetra::DistObject<char, LO, GO, Node>
163 {
164 private:
167  using STS = Teuchos::ScalarTraits<Scalar>;
168 
169 protected:
171  typedef char packet_type;
172 
173 public:
175 
176 
178  using scalar_type = Scalar;
179 
187 
189  typedef LO local_ordinal_type;
196  typedef Node node_type;
197 
199  typedef typename Node::device_type device_type;
201  typedef typename device_type::execution_space execution_space;
203  typedef typename device_type::memory_space memory_space;
204 
206  typedef ::Tpetra::Map<LO, GO, node_type> map_type;
208  typedef ::Tpetra::MultiVector<Scalar, LO, GO, node_type> mv_type;
210  typedef ::Tpetra::CrsGraph<LO, GO, node_type> crs_graph_type;
211 
213  typedef Kokkos::View<impl_scalar_type**,
215  device_type,
216  Kokkos::MemoryTraits<Kokkos::Unmanaged> >
218  typedef typename little_block_type::HostMirror little_block_host_type;
219 
221  typedef Kokkos::View<const impl_scalar_type**,
223  device_type,
224  Kokkos::MemoryTraits<Kokkos::Unmanaged> >
228  typedef typename BMV::little_host_vec_type little_host_vec_type;
229 
232  typedef typename BMV::const_little_host_vec_type const_host_little_vec_type;
233 
235  using local_inds_device_view_type =
236  typename row_matrix_type::local_inds_device_view_type;
237  using local_inds_host_view_type =
238  typename row_matrix_type::local_inds_host_view_type;
239  using nonconst_local_inds_host_view_type =
240  typename row_matrix_type::nonconst_local_inds_host_view_type;
241 
242  using global_inds_device_view_type =
243  typename row_matrix_type::global_inds_device_view_type;
244  using global_inds_host_view_type =
245  typename row_matrix_type::global_inds_host_view_type;
246  using nonconst_global_inds_host_view_type =
247  typename row_matrix_type::nonconst_global_inds_host_view_type;
248 
249  using values_device_view_type =
250  typename row_matrix_type::values_device_view_type;
251  using values_host_view_type =
252  typename row_matrix_type::values_host_view_type;
253  using nonconst_values_host_view_type =
254  typename row_matrix_type::nonconst_values_host_view_type;
255 
256  using local_graph_device_type = typename crs_graph_type::local_graph_device_type;
257 
258  using local_matrix_device_type =
259  KokkosSparse::Experimental::BsrMatrix<impl_scalar_type,
261  device_type,
262  void,
263  typename local_graph_device_type::size_type>;
264  using local_matrix_host_type =
265  typename local_matrix_device_type::HostMirror;
266 
268 
270 
272  BlockCrsMatrix ();
273 
283  BlockCrsMatrix (const crs_graph_type& graph, const LO blockSize);
284 
285  BlockCrsMatrix (const crs_graph_type& graph,
286  const typename local_matrix_device_type::values_type& values,
287  const LO blockSize);
288 
296  BlockCrsMatrix (const crs_graph_type& graph,
297  const map_type& domainPointMap,
298  const map_type& rangePointMap,
299  const LO blockSize);
300 
302  virtual ~BlockCrsMatrix () {}
303 
305 
307 
309  Teuchos::RCP<const map_type> getDomainMap () const override;
310 
312  Teuchos::RCP<const map_type> getRangeMap () const override;
313 
315  Teuchos::RCP<const map_type> getRowMap () const override;
316 
318  Teuchos::RCP<const map_type> getColMap () const override;
319 
321  global_size_t getGlobalNumRows() const override;
322 
324  size_t getLocalNumRows() const override;
325 
326  size_t getLocalMaxNumRowEntries() const override;
327 
337  void
338  apply (const mv_type& X,
339  mv_type& Y,
340  Teuchos::ETransp mode = Teuchos::NO_TRANS,
341  Scalar alpha = Teuchos::ScalarTraits<Scalar>::one (),
342  Scalar beta = Teuchos::ScalarTraits<Scalar>::zero ()) const override;
343 
346  bool hasTransposeApply () const override {
347  // FIXME (mfh 04 May 2014) Transpose and conjugate transpose modes
348  // are not implemented yet. Fill in applyBlockTrans() to fix this.
349  return false;
350  }
351 
353  void setAllToScalar (const Scalar& alpha);
354 
356 
358 
360  std::string description () const override;
361 
385  void
386  describe (Teuchos::FancyOStream& out,
387  const Teuchos::EVerbosityLevel verbLevel) const override;
388 
390 
392 
394  virtual LO getBlockSize () const override { return blockSize_; }
395 
397  virtual Teuchos::RCP<const ::Tpetra::RowGraph<LO,GO,Node> > getGraph () const override;
398 
399  const crs_graph_type & getCrsGraph () const { return graph_; }
400 
405  void
406  applyBlock (const BlockMultiVector<Scalar, LO, GO, Node>& X,
407  BlockMultiVector<Scalar, LO, GO, Node>& Y,
408  Teuchos::ETransp mode = Teuchos::NO_TRANS,
409  const Scalar alpha = Teuchos::ScalarTraits<Scalar>::one (),
410  const Scalar beta = Teuchos::ScalarTraits<Scalar>::zero ());
411 
414  void
415  importAndFillComplete (Teuchos::RCP<BlockCrsMatrix<Scalar, LO, GO, Node> >& destMatrix,
416  const Import<LO, GO, Node>& importer) const;
417 
420  void
421  exportAndFillComplete (Teuchos::RCP<BlockCrsMatrix<Scalar, LO, GO, Node> >& destMatrix,
422  const Export<LO, GO, Node>& exporter) const;
423 
424 
451  LO
452  replaceLocalValues (const LO localRowInd,
453  const LO colInds[],
454  const Scalar vals[],
455  const LO numColInds) const;
456 
483  LO
484  sumIntoLocalValues (const LO localRowInd,
485  const LO colInds[],
486  const Scalar vals[],
487  const LO numColInds) const;
488 
489 
522  void
523  getLocalRowView (LO LocalRow,
524  local_inds_host_view_type &indices,
525  values_host_view_type &values) const override;
526 
529  void
530  getLocalRowViewNonConst (LO LocalRow,
531  local_inds_host_view_type &indices,
532  nonconst_values_host_view_type &values) const;
533 
535  virtual void
536  getLocalRowCopy (LO LocalRow,
537  nonconst_local_inds_host_view_type &Indices,
538  nonconst_values_host_view_type &Values,
539  size_t& NumEntries) const override;
541  getLocalBlockDeviceNonConst (const LO localRowInd, const LO localColInd) const;
542 
543  little_block_host_type
544  getLocalBlockHostNonConst (const LO localRowInd, const LO localColInd) const;
545 
546 
570  LO
571  getLocalRowOffsets (const LO localRowInd,
572  ptrdiff_t offsets[],
573  const LO colInds[],
574  const LO numColInds) const;
575 
581  LO
582  replaceLocalValuesByOffsets (const LO localRowInd,
583  const ptrdiff_t offsets[],
584  const Scalar vals[],
585  const LO numOffsets) const;
586 
587  LO
588  absMaxLocalValuesByOffsets (const LO localRowInd,
589  const ptrdiff_t offsets[],
590  const Scalar vals[],
591  const LO numOffsets) const;
592 
598  LO
599  sumIntoLocalValuesByOffsets (const LO localRowInd,
600  const ptrdiff_t offsets[],
601  const Scalar vals[],
602  const LO numOffsets) const;
603 
610  size_t getNumEntriesInLocalRow (const LO localRowInd) const override;
611 
612 
615  local_matrix_device_type getLocalMatrixDevice () const;
616 
633  bool localError () const {
634  return *localError_;
635  }
636 
651  std::string errorMessages () const {
652  return (*errs_).is_null () ? std::string ("") : (*errs_)->str ();
653  }
654 
686  void
687  getLocalDiagOffsets (const Kokkos::View<size_t*, device_type,
688  Kokkos::MemoryUnmanaged>& offsets) const;
689 
690 
704  void
705  getLocalDiagCopy (const Kokkos::View<impl_scalar_type***, device_type,
706  Kokkos::MemoryUnmanaged>& diag,
707  const Kokkos::View<const size_t*, device_type,
708  Kokkos::MemoryUnmanaged>& offsets) const;
709 
723 protected:
725  LO
726  absMaxLocalValues (const LO localRowInd,
727  const LO colInds[],
728  const Scalar vals[],
729  const LO numColInds) const;
730 
736 
737 
742  using buffer_device_type = typename DistObject<Scalar, LO, GO,
744 
745  virtual bool checkSizes (const ::Tpetra::SrcDistObject& source) override;
746 
747  // clang-format on
748  using dist_object_type::
750  // clang-format off
752 
753  virtual void
755  (const SrcDistObject& sourceObj,
756  const size_t numSameIDs,
757  const Kokkos::DualView<const local_ordinal_type*,
758  buffer_device_type>& permuteToLIDs,
759  const Kokkos::DualView<const local_ordinal_type*,
760  buffer_device_type>& permuteFromLIDs,
761  const CombineMode CM) override;
762 
763  // clang-format on
765  // clang-format off
769 
770  virtual void
772  (const SrcDistObject& sourceObj,
773  const Kokkos::DualView<const local_ordinal_type*,
774  buffer_device_type>& exportLIDs,
775  Kokkos::DualView<packet_type*,
776  buffer_device_type>& exports,
777  Kokkos::DualView<size_t*,
778  buffer_device_type> numPacketsPerLID,
779  size_t& constantNumPackets) override;
780 
781  // clang-format on
783  // clang-format off
787 
788  virtual void
790  (const Kokkos::DualView<const local_ordinal_type*,
791  buffer_device_type>& importLIDs,
792  Kokkos::DualView<packet_type*,
793  buffer_device_type> imports,
794  Kokkos::DualView<size_t*,
795  buffer_device_type> numPacketsPerLID,
796  const size_t constantNumPackets,
797  const CombineMode combineMode) override;
799 
800 private:
802  crs_graph_type graph_;
803  Teuchos::RCP<crs_graph_type> graphRCP_;
812  map_type rowMeshMap_;
819  map_type domainPointMap_;
826  map_type rangePointMap_;
828  LO blockSize_;
829 
843  using graph_row_offset_host_type = typename crs_graph_type::local_graph_device_type::row_map_type::HostMirror;
844  graph_row_offset_host_type ptrHost_;
845 
851  using graph_column_indices_host_type = typename crs_graph_type::local_graph_device_type::entries_type::HostMirror;
852  graph_column_indices_host_type indHost_;
853 
859  using impl_scalar_type_dualview = Kokkos::DualView<impl_scalar_type*, device_type>;
862 
884  Teuchos::RCP<Teuchos::RCP<BMV> > X_colMap_;
888  Teuchos::RCP<Teuchos::RCP<BMV> > Y_rowMap_;
889 
897  Teuchos::RCP<Teuchos::RCP<typename crs_graph_type::import_type> > pointImporter_;
898 
900  LO offsetPerBlock_;
901 
913  Teuchos::RCP<bool> localError_;
914 
922  Teuchos::RCP<Teuchos::RCP<std::ostringstream> > errs_;
923 
925  std::ostream& markLocalErrorAndGetStream ();
926 
927  // //! Clear the local error state and stream.
928  // void clearLocalErrorStateAndStream ();
929 
930  template<class Device>
931  struct is_cuda {
932 #if defined(KOKKOS_ENABLE_CUDA)
933  // CudaHostPinnedSpace::execution_space ==
934  // HostSpace::execution_space. That's OK; it's host memory, that
935  // just happens to be Cuda accessible. But what if somebody gives
936  // us Device<Cuda, CudaHostPinnedSpace>? It looks like they mean
937  // to run on device then, so we should sync to device.
938  static constexpr bool value =
939  std::is_same<typename Device::execution_space, Kokkos::Cuda>::value;
940  // Gonna badly fake this here for other execspaces
941 #elif defined(KOKKOS_ENABLE_HIP)
942  static constexpr bool value =
943  std::is_same<typename Device::execution_space, Kokkos::HIP>::value;
944 #elif defined(KOKKOS_ENABLE_SYCL)
945  static constexpr bool value =
946  std::is_same<typename Device::execution_space, Kokkos::Experimental::SYCL>::value;
947 #else
948  static constexpr bool value = false;
949 #endif
950  };
951 
952 public:
953  typename impl_scalar_type_dualview::t_host::const_type
954  getValuesHost() const;
955 
956  typename impl_scalar_type_dualview::t_dev::const_type
957  getValuesDevice() const;
958 
977  typename impl_scalar_type_dualview::t_host
978  getValuesHostNonConst() const;
979 
980  typename impl_scalar_type_dualview::t_dev
981  getValuesDeviceNonConst() const;
982 
984  typename impl_scalar_type_dualview::t_host::const_type
985  getValuesHost (const LO& lclRow) const;
986 
988  typename impl_scalar_type_dualview::t_dev::const_type
989  getValuesDevice (const LO& lclRow) const;
990 
992  typename impl_scalar_type_dualview::t_host
993  getValuesHostNonConst (const LO& lclRow);
994 
996  typename impl_scalar_type_dualview::t_dev
997  getValuesDeviceNonConst (const LO& lclRow);
999 
1000 private:
1001 
1011  void
1012  applyBlockTrans (const BlockMultiVector<Scalar, LO, GO, Node>& X,
1014  const Teuchos::ETransp mode,
1015  const Scalar alpha,
1016  const Scalar beta);
1017 
1025  void
1026  applyBlockNoTrans (const BlockMultiVector<Scalar, LO, GO, Node>& X,
1028  const Scalar alpha,
1029  const Scalar beta);
1030 
1038  void
1039  localApplyBlockNoTrans (const BlockMultiVector<Scalar, LO, GO, Node>& X,
1041  const Scalar alpha,
1042  const Scalar beta);
1043 
1083  LO
1084  findRelOffsetOfColumnIndex (const LO localRowIndex,
1085  const LO colIndexToFind,
1086  const LO hint = 0) const;
1087 
1090  LO offsetPerBlock () const;
1091 
1093  getConstLocalBlockFromInput (const impl_scalar_type* val, const size_t pointOffset) const;
1094 
1096  getNonConstLocalBlockFromInput (impl_scalar_type* val, const size_t pointOffset) const;
1097 
1098  little_block_host_type
1099  getNonConstLocalBlockFromInputHost (impl_scalar_type* val, const size_t pointOffset) const;
1100 
1101 
1102 
1103 public:
1104 
1106  virtual Teuchos::RCP<const Teuchos::Comm<int> > getComm() const override;
1107 
1108 
1110  virtual global_size_t getGlobalNumCols() const override;
1111 
1112  virtual size_t getLocalNumCols() const override;
1113 
1114  virtual GO getIndexBase() const override;
1115 
1117  virtual global_size_t getGlobalNumEntries() const override;
1118 
1120  virtual size_t getLocalNumEntries() const override;
1130  virtual size_t getNumEntriesInGlobalRow (GO globalRow) const override;
1131 
1134  virtual size_t getGlobalMaxNumRowEntries () const override;
1135 
1137  virtual bool hasColMap () const override;
1138 
1148  virtual bool isLocallyIndexed () const override;
1149 
1159  virtual bool isGloballyIndexed () const override;
1160 
1162  virtual bool isFillComplete () const override;
1163 
1165  virtual bool supportsRowViews () const override;
1166 
1167 
1169 
1171 
1192  virtual void
1193  getGlobalRowCopy (GO GlobalRow,
1194  nonconst_global_inds_host_view_type &Indices,
1195  nonconst_values_host_view_type &Values,
1196  size_t& NumEntries) const override;
1221  virtual void
1222  getGlobalRowView (GO GlobalRow,
1223  global_inds_host_view_type & indices,
1224  values_host_view_type & values) const override;
1225 
1237  virtual void getLocalDiagCopy (::Tpetra::Vector<Scalar,LO,GO,Node>& diag) const override;
1238 
1240 
1242 
1248  virtual void leftScale (const ::Tpetra::Vector<Scalar, LO, GO, Node>& x) override;
1249 
1255  virtual void rightScale (const ::Tpetra::Vector<Scalar, LO, GO, Node>& x) override;
1256 
1265  virtual typename ::Tpetra::RowMatrix<Scalar, LO, GO, Node>::mag_type
1266  getFrobeniusNorm () const override;
1268 
1269  // Friend declaration for nonmember function.
1270  template<class BlockCrsMatrixType>
1271  friend Teuchos::RCP<BlockCrsMatrixType>
1272  Tpetra::importAndFillCompleteBlockCrsMatrix (const Teuchos::RCP<const BlockCrsMatrixType>& sourceMatrix,
1273  const Import<typename BlockCrsMatrixType::local_ordinal_type,
1274  typename BlockCrsMatrixType::global_ordinal_type,
1275  typename BlockCrsMatrixType::node_type>& importer);
1276  // Friend declaration for nonmember function.
1277  template<class BlockCrsMatrixType>
1278  friend Teuchos::RCP<BlockCrsMatrixType>
1279  Tpetra::exportAndFillCompleteBlockCrsMatrix (const Teuchos::RCP<const BlockCrsMatrixType>& sourceMatrix,
1280  const Export<typename BlockCrsMatrixType::local_ordinal_type,
1281  typename BlockCrsMatrixType::global_ordinal_type,
1282  typename BlockCrsMatrixType::node_type>& exporter);
1283 
1284 };
1285 
1286 template<class BlockCrsMatrixType>
1287 Teuchos::RCP<BlockCrsMatrixType>
1288 importAndFillCompleteBlockCrsMatrix (const Teuchos::RCP<const BlockCrsMatrixType>& sourceMatrix,
1289  const Import<typename BlockCrsMatrixType::local_ordinal_type,
1290  typename BlockCrsMatrixType::global_ordinal_type,
1291  typename BlockCrsMatrixType::node_type>& importer)
1292 {
1293  Teuchos::RCP<BlockCrsMatrixType> destMatrix;
1294  sourceMatrix->importAndFillComplete (destMatrix, importer);
1295  return destMatrix;
1296 }
1297 
1298 
1299 template<class BlockCrsMatrixType>
1300 Teuchos::RCP<BlockCrsMatrixType>
1301 exportAndFillCompleteBlockCrsMatrix (const Teuchos::RCP<const BlockCrsMatrixType>& sourceMatrix,
1302  const Export<typename BlockCrsMatrixType::local_ordinal_type,
1303  typename BlockCrsMatrixType::global_ordinal_type,
1304  typename BlockCrsMatrixType::node_type>& exporter)
1305 {
1306  Teuchos::RCP<BlockCrsMatrixType> destMatrix;
1307  sourceMatrix->exportAndFillComplete (destMatrix, exporter);
1308  return destMatrix;
1309 }
1310 
1311 } // namespace Tpetra
1312 
1313 #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.
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.
Kokkos::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.
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. ...