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 #ifndef TPETRA_BLOCKCRSMATRIX_DECL_HPP
41 #define TPETRA_BLOCKCRSMATRIX_DECL_HPP
42 
45 
46 #include "Tpetra_CrsGraph.hpp"
47 #include "Tpetra_RowMatrix.hpp"
48 #include "Tpetra_BlockMultiVector_decl.hpp"
50 
51 namespace Tpetra {
52 
130 template<class Scalar,
131  class LO,
132  class GO,
133  class Node>
135  virtual public ::Tpetra::RowMatrix<Scalar, LO, GO, Node>,
136  virtual public ::Tpetra::DistObject<char, LO, GO, Node>
137 {
138 private:
141  using STS = Teuchos::ScalarTraits<Scalar>;
142 
143 protected:
145  typedef char packet_type;
146 
147 public:
149 
150 
152  using scalar_type = Scalar;
153 
161 
163  typedef LO local_ordinal_type;
170  typedef Node node_type;
171 
173  typedef typename Node::device_type device_type;
175  typedef typename device_type::execution_space execution_space;
177  typedef typename device_type::memory_space memory_space;
178 
180  typedef ::Tpetra::Map<LO, GO, node_type> map_type;
182  typedef ::Tpetra::MultiVector<Scalar, LO, GO, node_type> mv_type;
184  typedef ::Tpetra::CrsGraph<LO, GO, node_type> crs_graph_type;
185 
187  typedef Kokkos::View<impl_scalar_type**,
188  Kokkos::LayoutRight,
189  device_type,
190  Kokkos::MemoryTraits<Kokkos::Unmanaged> >
193  typedef Kokkos::View<const impl_scalar_type**,
194  Kokkos::LayoutRight,
195  device_type,
196  Kokkos::MemoryTraits<Kokkos::Unmanaged> >
199  typedef Kokkos::View<impl_scalar_type*,
200  Kokkos::LayoutRight,
201  device_type,
202  Kokkos::MemoryTraits<Kokkos::Unmanaged> >
205  typedef Kokkos::View<const impl_scalar_type*,
206  Kokkos::LayoutRight,
207  device_type,
208  Kokkos::MemoryTraits<Kokkos::Unmanaged> >
210 
212 
214 
216  BlockCrsMatrix ();
217 
227  BlockCrsMatrix (const crs_graph_type& graph, const LO blockSize);
228 
236  BlockCrsMatrix (const crs_graph_type& graph,
237  const map_type& domainPointMap,
238  const map_type& rangePointMap,
239  const LO blockSize);
240 
242  virtual ~BlockCrsMatrix () {}
243 
245 
247 
249  Teuchos::RCP<const map_type> getDomainMap () const;
250 
252  Teuchos::RCP<const map_type> getRangeMap () const;
253 
255  Teuchos::RCP<const map_type> getRowMap () const;
256 
258  Teuchos::RCP<const map_type> getColMap () const;
259 
262 
264  size_t getNodeNumRows() const;
265 
266  size_t getNodeMaxNumRowEntries() const;
267 
277  void
278  apply (const mv_type& X,
279  mv_type& Y,
280  Teuchos::ETransp mode = Teuchos::NO_TRANS,
281  Scalar alpha = Teuchos::ScalarTraits<Scalar>::one (),
282  Scalar beta = Teuchos::ScalarTraits<Scalar>::zero ()) const;
283 
286  bool hasTransposeApply () const {
287  // FIXME (mfh 04 May 2014) Transpose and conjugate transpose modes
288  // are not implemented yet. Fill in applyBlockTrans() to fix this.
289  return false;
290  }
291 
293  void setAllToScalar (const Scalar& alpha);
294 
296 
298 
300  std::string description () const;
301 
325  void
326  describe (Teuchos::FancyOStream& out,
327  const Teuchos::EVerbosityLevel verbLevel) const;
328 
330 
332 
334  LO getBlockSize () const { return blockSize_; }
335 
337  virtual Teuchos::RCP<const ::Tpetra::RowGraph<LO,GO,Node> > getGraph () const;
338 
339  const crs_graph_type & getCrsGraph () const { return graph_; }
340 
345  void
346  applyBlock (const BlockMultiVector<Scalar, LO, GO, Node>& X,
347  BlockMultiVector<Scalar, LO, GO, Node>& Y,
348  Teuchos::ETransp mode = Teuchos::NO_TRANS,
349  const Scalar alpha = Teuchos::ScalarTraits<Scalar>::one (),
350  const Scalar beta = Teuchos::ScalarTraits<Scalar>::zero ());
351 
355  void
356  gaussSeidelCopy (MultiVector<Scalar,LO,GO,Node> &X,
357  const ::Tpetra::MultiVector<Scalar,LO,GO,Node> &B,
358  const ::Tpetra::MultiVector<Scalar,LO,GO,Node> &D,
359  const Scalar& dampingFactor,
360  const ESweepDirection direction,
361  const int numSweeps,
362  const bool zeroInitialGuess) const;
363 
367  void
369  const ::Tpetra::MultiVector<Scalar,LO,GO,Node>& B,
370  const ::Tpetra::MultiVector<Scalar,LO,GO,Node>& D,
371  const Teuchos::ArrayView<LO>& rowIndices,
372  const Scalar& dampingFactor,
373  const ESweepDirection direction,
374  const int numSweeps,
375  const bool zeroInitialGuess) const;
376 
396  void
397  localGaussSeidel (const BlockMultiVector<Scalar, LO, GO, Node>& Residual,
398  BlockMultiVector<Scalar, LO, GO, Node>& Solution,
399  const Kokkos::View<impl_scalar_type***, device_type,
400  Kokkos::MemoryUnmanaged>& D_inv,
401  const Scalar& omega,
402  const ESweepDirection direction) const;
403 
430  LO
431  replaceLocalValues (const LO localRowInd,
432  const LO colInds[],
433  const Scalar vals[],
434  const LO numColInds) const;
435 
462  LO
463  sumIntoLocalValues (const LO localRowInd,
464  const LO colInds[],
465  const Scalar vals[],
466  const LO numColInds) const;
467 
497  LO
498  getLocalRowView (const LO localRowInd,
499  const LO*& colInds,
500  Scalar*& vals,
501  LO& numInds) const;
502 
504  void
505  getLocalRowView (LO LocalRow,
506  Teuchos::ArrayView<const LO> &indices,
507  Teuchos::ArrayView<const Scalar> &values) const;
508 
510  void
511  getLocalRowCopy (LO LocalRow,
512  const Teuchos::ArrayView<LO> &Indices,
513  const Teuchos::ArrayView<Scalar> &Values,
514  size_t &NumEntries) const;
515 
517  getLocalBlock (const LO localRowInd, const LO localColInd) const;
518 
542  LO
543  getLocalRowOffsets (const LO localRowInd,
544  ptrdiff_t offsets[],
545  const LO colInds[],
546  const LO numColInds) const;
547 
553  LO
554  replaceLocalValuesByOffsets (const LO localRowInd,
555  const ptrdiff_t offsets[],
556  const Scalar vals[],
557  const LO numOffsets) const;
558 
564  LO
565  sumIntoLocalValuesByOffsets (const LO localRowInd,
566  const ptrdiff_t offsets[],
567  const Scalar vals[],
568  const LO numOffsets) const;
569 
576  size_t getNumEntriesInLocalRow (const LO localRowInd) const;
577 
594  bool localError () const {
595  return *localError_;
596  }
597 
612  std::string errorMessages () const {
613  return (*errs_).is_null () ? std::string ("") : (*errs_)->str ();
614  }
615 
647  void
648  getLocalDiagOffsets (const Kokkos::View<size_t*, device_type,
649  Kokkos::MemoryUnmanaged>& offsets) const;
650 
651 
665  void
666  getLocalDiagCopy (const Kokkos::View<impl_scalar_type***, device_type,
667  Kokkos::MemoryUnmanaged>& diag,
668  const Kokkos::View<const size_t*, device_type,
669  Kokkos::MemoryUnmanaged>& offsets) const;
670 
684  void
685  getLocalDiagCopy (const Kokkos::View<impl_scalar_type***, device_type,
686  Kokkos::MemoryUnmanaged>& diag,
687  const Teuchos::ArrayView<const size_t>& offsets) const;
688 
689 
690 protected:
692  LO
693  absMaxLocalValues (const LO localRowInd,
694  const LO colInds[],
695  const Scalar vals[],
696  const LO numColInds) const;
697 
699  LO
700  absMaxLocalValuesByOffsets (const LO localRowInd,
701  const ptrdiff_t offsets[],
702  const Scalar vals[],
703  const LO numOffsets) const;
704 
710 
711 
716  using buffer_device_type = typename DistObject<Scalar, LO, GO,
718 
719  virtual bool checkSizes (const ::Tpetra::SrcDistObject& source);
720 
721  virtual void
723  (const SrcDistObject& sourceObj,
724  const size_t numSameIDs,
725  const Kokkos::DualView<const local_ordinal_type*,
726  buffer_device_type>& permuteToLIDs,
727  const Kokkos::DualView<const local_ordinal_type*,
728  buffer_device_type>& permuteFromLIDs);
729 
730  virtual void
732  (const SrcDistObject& sourceObj,
733  const Kokkos::DualView<const local_ordinal_type*,
734  buffer_device_type>& exportLIDs,
735  Kokkos::DualView<packet_type*,
736  buffer_device_type>& exports,
737  Kokkos::DualView<size_t*,
738  buffer_device_type> numPacketsPerLID,
739  size_t& constantNumPackets,
740  Distributor& /* distor */);
741 
742  virtual void
744  (const Kokkos::DualView<const local_ordinal_type*,
745  buffer_device_type>& importLIDs,
746  Kokkos::DualView<packet_type*,
747  buffer_device_type> imports,
748  Kokkos::DualView<size_t*,
749  buffer_device_type> numPacketsPerLID,
750  const size_t constantNumPackets,
751  Distributor& /* distor */,
752  const CombineMode combineMode);
754 
755 private:
757  crs_graph_type graph_;
758  Teuchos::RCP<crs_graph_type> graphRCP_;
767  map_type rowMeshMap_;
774  map_type domainPointMap_;
781  map_type rangePointMap_;
783  LO blockSize_;
784 
798  typename crs_graph_type::local_graph_type::row_map_type::HostMirror ptrHost_;
799 
805  typename crs_graph_type::local_graph_type::entries_type::HostMirror indHost_;
806 
812  typename Kokkos::DualView<impl_scalar_type*, device_type> val_;
813 
835  Teuchos::RCP<Teuchos::RCP<BMV> > X_colMap_;
839  Teuchos::RCP<Teuchos::RCP<BMV> > Y_rowMap_;
840 
848  Teuchos::RCP<Teuchos::RCP<typename crs_graph_type::import_type> > pointImporter_;
849 
851  LO offsetPerBlock_;
852 
864  Teuchos::RCP<bool> localError_;
865 
873  Teuchos::RCP<Teuchos::RCP<std::ostringstream> > errs_;
874 
876  std::ostream& markLocalErrorAndGetStream ();
877 
878  // //! Clear the local error state and stream.
879  // void clearLocalErrorStateAndStream ();
880 
881  template<class Device>
882  struct is_cuda {
883 #if defined(KOKKOS_ENABLE_CUDA)
884  // CudaHostPinnedSpace::execution_space ==
885  // HostSpace::execution_space. That's OK; it's host memory, that
886  // just happens to be Cuda accessible. But what if somebody gives
887  // us Device<Cuda, CudaHostPinnedSpace>? It looks like they mean
888  // to run on device then, so we should sync to device.
889  static constexpr bool value =
890  std::is_same<typename Device::execution_space, Kokkos::Cuda>::value;
891 #else
892  static constexpr bool value = false;
893 #endif // defined(KOKKOS_ENABLE_CUDA)
894  };
895 
896 public:
898 
899 
901  inline void modify_host()
902  {
903  val_.modify_host();
904  }
905 
907  inline void modify_device()
908  {
909  val_.modify_device();
910  }
911 
913  template<class MemorySpace>
914  void modify ()
915  {
916  if (is_cuda<MemorySpace>::value) {
917  this->modify_device ();
918  }
919  else {
920  this->modify_host ();
921  }
922  }
923 
925  inline bool need_sync_host() const
926  {
927  return val_.need_sync_host();
928  }
929 
931  inline bool need_sync_device() const
932  {
933  return val_.need_sync_device();
934  }
935 
937  template<class MemorySpace>
938  bool need_sync () const
939  {
940  if (is_cuda<MemorySpace>::value) {
941  return this->need_sync_device ();
942  }
943  else {
944  return this->need_sync_host ();
945  }
946  }
947 
949  inline void sync_host()
950  {
951  val_.sync_host();
952  }
953 
955  inline void sync_device()
956  {
957  val_.sync_device();
958  }
959 
961  template<class MemorySpace>
962  void sync ()
963  {
964  if (is_cuda<MemorySpace>::value) {
965  this->sync_device ();
966  }
967  else {
968  this->sync_host ();
969  }
970  }
971 
972  // \brief Get the host view of the matrix's values
973  typename Kokkos::DualView<impl_scalar_type*, device_type>::t_host getValuesHost () const {
974  return val_.view_host();
975  }
976 
977  // \brief Get the device view of the matrix's values
978  typename Kokkos::DualView<impl_scalar_type*, device_type>::t_dev getValuesDevice () const {
979  return val_.view_device();
980  }
981 
999  template<class MemorySpace>
1000  typename std::conditional<is_cuda<MemorySpace>::value,
1001  typename Kokkos::DualView<impl_scalar_type*, device_type>::t_dev,
1002  typename Kokkos::DualView<impl_scalar_type*, device_type>::t_host>::type
1004  {
1005  // Unlike std::conditional, if_c has a select method.
1006  return Kokkos::Impl::if_c<
1007  is_cuda<MemorySpace>::value,
1008  typename Kokkos::DualView<impl_scalar_type*, device_type>::t_dev,
1009  typename Kokkos::DualView<impl_scalar_type*, device_type>::t_host
1010  >::select (this->getValuesDevice (), this->getValuesHost ());
1011  }
1012 
1014 
1015 private:
1016 
1026  void
1027  applyBlockTrans (const BlockMultiVector<Scalar, LO, GO, Node>& X,
1029  const Teuchos::ETransp mode,
1030  const Scalar alpha,
1031  const Scalar beta);
1032 
1040  void
1041  applyBlockNoTrans (const BlockMultiVector<Scalar, LO, GO, Node>& X,
1043  const Scalar alpha,
1044  const Scalar beta);
1045 
1053  void
1054  localApplyBlockNoTrans (const BlockMultiVector<Scalar, LO, GO, Node>& X,
1056  const Scalar alpha,
1057  const Scalar beta);
1058 
1098  LO
1099  findRelOffsetOfColumnIndex (const LO localRowIndex,
1100  const LO colIndexToFind,
1101  const LO hint = 0) const;
1102 
1105  LO offsetPerBlock () const;
1106 
1108  getConstLocalBlockFromInput (const impl_scalar_type* val, const size_t pointOffset) const;
1109 
1111  getNonConstLocalBlockFromInput (impl_scalar_type* val, const size_t pointOffset) const;
1112 
1114  getConstLocalBlockFromAbsOffset (const size_t absBlockOffset) const;
1115 
1117  getNonConstLocalBlockFromAbsOffset (const size_t absBlockOffset) const;
1118 
1123  getConstLocalBlockFromRelOffset (const LO lclMeshRow,
1124  const size_t relMeshOffset) const;
1125 
1126 public:
1128  virtual Teuchos::RCP<const Teuchos::Comm<int> > getComm() const;
1129 
1130 
1132  virtual global_size_t getGlobalNumCols() const;
1133 
1134  virtual size_t getNodeNumCols() const;
1135 
1136  virtual GO getIndexBase() const;
1137 
1139  virtual global_size_t getGlobalNumEntries() const;
1140 
1142  virtual size_t getNodeNumEntries() const;
1143 
1153  virtual size_t getNumEntriesInGlobalRow (GO globalRow) const;
1154 
1157  virtual size_t getGlobalMaxNumRowEntries () const;
1158 
1160  virtual bool hasColMap () const;
1161 
1171  virtual bool isLocallyIndexed () const;
1172 
1182  virtual bool isGloballyIndexed () const;
1183 
1185  virtual bool isFillComplete () const;
1186 
1188  virtual bool supportsRowViews () const;
1189 
1190 
1192 
1194 
1215  virtual void
1216  getGlobalRowCopy (GO GlobalRow,
1217  const Teuchos::ArrayView<GO> &Indices,
1218  const Teuchos::ArrayView<Scalar> &Values,
1219  size_t& NumEntries) const;
1220 
1245  virtual void
1246  getGlobalRowView (GO GlobalRow,
1247  Teuchos::ArrayView<const GO>& indices,
1248  Teuchos::ArrayView<const Scalar>& values) const;
1249 
1261  virtual void getLocalDiagCopy (::Tpetra::Vector<Scalar,LO,GO,Node>& diag) const;
1262 
1264 
1266 
1272  virtual void leftScale (const ::Tpetra::Vector<Scalar, LO, GO, Node>& x);
1273 
1279  virtual void rightScale (const ::Tpetra::Vector<Scalar, LO, GO, Node>& x);
1280 
1289  virtual typename ::Tpetra::RowMatrix<Scalar, LO, GO, Node>::mag_type
1290  getFrobeniusNorm () const;
1292 };
1293 
1294 } // namespace Tpetra
1295 
1296 #endif // TPETRA_BLOCKCRSMATRIX_DECL_HPP
virtual size_t getNumEntriesInGlobalRow(GO globalRow) const
The current number of entries on the calling process in the specified global row. ...
::Tpetra::MultiVector< Scalar, LO, GO, node_type > mv_type
The implementation of MultiVector that this class uses.
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:...
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.
void gaussSeidelCopy(MultiVector< Scalar, LO, GO, Node > &X, const ::Tpetra::MultiVector< Scalar, LO, GO, Node > &B, const ::Tpetra::MultiVector< Scalar, LO, GO, Node > &D, const Scalar &dampingFactor, const ESweepDirection direction, const int numSweeps, const bool zeroInitialGuess) const
Version of gaussSeidel(), with fewer requirements on X.
LO replaceLocalValuesByOffsets(const LO localRowInd, const ptrdiff_t offsets[], const Scalar vals[], const LO numOffsets) const
Like replaceLocalValues, but avoids computing row offsets.
Sparse matrix whose entries are small dense square blocks, all of the same dimensions.
size_t getNodeNumRows() const
get the local number of block rows
void modify_device()
Mark the matrix&#39;s valueas as modified in device space.
typename DistObject< Scalar, LO, GO, Node >::buffer_device_type buffer_device_type
Kokkos::Device specialization for communication buffers.
virtual bool isGloballyIndexed() const
Whether matrix indices are globally indexed.
size_t getNumEntriesInLocalRow(const LO localRowInd) const
Return the number of entries in the given row on the calling process.
LO local_ordinal_type
The type of local indices.
virtual void getGlobalRowView(GO GlobalRow, Teuchos::ArrayView< const GO > &indices, Teuchos::ArrayView< const Scalar > &values) const
Get a constant, nonpersisting, globally indexed view of the given row of the matrix.
virtual typename::Tpetra::RowMatrix< Scalar, LO, GO, Node >::mag_type getFrobeniusNorm() const
The Frobenius norm of the matrix.
virtual global_size_t getGlobalNumCols() const
The global number of columns of this matrix.
::Tpetra::CrsGraph< LO, GO, node_type > crs_graph_type
The implementation of CrsGraph that this class uses.
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, Distributor &)
void setAllToScalar(const Scalar &alpha)
Set all matrix entries equal to alpha.
virtual bool isLocallyIndexed() const
Whether matrix indices are locally indexed.
bool localError() const
Whether this object had an error on the calling process.
Declaration of the Tpetra::CrsMatrix class.
void sync_device()
Sync the matrix&#39;s values to device space.
Scalar scalar_type
The type of entries in the matrix (that is, of each entry in each block).
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, Distributor &, const CombineMode combineMode)
virtual void leftScale(const ::Tpetra::Vector< Scalar, LO, GO, Node > &x)
Scale the RowMatrix on the left with the given Vector x.
virtual bool hasColMap() const
Whether this matrix has a well-defined column Map.
Kokkos::View< impl_scalar_type *, Kokkos::LayoutRight, device_type, Kokkos::MemoryTraits< Kokkos::Unmanaged > > little_vec_type
The type used to access nonconst vector blocks.
virtual size_t getNodeNumEntries() const
The local number of stored (structurally nonzero) entries.
::Tpetra::Map< LO, GO, node_type > map_type
The implementation of Map that this class uses.
virtual size_t getNodeNumCols() const
The number of columns needed to apply the forward operator on this node.
virtual ~BlockCrsMatrix()
Destructor (declared virtual for memory safety).
MultiVector for multiple degrees of freedom per mesh point.
GO global_ordinal_type
The type of global indices.
size_t global_size_t
Global size_t object.
BlockCrsMatrix()
Default constructor: Makes an empty block matrix.
virtual bool isFillComplete() const
Whether fillComplete() has been called.
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
For this matrix A, compute Y := beta * Y + alpha * Op(A) * X.
LO absMaxLocalValues(const LO localRowInd, const LO colInds[], const Scalar vals[], const LO numColInds) const
Like sumIntoLocalValues, but for the ABSMAX combine mode.
virtual size_t getGlobalMaxNumRowEntries() const
The maximum number of entries in any row over all processes in the matrix&#39;s communicator.
device_type::memory_space memory_space
The Kokkos memory space that this class uses.
size_t getNodeMaxNumRowEntries() const
Maximum number of entries in any row of the matrix, on this process.
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.
virtual void rightScale(const ::Tpetra::Vector< Scalar, LO, GO, Node > &x)
Scale the RowMatrix on the right with the given Vector x.
ESweepDirection
Sweep direction for Gauss-Seidel or Successive Over-Relaxation (SOR).
Teuchos::RCP< const map_type > getRangeMap() const
Get the (point) range Map of this matrix.
bool need_sync_device() const
Whether the matrix&#39;s values need sync&#39;ing to device space.
Teuchos::RCP< const map_type > getRowMap() const
get the (mesh) map for the rows of this block matrix.
std::conditional< is_cuda< MemorySpace >::value, typename Kokkos::DualView< impl_scalar_type *, device_type >::t_dev, typename Kokkos::DualView< impl_scalar_type *, device_type >::t_host >::type getValues()
Get the host or device View of the matrix&#39;s values (val_).
void modify_host()
Mark the matrix&#39;s valueas as modified in host space.
virtual global_size_t getGlobalNumEntries() const
The global number of stored (structurally nonzero) entries.
Sets up and executes a communication plan for a Tpetra DistObject.
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.
global_size_t getGlobalNumRows() const
get the global number of block rows
virtual void getGlobalRowCopy(GO GlobalRow, const Teuchos::ArrayView< GO > &Indices, const Teuchos::ArrayView< Scalar > &Values, size_t &NumEntries) const
Get a copy of the given global row&#39;s entries.
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.
void sync_host()
Sync the matrix&#39;s values to host space.
Abstract base class for objects that can be the source of an Import or Export operation.
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)
device_type::execution_space execution_space
The Kokkos execution space that this class uses.
Kokkos::View< const impl_scalar_type *, Kokkos::LayoutRight, device_type, Kokkos::MemoryTraits< Kokkos::Unmanaged > > const_little_vec_type
The type used to access const vector blocks.
Kokkos::View< impl_scalar_type **, Kokkos::LayoutRight, device_type, Kokkos::MemoryTraits< Kokkos::Unmanaged > > little_block_type
The type used to access nonconst matrix blocks.
virtual bool supportsRowViews() const
Whether this object implements getLocalRowView() and getGlobalRowView().
LO absMaxLocalValuesByOffsets(const LO localRowInd, const ptrdiff_t offsets[], const Scalar vals[], const LO numOffsets) const
Like sumIntoLocalValuesByOffsets, but for the ABSMAX combine mode.
virtual Teuchos::RCP< const Teuchos::Comm< int > > getComm() const
The communicator over which this matrix is distributed.
LO getLocalRowView(const LO localRowInd, const LO *&colInds, Scalar *&vals, LO &numInds) const
Get a view of the (mesh, i.e., block) row, using local (mesh, i.e., block) indices.
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.
void sync()
Sync the matrix&#39;s values to the given memory space.
void localGaussSeidel(const BlockMultiVector< Scalar, LO, GO, Node > &Residual, BlockMultiVector< Scalar, LO, GO, Node > &Solution, const Kokkos::View< impl_scalar_type ***, device_type, Kokkos::MemoryUnmanaged > &D_inv, const Scalar &omega, const ESweepDirection direction) const
Local Gauss-Seidel solve, given a factorized diagonal.
A read-only, row-oriented interface to a sparse matrix.
void modify()
Mark the matrix&#39;s values as modified in the given memory space.
void describe(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel) const
Print a description of this object to the given output stream.
A distributed dense vector.
LO getBlockSize() const
The number of degrees of freedom per mesh point.
bool need_sync() const
Whether the matrix&#39;s values need sync&#39;ing to the given memory space.
Teuchos::RCP< const map_type > getDomainMap() const
Get the (point) domain Map of this matrix.
bool hasTransposeApply() const
Whether it is valid to apply the transpose or conjugate transpose of this matrix. ...
void getLocalRowCopy(LO LocalRow, const Teuchos::ArrayView< LO > &Indices, const Teuchos::ArrayView< Scalar > &Values, size_t &NumEntries) const
Not implemented.
Kokkos::View< const impl_scalar_type **, Kokkos::LayoutRight, device_type, Kokkos::MemoryTraits< Kokkos::Unmanaged > > const_little_block_type
The type used to access const matrix blocks.
Node::device_type device_type
The Kokkos::Device specialization that this class uses.
Teuchos::RCP< const map_type > getColMap() const
get the (mesh) map for the columns of this block matrix.
virtual Teuchos::RCP< const ::Tpetra::RowGraph< LO, GO, Node > > getGraph() const
Get the (mesh) graph.
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.
void reorderedGaussSeidelCopy(::Tpetra::MultiVector< Scalar, LO, GO, Node > &X, const ::Tpetra::MultiVector< Scalar, LO, GO, Node > &B, const ::Tpetra::MultiVector< Scalar, LO, GO, Node > &D, const Teuchos::ArrayView< LO > &rowIndices, const Scalar &dampingFactor, const ESweepDirection direction, const int numSweeps, const bool zeroInitialGuess) const
Version of reorderedGaussSeidel(), with fewer requirements on X.
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.
std::string description() const
One-line description of this object.
bool need_sync_host() const
Whether the matrix&#39;s values need sync&#39;ing to host space.
virtual GO getIndexBase() const
The index base for global indices in this matrix.