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 
41  CrsMatrixStruct ();
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 };
63 
69 template <class Scalar = ::Tpetra::Details::DefaultTypes::scalar_type,
71  class GlobalOrdinal = ::Tpetra::Details::DefaultTypes::global_ordinal_type,
72  class Node = ::Tpetra::Details::DefaultTypes::node_type>
74 public:
77 
78  BlockCrsMatrixStruct (const LocalOrdinal blocksize_);
79 
80  virtual ~BlockCrsMatrixStruct ();
81 
82  void deleteContents ();
83 
85  Teuchos::RCP<const map_type> origRowMap;
87  Teuchos::RCP<const map_type> rowMap;
89  Teuchos::RCP<const map_type> colMap;
91  Teuchos::RCP<const map_type> domainMap;
93  Teuchos::RCP<const map_type> importColMap;
95  Teuchos::RCP<BlockCrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node> > importMatrix;
97  Teuchos::RCP<const BlockCrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node> > origMatrix;
99  const LocalOrdinal blocksize;
100 };
101 
102 template<class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
103 int
105 
106 
107 template<class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
108 class CrsWrapper {
109 public:
111 
112  virtual ~CrsWrapper () {}
113  virtual Teuchos::RCP<const map_type> getRowMap () const = 0;
114  virtual bool isFillComplete () = 0;
115 
116  virtual void
117  insertGlobalValues (GlobalOrdinal globalRow,
118  const Teuchos::ArrayView<const GlobalOrdinal> &indices,
119  const Teuchos::ArrayView<const Scalar> &values) = 0;
120  virtual void
121  sumIntoGlobalValues (GlobalOrdinal globalRow,
122  const Teuchos::ArrayView<const GlobalOrdinal> &indices,
123  const Teuchos::ArrayView<const Scalar> &values) = 0;
124 };
125 
126 template <class Scalar = ::Tpetra::Details::DefaultTypes::scalar_type,
128  class GlobalOrdinal = ::Tpetra::Details::DefaultTypes::global_ordinal_type,
129  class Node = ::Tpetra::Details::DefaultTypes::node_type>
130 class CrsWrapper_CrsMatrix :
131  public CrsWrapper<Scalar, LocalOrdinal, GlobalOrdinal, Node> {
132 public:
133  typedef Map<LocalOrdinal, GlobalOrdinal, Node> map_type;
134  typedef CrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node> crs_matrix_type;
135 
136  CrsWrapper_CrsMatrix (crs_matrix_type& crsmatrix);
137  virtual ~CrsWrapper_CrsMatrix ();
138  Teuchos::RCP<const map_type> getRowMap () const;
139 
140  bool isFillComplete ();
141 
142  void
143  insertGlobalValues (GlobalOrdinal globalRow,
144  const Teuchos::ArrayView<const GlobalOrdinal> &indices,
145  const Teuchos::ArrayView<const Scalar> &values);
146  void
147  sumIntoGlobalValues (GlobalOrdinal globalRow,
148  const Teuchos::ArrayView<const GlobalOrdinal> &indices,
149  const Teuchos::ArrayView<const Scalar> &values);
150 private:
151  crs_matrix_type& crsmat_;
152 };
153 
154 template <class Scalar = ::Tpetra::Details::DefaultTypes::scalar_type,
156  class GlobalOrdinal = ::Tpetra::Details::DefaultTypes::global_ordinal_type,
157  class Node = ::Tpetra::Details::DefaultTypes::node_type>
158 class CrsWrapper_GraphBuilder :
159  public CrsWrapper<Scalar, LocalOrdinal, GlobalOrdinal, Node> {
160 public:
161  typedef Map<LocalOrdinal, GlobalOrdinal, Node> map_type;
162 
163  CrsWrapper_GraphBuilder (const Teuchos::RCP<const map_type>& map);
164  virtual ~CrsWrapper_GraphBuilder ();
165 
166  Teuchos::RCP<const map_type> getRowMap () const {
167  return rowmap_;
168  }
169 
170  bool isFillComplete ();
171  void
172  insertGlobalValues (GlobalOrdinal globalRow,
173  const Teuchos::ArrayView<const GlobalOrdinal> &indices,
174  const Teuchos::ArrayView<const Scalar> &values);
175  void
176  sumIntoGlobalValues (GlobalOrdinal globalRow,
177  const Teuchos::ArrayView<const GlobalOrdinal> &indices,
178  const Teuchos::ArrayView<const Scalar> &values);
179 
180  std::map<GlobalOrdinal, std::set<GlobalOrdinal>*>& get_graph ();
181 
182  size_t get_max_row_length () {
183  return max_row_length_;
184  }
185 
186  private:
187  std::map<GlobalOrdinal, std::set<GlobalOrdinal>*> graph_;
188  const Teuchos::RCP<const map_type>& rowmap_;
189  global_size_t max_row_length_;
190 };
191 
192 template<class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
193 void
194 insert_matrix_locations (CrsWrapper_GraphBuilder<Scalar, LocalOrdinal, GlobalOrdinal, Node>& graphbuilder,
195  CrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node>& C);
196 
197 } // namespace Tpetra
198 #endif // TPETRA_MMHELPERS_DECL_HPP
199 
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.