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 
55 #include "Amesos2_SolverTraits.hpp"
56 #include "Amesos2_SolverCore.hpp"
58 
59 
60 namespace Amesos2 {
61 
62 
83 template <class Matrix,class Vector>
84 class 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
89 public:
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 mumps_type;
106  typedef typename type_map::magnitude_type magnitude_type;
107  typedef typename type_map::MUMPS_STRUC_C MUMPS_STRUC_C;
108 
109  typedef Kokkos::DefaultHostExecutionSpace HostExecSpaceType;
110  typedef typename HostExecSpaceType::memory_space HostMemSpaceType;
111 
112  typedef Kokkos::View<local_ordinal_type*, HostExecSpaceType> host_ordinal_type_view;
113  typedef Kokkos::View<mumps_type*, HostExecSpaceType> host_value_type_view;
114 
115  MUMPS(Teuchos::RCP<const Matrix> A,
116  Teuchos::RCP<Vector> X,
117  Teuchos::RCP<const Vector> B);
118  ~MUMPS( );
119 
120 
121 private:
122 
128  int preOrdering_impl();
129 
130 
131  int symbolicFactorization_impl();
132 
133 
140 
141 
153  int solve_impl(const Teuchos::Ptr<MultiVecAdapter<Vector> > X,
154  const Teuchos::Ptr<const MultiVecAdapter<Vector> > B) const;
155 
156 
160  bool matrixShapeOK_impl() const;
161 
177  void setParameters_impl(
178  const Teuchos::RCP<Teuchos::ParameterList> & parameterList );
179 
180 
187  Teuchos::RCP<const Teuchos::ParameterList> getValidParameters_impl() const;
188 
189 
198  bool loadA_impl(EPhase current_phase);
199 
200 
201  int ConvertToTriplet();
202 
203  void MUMPS_ERROR() const;
204 
205 #ifdef HAVE_MPI
206  MPI_Comm MUMPSComm;
207 #endif
208 
209 
210  bool MUMPS_MATRIX_LOAD;
211  bool MUMPS_STRUCT;
212  mutable bool MUMPS_MATRIX_LOAD_PREORDERING;
213 
214  // The following Arrays are persisting storage arrays for A, X, and B
216  host_value_type_view host_nzvals_view_;
218  host_ordinal_type_view host_rows_view_;
220  host_ordinal_type_view host_col_ptr_view_;
221 
223  mutable Teuchos::Array<mumps_type> xvals_; local_ordinal_type ldx_;
225  mutable Teuchos::Array<mumps_type> bvals_; local_ordinal_type ldb_;
226 
227  mutable MUMPS_STRUC_C mumps_par;
228 
229  bool is_contiguous_;
230 
231 }; // End class MUMPS
232 
233 
234 template <class Matrix,class Vector>
235 class MUMPSNS : public SolverCore<Amesos2::MUMPS, Matrix, Vector>
236 {
237  friend class SolverCore<Amesos2::MUMPS,Matrix,Vector>; // Give our base access
238  // to our private
239  // implementation funcs
240 public:
241 
242 
243  MUMPSNS(Teuchos::RCP<const Matrix> A,
244  Teuchos::RCP<Vector> X,
245  Teuchos::RCP<const Vector> B);
246  /*
247  {
248  TEUCHOS_TEST_FOR_EXCEPTION(true, std::logic_error,
249  "This solver is not support for these types.");
250 
251  }
252 
253  */
254  ~MUMPSNS( )
255  {}
256 
257 
258 private:
259 
260  int preOrdering_impl()
261  {
262 
263  TEUCHOS_TEST_FOR_EXCEPTION(true, std::logic_error,
264  "This solver is not support for these types.");
265 
266  }
267 
268  int symbolicFactorization_impl()
269  {
270 
271  TEUCHOS_TEST_FOR_EXCEPTION(true, std::logic_error,
272  "This solver is not support for these types.");
273 
274  }
275 
277  {
278 
279  TEUCHOS_TEST_FOR_EXCEPTION(true, std::logic_error,
280  "This solver is not support for these types.");
281 
282  }
283 
284  int solve_impl(const Teuchos::Ptr<MultiVecAdapter<Vector> > X,
285  const Teuchos::Ptr<const MultiVecAdapter<Vector> > B) const
286  {
287 
288  TEUCHOS_TEST_FOR_EXCEPTION(true, std::logic_error,
289  "This solver is not support for these types.");
290 
291  }
292 
293  bool matrixShapeOK_impl() const
294  {
295 
296  TEUCHOS_TEST_FOR_EXCEPTION(true, std::logic_error,
297  "This solver is not support for these types.");
298 
299  }
300 
301  void setParameters_impl(
302  const Teuchos::RCP<Teuchos::ParameterList> & parameterList )
303  {
304 
305  TEUCHOS_TEST_FOR_EXCEPTION(true, std::logic_error,
306  "This solver is not support for these types.");
307 
308  }
309 
310  Teuchos::RCP<const Teuchos::ParameterList> getValidParameters_impl() const
311  {
312 
313  TEUCHOS_TEST_FOR_EXCEPTION(true, std::logic_error,
314  "This solver is not support for these types.");
315 
316  }
317 
318 
319  bool loadA_impl(EPhase current_phase)
320  {
321 
322  TEUCHOS_TEST_FOR_EXCEPTION(true, std::logic_error,
323  "This solver is not support for these types.");
324 
325  }
326 
327 
328  int ConvertToTriplet()
329  {
330 
331  TEUCHOS_TEST_FOR_EXCEPTION(true, std::logic_error,
332  "This solver is not support for these types.");
333 
334  }
335 
336 
337  void MUMPS_ERROR() const
338  {
339 
340  TEUCHOS_TEST_FOR_EXCEPTION(true, std::logic_error,
341  "This solver is not support for these types.");
342 
343  }
344 
345 
346 #ifdef HAVE_MPI
347  MPI_Comm MUMPSComm;
348 #endif
349 
350  bool is_contiguous_;
351 
352 };
353 
354 
355 
356 // Specialize solver_traits struct for MUMPS
357 // TODO
358 template <>
359 struct solver_traits<MUMPS> {
360 #ifdef HAVE_TEUCHOS_COMPLEX
361  typedef Meta::make_list4<float,
362  double,
363  std::complex<float>,
364  std::complex<double> > supported_scalars;
365 #else
366  typedef Meta::make_list2<float, double> supported_scalars;
367 #endif
368 };
369 
370 } // end namespace Amesos2
371 
372 #endif // AMESOS2_MUMPS_DECL_HPP
Provides a mechanism to map function calls to the correct Solver function based on the scalar type of...
host_ordinal_type_view host_col_ptr_view_
Stores the row indices of the nonzero entries.
Definition: Amesos2_MUMPS_decl.hpp:220
Amesos2::SolverCore: A templated interface for interaction with third-party direct sparse solvers...
Definition: Amesos2_SolverCore_decl.hpp:105
int numericFactorization_impl()
MUMPS specific numeric factorization.
Definition: Amesos2_MUMPS_def.hpp:202
EPhase
Used to indicate a phase in the direct solution.
Definition: Amesos2_TypeDecl.hpp:65
Teuchos::Array< mumps_type > xvals_
Persisting 1D store for X.
Definition: Amesos2_MUMPS_decl.hpp:223
Map types to solver-specific data-types and enums.
Definition: Amesos2_TypeMap.hpp:82
int preOrdering_impl()
Performs pre-ordering on the matrix to increase efficiency.
Definition: Amesos2_MUMPS_def.hpp:173
Provides traits about solvers.
Definition: Amesos2_SolverTraits.hpp:71
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:225
host_ordinal_type_view host_rows_view_
Stores the location in Ai_ and Aval_ that starts row j.
Definition: Amesos2_MUMPS_decl.hpp:218
host_value_type_view host_nzvals_view_
Stores the values of the nonzero entries for MUMPS.
Definition: Amesos2_MUMPS_decl.hpp:216
bool matrixShapeOK_impl() const
Determines whether the shape of the matrix is OK for this solver.
Definition: Amesos2_MUMPS_def.hpp:288
bool loadA_impl(EPhase current_phase)
Reads matrix data into internal structures.
Definition: Amesos2_MUMPS_def.hpp:368
Amesos2 interface to the MUMPS package.
Definition: Amesos2_MUMPS_decl.hpp:84
Teuchos::Array< mumps_type > bvals_
Persisting 1D store for B.
Definition: Amesos2_MUMPS_decl.hpp:225
std::string name() const override
Return the name of this solver.
Teuchos::RCP< const Teuchos::ParameterList > getValidParameters_impl() const
Definition: Amesos2_MUMPS_def.hpp:340
void setParameters_impl(const Teuchos::RCP< Teuchos::ParameterList > &parameterList)
Definition: Amesos2_MUMPS_def.hpp:297
Provides access to interesting solver traits.
A templated MultiVector class adapter for Amesos2.
Definition: Amesos2_MultiVecAdapter_decl.hpp:176