22 #ifdef HAVE_AMESOS_KLU
23 #include "Amesos_Klu.h"
25 #ifdef HAVE_AMESOS_PASTIX
26 #include "Amesos_Pastix.h"
28 #ifdef HAVE_AMESOS_LAPACK
29 #include "Amesos_Lapack.h"
31 #ifdef HAVE_AMESOS_MUMPS
32 #include "Amesos_Mumps.h"
34 #ifdef HAVE_AMESOS_SCALAPACK
35 #include "Amesos_Scalapack.h"
37 #ifdef HAVE_AMESOS_UMFPACK
38 #include "Amesos_Umfpack.h"
40 #ifdef HAVE_AMESOS_SUPERLUDIST
41 #include "Amesos_Superludist.h"
43 #ifdef HAVE_AMESOS_SUPERLU
44 #include "Amesos_Superlu.h"
46 #ifdef HAVE_AMESOS_DSCPACK
47 #include "Amesos_Dscpack.h"
49 #ifdef HAVE_AMESOS_PARDISO
50 #include "Amesos_Pardiso.h"
52 #ifdef HAVE_AMESOS_TAUCS
53 #include "Amesos_Taucs.h"
55 #ifdef HAVE_AMESOS_PARAKLETE
56 #include "Amesos_Paraklete.h"
61 const std::string epetraFwdOp_str =
"epetraFwdOp";
85 *this->getValidParameters(),0
93 ,
const bool throwOnPrecInput
96 ,solverType_(solverType)
97 ,refactorizationPolicy_(refactorizationPolicy)
98 ,throwOnPrecInput_(throwOnPrecInput)
104 const LinearOpSourceBase<double> &fwdOpSrc
107 using Teuchos::outArg;
109 fwdOp = fwdOpSrc.getOp();
111 EOpTransp epetraFwdOpTransp;
114 double epetraFwdOpScalar;
115 epetraFwdOpViewExtractor_->getEpetraOpView(
117 outArg(epetraFwdOp), outArg(epetraFwdOpTransp),
118 outArg(epetraFwdOpApplyAs), outArg(epetraFwdOpAdjointSupport),
119 outArg(epetraFwdOpScalar)
121 if( !dynamic_cast<const Epetra_RowMatrix*>(&*epetraFwdOp) )
133 const RCP<
const LinearOpSourceBase<double> > &fwdOpSrc
134 ,LinearOpWithSolveBase<double> *Op
135 ,
const ESupportSolveUse
138 using Teuchos::outArg;
139 THYRA_FUNC_TIME_MONITOR(
"Stratimikos: AmesosLOWSF");
144 fwdOp = fwdOpSrc->getOp();
149 EOpTransp epetraFwdOpTransp;
152 double epetraFwdOpScalar;
153 epetraFwdOpViewExtractor_->getEpetraOpView(
155 outArg(epetraFwdOp), outArg(epetraFwdOpTransp),
156 outArg(epetraFwdOpApplyAs), outArg(epetraFwdOpAdjointSupport),
157 outArg(epetraFwdOpScalar)
188 epetraLP->SetOperator(const_cast<Epetra_Operator*>(&*epetraFwdOp));
189 Teuchos::set_extra_data< RCP<const Epetra_Operator> >( epetraFwdOp, epetraFwdOp_str,
190 Teuchos::inOutArg(epetraLP) );
195 THYRA_FUNC_TIME_MONITOR_DIFF(
"Stratimikos: AmesosLOWSF:InitConstruct",
199 amesosSolver =
Teuchos::rcp(
new Amesos_Lapack(*epetraLP));
201 #ifdef HAVE_AMESOS_KLU
202 case Thyra::Amesos::KLU :
206 #ifdef HAVE_AMESOS_PASTIX
207 case Thyra::Amesos::PASTIX :
208 amesosSolver =
Teuchos::rcp(
new Amesos_Pastix(*epetraLP));
211 #ifdef HAVE_AMESOS_MUMPS
212 case Thyra::Amesos::MUMPS :
213 amesosSolver =
Teuchos::rcp(
new Amesos_Mumps(*epetraLP));
216 #ifdef HAVE_AMESOS_SCALAPACK
217 case Thyra::Amesos::SCALAPACK :
218 amesosSolver =
Teuchos::rcp(
new Amesos_Scalapack(*epetraLP));
221 #ifdef HAVE_AMESOS_UMFPACK
222 case Thyra::Amesos::UMFPACK :
223 amesosSolver =
Teuchos::rcp(
new Amesos_Umfpack(*epetraLP));
226 #ifdef HAVE_AMESOS_SUPERLUDIST
227 case Thyra::Amesos::SUPERLUDIST :
228 amesosSolver =
Teuchos::rcp(
new Amesos_Superludist(*epetraLP));
231 #ifdef HAVE_AMESOS_SUPERLU
232 case Thyra::Amesos::SUPERLU :
233 amesosSolver =
Teuchos::rcp(
new Amesos_Superlu(*epetraLP));
236 #ifdef HAVE_AMESOS_DSCPACK
237 case Thyra::Amesos::DSCPACK :
238 amesosSolver =
Teuchos::rcp(
new Amesos_Dscpack(*epetraLP));
241 #ifdef HAVE_AMESOS_PARDISO
242 case Thyra::Amesos::PARDISO :
243 amesosSolver =
Teuchos::rcp(
new Amesos_Pardiso(*epetraLP));
246 #ifdef HAVE_AMESOS_TAUCS
247 case Thyra::Amesos::TAUCS :
248 amesosSolver =
Teuchos::rcp(
new Amesos_Taucs(*epetraLP));
251 #ifdef HAVE_AMESOS_PARAKLETE
252 case Thyra::Amesos::PARAKLETE :
253 amesosSolver =
Teuchos::rcp(
new Amesos_Paraklete(*epetraLP));
258 true, std::logic_error
259 ,
"Error, the solver type ID = " <<
solverType_ <<
" is invalid!"
267 THYRA_FUNC_TIME_MONITOR_DIFF(
"Stratimikos: AmesosLOWSF:Symbolic", Symbolic);
268 const int err = amesosSolver->SymbolicFactorization();
270 "Error, SymbolicFactorization() on amesos solver of type \'"<<
Teuchos::typeName(*amesosSolver)<<
"\'\n"
271 "returned error code "<<err<<
"!" );
274 THYRA_FUNC_TIME_MONITOR_DIFF(
"Stratimikos: AmesosLOWSF:Factor", Factor);
275 const int err = amesosSolver->NumericFactorization();
277 "Error, NumericFactorization() on amesos solver of type \'"<<
Teuchos::typeName(*amesosSolver)<<
"\'\n"
278 "returned error code "<<err<<
"!" );
281 amesosOp->
initialize(fwdOp,fwdOpSrc,epetraLP,amesosSolver,epetraFwdOpTransp,epetraFwdOpScalar);
291 epetraLP = Teuchos::rcp_const_cast<Epetra_LinearProblem>(amesosOp->
get_epetraLP());
295 epetraLP->SetOperator(const_cast<Epetra_Operator*>(&*epetraFwdOp));
296 Teuchos::get_nonconst_extra_data<RCP<const Epetra_Operator> >(epetraLP,epetraFwdOp_str) = epetraFwdOp;
301 THYRA_FUNC_TIME_MONITOR_DIFF(
"Stratimikos: AmesosLOWSF:Symbolic", Symbolic);
302 const int err = amesosSolver->SymbolicFactorization();
304 "Error, SymbolicFactorization() on amesos solver of type \'"<<
Teuchos::typeName(*amesosSolver)<<
"\'\n"
305 "returned error code "<<err<<
"!" );
308 THYRA_FUNC_TIME_MONITOR_DIFF(
"Stratimikos: AmesosLOWSF::Factor", Factor);
309 const int err = amesosSolver->NumericFactorization();
311 "Error, NumericFactorization() on amesos solver of type \'"<<
Teuchos::typeName(*amesosSolver)<<
"\'\n"
312 "returned error code "<<err<<
"!" );
320 amesosOp->
initialize(fwdOp,fwdOpSrc,epetraLP,amesosSolver,epetraFwdOpTransp,epetraFwdOpScalar);
322 amesosOp->setOStream(this->getOStream());
323 amesosOp->setVerbLevel(this->getVerbLevel());
332 const RCP<
const LinearOpSourceBase<double> > &fwdOpSrc
333 ,
const RCP<
const PreconditionerBase<double> > &
334 ,LinearOpWithSolveBase<double> *Op
335 ,
const ESupportSolveUse supportSolveUse
340 ,
"Error, the concrete implementation described as \'"<<this->
description()<<
"\' does not support preconditioners "
341 "and has been configured to throw this exception when the initializePreconditionedOp(...) function is called!"
347 const RCP<
const LinearOpSourceBase<double> > &fwdOpSrc
348 ,
const RCP<
const LinearOpSourceBase<double> > &
349 ,LinearOpWithSolveBase<double> *Op
350 ,
const ESupportSolveUse supportSolveUse
355 ,
"Error, the concrete implementation described as \'"<<this->
description()<<
"\' does not support preconditioners "
356 "and has been configured to throw this exception when the initializePreconditionedOp(...) function is called!"
362 LinearOpWithSolveBase<double> *Op
363 ,
RCP<
const LinearOpSourceBase<double> > *fwdOpSrc
364 ,
RCP<
const PreconditionerBase<double> > *prec
365 ,
RCP<
const LinearOpSourceBase<double> > *approxFwdOpSrc
376 if(_fwdOpSrc.
get()) {
379 Teuchos::get_nonconst_extra_data< RCP<const Epetra_Operator> >(
380 epetraLP,epetraFwdOp_str
388 if(fwdOpSrc) *fwdOpSrc = _fwdOpSrc;
419 Teuchos::readVerboseObjectSublist(&*
paramList_,
this);
452 std::ostringstream oss;
453 oss <<
"Thyra::AmesosLinearOpWithSolveFactory{";
465 if(validParamList.
get()==NULL) {
469 #ifdef HAVE_AMESOS_KLU
478 Teuchos::setupVerboseObjectSublist(&*validParamList);
480 return validParamList;
ERefactorizationPolicy
The policy used on refactoring a matrix.
const std::string & name() const
Teuchos::RCP< const LinearOpSourceBase< double > > extract_fwdOpSrc()
Extract the LinearOpSourceBase<double> object so that it can be modified.
std::string typeName(const T &t)
const std::string toString(const EAdjointEpetraOp adjointEpetraOp)
Teuchos::StringToIntMap refactorizationPolicyNameToEnumMap
bool supportsPreconditionerInputType(const EPreconditionerInputType precOpType) const
Returns false .
T & get(ParameterList &l, const std::string &name)
bool isCompatible(const LinearOpSourceBase< double > &fwdOpSrc) const
Returns true if dynamic_cast<const EpetraLinearOpBase*>(fwdOpSrc)!=NULL .
Amesos::ESolverType solverType_
~AmesosLinearOpWithSolveFactory()
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
Teuchos::RCP< Amesos_BaseSolver > get_amesosSolver() const
static const std::string Amesos_Settings_name
RCP< ParameterList > sublist(const RCP< ParameterList > ¶mList, const std::string &name, bool mustAlreadyExist=false, const std::string &docString="")
ParameterList & set(std::string const &name, T &&value, std::string const &docString="", RCP< const ParameterEntryValidator > const &validator=null)
static const std::string SolverType_name
static const std::string RefactorizationPolicy_name
static const std::string ThrowOnPreconditionerInput_name
Teuchos::RCP< const Teuchos::ParameterList > getParameterList() const
int get(const std::string &option, const std::string &groupName="") const
void setParameterList(Teuchos::RCP< Teuchos::ParameterList > const ¶mList)
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
Teuchos::RCP< Teuchos::ParameterList > getNonconstParameterList()
Amesos::ERefactorizationPolicy refactorizationPolicy_
Teuchos::RCP< Teuchos::ParameterList > paramList_
T_To & dyn_cast(T_From &from)
void uninitializeOp(LinearOpWithSolveBase< double > *Op, Teuchos::RCP< const LinearOpSourceBase< double > > *fwdOpSrc, Teuchos::RCP< const PreconditionerBase< double > > *prec, Teuchos::RCP< const LinearOpSourceBase< double > > *approxFwdOpSrc, ESupportSolveUse *supportSolveUse) const
Teuchos::StringToIntMap solverTypeNameToEnumMap
void initialize(const Teuchos::RCP< const LinearOpBase< double > > &fwdOp, const Teuchos::RCP< const LinearOpSourceBase< double > > &fwdOpSrc, const Teuchos::RCP< Epetra_LinearProblem > &epetraLP, const Teuchos::RCP< Amesos_BaseSolver > &amesosSolver, const EOpTransp amesosSolverTransp, const double amesosSolverScalar)
First initialization.
Concrete LinearOpWithSolveBase subclass that adapts any Amesos_BaseSolver object. ...
Completely new pivoting will be used on refactorizations!
void validateParameters(ParameterList const &validParamList, int const depth=1000, EValidateUsed const validateUsed=VALIDATE_USED_ENABLED, EValidateDefaults const validateDefaults=VALIDATE_DEFAULTS_ENABLED) const
Teuchos::RCP< LinearOpWithSolveBase< double > > createOp() const
void initializeOp(const Teuchos::RCP< const LinearOpSourceBase< double > > &fwdOpSrc, LinearOpWithSolveBase< double > *Op, const ESupportSolveUse supportSolveUse) const
static Teuchos::RCP< const Teuchos::ParameterList > generateAndGetValidParameters()
void initializePreconditionedOp(const Teuchos::RCP< const LinearOpSourceBase< double > > &fwdOpSrc, const Teuchos::RCP< const PreconditionerBase< double > > &prec, LinearOpWithSolveBase< double > *Op, const ESupportSolveUse supportSolveUse) const
Throws exception if this->throwOnPrecInput()==true and calls this->initializeOp(fwdOpSrc,Op) otherwise.
AmesosLinearOpWithSolveFactory(const Amesos::ESolverType solverType=Amesos::LAPACK, const Amesos::ERefactorizationPolicy refactorizationPolicy=Amesos::REPIVOT_ON_REFACTORIZATION, const bool throwOnPrecInput=true)
Constructor which sets the defaults.
Teuchos::RCP< Epetra_LinearProblem > get_epetraLP() const
Teuchos::RCP< const Teuchos::ParameterList > getValidParameters() const
const char * toString(const ESolverType solverType)
std::string description() const
EOpTransp get_amesosSolverTransp() const
#define TEUCHOS_TEST_FOR_EXCEPT(throw_exception_test)
Teuchos::RCP< Teuchos::ParameterList > unsetParameterList()