Amesos2 - Direct Sparse Solver Interfaces Version of the Day
Amesos2_Umfpack_decl.hpp
1// @HEADER
2//
3// ***********************************************************************
4//
5// Amesos2: Templated Direct Sparse Solver Package
6// Copyright 2011 Sandia Corporation
7//
8// Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
9// the U.S. Government retains certain rights in this software.
10//
11// Redistribution and use in source and binary forms, with or without
12// modification, are permitted provided that the following conditions are
13// met:
14//
15// 1. Redistributions of source code must retain the above copyright
16// notice, this list of conditions and the following disclaimer.
17//
18// 2. Redistributions in binary form must reproduce the above copyright
19// notice, this list of conditions and the following disclaimer in the
20// documentation and/or other materials provided with the distribution.
21//
22// 3. Neither the name of the Corporation nor the names of the
23// contributors may be used to endorse or promote products derived from
24// this software without specific prior written permission.
25//
26// THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
27// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
30// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
31// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
32// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
33// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
34// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
35// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
36// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37//
38// Questions? Contact Sivasankaran Rajamanickam (srajama@sandia.gov)
39//
40// ***********************************************************************
41//
42// @HEADER
43
44#ifndef AMESOS2_UMFPACK_DECL_HPP
45#define AMESOS2_UMFPACK_DECL_HPP
46
48#include "Amesos2_SolverCore.hpp"
49#include "Amesos2_Umfpack_FunctionMap.hpp"
50
51namespace Amesos2 {
52
53
61template <class Matrix,
62 class Vector>
63class Umfpack : public SolverCore<Amesos2::Umfpack, Matrix, Vector>
64{
65 friend class SolverCore<Amesos2::Umfpack,Matrix,Vector>; // Give our base access
66 // to our private
67 // implementation funcs
68public:
69
71 static const char* name; // declaration. Initialization outside.
72
73 typedef Umfpack<Matrix,Vector> type;
74 typedef SolverCore<Amesos2::Umfpack,Matrix,Vector> super_type;
75
76 // Since typedef's are not inheritted, go grab them
77 typedef typename super_type::scalar_type scalar_type;
78 typedef typename super_type::local_ordinal_type local_ordinal_type;
79 typedef typename super_type::global_ordinal_type global_ordinal_type;
80 typedef typename super_type::global_size_type global_size_type;
81
82 typedef TypeMap<Amesos2::Umfpack,scalar_type> type_map;
83
84 /*
85 * The Umfpack interface will need two other typedef's, which are:
86 * - the umfpack type that corresponds to scalar_type and
87 * - the corresponding type to use for magnitude
88 */
89 typedef typename type_map::type umfpack_type;
90 typedef typename type_map::magnitude_type magnitude_type;
91
92 typedef FunctionMap<Amesos2::Umfpack,umfpack_type> function_map;
93
95
96
103 Umfpack(Teuchos::RCP<const Matrix> A,
104 Teuchos::RCP<Vector> X,
105 Teuchos::RCP<const Vector> B);
106
107
109 ~Umfpack( );
110
112
114 std::string description() const;
115
116private:
117
123 int preOrdering_impl();
124
125
134
135
142
154 int solve_impl(const Teuchos::Ptr<MultiVecAdapter<Vector> > X,
155 const Teuchos::Ptr<const MultiVecAdapter<Vector> > B) const;
156
157
161 bool matrixShapeOK_impl() const;
162
163
166 void setParameters_impl(
167 const Teuchos::RCP<Teuchos::ParameterList> & parameterList );
168
169
176 Teuchos::RCP<const Teuchos::ParameterList> getValidParameters_impl() const;
177
178
187 bool loadA_impl(EPhase current_phase);
188
189 // struct holds all data necessary to make a umfpack factorization or solve call
190 mutable struct UMFPACKData {
191 // Umfpack internal opaque object
192 void *Symbolic;
193 void *Numeric;
194
195 // Info and Control state
196 double Info[UMFPACK_INFO];
197 double Control[UMFPACK_CONTROL];
198 } data_;
199
200 // The following Arrays are persisting storage arrays for A, X, and B
202 Teuchos::Array<umfpack_type> nzvals_;
204 Teuchos::Array<int> rowind_;
206 Teuchos::Array<int> colptr_;
207
209 Teuchos::Array<umfpack_type> xvals_; int ldx_;
211 Teuchos::Array<umfpack_type> bvals_; int ldb_;
212
213 bool is_contiguous_;
214}; // End class Umfpack
215
216
217// Specialize solver_traits struct for Umfpack
218template <>
219struct solver_traits<Umfpack> {
220#ifdef HAVE_TEUCHOS_COMPLEX
221 typedef Meta::make_list4<float,
222 double,
223 std::complex<float>,
224 std::complex<double>
225 >supported_scalars;
226#else
227 typedef Meta::make_list2<float,
228 double
229 >supported_scalars;
230#endif
231};
232
233} // end namespace Amesos2
234
235#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:106
Interface to Amesos2 solver objects.
Definition: Amesos2_Solver_decl.hpp:78
Amesos2 interface to the Umfpack package.
Definition: Amesos2_Umfpack_decl.hpp:64
bool loadA_impl(EPhase current_phase)
Reads matrix data into internal structures.
Definition: Amesos2_Umfpack_def.hpp:289
Teuchos::Array< int > colptr_
Stores the row indices of the nonzero entries.
Definition: Amesos2_Umfpack_decl.hpp:206
Teuchos::Array< int > rowind_
Stores the location in Ai_ and Aval_ that starts row j.
Definition: Amesos2_Umfpack_decl.hpp:204
static const char * name
Name of this solver interface.
Definition: Amesos2_Umfpack_decl.hpp:71
int numericFactorization_impl()
Umfpack specific numeric factorization.
Definition: Amesos2_Umfpack_def.hpp:121
Teuchos::Array< umfpack_type > bvals_
Persisting 1D store for B.
Definition: Amesos2_Umfpack_decl.hpp:211
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:145
Teuchos::Array< umfpack_type > xvals_
Persisting 1D store for X.
Definition: Amesos2_Umfpack_decl.hpp:209
Teuchos::Array< umfpack_type > nzvals_
Stores the values of the nonzero entries for Umfpack.
Definition: Amesos2_Umfpack_decl.hpp:202
std::string description() const
Returns a short description of this Solver.
Definition: Amesos2_Umfpack_def.hpp:82
int preOrdering_impl()
Performs pre-ordering on the matrix to increase efficiency.
Definition: Amesos2_Umfpack_def.hpp:91
int symbolicFactorization_impl()
Perform symbolic factorization of the matrix using Umfpack.
Definition: Amesos2_Umfpack_def.hpp:99
bool matrixShapeOK_impl() const
Determines whether the shape of the matrix is OK for this solver.
Definition: Amesos2_Umfpack_def.hpp:244
Teuchos::RCP< const Teuchos::ParameterList > getValidParameters_impl() const
Definition: Amesos2_Umfpack_def.hpp:271
Passes functions to TPL functions based on type.
Definition: Amesos2_FunctionMap.hpp:77
Map types to solver-specific data-types and enums.
Definition: Amesos2_TypeMap.hpp:82
Provides traits about solvers.
Definition: Amesos2_SolverTraits.hpp:71