82 #ifndef AMESOS2_FACTORY_HPP 83 #define AMESOS2_FACTORY_HPP 85 #include "Amesos2_config.h" 87 #include "Amesos2_Solver.hpp" 90 #include "Teuchos_ScalarTraits.hpp" 92 #include "Amesos2_MatrixTraits.hpp" 95 #ifdef HAVE_AMESOS2_BASKER 96 #include "Amesos2_Basker.hpp" 98 #if defined(HAVE_AMESOS2_KLU2) 99 #include "Amesos2_KLU2.hpp" 101 #ifdef HAVE_AMESOS2_SUPERLUDIST // Distributed-memory SuperLU 102 #include "Amesos2_Superludist.hpp" 104 #ifdef HAVE_AMESOS2_SUPERLUMT // Multi-threaded SuperLU 105 #include "Amesos2_Superlumt.hpp" 107 #ifdef HAVE_AMESOS2_SUPERLU // Sequential SuperLU 108 #include "Amesos2_Superlu.hpp" 110 #ifdef HAVE_AMESOS2_PARDISO_MKL // MKL version of Pardiso 111 #include "Amesos2_PardisoMKL.hpp" 113 #ifdef HAVE_AMESOS2_LAPACK 114 #include "Amesos2_Lapack.hpp" 116 #if defined (HAVE_AMESOS2_CHOLMOD) && defined (HAVE_AMESOS2_EXPERIMENTAL) 117 #include "Amesos2_Cholmod.hpp" 119 #ifdef HAVE_AMESOS2_MUMPS 120 #include "Amesos2_MUMPS.hpp" 126 template <
class,
class>
class Solver;
131 std::string tolower(
const std::string& s);
148 template <
class Matrix,
150 Solver<Matrix,Vector>*
151 create(
const Matrix* A, Vector* X,
const Vector* B);
168 template <
class Matrix,
170 Teuchos::RCP<Solver<Matrix,Vector> >
171 create(Teuchos::RCP<const Matrix> A,
172 Teuchos::RCP<Vector> X,
173 Teuchos::RCP<const Vector> B);
193 template <
class Matrix,
195 Solver<Matrix,Vector>*
196 create(
const char* solverName,
const Matrix* A, Vector* X,
const Vector* B);
215 template <
class Matrix,
217 Teuchos::RCP<Solver<Matrix,Vector> >
218 create(
const char* solverName,
219 const Teuchos::RCP<const Matrix> A,
220 const Teuchos::RCP<Vector> X,
221 const Teuchos::RCP<const Vector> B);
240 template <
class Matrix,
242 Solver<Matrix,Vector>*
243 create(
const std::string solverName,
const Matrix* A, Vector* X,
const Vector* B);
262 template <
class Matrix,
264 Teuchos::RCP<Solver<Matrix,Vector> >
265 create(
const std::string solverName,
266 const Teuchos::RCP<const Matrix> A,
267 const Teuchos::RCP<Vector> X,
268 const Teuchos::RCP<const Vector> B);
289 template <
class Matrix,
291 Solver<Matrix,Vector>*
292 create(
const std::string solverName,
const Matrix* A);
313 template <
class Matrix,
315 Teuchos::RCP<Solver<Matrix,Vector> >
316 create(
const std::string solverName,
317 const Teuchos::RCP<const Matrix> A);
324 template <
template <
class,
class>
class ConcreteSolver,
327 struct create_solver_with_supported_type {
328 static Teuchos::RCP<Solver<Matrix,Vector> > apply(Teuchos::RCP<const Matrix> A,
329 Teuchos::RCP<Vector> X,
330 Teuchos::RCP<const Vector> B )
334 typename MatrixTraits<Matrix>::scalar_t,
335 typename MultiVecAdapter<Vector>::scalar_t
337 > same_scalar_assertion;
338 (void)same_scalar_assertion;
341 return rcp(
new ConcreteSolver<Matrix,Vector>(A, X, B) );
353 template <
template <
class,
class>
class ConcreteSolver,
356 struct throw_no_scalar_support_exception {
357 static Teuchos::RCP<Solver<Matrix,Vector> > apply(Teuchos::RCP<const Matrix> A,
358 Teuchos::RCP<Vector> X,
359 Teuchos::RCP<const Vector> B )
362 typedef typename MatrixTraits<Matrix>::scalar_t scalar_t;
363 TEUCHOS_TEST_FOR_EXCEPTION(
true,
364 std::invalid_argument,
365 "The requested Amesos2 " 367 " solver interface does not support the " <<
368 Teuchos::ScalarTraits<scalar_t>::name() <<
382 template <
template <
class,
class>
class ConcreteSolver,
385 struct handle_solver_type_support {
386 static Teuchos::RCP<Solver<Matrix,Vector> > apply(Teuchos::RCP<const Matrix> A,
387 Teuchos::RCP<Vector> X,
388 Teuchos::RCP<const Vector> B )
390 return Meta::if_then_else<
391 solver_supports_scalar<ConcreteSolver, typename MatrixTraits<Matrix>::scalar_t>::value,
392 create_solver_with_supported_type<ConcreteSolver,Matrix,Vector>,
393 throw_no_scalar_support_exception<ConcreteSolver,Matrix,Vector> >::type::apply(A, X, B);
409 bool query(
const char* solverName);
419 bool query(
const std::string solverName);
426 template <
class Matrix,
428 Solver<Matrix,Vector>*
429 create(Matrix* A, Vector* X, Vector* B)
431 std::string solver =
"Klu2";
433 return( create(solver, rcp(A,
false), rcp(X,
false), rcp(B,
false)).getRawPtr() );
437 template <
class Matrix,
439 Teuchos::RCP<Solver<Matrix,Vector> >
440 create(Teuchos::RCP<const Matrix> A,
441 Teuchos::RCP<Vector> X,
442 Teuchos::RCP<const Vector> B)
444 std::string solver =
"Klu2";
445 return( create(solver, A, X, B) );
449 template <
class Matrix,
451 Solver<Matrix,Vector>*
452 create(
const char* solverName,
const Matrix* A, Vector* X,
const Vector* B)
454 std::string solver = solverName;
456 return( create(solver, rcp(A,
false), rcp(X,
false), rcp(B,
false)).getRawPtr() );
460 template <
class Matrix,
462 Teuchos::RCP<Solver<Matrix,Vector> >
463 create(
const char* solverName,
464 const Teuchos::RCP<const Matrix> A,
465 const Teuchos::RCP<Vector> X,
466 const Teuchos::RCP<const Vector> B)
468 std::string solver = solverName;
469 return( create(solver, A, X, B) );
473 template <
class Matrix,
475 Solver<Matrix,Vector>*
476 create(
const std::string solverName,
const Matrix* A){
477 return( create(solverName, rcp(A,
false),
478 Teuchos::RCP<Vector>(),
479 Teuchos::RCP<const Vector>()).getRawPtr() );
483 template <
class Matrix,
485 Teuchos::RCP<Solver<Matrix,Vector> >
486 create(
const std::string solverName,
const Teuchos::RCP<const Matrix> A){
487 return( create(solverName, A, Teuchos::RCP<Vector>(), Teuchos::RCP<const Vector>()) );
491 template <
class Matrix,
493 Teuchos::RCP<Solver<Matrix,Vector> >
494 create(
const std::string solverName,
const Matrix* A, Vector* X,
const Vector* B)
497 return( create(solverName, rcp(A,
false), rcp(X,
false), rcp(B,
false)) );
501 template <
class Matrix,
503 Teuchos::RCP<Solver<Matrix,Vector> >
504 create(
const std::string solver_name,
505 const Teuchos::RCP<const Matrix> A,
506 const Teuchos::RCP<Vector> X,
507 const Teuchos::RCP<const Vector> B)
509 std::string solverName = tolower(solver_name);
514 #ifdef HAVE_AMESOS2_BASKER 515 if((solverName ==
"Basker") || (solverName ==
"basker"))
518 return handle_solver_type_support<Basker, Matrix,Vector>::apply(A,X,B);
524 #ifdef HAVE_AMESOS2_KLU2 526 if((solverName ==
"amesos2_klu2") || (solverName ==
"klu2") ||
527 (solverName ==
"amesos2_klu") || (solverName ==
"klu")){
528 return handle_solver_type_support<KLU2,Matrix,Vector>::apply(A, X, B);
532 #ifdef HAVE_AMESOS2_SUPERLUDIST 533 if((solverName ==
"amesos2_superludist") ||
534 (solverName ==
"superludist") ||
535 (solverName ==
"amesos2_superlu_dist") ||
536 (solverName ==
"superlu_dist")){
537 return handle_solver_type_support<Superludist,Matrix,Vector>::apply(A, X, B);
541 #ifdef HAVE_AMESOS2_SUPERLUMT 542 if((solverName ==
"amesos2_superlumt") ||
543 (solverName ==
"superlumt") ||
544 (solverName ==
"amesos2_superlu_mt") ||
545 (solverName ==
"superlu_mt")){
546 return handle_solver_type_support<Superlumt,Matrix,Vector>::apply(A, X, B);
550 #ifdef HAVE_AMESOS2_SUPERLU 551 if((solverName ==
"amesos2_superlu") ||
552 (solverName ==
"superlu")){
553 return handle_solver_type_support<Superlu,Matrix,Vector>::apply(A, X, B);
557 #ifdef HAVE_AMESOS2_PARDISO_MKL 558 if((solverName ==
"amesos2_pardiso_mkl") ||
559 (solverName ==
"pardiso_mkl") ||
560 (solverName ==
"amesos2_pardisomkl") ||
561 (solverName ==
"pardisomkl")){
562 return handle_solver_type_support<PardisoMKL,Matrix,Vector>::apply(A, X, B);
566 #ifdef HAVE_AMESOS2_LAPACK 567 if((solverName ==
"amesos2_lapack") ||
568 (solverName ==
"lapack")){
569 return handle_solver_type_support<Lapack,Matrix,Vector>::apply(A, X, B);
574 #ifdef HAVE_AMESOS2_MUMPS 575 if((solverName ==
"MUMPS") || (solverName ==
"mumps") ||
576 (solverName ==
"amesos2_MUMPS") || (solverName ==
"amesos2_mumps"))
578 return handle_solver_type_support<MUMPS,Matrix,Vector>::apply(A,X,B);
582 #if defined (HAVE_AMESOS2_CHOLMOD) && defined (HAVE_AMESOS2_EXPERIMENTAL) 583 if(solverName ==
"amesos2_cholmod")
584 return handle_solver_type_support<Cholmod,Matrix,Vector>::apply(A, X, B);
591 std::string err_msg = solver_name +
" is not enabled or is not supported";
592 TEUCHOS_TEST_FOR_EXCEPTION(
true, std::invalid_argument, err_msg);
593 return( Teuchos::null );
598 #endif // AMESOS2_FACTORY_HPP A templated adapter/wrapper class for Trilinos Multivector type classes. Provides the functions neces...
Definition: Amesos2_AbstractConcreteMatrixAdapter.hpp:48
Simple compile-time assertion class.
Provides access to interesting solver traits.