Amesos2 - Direct Sparse Solver Interfaces Version of the Day
Amesos2_MUMPS_decl.hpp
Go to the documentation of this file.
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 Michael A. Heroux (maherou@sandia.gov)
39//
40// ***********************************************************************
41//
42// @HEADER
43
52#ifndef AMESOS2_MUMPS_DECL_HPP
53#define AMESOS2_MUMPS_DECL_HPP
54
56#include "Amesos2_SolverCore.hpp"
58
59
60namespace Amesos2 {
61
62
83template <class Matrix,class Vector>
84class MUMPS : public SolverCore<Amesos2::MUMPS, Matrix, Vector>
85{
86 friend class SolverCore<Amesos2::MUMPS,Matrix,Vector>; // Give our base access
87 // to our private
88 // implementation funcs
89public:
90
92 static const char* name; // declaration. Initialization outside.
93
94 typedef MUMPS<Matrix,Vector> type;
95 typedef SolverCore<Amesos2::MUMPS,Matrix,Vector> super_type;
96
97 // Since typedef's are not inheritted, go grab them
98 typedef typename super_type::scalar_type scalar_type;
99 typedef typename super_type::local_ordinal_type local_ordinal_type;
100 typedef typename super_type::global_ordinal_type global_ordinal_type;
101 typedef typename super_type::global_size_type global_size_type;
102
103 typedef TypeMap<Amesos2::MUMPS,scalar_type> type_map;
104
105 typedef typename type_map::type slu_type;
106 typedef typename type_map::magnitude_type magnitude_type;
107 typedef typename type_map::MUMPS_STRUC_C MUMPS_STRUC_C;
108
109 typedef FunctionMap<Amesos2::MUMPS,slu_type> function_map;
110
111 MUMPS(Teuchos::RCP<const Matrix> A,
112 Teuchos::RCP<Vector> X,
113 Teuchos::RCP<const Vector> B);
114 ~MUMPS( );
115
116
117private:
118
124 int preOrdering_impl();
125
126
127 int symbolicFactorization_impl();
128
129
136
137
149 int solve_impl(const Teuchos::Ptr<MultiVecAdapter<Vector> > X,
150 const Teuchos::Ptr<const MultiVecAdapter<Vector> > B) const;
151
152
156 bool matrixShapeOK_impl() const;
157
174 const Teuchos::RCP<Teuchos::ParameterList> & parameterList );
175
176
183 Teuchos::RCP<const Teuchos::ParameterList> getValidParameters_impl() const;
184
185
194 bool loadA_impl(EPhase current_phase);
195
196
197 int ConvertToTriplet();
198
199 void MUMPS_ERROR() const;
200
201#ifdef HAVE_MPI
202 MPI_Comm MUMPSComm;
203#endif
204
205
206 bool MUMPS_MATRIX_LOAD;
207 bool MUMPS_STRUCT;
208 mutable bool MUMPS_MATRIX_LOAD_PREORDERING;
209
210 // The following Arrays are persisting storage arrays for A, X, and B
212 Teuchos::Array<slu_type> nzvals_;
214 Teuchos::Array<local_ordinal_type> rowind_;
216 Teuchos::Array<local_ordinal_type> colptr_;
217
219 mutable Teuchos::Array<slu_type> xvals_; local_ordinal_type ldx_;
221 mutable Teuchos::Array<slu_type> bvals_; local_ordinal_type ldb_;
222
223 mutable MUMPS_STRUC_C mumps_par;
224
225 bool is_contiguous_;
226
227}; // End class MUMPS
228
229
230template <class Matrix,class Vector>
231class MUMPSNS : public SolverCore<Amesos2::MUMPS, Matrix, Vector>
232{
233 friend class SolverCore<Amesos2::MUMPS,Matrix,Vector>; // Give our base access
234 // to our private
235 // implementation funcs
236public:
237
238
239 MUMPSNS(Teuchos::RCP<const Matrix> A,
240 Teuchos::RCP<Vector> X,
241 Teuchos::RCP<const Vector> B);
242 /*
243 {
244 TEUCHOS_TEST_FOR_EXCEPTION(true, std::logic_error,
245 "This solver is not support for these types.");
246
247 }
248
249 */
250 ~MUMPSNS( )
251 {}
252
253
254private:
255
256 int preOrdering_impl()
257 {
258
259 TEUCHOS_TEST_FOR_EXCEPTION(true, std::logic_error,
260 "This solver is not support for these types.");
261
262 }
263
264 int symbolicFactorization_impl()
265 {
266
267 TEUCHOS_TEST_FOR_EXCEPTION(true, std::logic_error,
268 "This solver is not support for these types.");
269
270 }
271
272 int numericFactorization_impl()
273 {
274
275 TEUCHOS_TEST_FOR_EXCEPTION(true, std::logic_error,
276 "This solver is not support for these types.");
277
278 }
279
280 int solve_impl(const Teuchos::Ptr<MultiVecAdapter<Vector> > X,
281 const Teuchos::Ptr<const MultiVecAdapter<Vector> > B) const
282 {
283
284 TEUCHOS_TEST_FOR_EXCEPTION(true, std::logic_error,
285 "This solver is not support for these types.");
286
287 }
288
289 bool matrixShapeOK_impl() const
290 {
291
292 TEUCHOS_TEST_FOR_EXCEPTION(true, std::logic_error,
293 "This solver is not support for these types.");
294
295 }
296
297 void setParameters_impl(
298 const Teuchos::RCP<Teuchos::ParameterList> & parameterList )
299 {
300
301 TEUCHOS_TEST_FOR_EXCEPTION(true, std::logic_error,
302 "This solver is not support for these types.");
303
304 }
305
306 Teuchos::RCP<const Teuchos::ParameterList> getValidParameters_impl() const
307 {
308
309 TEUCHOS_TEST_FOR_EXCEPTION(true, std::logic_error,
310 "This solver is not support for these types.");
311
312 }
313
314
315 bool loadA_impl(EPhase current_phase)
316 {
317
318 TEUCHOS_TEST_FOR_EXCEPTION(true, std::logic_error,
319 "This solver is not support for these types.");
320
321 }
322
323
324 int ConvertToTriplet()
325 {
326
327 TEUCHOS_TEST_FOR_EXCEPTION(true, std::logic_error,
328 "This solver is not support for these types.");
329
330 }
331
332
333 void MUMPS_ERROR() const
334 {
335
336 TEUCHOS_TEST_FOR_EXCEPTION(true, std::logic_error,
337 "This solver is not support for these types.");
338
339 }
340
341
342#ifdef HAVE_MPI
343 MPI_Comm MUMPSComm;
344#endif
345
346 bool is_contiguous_;
347
348};
349
350
351
352// Specialize solver_traits struct for MUMPS
353// TODO
354template <>
355struct solver_traits<MUMPS> {
356#ifdef HAVE_TEUCHOS_COMPLEX
357 typedef Meta::make_list4<float,
358 double,
359 std::complex<float>,
360 std::complex<double> > supported_scalars;
361#else
362 typedef Meta::make_list2<float, double> supported_scalars;
363#endif
364};
365
366} // end namespace Amesos2
367
368#endif // AMESOS2_MUMPS_DECL_HPP
Provides a mechanism to map function calls to the correct Solver function based on the scalar type of...
Provides access to interesting solver traits.
Amesos2 interface to the MUMPS package.
Definition: Amesos2_MUMPS_decl.hpp:85
bool loadA_impl(EPhase current_phase)
Reads matrix data into internal structures.
Definition: Amesos2_MUMPS_def.hpp:387
bool matrixShapeOK_impl() const
Determines whether the shape of the matrix is OK for this solver.
Definition: Amesos2_MUMPS_def.hpp:307
int solve_impl(const Teuchos::Ptr< MultiVecAdapter< Vector > > X, const Teuchos::Ptr< const MultiVecAdapter< Vector > > B) const
MUMPS specific solve.
Definition: Amesos2_MUMPS_def.hpp:233
Teuchos::Array< slu_type > xvals_
Persisting 1D store for X.
Definition: Amesos2_MUMPS_decl.hpp:219
static const char * name
Name of this solver interface.
Definition: Amesos2_MUMPS_decl.hpp:92
Teuchos::Array< local_ordinal_type > colptr_
Stores the row indices of the nonzero entries.
Definition: Amesos2_MUMPS_decl.hpp:216
int numericFactorization_impl()
MUMPS specific numeric factorization.
Definition: Amesos2_MUMPS_def.hpp:203
Teuchos::Array< slu_type > nzvals_
Stores the values of the nonzero entries for MUMPS.
Definition: Amesos2_MUMPS_decl.hpp:212
int preOrdering_impl()
Performs pre-ordering on the matrix to increase efficiency.
Definition: Amesos2_MUMPS_def.hpp:174
Teuchos::Array< local_ordinal_type > rowind_
Stores the location in Ai_ and Aval_ that starts row j.
Definition: Amesos2_MUMPS_decl.hpp:214
Teuchos::RCP< const Teuchos::ParameterList > getValidParameters_impl() const
Definition: Amesos2_MUMPS_def.hpp:359
void setParameters_impl(const Teuchos::RCP< Teuchos::ParameterList > &parameterList)
Definition: Amesos2_MUMPS_def.hpp:316
Teuchos::Array< slu_type > bvals_
Persisting 1D store for B.
Definition: Amesos2_MUMPS_decl.hpp:221
Amesos2::SolverCore: A templated interface for interaction with third-party direct sparse solvers.
Definition: Amesos2_SolverCore_decl.hpp:106
EPhase
Used to indicate a phase in the direct solution.
Definition: Amesos2_TypeDecl.hpp:65
Passes functions to TPL functions based on type.
Definition: Amesos2_FunctionMap.hpp:77
A templated MultiVector class adapter for Amesos2.
Definition: Amesos2_MultiVecAdapter_decl.hpp:176
Map types to solver-specific data-types and enums.
Definition: Amesos2_TypeMap.hpp:82
Provides traits about solvers.
Definition: Amesos2_SolverTraits.hpp:71