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_UMFPACK // Umfpack 108 #include "Amesos2_Umfpack.hpp" 110 #ifdef HAVE_AMESOS2_SUPERLU // Sequential SuperLU 111 #include "Amesos2_Superlu.hpp" 113 #ifdef HAVE_AMESOS2_PARDISO_MKL // MKL version of Pardiso 114 #include "Amesos2_PardisoMKL.hpp" 116 #ifdef HAVE_AMESOS2_LAPACK 117 #include "Amesos2_Lapack.hpp" 119 #if defined (HAVE_AMESOS2_CHOLMOD) && defined (HAVE_AMESOS2_EXPERIMENTAL) 120 #include "Amesos2_Cholmod.hpp" 122 #ifdef HAVE_AMESOS2_MUMPS 123 #include "Amesos2_MUMPS.hpp" 129 template <
class,
class>
class Solver;
134 std::string tolower(
const std::string& s);
151 template <
class Matrix,
153 Solver<Matrix,Vector>*
154 create(
const Matrix* A, Vector* X,
const Vector* B);
171 template <
class Matrix,
173 Teuchos::RCP<Solver<Matrix,Vector> >
174 create(Teuchos::RCP<const Matrix> A,
175 Teuchos::RCP<Vector> X,
176 Teuchos::RCP<const Vector> B);
196 template <
class Matrix,
198 Solver<Matrix,Vector>*
199 create(
const char* solverName,
const Matrix* A, Vector* X,
const Vector* B);
218 template <
class Matrix,
220 Teuchos::RCP<Solver<Matrix,Vector> >
221 create(
const char* solverName,
222 const Teuchos::RCP<const Matrix> A,
223 const Teuchos::RCP<Vector> X,
224 const Teuchos::RCP<const Vector> B);
243 template <
class Matrix,
245 Solver<Matrix,Vector>*
246 create(
const std::string solverName,
const Matrix* A, Vector* X,
const Vector* B);
265 template <
class Matrix,
267 Teuchos::RCP<Solver<Matrix,Vector> >
268 create(
const std::string solverName,
269 const Teuchos::RCP<const Matrix> A,
270 const Teuchos::RCP<Vector> X,
271 const Teuchos::RCP<const Vector> B);
292 template <
class Matrix,
294 Solver<Matrix,Vector>*
295 create(
const std::string solverName,
const Matrix* A);
316 template <
class Matrix,
318 Teuchos::RCP<Solver<Matrix,Vector> >
319 create(
const std::string solverName,
320 const Teuchos::RCP<const Matrix> A);
327 template <
template <
class,
class>
class ConcreteSolver,
330 struct create_solver_with_supported_type {
331 static Teuchos::RCP<Solver<Matrix,Vector> > apply(Teuchos::RCP<const Matrix> A,
332 Teuchos::RCP<Vector> X,
333 Teuchos::RCP<const Vector> B )
337 typename MatrixTraits<Matrix>::scalar_t,
338 typename MultiVecAdapter<Vector>::scalar_t
340 > same_scalar_assertion;
341 (void)same_scalar_assertion;
344 return rcp(
new ConcreteSolver<Matrix,Vector>(A, X, B) );
356 template <
template <
class,
class>
class ConcreteSolver,
359 struct throw_no_scalar_support_exception {
360 static Teuchos::RCP<Solver<Matrix,Vector> > apply(Teuchos::RCP<const Matrix> A,
361 Teuchos::RCP<Vector> X,
362 Teuchos::RCP<const Vector> B )
365 typedef typename MatrixTraits<Matrix>::scalar_t scalar_t;
366 TEUCHOS_TEST_FOR_EXCEPTION(
true,
367 std::invalid_argument,
368 "The requested Amesos2 " 370 " solver interface does not support the " <<
371 Teuchos::ScalarTraits<scalar_t>::name() <<
385 template <
template <
class,
class>
class ConcreteSolver,
388 struct handle_solver_type_support {
389 static Teuchos::RCP<Solver<Matrix,Vector> > apply(Teuchos::RCP<const Matrix> A,
390 Teuchos::RCP<Vector> X,
391 Teuchos::RCP<const Vector> B )
393 return Meta::if_then_else<
394 solver_supports_scalar<ConcreteSolver, typename MatrixTraits<Matrix>::scalar_t>::value,
395 create_solver_with_supported_type<ConcreteSolver,Matrix,Vector>,
396 throw_no_scalar_support_exception<ConcreteSolver,Matrix,Vector> >::type::apply(A, X, B);
412 bool query(
const char* solverName);
422 bool query(
const std::string solverName);
429 template <
class Matrix,
431 Solver<Matrix,Vector>*
432 create(Matrix* A, Vector* X, Vector* B)
434 std::string solver =
"Klu2";
436 return( create(solver, rcp(A,
false), rcp(X,
false), rcp(B,
false)).getRawPtr() );
440 template <
class Matrix,
442 Teuchos::RCP<Solver<Matrix,Vector> >
443 create(Teuchos::RCP<const Matrix> A,
444 Teuchos::RCP<Vector> X,
445 Teuchos::RCP<const Vector> B)
447 std::string solver =
"Klu2";
448 return( create(solver, A, X, B) );
452 template <
class Matrix,
454 Solver<Matrix,Vector>*
455 create(
const char* solverName,
const Matrix* A, Vector* X,
const Vector* B)
457 std::string solver = solverName;
459 return( create(solver, rcp(A,
false), rcp(X,
false), rcp(B,
false)).getRawPtr() );
463 template <
class Matrix,
465 Teuchos::RCP<Solver<Matrix,Vector> >
466 create(
const char* solverName,
467 const Teuchos::RCP<const Matrix> A,
468 const Teuchos::RCP<Vector> X,
469 const Teuchos::RCP<const Vector> B)
471 std::string solver = solverName;
472 return( create(solver, A, X, B) );
476 template <
class Matrix,
478 Solver<Matrix,Vector>*
479 create(
const std::string solverName,
const Matrix* A){
480 return( create(solverName, rcp(A,
false),
481 Teuchos::RCP<Vector>(),
482 Teuchos::RCP<const Vector>()).getRawPtr() );
486 template <
class Matrix,
488 Teuchos::RCP<Solver<Matrix,Vector> >
489 create(
const std::string solverName,
const Teuchos::RCP<const Matrix> A){
490 return( create(solverName, A, Teuchos::RCP<Vector>(), Teuchos::RCP<const Vector>()) );
494 template <
class Matrix,
496 Teuchos::RCP<Solver<Matrix,Vector> >
497 create(
const std::string solverName,
const Matrix* A, Vector* X,
const Vector* B)
500 return( create(solverName, rcp(A,
false), rcp(X,
false), rcp(B,
false)) );
504 template <
class Matrix,
506 Teuchos::RCP<Solver<Matrix,Vector> >
507 create(
const std::string solver_name,
508 const Teuchos::RCP<const Matrix> A,
509 const Teuchos::RCP<Vector> X,
510 const Teuchos::RCP<const Vector> B)
512 std::string solverName = tolower(solver_name);
517 #ifdef HAVE_AMESOS2_BASKER 518 if((solverName ==
"Basker") || (solverName ==
"basker"))
520 return handle_solver_type_support<Basker, Matrix,Vector>::apply(A,X,B);
526 #ifdef HAVE_AMESOS2_KLU2 527 if((solverName ==
"amesos2_klu2") || (solverName ==
"klu2") ||
528 (solverName ==
"amesos2_klu") || (solverName ==
"klu")){
529 return handle_solver_type_support<KLU2,Matrix,Vector>::apply(A, X, B);
533 #ifdef HAVE_AMESOS2_SUPERLUDIST 534 if((solverName ==
"amesos2_superludist") ||
535 (solverName ==
"superludist") ||
536 (solverName ==
"amesos2_superlu_dist") ||
537 (solverName ==
"superlu_dist")){
538 return handle_solver_type_support<Superludist,Matrix,Vector>::apply(A, X, B);
542 #ifdef HAVE_AMESOS2_SUPERLUMT 543 if((solverName ==
"amesos2_superlumt") ||
544 (solverName ==
"superlumt") ||
545 (solverName ==
"amesos2_superlu_mt") ||
546 (solverName ==
"superlu_mt")){
547 return handle_solver_type_support<Superlumt,Matrix,Vector>::apply(A, X, B);
551 #ifdef HAVE_AMESOS2_UMFPACK 552 if((solverName ==
"amesos2_umfpack") ||
553 (solverName ==
"umfpack")){
554 return handle_solver_type_support<Umfpack,Matrix,Vector>::apply(A, X, B);
558 #ifdef HAVE_AMESOS2_SUPERLU 559 if((solverName ==
"amesos2_superlu") ||
560 (solverName ==
"superlu")){
561 return handle_solver_type_support<Superlu,Matrix,Vector>::apply(A, X, B);
565 #ifdef HAVE_AMESOS2_PARDISO_MKL 566 if((solverName ==
"amesos2_pardiso_mkl") ||
567 (solverName ==
"pardiso_mkl") ||
568 (solverName ==
"amesos2_pardisomkl") ||
569 (solverName ==
"pardisomkl")){
570 return handle_solver_type_support<PardisoMKL,Matrix,Vector>::apply(A, X, B);
574 #ifdef HAVE_AMESOS2_LAPACK 575 if((solverName ==
"amesos2_lapack") ||
576 (solverName ==
"lapack")){
577 return handle_solver_type_support<Lapack,Matrix,Vector>::apply(A, X, B);
582 #ifdef HAVE_AMESOS2_MUMPS 583 if((solverName ==
"MUMPS") || (solverName ==
"mumps") ||
584 (solverName ==
"amesos2_MUMPS") || (solverName ==
"amesos2_mumps"))
586 return handle_solver_type_support<MUMPS,Matrix,Vector>::apply(A,X,B);
590 #if defined (HAVE_AMESOS2_CHOLMOD) && defined (HAVE_AMESOS2_EXPERIMENTAL) 591 if(solverName ==
"amesos2_cholmod")
592 return handle_solver_type_support<Cholmod,Matrix,Vector>::apply(A, X, B);
599 std::string err_msg = solver_name +
" is not enabled or is not supported";
600 TEUCHOS_TEST_FOR_EXCEPTION(
true, std::invalid_argument, err_msg);
601 return( Teuchos::null );
606 #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.