Amesos2 - Direct Sparse Solver Interfaces Version of the Day
Amesos2_MUMPS_decl.hpp
Go to the documentation of this file.
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
18#ifndef AMESOS2_MUMPS_DECL_HPP
19#define AMESOS2_MUMPS_DECL_HPP
20
22#include "Amesos2_SolverCore.hpp"
24
25
26namespace Amesos2 {
27
28
49template <class Matrix,class Vector>
50class MUMPS : public SolverCore<Amesos2::MUMPS, Matrix, Vector>
51{
52 friend class SolverCore<Amesos2::MUMPS,Matrix,Vector>; // Give our base access
53 // to our private
54 // implementation funcs
55public:
56
58 static const char* name; // declaration. Initialization outside.
59
60 typedef MUMPS<Matrix,Vector> type;
61 typedef SolverCore<Amesos2::MUMPS,Matrix,Vector> super_type;
62
63 // Since typedef's are not inheritted, go grab them
64 typedef typename super_type::scalar_type scalar_type;
65 typedef typename super_type::local_ordinal_type local_ordinal_type;
66 typedef typename super_type::global_ordinal_type global_ordinal_type;
67 typedef typename super_type::global_size_type global_size_type;
68
69 typedef TypeMap<Amesos2::MUMPS,scalar_type> type_map;
70
71 typedef typename type_map::type mumps_type;
72 typedef typename type_map::magnitude_type magnitude_type;
73 typedef typename type_map::MUMPS_STRUC_C MUMPS_STRUC_C;
74
75 typedef Kokkos::DefaultHostExecutionSpace HostExecSpaceType;
76 typedef typename HostExecSpaceType::memory_space HostMemSpaceType;
77
78 typedef Kokkos::View<local_ordinal_type*, HostExecSpaceType> host_ordinal_type_view;
79 typedef Kokkos::View<mumps_type*, HostExecSpaceType> host_value_type_view;
80 typedef typename Kokkos::View<mumps_type**, Kokkos::LayoutLeft,
81 typename HostExecSpaceType::memory_space> host_mv_view;
82
83 MUMPS(Teuchos::RCP<const Matrix> A,
84 Teuchos::RCP<Vector> X,
85 Teuchos::RCP<const Vector> B);
86 ~MUMPS( );
87
88
89private:
90
96 int preOrdering_impl();
97
98
99 int symbolicFactorization_impl();
100
101
108
109
121 int solve_impl(const Teuchos::Ptr<MultiVecAdapter<Vector> > X,
122 const Teuchos::Ptr<const MultiVecAdapter<Vector> > B) const;
123
128 void describe_impl(Teuchos::FancyOStream &out,
129 const Teuchos::EVerbosityLevel verbLevel) const;
130
134 bool matrixShapeOK_impl() const;
135
159 const Teuchos::RCP<Teuchos::ParameterList> & parameterList );
160
161
168 Teuchos::RCP<const Teuchos::ParameterList> getValidParameters_impl() const;
169
170
179 bool loadA_impl(EPhase current_phase);
180
181
182 int ConvertToTriplet();
183
184 void MUMPS_ERROR() const;
185
186
187#ifdef HAVE_MPI
188 MPI_Comm MUMPSComm;
189#endif
190
191 // For partial factorizations
192 size_t schur_size;
193 host_ordinal_type_view schur_part;
194 host_value_type_view schur_out;
195 scalar_type* schur_out_ptr;
196 bool only_forward_solve;
197 bool only_backward_solve;
198 mutable host_value_type_view schur_rhs;
199
200 bool MUMPS_MATRIX_LOAD;
201 bool MUMPS_STRUCT;
202 mutable bool MUMPS_MATRIX_LOAD_PREORDERING;
203
204 // The following Arrays are persisting storage arrays for A, X, and B
206 host_value_type_view host_nzvals_view_;
208 host_ordinal_type_view host_rows_view_;
210 host_ordinal_type_view host_col_ptr_view_;
211
213 mutable host_mv_view xvals_;
214 local_ordinal_type ldx_;
216 mutable host_mv_view bvals_;
217 local_ordinal_type ldb_;
218
219 mutable MUMPS_STRUC_C mumps_par;
220
221 bool is_contiguous_;
222
223}; // End class MUMPS
224
225
226template <class Matrix,class Vector>
227class MUMPSNS : public SolverCore<Amesos2::MUMPS, Matrix, Vector>
228{
229 friend class SolverCore<Amesos2::MUMPS,Matrix,Vector>; // Give our base access
230 // to our private
231 // implementation funcs
232public:
233
234
235 MUMPSNS(Teuchos::RCP<const Matrix> A,
236 Teuchos::RCP<Vector> X,
237 Teuchos::RCP<const Vector> B);
238 /*
239 {
240 TEUCHOS_TEST_FOR_EXCEPTION(true, std::logic_error,
241 "This solver is not support for these types.");
242
243 }
244
245 */
246 ~MUMPSNS( )
247 {}
248
249
250private:
251
252 int preOrdering_impl()
253 {
254
255 TEUCHOS_TEST_FOR_EXCEPTION(true, std::logic_error,
256 "This solver is not support for these types.");
257
258 }
259
260 int symbolicFactorization_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 numericFactorization_impl()
269 {
270
271 TEUCHOS_TEST_FOR_EXCEPTION(true, std::logic_error,
272 "This solver is not support for these types.");
273
274 }
275
276 int solve_impl(const Teuchos::Ptr<MultiVecAdapter<Vector> > X,
277 const Teuchos::Ptr<const MultiVecAdapter<Vector> > B) const
278 {
279
280 TEUCHOS_TEST_FOR_EXCEPTION(true, std::logic_error,
281 "This solver is not support for these types.");
282
283 }
284
285 bool matrixShapeOK_impl() 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 void setParameters_impl(
294 const Teuchos::RCP<Teuchos::ParameterList> & parameterList )
295 {
296
297 TEUCHOS_TEST_FOR_EXCEPTION(true, std::logic_error,
298 "This solver is not support for these types.");
299
300 }
301
302 Teuchos::RCP<const Teuchos::ParameterList> getValidParameters_impl() const
303 {
304
305 TEUCHOS_TEST_FOR_EXCEPTION(true, std::logic_error,
306 "This solver is not support for these types.");
307
308 }
309
310
311 bool loadA_impl(EPhase current_phase)
312 {
313
314 TEUCHOS_TEST_FOR_EXCEPTION(true, std::logic_error,
315 "This solver is not support for these types.");
316
317 }
318
319
320 int ConvertToTriplet()
321 {
322
323 TEUCHOS_TEST_FOR_EXCEPTION(true, std::logic_error,
324 "This solver is not support for these types.");
325
326 }
327
328
329 void MUMPS_ERROR() const
330 {
331
332 TEUCHOS_TEST_FOR_EXCEPTION(true, std::logic_error,
333 "This solver is not support for these types.");
334
335 }
336
337
338#ifdef HAVE_MPI
339 MPI_Comm MUMPSComm;
340#endif
341
342 bool is_contiguous_;
343
344};
345
346
347
348// Specialize solver_traits struct for MUMPS
349// TODO
350template <>
351struct solver_traits<MUMPS> {
352#ifdef HAVE_TEUCHOS_COMPLEX
353 typedef Meta::make_list4<float,
354 double,
355 std::complex<float>,
356 std::complex<double> > supported_scalars;
357#else
358 typedef Meta::make_list2<float, double> supported_scalars;
359#endif
360};
361
362template <typename Scalar, typename LocalOrdinal, typename ExecutionSpace>
363struct solver_supports_matrix<MUMPS,
364 KokkosSparse::CrsMatrix<Scalar, LocalOrdinal, ExecutionSpace>> {
365 static const bool value = true;
366};
367
368} // end namespace Amesos2
369
370#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:51
host_ordinal_type_view host_rows_view_
Stores the location in Ai_ and Aval_ that starts row j.
Definition Amesos2_MUMPS_decl.hpp:208
bool loadA_impl(EPhase current_phase)
Reads matrix data into internal structures.
Definition Amesos2_MUMPS_def.hpp:445
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:206
static const char * name
Name of this solver interface.
Definition Amesos2_MUMPS_decl.hpp:58
host_value_type_view host_nzvals_view_
Stores the values of the nonzero entries for MUMPS.
Definition Amesos2_MUMPS_decl.hpp:206
host_ordinal_type_view host_col_ptr_view_
Stores the row indices of the nonzero entries.
Definition Amesos2_MUMPS_decl.hpp:210
int numericFactorization_impl()
MUMPS specific numeric factorization.
Definition Amesos2_MUMPS_def.hpp:177
int preOrdering_impl()
Performs pre-ordering on the matrix to increase efficiency.
Definition Amesos2_MUMPS_def.hpp:145
host_mv_view bvals_
Persisting 1D store for B.
Definition Amesos2_MUMPS_decl.hpp:216
host_mv_view xvals_
Persisting 1D store for X.
Definition Amesos2_MUMPS_decl.hpp:213
Teuchos::RCP< const Teuchos::ParameterList > getValidParameters_impl() const
Definition Amesos2_MUMPS_def.hpp:402
void setParameters_impl(const Teuchos::RCP< Teuchos::ParameterList > &parameterList)
Definition Amesos2_MUMPS_def.hpp:316
void describe_impl(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel) const
Prints the status information about the current solver with some level of verbosity.
Definition Amesos2_MUMPS_def.hpp:494
Amesos2::SolverCore: A templated interface for interaction with third-party direct sparse solvers.
Definition Amesos2_SolverCore_decl.hpp:72
EPhase
Used to indicate a phase in the direct solution.
Definition Amesos2_TypeDecl.hpp:31
A templated MultiVector class adapter for Amesos2.
Definition Amesos2_MultiVecAdapter_decl.hpp:142
Map types to solver-specific data-types and enums.
Definition Amesos2_TypeMap.hpp:48
Provides traits about solvers.
Definition Amesos2_SolverTraits.hpp:37