00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047 #include "Teko_SolveInverseFactory.hpp"
00048
00049
00050 #include "Thyra_DefaultLinearOpSource.hpp"
00051 #include "Thyra_DefaultInverseLinearOp.hpp"
00052 #include "Thyra_DefaultPreconditioner.hpp"
00053
00054
00055 #include "Stratimikos_DefaultLinearSolverBuilder.hpp"
00056
00057
00058 #include "Teko_Utilities.hpp"
00059 #include "Teko_BlockPreconditionerFactory.hpp"
00060 #include "Teko_Preconditioner.hpp"
00061 #include "Teko_PreconditionerLinearOp.hpp"
00062
00063 using Teuchos::rcp;
00064 using Teuchos::rcp_const_cast;
00065 using Teuchos::rcp_dynamic_cast;
00066 using Teuchos::RCP;
00067
00068 namespace Teko {
00069
00079 SolveInverseFactory::SolveInverseFactory(const Teuchos::RCP<Thyra::LinearOpWithSolveFactoryBase<double> > & lowsFactory)
00080 : lowsFactory_(lowsFactory)
00081 { }
00082
00084 SolveInverseFactory::SolveInverseFactory(const SolveInverseFactory & siFactory)
00085 : lowsFactory_(siFactory.lowsFactory_)
00086 { }
00087
00097 InverseLinearOp SolveInverseFactory::buildInverse(const LinearOp & linearOp) const
00098 {
00099 Teko_DEBUG_SCOPE("SolveInverseFactory::buildInverse(linearOp)",10);
00100
00101
00102 Teuchos::RCP<Thyra::LinearOpWithSolveBase<double> > invLOWS = lowsFactory_->createOp();
00103 lowsFactory_->initializeOp(Thyra::defaultLinearOpSource(linearOp),&*invLOWS,Thyra::SUPPORT_SOLVE_FORWARD_ONLY);
00104
00105 return Thyra::nonconstInverse<double>(invLOWS);
00106 }
00107
00120 InverseLinearOp SolveInverseFactory::buildInverse(const LinearOp & linearOp,const LinearOp & precOp) const
00121 {
00122 Teko_DEBUG_SCOPE("SolveInverseFactory::buildInverse(linearOp,precOp)",10);
00123
00124
00125 Teuchos::RCP<Thyra::LinearOpWithSolveBase<double> > invLOWS = lowsFactory_->createOp();
00126 lowsFactory_->initializePreconditionedOp(Thyra::defaultLinearOpSource(linearOp),
00127 Thyra::unspecifiedPrec(precOp),
00128 &*invLOWS,Thyra::SUPPORT_SOLVE_FORWARD_ONLY);
00129
00130 return Thyra::nonconstInverse<double>(invLOWS);
00131 }
00132
00144 void SolveInverseFactory::rebuildInverse(const LinearOp & source,InverseLinearOp & dest) const
00145 {
00146 RCP<Thyra::DefaultInverseLinearOp<double> > invDest = rcp_dynamic_cast<Thyra::DefaultInverseLinearOp<double> >(dest);
00147 RCP<Thyra::LinearOpWithSolveBase<double> > lows = invDest->getNonconstLows();
00148
00149
00150
00151
00152 lowsFactory_->initializeOp(Thyra::defaultLinearOpSource(source),&*lows);
00153 }
00154
00167 void SolveInverseFactory::rebuildInverse(const LinearOp & source,const LinearOp & precOp,InverseLinearOp & dest) const
00168 {
00169 RCP<Thyra::DefaultInverseLinearOp<double> > invDest = rcp_dynamic_cast<Thyra::DefaultInverseLinearOp<double> >(dest);
00170 RCP<Thyra::LinearOpWithSolveBase<double> > lows = invDest->getNonconstLows();
00171
00172
00173 lowsFactory_->initializePreconditionedOp(Thyra::defaultLinearOpSource(source),
00174 Thyra::unspecifiedPrec(precOp),
00175 &*lows,Thyra::SUPPORT_SOLVE_FORWARD_ONLY);
00176 }
00177
00186 Teuchos::RCP<const Teuchos::ParameterList> SolveInverseFactory::getParameterList() const
00187 {
00188 return lowsFactory_->getParameterList();
00189 }
00190
00191 }