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 #if KOKKOSKERNELS_VERSION >= 40299
55 #include "Tpetra_Details_MatrixApplyHelper.hpp"
56 #endif
57 
58 namespace Tpetra {
59 
60 template<class BlockCrsMatrixType>
61 Teuchos::RCP<BlockCrsMatrixType>
62 importAndFillCompleteBlockCrsMatrix (const Teuchos::RCP<const BlockCrsMatrixType>& sourceMatrix,
63  const Import<typename BlockCrsMatrixType::local_ordinal_type,
64  typename BlockCrsMatrixType::global_ordinal_type,
65  typename BlockCrsMatrixType::node_type>& importer);
66 template<class BlockCrsMatrixType>
67 Teuchos::RCP<BlockCrsMatrixType>
68 exportAndFillCompleteBlockCrsMatrix (const Teuchos::RCP<const BlockCrsMatrixType>& sourceMatrix,
69  const Export<typename BlockCrsMatrixType::local_ordinal_type,
70  typename BlockCrsMatrixType::global_ordinal_type,
71  typename BlockCrsMatrixType::node_type>& exporter);
72 
150 
151 namespace Impl {
153 #if defined(TPETRA_ENABLE_BLOCKCRS_LITTLEBLOCK_LAYOUTLEFT)
154  using BlockCrsMatrixLittleBlockArrayLayout = Kokkos::LayoutLeft;
155 #else
156  using BlockCrsMatrixLittleBlockArrayLayout = Kokkos::LayoutRight;
157 #endif
158 }
159 
160 template<class Scalar,
161  class LO,
162  class GO,
163  class Node>
165  virtual public ::Tpetra::RowMatrix<Scalar, LO, GO, Node>,
166  virtual public ::Tpetra::DistObject<char, LO, GO, Node>
167 {
168 private:
171  using STS = Teuchos::ScalarTraits<Scalar>;
172 
173 protected:
175  typedef char packet_type;
176 
177 public:
179 
180 
182  using scalar_type = Scalar;
183 
191 
193  typedef LO local_ordinal_type;
200  typedef Node node_type;
201 
203  typedef typename Node::device_type device_type;
205  typedef typename device_type::execution_space execution_space;
207  typedef typename device_type::memory_space memory_space;
208 
210  typedef ::Tpetra::Map<LO, GO, node_type> map_type;
212  typedef ::Tpetra::MultiVector<Scalar, LO, GO, node_type> mv_type;
214  typedef ::Tpetra::CrsGraph<LO, GO, node_type> crs_graph_type;
215 
217  typedef Kokkos::View<impl_scalar_type**,
219  device_type,
220  Kokkos::MemoryTraits<Kokkos::Unmanaged> >
222  typedef typename little_block_type::HostMirror little_block_host_type;
223 
225  typedef Kokkos::View<const impl_scalar_type**,
227  device_type,
228  Kokkos::MemoryTraits<Kokkos::Unmanaged> >
232  typedef typename BMV::little_host_vec_type little_host_vec_type;
233 
236  typedef typename BMV::const_little_host_vec_type const_host_little_vec_type;
237 
239  using local_inds_device_view_type =
240  typename row_matrix_type::local_inds_device_view_type;
241  using local_inds_host_view_type =
242  typename row_matrix_type::local_inds_host_view_type;
243  using nonconst_local_inds_host_view_type =
244  typename row_matrix_type::nonconst_local_inds_host_view_type;
245 
246  using global_inds_device_view_type =
247  typename row_matrix_type::global_inds_device_view_type;
248  using global_inds_host_view_type =
249  typename row_matrix_type::global_inds_host_view_type;
250  using nonconst_global_inds_host_view_type =
251  typename row_matrix_type::nonconst_global_inds_host_view_type;
252 
253  using values_device_view_type =
254  typename row_matrix_type::values_device_view_type;
255  using values_host_view_type =
256  typename row_matrix_type::values_host_view_type;
257  using nonconst_values_host_view_type =
258  typename row_matrix_type::nonconst_values_host_view_type;
259 
260  using local_graph_device_type = typename crs_graph_type::local_graph_device_type;
261 
262  using local_matrix_device_type =
263  KokkosSparse::Experimental::BsrMatrix<impl_scalar_type,
265  device_type,
266  void,
267  typename local_graph_device_type::size_type>;
268 
269 #if KOKKOSKERNELS_VERSION >= 40299
270 private:
271  // TODO: When KokkosKernels 4.4 is released, local_matrix_device_type can be permanently modified to use the default_size_type
272  // 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).
273  using local_matrix_int_rowptrs_device_type =
274  KokkosSparse::Experimental::BsrMatrix<impl_scalar_type,
276  device_type,
277  void,
278  int>;
279 
281  using ApplyHelper = Details::MatrixApplyHelper<
282  local_matrix_device_type,
283  local_matrix_int_rowptrs_device_type,
284  typename mv_type::device_view_type>;
285 
293  mutable std::shared_ptr<ApplyHelper> applyHelper;
294 
295 public:
296 #endif
297 
298  using local_matrix_host_type =
299  typename local_matrix_device_type::HostMirror;
300 
302 
304 
306  BlockCrsMatrix ();
307 
317  BlockCrsMatrix (const crs_graph_type& graph, const LO blockSize);
318 
319  BlockCrsMatrix (const crs_graph_type& graph,
320  const typename local_matrix_device_type::values_type& values,
321  const LO blockSize);
322 
330  BlockCrsMatrix (const crs_graph_type& graph,
331  const map_type& domainPointMap,
332  const map_type& rangePointMap,
333  const LO blockSize);
334 
336  virtual ~BlockCrsMatrix () {}
337 
339 
341 
343  Teuchos::RCP<const map_type> getDomainMap () const override;
344 
346  Teuchos::RCP<const map_type> getRangeMap () const override;
347 
349  Teuchos::RCP<const map_type> getRowMap () const override;
350 
352  Teuchos::RCP<const map_type> getColMap () const override;
353 
355  global_size_t getGlobalNumRows() const override;
356 
358  size_t getLocalNumRows() const override;
359 
360  size_t getLocalMaxNumRowEntries() const override;
361 
371  void
372  apply (const mv_type& X,
373  mv_type& Y,
374  Teuchos::ETransp mode = Teuchos::NO_TRANS,
375  Scalar alpha = Teuchos::ScalarTraits<Scalar>::one (),
376  Scalar beta = Teuchos::ScalarTraits<Scalar>::zero ()) const override;
377 
380  bool hasTransposeApply () const override {
381  // FIXME (mfh 04 May 2014) Transpose and conjugate transpose modes
382  // are not implemented yet. Fill in applyBlockTrans() to fix this.
383  return false;
384  }
385 
387  void setAllToScalar (const Scalar& alpha);
388 
390 
392 
394  std::string description () const override;
395 
419  void
420  describe (Teuchos::FancyOStream& out,
421  const Teuchos::EVerbosityLevel verbLevel) const override;
422 
424 
426 
428  virtual LO getBlockSize () const override { return blockSize_; }
429 
431  virtual Teuchos::RCP<const ::Tpetra::RowGraph<LO,GO,Node> > getGraph () const override;
432 
433  const crs_graph_type & getCrsGraph () const { return graph_; }
434 
439  void
440  applyBlock (const BlockMultiVector<Scalar, LO, GO, Node>& X,
441  BlockMultiVector<Scalar, LO, GO, Node>& Y,
442  Teuchos::ETransp mode = Teuchos::NO_TRANS,
443  const Scalar alpha = Teuchos::ScalarTraits<Scalar>::one (),
444  const Scalar beta = Teuchos::ScalarTraits<Scalar>::zero ());
445 
448  void
449  importAndFillComplete (Teuchos::RCP<BlockCrsMatrix<Scalar, LO, GO, Node> >& destMatrix,
450  const Import<LO, GO, Node>& importer) const;
451 
454  void
455  exportAndFillComplete (Teuchos::RCP<BlockCrsMatrix<Scalar, LO, GO, Node> >& destMatrix,
456  const Export<LO, GO, Node>& exporter) const;
457 
458 
485  LO
486  replaceLocalValues (const LO localRowInd,
487  const LO colInds[],
488  const Scalar vals[],
489  const LO numColInds) const;
490 
517  LO
518  sumIntoLocalValues (const LO localRowInd,
519  const LO colInds[],
520  const Scalar vals[],
521  const LO numColInds) const;
522 
523 
556  void
557  getLocalRowView (LO LocalRow,
558  local_inds_host_view_type &indices,
559  values_host_view_type &values) const override;
560 
563  void
564  getLocalRowViewNonConst (LO LocalRow,
565  local_inds_host_view_type &indices,
566  nonconst_values_host_view_type &values) const;
567 
569  virtual void
570  getLocalRowCopy (LO LocalRow,
571  nonconst_local_inds_host_view_type &Indices,
572  nonconst_values_host_view_type &Values,
573  size_t& NumEntries) const override;
575  getLocalBlockDeviceNonConst (const LO localRowInd, const LO localColInd) const;
576 
577  little_block_host_type
578  getLocalBlockHostNonConst (const LO localRowInd, const LO localColInd) const;
579 
580 
604  LO
605  getLocalRowOffsets (const LO localRowInd,
606  ptrdiff_t offsets[],
607  const LO colInds[],
608  const LO numColInds) const;
609 
615  LO
616  replaceLocalValuesByOffsets (const LO localRowInd,
617  const ptrdiff_t offsets[],
618  const Scalar vals[],
619  const LO numOffsets) const;
620 
621  LO
622  absMaxLocalValuesByOffsets (const LO localRowInd,
623  const ptrdiff_t offsets[],
624  const Scalar vals[],
625  const LO numOffsets) const;
626 
632  LO
633  sumIntoLocalValuesByOffsets (const LO localRowInd,
634  const ptrdiff_t offsets[],
635  const Scalar vals[],
636  const LO numOffsets) const;
637 
644  size_t getNumEntriesInLocalRow (const LO localRowInd) const override;
645 
646 
649  local_matrix_device_type getLocalMatrixDevice () const;
650 
667  bool localError () const {
668  return *localError_;
669  }
670 
685  std::string errorMessages () const {
686  return (*errs_).is_null () ? std::string ("") : (*errs_)->str ();
687  }
688 
720  void
721  getLocalDiagOffsets (const Kokkos::View<size_t*, device_type,
722  Kokkos::MemoryUnmanaged>& offsets) const;
723 
724 
738  void
739  getLocalDiagCopy (const Kokkos::View<impl_scalar_type***, device_type,
740  Kokkos::MemoryUnmanaged>& diag,
741  const Kokkos::View<const size_t*, device_type,
742  Kokkos::MemoryUnmanaged>& offsets) const;
743 
757 protected:
759  LO
760  absMaxLocalValues (const LO localRowInd,
761  const LO colInds[],
762  const Scalar vals[],
763  const LO numColInds) const;
764 
770 
771 
776  using buffer_device_type = typename DistObject<Scalar, LO, GO,
778 
779  virtual bool checkSizes (const ::Tpetra::SrcDistObject& source) override;
780 
781  // clang-format on
782  using dist_object_type::
784  // clang-format off
786 
787  virtual void
789  (const SrcDistObject& sourceObj,
790  const size_t numSameIDs,
791  const Kokkos::DualView<const local_ordinal_type*,
792  buffer_device_type>& permuteToLIDs,
793  const Kokkos::DualView<const local_ordinal_type*,
794  buffer_device_type>& permuteFromLIDs,
795  const CombineMode CM) override;
796 
797  // clang-format on
799  // clang-format off
803 
804  virtual void
806  (const SrcDistObject& sourceObj,
807  const Kokkos::DualView<const local_ordinal_type*,
808  buffer_device_type>& exportLIDs,
809  Kokkos::DualView<packet_type*,
810  buffer_device_type>& exports,
811  Kokkos::DualView<size_t*,
812  buffer_device_type> numPacketsPerLID,
813  size_t& constantNumPackets) override;
814 
815  // clang-format on
817  // clang-format off
821 
822  virtual void
824  (const Kokkos::DualView<const local_ordinal_type*,
825  buffer_device_type>& importLIDs,
826  Kokkos::DualView<packet_type*,
827  buffer_device_type> imports,
828  Kokkos::DualView<size_t*,
829  buffer_device_type> numPacketsPerLID,
830  const size_t constantNumPackets,
831  const CombineMode combineMode) override;
833 
834 private:
836  crs_graph_type graph_;
837  Teuchos::RCP<crs_graph_type> graphRCP_;
846  map_type rowMeshMap_;
853  map_type domainPointMap_;
860  map_type rangePointMap_;
862  LO blockSize_;
863 
877  using graph_row_offset_host_type = typename crs_graph_type::local_graph_device_type::row_map_type::HostMirror;
878  graph_row_offset_host_type ptrHost_;
879 
885  using graph_column_indices_host_type = typename crs_graph_type::local_graph_device_type::entries_type::HostMirror;
886  graph_column_indices_host_type indHost_;
887 
893  using impl_scalar_type_dualview = Kokkos::DualView<impl_scalar_type*, device_type>;
896 
918  Teuchos::RCP<Teuchos::RCP<BMV> > X_colMap_;
922  Teuchos::RCP<Teuchos::RCP<BMV> > Y_rowMap_;
923 
931  Teuchos::RCP<Teuchos::RCP<typename crs_graph_type::import_type> > pointImporter_;
932 
934  LO offsetPerBlock_;
935 
947  Teuchos::RCP<bool> localError_;
948 
956  Teuchos::RCP<Teuchos::RCP<std::ostringstream> > errs_;
957 
959  std::ostream& markLocalErrorAndGetStream ();
960 
961  // //! Clear the local error state and stream.
962  // void clearLocalErrorStateAndStream ();
963 
964  template<class Device>
965  struct is_cuda {
966 #if defined(KOKKOS_ENABLE_CUDA)
967  // CudaHostPinnedSpace::execution_space ==
968  // HostSpace::execution_space. That's OK; it's host memory, that
969  // just happens to be Cuda accessible. But what if somebody gives
970  // us Device<Cuda, CudaHostPinnedSpace>? It looks like they mean
971  // to run on device then, so we should sync to device.
972  static constexpr bool value =
973  std::is_same<typename Device::execution_space, Kokkos::Cuda>::value;
974  // Gonna badly fake this here for other execspaces
975 #elif defined(KOKKOS_ENABLE_HIP)
976  static constexpr bool value =
977  std::is_same<typename Device::execution_space, Kokkos::HIP>::value;
978 #elif defined(KOKKOS_ENABLE_SYCL)
979  static constexpr bool value =
980  std::is_same<typename Device::execution_space, Kokkos::Experimental::SYCL>::value;
981 #else
982  static constexpr bool value = false;
983 #endif
984  };
985 
986 public:
987  typename impl_scalar_type_dualview::t_host::const_type
988  getValuesHost() const;
989 
990  typename impl_scalar_type_dualview::t_dev::const_type
991  getValuesDevice() const;
992 
1011  typename impl_scalar_type_dualview::t_host
1012  getValuesHostNonConst() const;
1013 
1014  typename impl_scalar_type_dualview::t_dev
1015  getValuesDeviceNonConst() const;
1016 
1018  typename impl_scalar_type_dualview::t_host::const_type
1019  getValuesHost (const LO& lclRow) const;
1020 
1022  typename impl_scalar_type_dualview::t_dev::const_type
1023  getValuesDevice (const LO& lclRow) const;
1024 
1026  typename impl_scalar_type_dualview::t_host
1027  getValuesHostNonConst (const LO& lclRow);
1028 
1030  typename impl_scalar_type_dualview::t_dev
1031  getValuesDeviceNonConst (const LO& lclRow);
1033 
1034 private:
1035 
1045  void
1046  applyBlockTrans (const BlockMultiVector<Scalar, LO, GO, Node>& X,
1048  const Teuchos::ETransp mode,
1049  const Scalar alpha,
1050  const Scalar beta);
1051 
1059  void
1060  applyBlockNoTrans (const BlockMultiVector<Scalar, LO, GO, Node>& X,
1062  const Scalar alpha,
1063  const Scalar beta);
1064 
1072  void
1073  localApplyBlockNoTrans (const BlockMultiVector<Scalar, LO, GO, Node>& X,
1075  const Scalar alpha,
1076  const Scalar beta);
1077 
1117  LO
1118  findRelOffsetOfColumnIndex (const LO localRowIndex,
1119  const LO colIndexToFind,
1120  const LO hint = 0) const;
1121 
1124  LO offsetPerBlock () const;
1125 
1127  getConstLocalBlockFromInput (const impl_scalar_type* val, const size_t pointOffset) const;
1128 
1130  getNonConstLocalBlockFromInput (impl_scalar_type* val, const size_t pointOffset) const;
1131 
1132  little_block_host_type
1133  getNonConstLocalBlockFromInputHost (impl_scalar_type* val, const size_t pointOffset) const;
1134 
1135 
1136 
1137 public:
1138 
1140  virtual Teuchos::RCP<const Teuchos::Comm<int> > getComm() const override;
1141 
1142 
1144  virtual global_size_t getGlobalNumCols() const override;
1145 
1146  virtual size_t getLocalNumCols() const override;
1147 
1148  virtual GO getIndexBase() const override;
1149 
1151  virtual global_size_t getGlobalNumEntries() const override;
1152 
1154  virtual size_t getLocalNumEntries() const override;
1164  virtual size_t getNumEntriesInGlobalRow (GO globalRow) const override;
1165 
1168  virtual size_t getGlobalMaxNumRowEntries () const override;
1169 
1171  virtual bool hasColMap () const override;
1172 
1182  virtual bool isLocallyIndexed () const override;
1183 
1193  virtual bool isGloballyIndexed () const override;
1194 
1196  virtual bool isFillComplete () const override;
1197 
1199  virtual bool supportsRowViews () const override;
1200 
1201 
1203 
1205 
1226  virtual void
1227  getGlobalRowCopy (GO GlobalRow,
1228  nonconst_global_inds_host_view_type &Indices,
1229  nonconst_values_host_view_type &Values,
1230  size_t& NumEntries) const override;
1255  virtual void
1256  getGlobalRowView (GO GlobalRow,
1257  global_inds_host_view_type & indices,
1258  values_host_view_type & values) const override;
1259 
1271  virtual void getLocalDiagCopy (::Tpetra::Vector<Scalar,LO,GO,Node>& diag) const override;
1272 
1274 
1276 
1282  virtual void leftScale (const ::Tpetra::Vector<Scalar, LO, GO, Node>& x) override;
1283 
1289  virtual void rightScale (const ::Tpetra::Vector<Scalar, LO, GO, Node>& x) override;
1290 
1299  virtual typename ::Tpetra::RowMatrix<Scalar, LO, GO, Node>::mag_type
1300  getFrobeniusNorm () const override;
1302 
1303  // Friend declaration for nonmember function.
1304  template<class BlockCrsMatrixType>
1305  friend Teuchos::RCP<BlockCrsMatrixType>
1306  Tpetra::importAndFillCompleteBlockCrsMatrix (const Teuchos::RCP<const BlockCrsMatrixType>& sourceMatrix,
1307  const Import<typename BlockCrsMatrixType::local_ordinal_type,
1308  typename BlockCrsMatrixType::global_ordinal_type,
1309  typename BlockCrsMatrixType::node_type>& importer);
1310  // Friend declaration for nonmember function.
1311  template<class BlockCrsMatrixType>
1312  friend Teuchos::RCP<BlockCrsMatrixType>
1313  Tpetra::exportAndFillCompleteBlockCrsMatrix (const Teuchos::RCP<const BlockCrsMatrixType>& sourceMatrix,
1314  const Export<typename BlockCrsMatrixType::local_ordinal_type,
1315  typename BlockCrsMatrixType::global_ordinal_type,
1316  typename BlockCrsMatrixType::node_type>& exporter);
1317 
1318 };
1319 
1320 template<class BlockCrsMatrixType>
1321 Teuchos::RCP<BlockCrsMatrixType>
1322 importAndFillCompleteBlockCrsMatrix (const Teuchos::RCP<const BlockCrsMatrixType>& sourceMatrix,
1323  const Import<typename BlockCrsMatrixType::local_ordinal_type,
1324  typename BlockCrsMatrixType::global_ordinal_type,
1325  typename BlockCrsMatrixType::node_type>& importer)
1326 {
1327  Teuchos::RCP<BlockCrsMatrixType> destMatrix;
1328  sourceMatrix->importAndFillComplete (destMatrix, importer);
1329  return destMatrix;
1330 }
1331 
1332 
1333 template<class BlockCrsMatrixType>
1334 Teuchos::RCP<BlockCrsMatrixType>
1335 exportAndFillCompleteBlockCrsMatrix (const Teuchos::RCP<const BlockCrsMatrixType>& sourceMatrix,
1336  const Export<typename BlockCrsMatrixType::local_ordinal_type,
1337  typename BlockCrsMatrixType::global_ordinal_type,
1338  typename BlockCrsMatrixType::node_type>& exporter)
1339 {
1340  Teuchos::RCP<BlockCrsMatrixType> destMatrix;
1341  sourceMatrix->exportAndFillComplete (destMatrix, exporter);
1342  return destMatrix;
1343 }
1344 
1345 } // namespace Tpetra
1346 
1347 #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. ...