Tpetra parallel linear algebra Version of the Day
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
51namespace Tpetra {
52
130template<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{
138private:
141 using STS = Teuchos::ScalarTraits<Scalar>;
142
143protected:
145 typedef char packet_type;
146
147public:
149
150
152 using scalar_type = Scalar;
153
161
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,
190 Kokkos::MemoryTraits<Kokkos::Unmanaged> >
192 typedef typename little_block_type::HostMirror little_block_host_type;
193
195 typedef Kokkos::View<const impl_scalar_type**,
196 Kokkos::LayoutRight,
198 Kokkos::MemoryTraits<Kokkos::Unmanaged> >
202 typedef typename BMV::little_host_vec_type little_host_vec_type;
203
206 typedef typename BMV::const_little_host_vec_type const_host_little_vec_type;
207
209 using local_inds_device_view_type =
210 typename row_matrix_type::local_inds_device_view_type;
211 using local_inds_host_view_type =
212 typename row_matrix_type::local_inds_host_view_type;
213 using nonconst_local_inds_host_view_type =
214 typename row_matrix_type::nonconst_local_inds_host_view_type;
215
216 using global_inds_device_view_type =
217 typename row_matrix_type::global_inds_device_view_type;
218 using global_inds_host_view_type =
219 typename row_matrix_type::global_inds_host_view_type;
220 using nonconst_global_inds_host_view_type =
221 typename row_matrix_type::nonconst_global_inds_host_view_type;
222
223 using values_device_view_type =
224 typename row_matrix_type::values_device_view_type;
225 using values_host_view_type =
226 typename row_matrix_type::values_host_view_type;
227 using nonconst_values_host_view_type =
228 typename row_matrix_type::nonconst_values_host_view_type;
229
231
233
236
246 BlockCrsMatrix (const crs_graph_type& graph, const LO blockSize);
247
255 BlockCrsMatrix (const crs_graph_type& graph,
256 const map_type& domainPointMap,
257 const map_type& rangePointMap,
258 const LO blockSize);
259
261 virtual ~BlockCrsMatrix () {}
262
264
266
268 Teuchos::RCP<const map_type> getDomainMap () const override;
269
271 Teuchos::RCP<const map_type> getRangeMap () const override;
272
274 Teuchos::RCP<const map_type> getRowMap () const override;
275
277 Teuchos::RCP<const map_type> getColMap () const override;
278
280 global_size_t getGlobalNumRows() const override;
281
283 size_t getNodeNumRows() const override;
284
285 size_t getNodeMaxNumRowEntries() const override;
286
296 void
297 apply (const mv_type& X,
298 mv_type& Y,
299 Teuchos::ETransp mode = Teuchos::NO_TRANS,
300 Scalar alpha = Teuchos::ScalarTraits<Scalar>::one (),
301 Scalar beta = Teuchos::ScalarTraits<Scalar>::zero ()) const override;
302
305 bool hasTransposeApply () const override {
306 // FIXME (mfh 04 May 2014) Transpose and conjugate transpose modes
307 // are not implemented yet. Fill in applyBlockTrans() to fix this.
308 return false;
309 }
310
312 void setAllToScalar (const Scalar& alpha);
313
315
317
319 std::string description () const override;
320
344 void
345 describe (Teuchos::FancyOStream& out,
346 const Teuchos::EVerbosityLevel verbLevel) const override;
347
349
351
353 LO getBlockSize () const { return blockSize_; }
354
356 virtual Teuchos::RCP<const ::Tpetra::RowGraph<LO,GO,Node> > getGraph () const override;
357
358 const crs_graph_type & getCrsGraph () const { return graph_; }
359
364 void
365 applyBlock (const BlockMultiVector<Scalar, LO, GO, Node>& X,
366 BlockMultiVector<Scalar, LO, GO, Node>& Y,
367 Teuchos::ETransp mode = Teuchos::NO_TRANS,
368 const Scalar alpha = Teuchos::ScalarTraits<Scalar>::one (),
369 const Scalar beta = Teuchos::ScalarTraits<Scalar>::zero ());
370
397 LO
398 replaceLocalValues (const LO localRowInd,
399 const LO colInds[],
400 const Scalar vals[],
401 const LO numColInds) const;
402
429 LO
430 sumIntoLocalValues (const LO localRowInd,
431 const LO colInds[],
432 const Scalar vals[],
433 const LO numColInds) const;
434
435
467#ifdef TPETRA_ENABLE_DEPRECATED_CODE
468 LO
469 getLocalRowView (const LO localRowInd,
470 const LO*& colInds,
471 Scalar*& vals,
472 LO& numInds) const;
473
474
476 void
477 getLocalRowView (LO LocalRow,
478 Teuchos::ArrayView<const LO> &indices,
479 Teuchos::ArrayView<const Scalar> &values) const override;
480#endif // TPETRA_ENABLE_DEPRECATED_CODE
484 void
485 getLocalRowView (LO LocalRow,
486 local_inds_host_view_type &indices,
487 values_host_view_type &values) const override;
488
491 void
492 getLocalRowViewNonConst (LO LocalRow,
493 local_inds_host_view_type &indices,
494 nonconst_values_host_view_type &values) const;
495
497 virtual void
498 getLocalRowCopy (LO LocalRow,
499 nonconst_local_inds_host_view_type &Indices,
500 nonconst_values_host_view_type &Values,
501 size_t& NumEntries) const override;
502#ifdef TPETRA_ENABLE_DEPRECATED_CODE
503 virtual void
504 getLocalRowCopy (LO LocalRow,
505 const Teuchos::ArrayView<LO> &Indices,
506 const Teuchos::ArrayView<Scalar> &Values,
507 size_t &NumEntries) const override;
508#endif
509
510#ifdef TPETRA_ENABLE_DEPRECATED_CODE
512 getLocalBlock (const LO localRowInd, const LO localColInd) const;
513#endif
514
516 getLocalBlockDeviceNonConst (const LO localRowInd, const LO localColInd) const;
517
518 little_block_host_type
519 getLocalBlockHostNonConst (const LO localRowInd, const LO localColInd) const;
520
521
545 LO
546 getLocalRowOffsets (const LO localRowInd,
547 ptrdiff_t offsets[],
548 const LO colInds[],
549 const LO numColInds) const;
550
556 LO
557 replaceLocalValuesByOffsets (const LO localRowInd,
558 const ptrdiff_t offsets[],
559 const Scalar vals[],
560 const LO numOffsets) const;
561
562 LO
563 absMaxLocalValuesByOffsets (const LO localRowInd,
564 const ptrdiff_t offsets[],
565 const Scalar vals[],
566 const LO numOffsets) const;
567
573 LO
574 sumIntoLocalValuesByOffsets (const LO localRowInd,
575 const ptrdiff_t offsets[],
576 const Scalar vals[],
577 const LO numOffsets) const;
578
585 size_t getNumEntriesInLocalRow (const LO localRowInd) const override;
586
603 bool localError () const {
604 return *localError_;
605 }
606
621 std::string errorMessages () const {
622 return (*errs_).is_null () ? std::string ("") : (*errs_)->str ();
623 }
624
656 void
657 getLocalDiagOffsets (const Kokkos::View<size_t*, device_type,
658 Kokkos::MemoryUnmanaged>& offsets) const;
659
660
674 void
675 getLocalDiagCopy (const Kokkos::View<impl_scalar_type***, device_type,
676 Kokkos::MemoryUnmanaged>& diag,
677 const Kokkos::View<const size_t*, device_type,
678 Kokkos::MemoryUnmanaged>& offsets) const;
679
693#ifdef TPETRA_ENABLE_DEPRECATED_CODE
694 void
695 getLocalDiagCopy (const Kokkos::View<impl_scalar_type***, device_type,
696 Kokkos::MemoryUnmanaged>& diag,
697 const Teuchos::ArrayView<const size_t>& offsets) const;
698#endif
699
700protected:
702 LO
703 absMaxLocalValues (const LO localRowInd,
704 const LO colInds[],
705 const Scalar vals[],
706 const LO numColInds) const;
707
713
714
719 using buffer_device_type = typename DistObject<Scalar, LO, GO,
721
722 virtual bool checkSizes (const ::Tpetra::SrcDistObject& source) override;
723
724 virtual void
726 (const SrcDistObject& sourceObj,
727 const size_t numSameIDs,
728 const Kokkos::DualView<const local_ordinal_type*,
729 buffer_device_type>& permuteToLIDs,
730 const Kokkos::DualView<const local_ordinal_type*,
731 buffer_device_type>& permuteFromLIDs,
732 const CombineMode CM) override;
733
734 virtual void
736 (const SrcDistObject& sourceObj,
737 const Kokkos::DualView<const local_ordinal_type*,
738 buffer_device_type>& exportLIDs,
739 Kokkos::DualView<packet_type*,
740 buffer_device_type>& exports,
741 Kokkos::DualView<size_t*,
742 buffer_device_type> numPacketsPerLID,
743 size_t& constantNumPackets) override;
744
745 virtual void
747 (const Kokkos::DualView<const local_ordinal_type*,
748 buffer_device_type>& importLIDs,
749 Kokkos::DualView<packet_type*,
750 buffer_device_type> imports,
751 Kokkos::DualView<size_t*,
752 buffer_device_type> numPacketsPerLID,
753 const size_t constantNumPackets,
754 const CombineMode combineMode) override;
756
757private:
759 crs_graph_type graph_;
760 Teuchos::RCP<crs_graph_type> graphRCP_;
769 map_type rowMeshMap_;
776 map_type domainPointMap_;
783 map_type rangePointMap_;
785 LO blockSize_;
786
800 using graph_row_offset_host_type = typename crs_graph_type::local_graph_device_type::row_map_type::HostMirror;
801 graph_row_offset_host_type ptrHost_;
802
808 using graph_column_indices_host_type = typename crs_graph_type::local_graph_device_type::entries_type::HostMirror;
809 graph_column_indices_host_type indHost_;
810
816 using impl_scalar_type_dualview = Kokkos::DualView<impl_scalar_type*, device_type>;
817 using impl_scalar_type_wrapped_dualview = Details::WrappedDualView<impl_scalar_type_dualview>;
818 mutable impl_scalar_type_wrapped_dualview val_;
819
841 Teuchos::RCP<Teuchos::RCP<BMV> > X_colMap_;
845 Teuchos::RCP<Teuchos::RCP<BMV> > Y_rowMap_;
846
854 Teuchos::RCP<Teuchos::RCP<typename crs_graph_type::import_type> > pointImporter_;
855
857 LO offsetPerBlock_;
858
870 Teuchos::RCP<bool> localError_;
871
879 Teuchos::RCP<Teuchos::RCP<std::ostringstream> > errs_;
880
882 std::ostream& markLocalErrorAndGetStream ();
883
884 // //! Clear the local error state and stream.
885 // void clearLocalErrorStateAndStream ();
886
887 template<class Device>
888 struct is_cuda {
889#if defined(KOKKOS_ENABLE_CUDA)
890 // CudaHostPinnedSpace::execution_space ==
891 // HostSpace::execution_space. That's OK; it's host memory, that
892 // just happens to be Cuda accessible. But what if somebody gives
893 // us Device<Cuda, CudaHostPinnedSpace>? It looks like they mean
894 // to run on device then, so we should sync to device.
895 static constexpr bool value =
896 std::is_same<typename Device::execution_space, Kokkos::Cuda>::value;
897 // Gonna badly fake this here for other execspaces
898#elif defined(KOKKOS_ENABLE_HIP)
899 static constexpr bool value =
900 std::is_same<typename Device::execution_space, Kokkos::Experimental::HIP>::value;
901#elif defined(KOKKOS_ENABLE_SYCL)
902 static constexpr bool value =
903 std::is_same<typename Device::execution_space, Kokkos::Experimental::SYCL>::value;
904#else
905 static constexpr bool value = false;
906#endif
907 };
908
909public:
910#ifdef TPETRA_ENABLE_DEPRECATED_CODE
911 // KK: sync modify syntax will not work
912 // the interface is deprecated bu the functionalities are removed
914
915
916 inline void modify_host()
917 {
918 //throw std::logic_error("do not use");
919 }
920
922 inline void modify_device()
923 {
924 //throw std::logic_error("do not use");
925 }
926
928 template<class MemorySpace>
929 void modify ()
930 {
931 //throw std::logic_error("do not use");
932 }
933
935 inline bool need_sync_host() const
936 {
937 //throw std::logic_error("do not use");
938 return false;
939 }
940
942 inline bool need_sync_device() const
943 {
944 //throw std::logic_error("do not use");
945 return false;
946 }
947
949 template<class MemorySpace>
950 bool need_sync () const
951 {
952 //throw std::logic_error("do not use");
953 return false;
954 }
955
957 inline void sync_host()
958 {
959 //throw std::logic_error("do not use");
960 }
961
963 inline void sync_device()
964 {
965 //throw std::logic_error("do not use");
966 }
967
969 template<class MemorySpace>
970 void sync ()
971 {
972 //throw std::logic_error("do not use");
973 }
974#endif
975
976
977 typename impl_scalar_type_dualview::t_host::const_type
978 getValuesHost() const;
979
980 typename impl_scalar_type_dualview::t_dev::const_type
981 getValuesDevice() const;
982
1001#ifdef TPETRA_ENABLE_DEPRECATED_CODE
1002 template<class MemorySpace>
1003 typename std::conditional<is_cuda<MemorySpace>::value,
1004 typename impl_scalar_type_dualview::t_dev,
1005 typename impl_scalar_type_dualview::t_host>::type
1006 getValues () const
1007 {
1008 // Unlike std::conditional, if_c has a select method.
1009 return Kokkos::Impl::if_c<
1010 is_cuda<MemorySpace>::value,
1011 typename impl_scalar_type_dualview::t_dev,
1012 typename impl_scalar_type_dualview::t_host
1013 >::select (this->getValuesDeviceNonConst (), this->getValuesHostNonConst ());
1014 }
1015#endif
1016
1017 typename impl_scalar_type_dualview::t_host
1018 getValuesHostNonConst() const;
1019
1020 typename impl_scalar_type_dualview::t_dev
1021 getValuesDeviceNonConst() const;
1022
1024 typename impl_scalar_type_dualview::t_host::const_type
1025 getValuesHost (const LO& lclRow) const;
1026
1028 typename impl_scalar_type_dualview::t_dev::const_type
1029 getValuesDevice (const LO& lclRow) const;
1030
1032 typename impl_scalar_type_dualview::t_host
1033 getValuesHostNonConst (const LO& lclRow);
1034
1036 typename impl_scalar_type_dualview::t_dev
1037 getValuesDeviceNonConst (const LO& lclRow);
1039
1040private:
1041
1051 void
1052 applyBlockTrans (const BlockMultiVector<Scalar, LO, GO, Node>& X,
1053 BlockMultiVector<Scalar, LO, GO, Node>& Y,
1054 const Teuchos::ETransp mode,
1055 const Scalar alpha,
1056 const Scalar beta);
1057
1065 void
1066 applyBlockNoTrans (const BlockMultiVector<Scalar, LO, GO, Node>& X,
1067 BlockMultiVector<Scalar, LO, GO, Node>& Y,
1068 const Scalar alpha,
1069 const Scalar beta);
1070
1078 void
1079 localApplyBlockNoTrans (const BlockMultiVector<Scalar, LO, GO, Node>& X,
1080 BlockMultiVector<Scalar, LO, GO, Node>& Y,
1081 const Scalar alpha,
1082 const Scalar beta);
1083
1123 LO
1124 findRelOffsetOfColumnIndex (const LO localRowIndex,
1125 const LO colIndexToFind,
1126 const LO hint = 0) const;
1127
1130 LO offsetPerBlock () const;
1131
1133 getConstLocalBlockFromInput (const impl_scalar_type* val, const size_t pointOffset) const;
1134
1136 getNonConstLocalBlockFromInput (impl_scalar_type* val, const size_t pointOffset) const;
1137
1138 little_block_host_type
1139 getNonConstLocalBlockFromInputHost (impl_scalar_type* val, const size_t pointOffset) const;
1140
1141
1142
1143public:
1145 virtual Teuchos::RCP<const Teuchos::Comm<int> > getComm() const override;
1146
1147
1149 virtual global_size_t getGlobalNumCols() const override;
1150
1151 virtual size_t getNodeNumCols() const override;
1152
1153 virtual GO getIndexBase() const override;
1154
1156 virtual global_size_t getGlobalNumEntries() const override;
1157
1159 virtual size_t getNodeNumEntries() const override;
1160
1170 virtual size_t getNumEntriesInGlobalRow (GO globalRow) const override;
1171
1174 virtual size_t getGlobalMaxNumRowEntries () const override;
1175
1177 virtual bool hasColMap () const override;
1178
1188 virtual bool isLocallyIndexed () const override;
1189
1199 virtual bool isGloballyIndexed () const override;
1200
1202 virtual bool isFillComplete () const override;
1203
1205 virtual bool supportsRowViews () const override;
1206
1207
1209
1211
1232 virtual void
1233 getGlobalRowCopy (GO GlobalRow,
1234 nonconst_global_inds_host_view_type &Indices,
1235 nonconst_values_host_view_type &Values,
1236 size_t& NumEntries) const override;
1237#ifdef TPETRA_ENABLE_DEPRECATED_CODE
1238 virtual void
1239 getGlobalRowCopy (GO GlobalRow,
1240 const Teuchos::ArrayView<GO> &Indices,
1241 const Teuchos::ArrayView<Scalar> &Values,
1242 size_t& NumEntries) const override;
1243#endif
1244
1269#ifdef TPETRA_ENABLE_DEPRECATED_CODE
1270 virtual void
1271 getGlobalRowView (GO GlobalRow,
1272 Teuchos::ArrayView<const GO>& indices,
1273 Teuchos::ArrayView<const Scalar>& values) const override;
1274#endif // TPETRA_ENABLE_DEPRECATED_CODE
1275 virtual void
1276 getGlobalRowView (GO GlobalRow,
1277 global_inds_host_view_type & indices,
1278 values_host_view_type & values) const override;
1279
1291 virtual void getLocalDiagCopy (::Tpetra::Vector<Scalar,LO,GO,Node>& diag) const override;
1292
1294
1296
1302 virtual void leftScale (const ::Tpetra::Vector<Scalar, LO, GO, Node>& x) override;
1303
1309 virtual void rightScale (const ::Tpetra::Vector<Scalar, LO, GO, Node>& x) override;
1310
1319 virtual typename ::Tpetra::RowMatrix<Scalar, LO, GO, Node>::mag_type
1320 getFrobeniusNorm () const override;
1322};
1323
1324} // namespace Tpetra
1325
1326#endif // TPETRA_BLOCKCRSMATRIX_DECL_HPP
Declaration of the Tpetra::CrsMatrix class.
Sparse matrix whose entries are small dense square blocks, all of the same dimensions.
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,...
virtual ~BlockCrsMatrix()
Destructor (declared virtual for memory safety).
virtual bool isLocallyIndexed() const override
Whether matrix indices are locally indexed.
virtual bool isFillComplete() const override
Whether fillComplete() has been called.
virtual size_t getGlobalMaxNumRowEntries() const override
The maximum number of entries in any row over all processes in the matrix's communicator.
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.
LO replaceLocalValuesByOffsets(const LO localRowInd, const ptrdiff_t offsets[], const Scalar vals[], const LO numOffsets) const
Like replaceLocalValues, but avoids computing row offsets.
virtual size_t getNodeNumEntries() const override
The local number of stored (structurally nonzero) entries.
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.
std::string errorMessages() const
The current stream of error messages.
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:...
Scalar scalar_type
The type of entries in the matrix (that is, of each entry in each block).
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.
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 **, Kokkos::LayoutRight, device_type, Kokkos::MemoryTraits< Kokkos::Unmanaged > > little_block_type
The type used to access nonconst matrix blocks.
LO local_ordinal_type
The type of local indices.
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'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.
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
::Tpetra::MultiVector< Scalar, LO, GO, node_type > mv_type
The implementation of MultiVector that this class uses.
Teuchos::RCP< const map_type > getRangeMap() const override
Get the (point) range Map of this matrix.
LO sumIntoLocalValuesByOffsets(const LO localRowInd, const ptrdiff_t offsets[], const Scalar vals[], const LO numOffsets) const
Like sumIntoLocalValues, but avoids computing row offsets.
virtual bool hasColMap() const override
Whether this matrix has a well-defined column Map.
device_type::execution_space execution_space
The Kokkos execution space that this class uses.
size_t getNodeMaxNumRowEntries() const override
Maximum number of entries in any row of the matrix, on this process.
bool hasTransposeApply() const override
Whether it is valid to apply the transpose or conjugate transpose of this matrix.
impl_scalar_type_dualview::t_host getValuesHostNonConst() const
Get the host or device View of the matrix's values (val_).
Teuchos::RCP< const map_type > getColMap() const override
get the (mesh) map for the columns of this block matrix.
virtual typename::Tpetra::RowMatrix< Scalar, LO, GO, Node >::mag_type getFrobeniusNorm() const override
The Frobenius norm of the matrix.
virtual Teuchos::RCP< const ::Tpetra::RowGraph< LO, GO, Node > > getGraph() const override
Get the (mesh) graph.
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
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.
virtual global_size_t getGlobalNumCols() const override
The global number of columns 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.
Teuchos::RCP< const map_type > getRowMap() const override
get the (mesh) map for the rows of this block matrix.
std::string description() const override
One-line description of this object.
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.
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.
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:...
GO global_ordinal_type
The type of global indices.
size_t getNumEntriesInLocalRow(const LO localRowInd) const override
Return the number of entries in the given row on the calling process.
virtual bool supportsRowViews() const override
Whether this object implements getLocalRowView() and getGlobalRowView().
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,...
virtual size_t getNumEntriesInGlobalRow(GO globalRow) const override
The current number of entries on the calling process in the specified global row.
size_t getNodeNumRows() const override
get the local number of block rows
Node::device_type device_type
The Kokkos::Device specialization that this class uses.
BMV::little_vec_type little_vec_type
The type used to access nonconst vector blocks.
void setAllToScalar(const Scalar &alpha)
Set all matrix entries equal to alpha.
BMV::const_little_vec_type const_little_vec_type
The type used to access const vector blocks.
void getLocalRowViewNonConst(LO LocalRow, local_inds_host_view_type &indices, nonconst_values_host_view_type &values) const
char packet_type
Implementation detail; tells.
typename DistObject< Scalar, LO, GO, Node >::buffer_device_type buffer_device_type
Kokkos::Device specialization for communication buffers.
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
::Tpetra::Map< LO, GO, node_type > map_type
The implementation of Map that this class uses.
virtual void rightScale(const ::Tpetra::Vector< Scalar, LO, GO, Node > &x) override
Scale the RowMatrix on the right with the given Vector x.
virtual GO getIndexBase() const override
The index base for global indices in this matrix.
bool localError() const
Whether this object had an error on the calling process.
virtual global_size_t getGlobalNumEntries() const override
The global number of stored (structurally nonzero) entries.
typename BMV::impl_scalar_type impl_scalar_type
The implementation type of entries in the matrix.
virtual Teuchos::RCP< const Teuchos::Comm< int > > getComm() const override
The communicator over which this matrix is distributed.
::Tpetra::CrsGraph< LO, GO, node_type > crs_graph_type
The implementation of CrsGraph that this class uses.
device_type::memory_space memory_space
The Kokkos memory space that this class uses.
global_size_t getGlobalNumRows() const override
get the global number of block rows
virtual void leftScale(const ::Tpetra::Vector< Scalar, LO, GO, Node > &x) override
Scale the RowMatrix on the left with the given Vector x.
Teuchos::RCP< const map_type > getDomainMap() const override
Get the (point) domain Map of this matrix.
virtual bool isGloballyIndexed() const override
Whether matrix indices are globally indexed.
BlockCrsMatrix()
Default constructor: Makes an empty block matrix.
virtual size_t getNodeNumCols() const override
The number of columns needed to apply the forward operator on this node.
LO getBlockSize() const
The number of degrees of freedom per mesh point.
MultiVector for multiple degrees of freedom per mesh point.
typename mv_type::impl_scalar_type impl_scalar_type
The implementation type of entries in the object.
Kokkos::View< impl_scalar_type *, device_type > little_vec_type
"Block view" of all degrees of freedom at a mesh point, for a single column of the MultiVector.
Kokkos::View< const impl_scalar_type *, device_type > const_little_vec_type
"Const block view" of all degrees of freedom at a mesh point, for a single column of the MultiVector.
Base class for distributed Tpetra objects that support data redistribution.
A read-only, row-oriented interface to a sparse matrix.
Abstract base class for objects that can be the source of an Import or Export operation.
A distributed dense vector.
Namespace Tpetra contains the class and methods constituting the Tpetra library.
size_t global_size_t
Global size_t object.
CombineMode
Rule for combining data in an Import or Export.