Tpetra parallel linear algebra  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Tpetra_FECrsMatrix_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 #ifndef TPETRA_FECRSMATRIX_DECL_HPP
42 #define TPETRA_FECRSMATRIX_DECL_HPP
43 
44 
52 
54 #include "Tpetra_FECrsGraph.hpp"
55 
56 namespace Tpetra {
57 
58 
59 
60 // \class FECrsMatrix
61 // \brief Sparse matrix that presents a row-oriented interface that lets
62 // users read or modify entries.
63 template<class Scalar = ::Tpetra::Details::DefaultTypes::scalar_type,
65  class GlobalOrdinal = ::Tpetra::Details::DefaultTypes::global_ordinal_type,
67 class FECrsMatrix :
68  public CrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node>
69 {
70  friend class CrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node>;
71 public:
73 
74 
77  typedef typename CrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node>::scalar_type scalar_type;
78 
88  typedef typename CrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node>::impl_scalar_type impl_scalar_type;
89 
91  typedef typename CrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node>::local_ordinal_type local_ordinal_type;
92 
94  typedef typename CrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node>::global_ordinal_type global_ordinal_type;
95 
97  typedef typename CrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node>::node_type node_type;
98 
100  typedef typename CrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node>::device_type device_type;
101 
103  typedef typename CrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node>::execution_space execution_space;
104 
110  typedef typename CrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node>::mag_type mag_type;
111 
113  typedef typename CrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node>::map_type map_type;
114 
116  typedef typename CrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node>::import_type import_type;
117 
119  typedef typename CrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node>::export_type export_type;
120 
122  typedef typename CrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node>::crs_graph_type crs_graph_type;
123 
125  typedef typename CrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node>::local_graph_type local_graph_type;
126 
129  typedef typename CrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node>::local_matrix_type local_matrix_type;
130 
132  typedef CrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node> crs_matrix_type;
133 
135  typedef FECrsGraph<LocalOrdinal, GlobalOrdinal, Node> fe_crs_graph_type;
136 
138 
140 
141 
166  explicit FECrsMatrix (const Teuchos::RCP<const fe_crs_graph_type>& graph,
167  const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
168 
170  FECrsMatrix (const FECrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node>&) = delete;
171 
173  FECrsMatrix (FECrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node>&&) = delete;
174 
176  FECrsMatrix&
177  operator= (const FECrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node>&) = delete;
179  FECrsMatrix&
180  operator= (FECrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node>&&) = delete;
181 
191  virtual ~FECrsMatrix () = default;
192 
194 
195 
224  void globalAssemble () {endFill();}
225 
227  void endFill();
228 
230  void beginFill();
231 
232  protected:
236  void doOwnedPlusSharedToOwned(const CombineMode CM=Tpetra::ADD);
237 
240  void doOwnedToOwnedPlusShared(const CombineMode CM=Tpetra::ADD);
241 
243  void switchActiveCrsMatrix();
245 
246  private:
247  // Enum for activity
248  enum FEWhichActive
249  {
250  FE_ACTIVE_OWNED,
251  FE_ACTIVE_OWNED_PLUS_SHARED
252  };
253 
254  // The FECrsGraph from construction time
255  Teuchos::RCP<const FECrsGraph<LocalOrdinal, GlobalOrdinal, Node> > feGraph_;
256 
257  // This is whichever multivector isn't currently active
258  Teuchos::RCP<CrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node> > inactiveCrsMatrix_;
259  // This is in RCP to make shallow copies of the FECrsMatrix work correctly
260  Teuchos::RCP<FEWhichActive> activeCrsMatrix_;
261 
262 }; // end class FECrsMatrix
263 
264 
265 
266 } // end namespace Tpetra
267 
268 
269 
270 #endif // TPETRA_FECRSMATRIX_DECL_HPP
Declaration of the Tpetra::CrsMatrix class.
int local_ordinal_type
Default value of Scalar template parameter.
CombineMode
Rule for combining data in an Import or Export.
Sum new values into existing values.
::Kokkos::Compat::KokkosDeviceWrapperNode< execution_space > node_type
Default value of Node template parameter.
CrsMatrix(const CrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > &)=default
Copy constructor.