Tpetra parallel linear algebra Version of the Day
Loading...
Searching...
No Matches
TpetraExt_MMHelpers_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// Questions? Contact Michael A. Heroux (maherou@sandia.gov)
38//
39// ************************************************************************
40// @HEADER
41
42
43#ifndef TPETRA_MMHELPERS_DECL_HPP
44#define TPETRA_MMHELPERS_DECL_HPP
45
46#include <Tpetra_CrsMatrix.hpp>
47#include <Tpetra_BlockCrsMatrix.hpp>
48#include <Teuchos_Array.hpp>
49#include <map>
50#include <set>
51
57
58namespace Tpetra {
59
65template <class Scalar = ::Tpetra::Details::DefaultTypes::scalar_type,
67 class GlobalOrdinal = ::Tpetra::Details::DefaultTypes::global_ordinal_type,
68 class Node = ::Tpetra::Details::DefaultTypes::node_type>
70public:
73
75
76 virtual ~CrsMatrixStruct ();
77
78 void deleteContents ();
79
81 Teuchos::RCP<const map_type> origRowMap;
83 Teuchos::RCP<const map_type> rowMap;
85 Teuchos::RCP<const map_type> colMap;
87 Teuchos::RCP<const map_type> domainMap;
89 Teuchos::RCP<const map_type> importColMap;
91 Teuchos::RCP<CrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node> > importMatrix;
93 Teuchos::RCP<const CrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node> > origMatrix;
94
95};
96
102template <class Scalar = ::Tpetra::Details::DefaultTypes::scalar_type,
104 class GlobalOrdinal = ::Tpetra::Details::DefaultTypes::global_ordinal_type,
105 class Node = ::Tpetra::Details::DefaultTypes::node_type>
107public:
110
112
113 virtual ~BlockCrsMatrixStruct ();
114
115 void deleteContents ();
116
118 Teuchos::RCP<const map_type> origRowMap;
120 Teuchos::RCP<const map_type> rowMap;
122 Teuchos::RCP<const map_type> colMap;
124 Teuchos::RCP<const map_type> domainMap;
126 Teuchos::RCP<const map_type> importColMap;
128 Teuchos::RCP<BlockCrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node> > importMatrix;
130 Teuchos::RCP<const BlockCrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node> > origMatrix;
133};
134
135template<class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
136int
138
139
140template<class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
141class CrsWrapper {
142public:
144
145 virtual ~CrsWrapper () {}
146 virtual Teuchos::RCP<const map_type> getRowMap () const = 0;
147 virtual bool isFillComplete () = 0;
148
149 virtual void
150 insertGlobalValues (GlobalOrdinal globalRow,
151 const Teuchos::ArrayView<const GlobalOrdinal> &indices,
152 const Teuchos::ArrayView<const Scalar> &values) = 0;
153 virtual void
154 sumIntoGlobalValues (GlobalOrdinal globalRow,
155 const Teuchos::ArrayView<const GlobalOrdinal> &indices,
156 const Teuchos::ArrayView<const Scalar> &values) = 0;
157};
158
159template <class Scalar = ::Tpetra::Details::DefaultTypes::scalar_type,
161 class GlobalOrdinal = ::Tpetra::Details::DefaultTypes::global_ordinal_type,
162 class Node = ::Tpetra::Details::DefaultTypes::node_type>
163class CrsWrapper_CrsMatrix :
164 public CrsWrapper<Scalar, LocalOrdinal, GlobalOrdinal, Node> {
165public:
166 typedef Map<LocalOrdinal, GlobalOrdinal, Node> map_type;
167 typedef CrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node> crs_matrix_type;
168
169 CrsWrapper_CrsMatrix (crs_matrix_type& crsmatrix);
170 virtual ~CrsWrapper_CrsMatrix ();
171 Teuchos::RCP<const map_type> getRowMap () const;
172
173 bool isFillComplete ();
174
175 void
176 insertGlobalValues (GlobalOrdinal globalRow,
177 const Teuchos::ArrayView<const GlobalOrdinal> &indices,
178 const Teuchos::ArrayView<const Scalar> &values);
179 void
180 sumIntoGlobalValues (GlobalOrdinal globalRow,
181 const Teuchos::ArrayView<const GlobalOrdinal> &indices,
182 const Teuchos::ArrayView<const Scalar> &values);
183private:
184 crs_matrix_type& crsmat_;
185};
186
187template <class Scalar = ::Tpetra::Details::DefaultTypes::scalar_type,
189 class GlobalOrdinal = ::Tpetra::Details::DefaultTypes::global_ordinal_type,
190 class Node = ::Tpetra::Details::DefaultTypes::node_type>
191class CrsWrapper_GraphBuilder :
192 public CrsWrapper<Scalar, LocalOrdinal, GlobalOrdinal, Node> {
193public:
194 typedef Map<LocalOrdinal, GlobalOrdinal, Node> map_type;
195
196 CrsWrapper_GraphBuilder (const Teuchos::RCP<const map_type>& map);
197 virtual ~CrsWrapper_GraphBuilder ();
198
199 Teuchos::RCP<const map_type> getRowMap () const {
200 return rowmap_;
201 }
202
203 bool isFillComplete ();
204 void
205 insertGlobalValues (GlobalOrdinal globalRow,
206 const Teuchos::ArrayView<const GlobalOrdinal> &indices,
207 const Teuchos::ArrayView<const Scalar> &values);
208 void
209 sumIntoGlobalValues (GlobalOrdinal globalRow,
210 const Teuchos::ArrayView<const GlobalOrdinal> &indices,
211 const Teuchos::ArrayView<const Scalar> &values);
212
213 std::map<GlobalOrdinal, std::set<GlobalOrdinal>*>& get_graph ();
214
215 size_t get_max_row_length () {
216 return max_row_length_;
217 }
218
219 private:
220 std::map<GlobalOrdinal, std::set<GlobalOrdinal>*> graph_;
221 const Teuchos::RCP<const map_type>& rowmap_;
222 global_size_t max_row_length_;
223};
224
225template<class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
226void
227insert_matrix_locations (CrsWrapper_GraphBuilder<Scalar, LocalOrdinal, GlobalOrdinal, Node>& graphbuilder,
228 CrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node>& C);
229
230} // namespace Tpetra
231#endif // TPETRA_MMHELPERS_DECL_HPP
232
Struct that holds views of the contents of a BlockCrsMatrix.
Teuchos::RCP< const map_type > importColMap
Colmap garnered as a result of the import.
Teuchos::RCP< BlockCrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > > importMatrix
The imported matrix.
Teuchos::RCP< const map_type > colMap
Col map for the original version of the matrix.
Teuchos::RCP< const map_type > domainMap
Domain map for original matrix.
Teuchos::RCP< const BlockCrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > > origMatrix
The original matrix.
Teuchos::RCP< const map_type > rowMap
Desired row map for "imported" version of the matrix.
const LocalOrdinal blocksize
The blocksize of all matrices.
Teuchos::RCP< const map_type > origRowMap
Original row map of matrix.
Struct that holds views of the contents of a CrsMatrix.
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< const map_type > importColMap
Colmap garnered as a result of the import.
Teuchos::RCP< CrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > > importMatrix
The imported matrix.
Teuchos::RCP< const map_type > domainMap
Domain map for original matrix.
Teuchos::RCP< const map_type > rowMap
Desired row map for "imported" version of the matrix.
Teuchos::RCP< const map_type > origRowMap
Original row map of matrix.
Sparse matrix that presents a row-oriented interface that lets users read or modify entries.
int local_ordinal_type
Default value of Scalar template parameter.
Namespace Tpetra contains the class and methods constituting the Tpetra library.
size_t global_size_t
Global size_t object.