Tpetra parallel linear algebra  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
TpetraExt_MMHelpers_decl.hpp
Go to the documentation of this file.
1 // @HEADER
2 // *****************************************************************************
3 // Tpetra: Templated Linear Algebra Services Package
4 //
5 // Copyright 2008 NTESS and the Tpetra contributors.
6 // SPDX-License-Identifier: BSD-3-Clause
7 // *****************************************************************************
8 // @HEADER
9 
10 #ifndef TPETRA_MMHELPERS_DECL_HPP
11 #define TPETRA_MMHELPERS_DECL_HPP
12 
13 #include <Tpetra_CrsMatrix.hpp>
14 #include <Tpetra_BlockCrsMatrix.hpp>
15 #include <Teuchos_Array.hpp>
16 #include <map>
17 #include <set>
18 
24 
25 namespace Tpetra {
26 
32 template <class Scalar = ::Tpetra::Details::DefaultTypes::scalar_type,
34  class GlobalOrdinal = ::Tpetra::Details::DefaultTypes::global_ordinal_type,
35  class Node = ::Tpetra::Details::DefaultTypes::node_type>
37  public:
40 
42 
43  virtual ~CrsMatrixStruct();
44 
45  void deleteContents();
46 
48  Teuchos::RCP<const map_type> origRowMap;
50  Teuchos::RCP<const map_type> rowMap;
52  Teuchos::RCP<const map_type> colMap;
54  Teuchos::RCP<const map_type> domainMap;
56  Teuchos::RCP<const map_type> importColMap;
58  Teuchos::RCP<CrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node> > importMatrix;
60  Teuchos::RCP<const CrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node> > origMatrix;
61 };
62 
68 template <class Scalar = ::Tpetra::Details::DefaultTypes::scalar_type,
70  class GlobalOrdinal = ::Tpetra::Details::DefaultTypes::global_ordinal_type,
71  class Node = ::Tpetra::Details::DefaultTypes::node_type>
73  public:
76 
77  BlockCrsMatrixStruct(const LocalOrdinal blocksize_);
78 
79  virtual ~BlockCrsMatrixStruct();
80 
81  void deleteContents();
82 
84  Teuchos::RCP<const map_type> origRowMap;
86  Teuchos::RCP<const map_type> rowMap;
88  Teuchos::RCP<const map_type> colMap;
90  Teuchos::RCP<const map_type> domainMap;
92  Teuchos::RCP<const map_type> importColMap;
94  Teuchos::RCP<BlockCrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node> > importMatrix;
96  Teuchos::RCP<const BlockCrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node> > origMatrix;
98  const LocalOrdinal blocksize;
99 };
100 
101 template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
102 int dumpCrsMatrixStruct(const CrsMatrixStruct<Scalar, LocalOrdinal, GlobalOrdinal, Node> &M);
103 
104 template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
105 class CrsWrapper {
106  public:
108 
109  virtual ~CrsWrapper() {}
110  virtual Teuchos::RCP<const map_type> getRowMap() const = 0;
111  virtual bool isFillComplete() = 0;
112 
113  virtual void
114  insertGlobalValues(GlobalOrdinal globalRow,
115  const Teuchos::ArrayView<const GlobalOrdinal> &indices,
116  const Teuchos::ArrayView<const Scalar> &values) = 0;
117  virtual void
118  sumIntoGlobalValues(GlobalOrdinal globalRow,
119  const Teuchos::ArrayView<const GlobalOrdinal> &indices,
120  const Teuchos::ArrayView<const Scalar> &values) = 0;
121 };
122 
123 template <class Scalar = ::Tpetra::Details::DefaultTypes::scalar_type,
125  class GlobalOrdinal = ::Tpetra::Details::DefaultTypes::global_ordinal_type,
126  class Node = ::Tpetra::Details::DefaultTypes::node_type>
127 class CrsWrapper_CrsMatrix : public CrsWrapper<Scalar, LocalOrdinal, GlobalOrdinal, Node> {
128  public:
129  typedef Map<LocalOrdinal, GlobalOrdinal, Node> map_type;
130  typedef CrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node> crs_matrix_type;
131 
132  CrsWrapper_CrsMatrix(crs_matrix_type &crsmatrix);
133  virtual ~CrsWrapper_CrsMatrix();
134  Teuchos::RCP<const map_type> getRowMap() const;
135 
136  bool isFillComplete();
137 
138  void
139  insertGlobalValues(GlobalOrdinal globalRow,
140  const Teuchos::ArrayView<const GlobalOrdinal> &indices,
141  const Teuchos::ArrayView<const Scalar> &values);
142  void
143  sumIntoGlobalValues(GlobalOrdinal globalRow,
144  const Teuchos::ArrayView<const GlobalOrdinal> &indices,
145  const Teuchos::ArrayView<const Scalar> &values);
146 
147  private:
148  crs_matrix_type &crsmat_;
149 };
150 
151 template <class Scalar = ::Tpetra::Details::DefaultTypes::scalar_type,
153  class GlobalOrdinal = ::Tpetra::Details::DefaultTypes::global_ordinal_type,
154  class Node = ::Tpetra::Details::DefaultTypes::node_type>
155 class CrsWrapper_GraphBuilder : public CrsWrapper<Scalar, LocalOrdinal, GlobalOrdinal, Node> {
156  public:
157  typedef Map<LocalOrdinal, GlobalOrdinal, Node> map_type;
158 
159  CrsWrapper_GraphBuilder(const Teuchos::RCP<const map_type> &map);
160  virtual ~CrsWrapper_GraphBuilder();
161 
162  Teuchos::RCP<const map_type> getRowMap() const {
163  return rowmap_;
164  }
165 
166  bool isFillComplete();
167  void
168  insertGlobalValues(GlobalOrdinal globalRow,
169  const Teuchos::ArrayView<const GlobalOrdinal> &indices,
170  const Teuchos::ArrayView<const Scalar> &values);
171  void
172  sumIntoGlobalValues(GlobalOrdinal globalRow,
173  const Teuchos::ArrayView<const GlobalOrdinal> &indices,
174  const Teuchos::ArrayView<const Scalar> &values);
175 
176  std::map<GlobalOrdinal, std::set<GlobalOrdinal> *> &get_graph();
177 
178  size_t get_max_row_length() {
179  return max_row_length_;
180  }
181 
182  private:
183  std::map<GlobalOrdinal, std::set<GlobalOrdinal> *> graph_;
184  const Teuchos::RCP<const map_type> &rowmap_;
185  global_size_t max_row_length_;
186 };
187 
188 template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
189 void insert_matrix_locations(CrsWrapper_GraphBuilder<Scalar, LocalOrdinal, GlobalOrdinal, Node> &graphbuilder,
190  CrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node> &C);
191 
192 } // namespace Tpetra
193 #endif // TPETRA_MMHELPERS_DECL_HPP
Teuchos::RCP< const map_type > importColMap
Colmap garnered as a result of the import.
Sparse matrix that presents a row-oriented interface that lets users read or modify entries...
Sparse matrix whose entries are small dense square blocks, all of the same dimensions.
Teuchos::RCP< const map_type > domainMap
Domain map for original matrix.
Teuchos::RCP< const map_type > colMap
Col map for the original version of the matrix.
Teuchos::RCP< const CrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > > origMatrix
The original matrix.
Teuchos::RCP< BlockCrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > > importMatrix
The imported matrix.
int local_ordinal_type
Default value of Scalar template parameter.
Teuchos::RCP< const map_type > importColMap
Colmap garnered as a result of the import.
size_t global_size_t
Global size_t object.
Teuchos::RCP< CrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > > importMatrix
The imported matrix.
Struct that holds views of the contents of a BlockCrsMatrix.
Teuchos::RCP< const map_type > origRowMap
Original row map of matrix.
Teuchos::RCP< const map_type > rowMap
Desired row map for &quot;imported&quot; version of the matrix.
const LocalOrdinal blocksize
The blocksize of all matrices.
A parallel distribution of indices over processes.
Teuchos::RCP< const map_type > rowMap
Desired row map for &quot;imported&quot; version of the matrix.
Struct that holds views of the contents of a CrsMatrix.
Teuchos::RCP< const BlockCrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > > origMatrix
The original matrix.
Teuchos::RCP< const map_type > colMap
Col map for the original version of the matrix.
Teuchos::RCP< const map_type > origRowMap
Original row map of matrix.
Teuchos::RCP< const map_type > domainMap
Domain map for original matrix.