44 #include "Thyra_AmesosLinearOpWithSolve.hpp"
46 #include "Thyra_MultiVectorStdOps.hpp"
47 #include "Epetra_MultiVector.h"
48 #include "Teuchos_TimeMonitor.hpp"
58 amesosSolverTransp_(Thyra::
NOTRANS),
59 amesosSolverScalar_(1.0)
69 const double amesosSolverScalar
72 this->
initialize(fwdOp,fwdOpSrc,epetraLP,amesosSolver,
73 amesosSolverTransp,amesosSolverScalar);
83 const double amesosSolverScalar
97 amesosSolver_ = amesosSolver;
98 amesosSolverTransp_ = amesosSolverTransp;
99 amesosSolverScalar_ = amesosSolverScalar;
100 const std::string fwdOpLabel = fwdOp_->getObjectLabel();
101 if(fwdOpLabel.length())
110 _fwdOpSrc = fwdOpSrc_;
111 fwdOpSrc_ = Teuchos::null;
122 double *amesosSolverScalar
126 if(fwdOp) *fwdOp = fwdOp_;
127 if(fwdOpSrc) *fwdOpSrc = fwdOpSrc_;
128 if(epetraLP) *epetraLP = epetraLP_;
129 if(amesosSolver) *amesosSolver = amesosSolver_;
130 if(amesosSolverTransp) *amesosSolverTransp = amesosSolverTransp_;
131 if(amesosSolverScalar) *amesosSolverScalar = amesosSolverScalar_;
133 fwdOp_ = Teuchos::null;
134 fwdOpSrc_ = Teuchos::null;
135 epetraLP_ = Teuchos::null;
136 amesosSolver_ = Teuchos::null;
138 amesosSolverScalar_ = 0.0;
149 return ( fwdOp_.get() ? fwdOp_->range() : Teuchos::null );
156 return ( fwdOp_.get() ? fwdOp_->domain() : Teuchos::null );
163 return Teuchos::null;
172 std::ostringstream oss;
176 <<
"{fwdOp="<<fwdOp_->description()
177 <<
",amesosSolver="<<
typeName(*amesosSolver_)<<
"}";
190 using Teuchos::describe;
202 <<
"rangeDim=" << this->
range()->dim()
203 <<
",domainDim="<< this->
domain()->dim() <<
"}\n";
206 out <<
"fwdOp = " <<
describe(*fwdOp_,verbLevel);
209 out <<
"amesosSolver=" <<
typeName(*amesosSolver_) <<
"\n";
227 return ::Thyra::opSupported(*fwdOp_,M_trans);
239 Thyra::apply( *fwdOp_, M_trans, X, Y, alpha, beta );
259 const bool oldUseTranspose = amesosSolver_->
UseTranspose();
260 const bool supportsAdjoint = (amesosSolver_->
SetUseTranspose(
true) == 0);
262 return supportsAdjoint;
282 using Teuchos::rcpFromPtr;
283 using Teuchos::rcpFromRef;
287 totalTimer.
start(
true);
289 THYRA_FUNC_TIME_MONITOR(
"Stratimikos: AmesosLOWS");
293 OSTab tab = this->getOSTab();
295 *out <<
"\nSolving block system using Amesos solver "
296 <<
typeName(*amesosSolver_) <<
" ...\n\n";
304 &opRangeMap = ( amesosOpTransp ==
NOTRANS
306 &opDomainMap = ( amesosOpTransp ==
NOTRANS
320 epetraLP_->
SetLHS(&*epetra_X);
321 epetraLP_->
SetRHS(const_cast<Epetra_MultiVector*>(&*epetra_B));
327 const bool oldUseTranspose = amesosSolver_->
UseTranspose();
329 const int err = amesosSolver_->
Solve();
331 "Error, the function Solve() on the amesos solver of type\n"
332 "\'"<<
typeName(*amesosSolver_)<<
"\' failed with error code "<<err<<
"!"
341 epetra_X = Teuchos::null;
342 epetra_B = Teuchos::null;
347 if(amesosSolverScalar_!=1.0)
348 Thyra::scale(1.0/amesosSolverScalar_, X);
357 std::string(
"Solver ")+
typeName(*amesosSolver_)+std::string(
" converged!");
RCP< Epetra_MultiVector > get_Epetra_MultiVector(const Epetra_Map &map, const RCP< MultiVectorBase< double > > &mv)
void SetLHS(Epetra_MultiVector *X)
Teuchos::RCP< const LinearOpSourceBase< double > > extract_fwdOpSrc()
Extract the LinearOpSourceBase<double> object so that it can be modified.
bool is_null(const boost::shared_ptr< T > &p)
Epetra_MultiVector * GetLHS() const
basic_OSTab< char > OSTab
Epetra_MultiVector * GetRHS() const
void describe(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel) const
virtual bool opSupportedImpl(EOpTransp M_trans) const
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
std::string description() const
EOpTransp real_trans(EOpTransp transp)
virtual const Epetra_Map & OperatorDomainMap() const =0
virtual bool solveSupportsImpl(EOpTransp M_trans) const
virtual const Epetra_Map & OperatorRangeMap() const =0
void start(bool reset=false)
virtual bool UseTranspose() const =0
SolveStatus< double > solveImpl(const EOpTransp M_trans, const MultiVectorBase< double > &B, const Ptr< MultiVectorBase< double > > &X, const Ptr< const SolveCriteria< double > > solveCriteria) const
Teuchos::RCP< const VectorSpaceBase< double > > range() const
EOpTransp trans_trans(EOpTransp trans1, EOpTransp trans2)
static ScalarMag unknownTolerance()
virtual std::string description() const
virtual void setObjectLabel(const std::string &objectLabel)
virtual bool solveSupportsSolveMeasureTypeImpl(EOpTransp M_trans, const SolveMeasureType &solveMeasureType) const
virtual int SetUseTranspose(bool UseTranspose)=0
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.
void uninitialize(Teuchos::RCP< const LinearOpBase< double > > *fwdOp=NULL, Teuchos::RCP< const LinearOpSourceBase< double > > *fwdOpSrc=NULL, Teuchos::RCP< Epetra_LinearProblem > *epetraLP=NULL, Teuchos::RCP< Amesos_BaseSolver > *amesosSolver=NULL, EOpTransp *amesosSolverTransp=NULL, double *amesosSolverScalar=NULL)
Uninitialize.
void SetRHS(Epetra_MultiVector *B)
virtual void applyImpl(const EOpTransp M_trans, const MultiVectorBase< double > &X, const Ptr< MultiVectorBase< double > > &Y, const double alpha, const double beta) const
Teuchos::RCP< const LinearOpBase< double > > clone() const
double totalElapsedTime(bool readCurrentTime=false) const
Epetra_Operator * GetOperator() const
Teuchos::RCP< const VectorSpaceBase< double > > domain() const
AmesosLinearOpWithSolve()
Construct to uninitialized.
#define TEUCHOS_TEST_FOR_EXCEPT(throw_exception_test)
std::string typeName(const T &t)