Tpetra parallel linear algebra  Version of the Day
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 
78 
89 
92 
95 
98 
101 
104 
111 
114 
117 
120 
123 
126 
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.
typename device_type::execution_space execution_space
The Kokkos execution space.
CrsGraph< LocalOrdinal, GlobalOrdinal, Node > crs_graph_type
The CrsGraph specialization suitable for this CrsMatrix specialization.
Node node_type
This class' Kokkos Node type.
GlobalOrdinal global_ordinal_type
The type of each global index in the matrix.
KokkosSparse::CrsMatrix< impl_scalar_type, local_ordinal_type, execution_space, void, typename local_graph_type::size_type > local_matrix_type
The specialization of Kokkos::CrsMatrix that represents the part of the sparse matrix on each MPI pro...
typename crs_graph_type::local_graph_type local_graph_type
The part of the sparse matrix's graph on each MPI process.
typename Kokkos::ArithTraits< Scalar >::val_type impl_scalar_type
The type used internally in place of Scalar.
Map< LocalOrdinal, GlobalOrdinal, Node > map_type
The Map specialization suitable for this CrsMatrix specialization.
typename Node::device_type device_type
The Kokkos device type.
Scalar scalar_type
The type of each entry in the matrix.
LocalOrdinal local_ordinal_type
The type of each local index in the matrix.
Export< LocalOrdinal, GlobalOrdinal, Node > export_type
The Export specialization suitable for this CrsMatrix specialization.
typename Kokkos::ArithTraits< impl_scalar_type >::mag_type mag_type
Type of a norm result.
CrsMatrix(const CrsMatrix< ::Tpetra::Details::DefaultTypes::scalar_type, ::Tpetra::Details::DefaultTypes::local_ordinal_type, ::Tpetra::Details::DefaultTypes::global_ordinal_type, ::Tpetra::Details::DefaultTypes::node_type > &)=default
Copy constructor.
Import< LocalOrdinal, GlobalOrdinal, Node > import_type
The Import specialization suitable for this CrsMatrix specialization.
int local_ordinal_type
Default value of Scalar template parameter.
::Kokkos::Compat::KokkosDeviceWrapperNode< execution_space > node_type
Default value of Node template parameter.
Namespace Tpetra contains the class and methods constituting the Tpetra library.
CombineMode
Rule for combining data in an Import or Export.
@ ADD
Sum new values into existing values.