| 1 |
// @HEADER |
| 2 |
// ***************************************************************************** |
| 3 |
// ShyLU: Scalable Hybrid LU Preconditioner and Solver |
| 4 |
// |
| 5 |
// Copyright 2011 NTESS and the ShyLU contributors. |
| 6 |
// SPDX-License-Identifier: BSD-3-Clause |
| 7 |
// ***************************************************************************** |
| 8 |
// @HEADER |
| 9 |
|
| 10 |
#ifndef _FROSCH_SOLVER_FACTORY_DEF_HPP |
| 11 |
#define _FROSCH_SOLVER_FACTORY_DEF_HPP |
| 12 |
|
| 13 |
#include "FROSch_SolverFactory_decl.hpp" |
| 14 |
|
| 15 |
#include "Stratimikos_FROSch_def.hpp" |
| 16 |
|
| 17 |
|
| 18 |
namespace FROSch { |
| 19 |
|
| 20 |
using namespace std; |
| 21 |
using namespace Teuchos; |
| 22 |
using namespace Xpetra; |
| 23 |
|
| 24 |
template <class SC, class LO, class GO, class NO> |
| 25 |
typename SolverFactory<SC,LO,GO,NO>::SolverPtr SolverFactory<SC,LO,GO,NO>::Build(ConstXMatrixPtr k, |
| 26 |
ParameterListPtr parameterList, |
| 27 |
string description) |
| 28 |
{ |
| 29 |
const string solverType = parameterList->get("SolverType","Amesos2"); |
| 30 |
if (!solverType.compare("Amesos")) { |
| 31 |
#ifdef HAVE_SHYLU_DDFROSCH_AMESOS |
| 32 |
FROSCH_ASSERT(k->getRowMap()->lib()==UseEpetra,"FROSch::SolverFactory: Amesos is not compatible with Tpetra."); |
| 33 |
#ifdef HAVE_SHYLU_DDFROSCH_EPETRA |
| 34 |
return AmesosSolverEpetraPtr(new AmesosSolverEpetra<SC,LO,GO,NO>(k,parameterList,description)); |
| 35 |
#else |
| 36 |
ThrowErrorMissingPackage("FROSch::SolverFactory","Epetra"); |
| 37 |
#endif |
| 38 |
#else |
| 39 |
ThrowErrorMissingPackage("FROSch::SolverFactory","Amesos"); |
| 40 |
#endif |
| 41 |
} else if (!solverType.compare("Amesos2")) { |
| 42 |
if (k->getRowMap()->lib()==UseEpetra) { |
| 43 |
#ifdef HAVE_SHYLU_DDFROSCH_EPETRA |
| 44 |
return Amesos2SolverEpetraPtr(new Amesos2SolverEpetra<SC,LO,GO,NO>(k,parameterList,description)); |
| 45 |
#else |
| 46 |
ThrowErrorMissingPackage("FROSch::SolverFactory","Epetra"); |
| 47 |
#endif |
| 48 |
} else if (k->getRowMap()->lib()==UseTpetra) { |
| 49 |
return Amesos2SolverTpetraPtr(new Amesos2SolverTpetra<SC,LO,GO,NO>(k,parameterList,description)); |
| 50 |
} else { |
| 51 |
FROSCH_ASSERT(false, "FROSch::SolverFactory: This can't happen. Either use Epetra or Tetra linear algebra stack."); |
| 52 |
} |
| 53 |
} else if (!solverType.compare("Belos")) { |
| 54 |
#ifdef HAVE_SHYLU_DDFROSCH_BELOS |
| 55 |
if (k->getRowMap()->lib()==UseEpetra) { |
| 56 |
#ifdef HAVE_SHYLU_DDFROSCH_EPETRA |
| 57 |
return BelosSolverEpetraPtr(new BelosSolverEpetra<SC,LO,GO,NO>(k,parameterList,description)); |
| 58 |
#else |
| 59 |
ThrowErrorMissingPackage("FROSch::SolverFactory","Epetra"); |
| 60 |
#endif |
| 61 |
} else if (k->getRowMap()->lib()==UseTpetra) { |
| 62 |
return BelosSolverTpetraPtr(new BelosSolverTpetra<SC,LO,GO,NO>(k,parameterList,description)); |
| 63 |
} else { |
| 64 |
FROSCH_ASSERT(false, "FROSch::SolverFactory: This can't happen. Either use Epetra or Tetra linear algebra stack."); |
| 65 |
} |
| 66 |
#else |
| 67 |
ThrowErrorMissingPackage("FROSch::SolverFactory","Belos"); |
| 68 |
#endif |
| 69 |
} else if (!solverType.compare("FROSchPreconditioner")) { |
| 70 |
return FROSchPreconditionerPtr(new FROSchPreconditioner<SC,LO,GO,NO>(k,parameterList,description)); |
| 71 |
} else if (!solverType.compare("Ifpack2")) { |
| 72 |
#ifdef HAVE_SHYLU_DDFROSCH_IFPACK2 |
| 73 |
FROSCH_ASSERT(k->getRowMap()->lib()==UseTpetra,"FROSch::SolverFactory: Ifpack2 is not compatible with Epetra."); |
| 74 |
return Ifpack2PreconditionerTpetraPtr(new Ifpack2PreconditionerTpetra<SC,LO,GO,NO>(k,parameterList,description)); |
| 75 |
#else |
| 76 |
ThrowErrorMissingPackage("FROSch::SolverFactory","Ifpack2"); |
| 77 |
#endif |
| 78 |
} else if (!solverType.compare("MueLu")) { |
| 79 |
#ifdef HAVE_SHYLU_DDFROSCH_MUELU |
| 80 |
return MueLuPreconditionerPtr(new MueLuPreconditioner<SC,LO,GO,NO>(k,parameterList,description)); |
| 81 |
#else |
| 82 |
ThrowErrorMissingPackage("FROSch::SolverFactory","MueLu"); |
| 83 |
#endif |
| 84 |
} else if (!solverType.compare("ThyraPreconditioner")) { |
| 85 |
#ifdef HAVE_SHYLU_DDFROSCH_THYRA |
| 86 |
#ifdef HAVE_SHYLU_DDFROSCH_STRATIMIKOS |
| 87 |
return ThyraPreconditionerPtr(new ThyraPreconditioner<SC,LO,GO,NO>(k,parameterList,description)); |
| 88 |
#else |
| 89 |
ThrowErrorMissingPackage("FROSch::SolverFactory","Stratimikos"); |
| 90 |
#endif |
| 91 |
#else |
| 92 |
ThrowErrorMissingPackage("FROSch::SolverFactory","Thyra"); |
| 93 |
#endif |
| 94 |
} else if (!solverType.compare("ThyraSolver")) { |
| 95 |
#ifdef HAVE_SHYLU_DDFROSCH_THYRA |
| 96 |
#ifdef HAVE_SHYLU_DDFROSCH_STRATIMIKOS |
| 97 |
return ThyraSolverPtr(new ThyraSolver<SC,LO,GO,NO>(k,parameterList,description)); |
| 98 |
#else |
| 99 |
ThrowErrorMissingPackage("FROSch::SolverFactory","Stratimikos"); |
| 100 |
#endif |
| 101 |
#else |
| 102 |
ThrowErrorMissingPackage("FROSch::SolverFactory","Thyra"); |
| 103 |
#endif |
| 104 |
} else { |
| 105 |
FROSCH_ASSERT(false,"SolverType unknown..."); |
| 106 |
} |
| 107 |
return null; // Can we get rid of this? Without there used to be a warning... |
| 108 |
} |
| 109 |
} |
| 110 |
|
| 111 |
#endif |