Amesos2 - Direct Sparse Solver Interfaces Version of the Day
Amesos2_Umfpack_decl.hpp
1// @HEADER
2// *****************************************************************************
3// Amesos2: Templated Direct Sparse Solver Package
4//
5// Copyright 2011 NTESS and the Amesos2 contributors.
6// SPDX-License-Identifier: BSD-3-Clause
7// *****************************************************************************
8// @HEADER
9
10#ifndef AMESOS2_UMFPACK_DECL_HPP
11#define AMESOS2_UMFPACK_DECL_HPP
12
14#include "Amesos2_SolverCore.hpp"
15#include "Amesos2_Umfpack_FunctionMap.hpp"
16
17namespace Amesos2 {
18
19
27template <class Matrix,
28 class Vector>
29class Umfpack : public SolverCore<Amesos2::Umfpack, Matrix, Vector>
30{
31 friend class SolverCore<Amesos2::Umfpack,Matrix,Vector>; // Give our base access
32 // to our private
33 // implementation funcs
34public:
35
37 static const char* name; // declaration. Initialization outside.
38
39 typedef Umfpack<Matrix,Vector> type;
40 typedef SolverCore<Amesos2::Umfpack,Matrix,Vector> super_type;
41
42 // Since typedef's are not inheritted, go grab them
43 typedef typename super_type::scalar_type scalar_type;
44 typedef typename super_type::local_ordinal_type local_ordinal_type;
45 typedef typename super_type::global_ordinal_type global_ordinal_type;
46 typedef typename super_type::global_size_type global_size_type;
47
48 typedef TypeMap<Amesos2::Umfpack,scalar_type> type_map;
49
50 /*
51 * The Umfpack interface will need two other typedef's, which are:
52 * - the umfpack type that corresponds to scalar_type and
53 * - the corresponding type to use for magnitude
54 */
55 typedef typename type_map::type umfpack_type;
56 typedef typename type_map::magnitude_type magnitude_type;
57
58 typedef FunctionMap<Amesos2::Umfpack,umfpack_type> function_map;
59
60 typedef Kokkos::DefaultHostExecutionSpace HostExecSpaceType;
61 typedef Kokkos::View<int*, HostExecSpaceType> host_size_type_array;
62 typedef Kokkos::View<int*, HostExecSpaceType> host_ordinal_type_array;
63 typedef Kokkos::View<umfpack_type*, HostExecSpaceType> host_value_type_array;
64
66
67
74 Umfpack(Teuchos::RCP<const Matrix> A,
75 Teuchos::RCP<Vector> X,
76 Teuchos::RCP<const Vector> B);
77
78
80 ~Umfpack( );
81
83
85 std::string description() const;
86
87private:
88
94 int preOrdering_impl();
95
96
105
106
113
125 int solve_impl(const Teuchos::Ptr<MultiVecAdapter<Vector> > X,
126 const Teuchos::Ptr<const MultiVecAdapter<Vector> > B) const;
127
128
132 bool matrixShapeOK_impl() const;
133
134
137 void setParameters_impl(
138 const Teuchos::RCP<Teuchos::ParameterList> & parameterList );
139
140
147 Teuchos::RCP<const Teuchos::ParameterList> getValidParameters_impl() const;
148
149
158 bool loadA_impl(EPhase current_phase);
159
160 // struct holds all data necessary to make a umfpack factorization or solve call
161 mutable struct UMFPACKData {
162 // Umfpack internal opaque object
163 void *Symbolic;
164 void *Numeric;
165
166 // Info and Control state
167 double Info[UMFPACK_INFO];
168 double Control[UMFPACK_CONTROL];
169 } data_;
170
171 // The following Kokkos::View's are persisting storage for A's CCS arrays
173 host_value_type_array nzvals_view_;
175 host_ordinal_type_array rowind_view_;
177 host_size_type_array colptr_view_;
178
179 // The following Arrays are persisting storage arrays for X, and B
181 Teuchos::Array<umfpack_type> xvals_; int ldx_;
183 Teuchos::Array<umfpack_type> bvals_; int ldb_;
184
185 bool is_contiguous_;
186}; // End class Umfpack
187
188
189// Specialize solver_traits struct for Umfpack
190template <>
191struct solver_traits<Umfpack> {
192#ifdef HAVE_TEUCHOS_COMPLEX
193 typedef Meta::make_list4<float,
194 double,
195 std::complex<float>,
196 std::complex<double>
197 >supported_scalars;
198#else
199 typedef Meta::make_list2<float,
200 double
201 >supported_scalars;
202#endif
203};
204
205} // end namespace Amesos2
206
207#endif // AMESOS2_UMFPACK_DECL_HPP
Provides access to interesting solver traits.
Amesos2::SolverCore: A templated interface for interaction with third-party direct sparse solvers.
Definition Amesos2_SolverCore_decl.hpp:72
Amesos2 interface to the Umfpack package.
Definition Amesos2_Umfpack_decl.hpp:30
bool loadA_impl(EPhase current_phase)
Reads matrix data into internal structures.
Definition Amesos2_Umfpack_def.hpp:232
static const char * name
Name of this solver interface.
Definition Amesos2_Umfpack_decl.hpp:37
int numericFactorization_impl()
Umfpack specific numeric factorization.
Definition Amesos2_Umfpack_def.hpp:84
host_size_type_array colptr_view_
Stores the row indices of the nonzero entries.
Definition Amesos2_Umfpack_decl.hpp:177
Teuchos::Array< umfpack_type > bvals_
Persisting 1D store for B.
Definition Amesos2_Umfpack_decl.hpp:183
host_value_type_array nzvals_view_
Stores the values of the nonzero entries for Umfpack.
Definition Amesos2_Umfpack_decl.hpp:173
host_ordinal_type_array rowind_view_
Stores the location in Ai_ and Aval_ that starts row j.
Definition Amesos2_Umfpack_decl.hpp:175
int solve_impl(const Teuchos::Ptr< MultiVecAdapter< Vector > > X, const Teuchos::Ptr< const MultiVecAdapter< Vector > > B) const
Umfpack specific solve.
Definition Amesos2_Umfpack_def.hpp:108
Teuchos::Array< umfpack_type > xvals_
Persisting 1D store for X.
Definition Amesos2_Umfpack_decl.hpp:181
std::string description() const
Returns a short description of this Solver.
Definition Amesos2_Umfpack_def.hpp:45
int preOrdering_impl()
Performs pre-ordering on the matrix to increase efficiency.
Definition Amesos2_Umfpack_def.hpp:54
int symbolicFactorization_impl()
Perform symbolic factorization of the matrix using Umfpack.
Definition Amesos2_Umfpack_def.hpp:62
bool matrixShapeOK_impl() const
Determines whether the shape of the matrix is OK for this solver.
Definition Amesos2_Umfpack_def.hpp:187
Teuchos::RCP< const Teuchos::ParameterList > getValidParameters_impl() const
Definition Amesos2_Umfpack_def.hpp:214
Passes functions to TPL functions based on type.
Definition Amesos2_FunctionMap.hpp:43
Map types to solver-specific data-types and enums.
Definition Amesos2_TypeMap.hpp:48
Provides traits about solvers.
Definition Amesos2_SolverTraits.hpp:37