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 #ifndef __Teko_PreconditionerLinearOp_hpp__
00048 #define __Teko_PreconditionerLinearOp_hpp__
00049
00050 #include "Teko_PreconditionerLinearOpDecl.hpp"
00051
00052 #include "Thyra_LinearOpBase.hpp"
00053 #include "Thyra_PreconditionerBase.hpp"
00054
00055 namespace Teko {
00056
00057 template <typename ScalarT>
00058 PreconditionerLinearOp<ScalarT>::PreconditionerLinearOp()
00059 { }
00060
00061 template <typename ScalarT>
00062 PreconditionerLinearOp<ScalarT>::PreconditionerLinearOp(const Teuchos::RCP<Thyra::PreconditionerBase<ScalarT> > & prec)
00063 {
00064 preconditioner_.initialize(prec);
00065 }
00066
00067 template <typename ScalarT>
00068 PreconditionerLinearOp<ScalarT>::PreconditionerLinearOp(const Teuchos::RCP<const Thyra::PreconditionerBase<ScalarT> > & prec)
00069 {
00070 preconditioner_.initialize(prec);
00071 }
00072
00074 template <typename ScalarT>
00075 void PreconditionerLinearOp<ScalarT>::initialize(const Teuchos::RCP<Thyra::PreconditionerBase<ScalarT> > & prec)
00076 {
00077 uninitialize();
00078 preconditioner_.initialize(prec);
00079 }
00080
00082 template <typename ScalarT>
00083 void PreconditionerLinearOp<ScalarT>::initialize(const Teuchos::RCP<const Thyra::PreconditionerBase<ScalarT> > & prec)
00084 {
00085 uninitialize();
00086 preconditioner_.initialize(prec);
00087 }
00088
00090 template <typename ScalarT>
00091 void PreconditionerLinearOp<ScalarT>::uninitialize()
00092 {
00093 preconditioner_.uninitialize();
00094 }
00095
00097 template <typename ScalarT>
00098 Teuchos::RCP<const Thyra::VectorSpaceBase<ScalarT> > PreconditionerLinearOp<ScalarT>::range() const
00099 {
00100 return getOperator_cnoc()->range();
00101 }
00102
00104 template <typename ScalarT>
00105 Teuchos::RCP<const Thyra::VectorSpaceBase<ScalarT> > PreconditionerLinearOp<ScalarT>::domain() const
00106 {
00107 return getOperator_cnoc()->domain();
00108 }
00109
00110 template <typename ScalarT>
00111 bool PreconditionerLinearOp<ScalarT>::opSupportedImpl(
00112 const Thyra::EOpTransp M_trans) const
00113 {
00114 return getOperator_cnoc()->opSupported(M_trans);
00115 }
00116
00117 template <typename ScalarT>
00118 void PreconditionerLinearOp<ScalarT>::applyImpl(
00119 const Thyra::EOpTransp M_trans,
00120 const Thyra::MultiVectorBase<ScalarT> & x,
00121 const Teuchos::Ptr<Thyra::MultiVectorBase<ScalarT> > & y,
00122 const ScalarT alpha,
00123 const ScalarT beta
00124 ) const
00125 {
00126 getOperator_cnoc()->apply(M_trans, x, y, alpha, beta);
00127 }
00128
00129
00131 template <typename ScalarT>
00132 Teuchos::RCP<Thyra::PreconditionerBase<ScalarT> > PreconditionerLinearOp<ScalarT>::getNonconstPreconditioner()
00133 {
00134 return preconditioner_.getNonconstObj();
00135 }
00136
00138 template <typename ScalarT>
00139 Teuchos::RCP<const Thyra::PreconditionerBase<ScalarT> > PreconditionerLinearOp<ScalarT>::getPreconditioner() const
00140 {
00141 return preconditioner_.getConstObj();
00142 }
00143
00145 template <typename ScalarT>
00146 Teuchos::ConstNonconstObjectContainer<Thyra::LinearOpBase<ScalarT> > PreconditionerLinearOp<ScalarT>::getOperator_cnoc() const
00147 {
00148 Teuchos::ConstNonconstObjectContainer<Thyra::LinearOpBase<ScalarT> > oper;
00149 oper.initialize(preconditioner_.getConstObj()->getUnspecifiedPrecOp());
00150
00151 return oper;
00152 }
00153
00155 template <typename ScalarT>
00156 Teuchos::ConstNonconstObjectContainer<Thyra::LinearOpBase<ScalarT> > PreconditionerLinearOp<ScalarT>::getOperator_cnoc()
00157 {
00158 Teuchos::ConstNonconstObjectContainer<Thyra::LinearOpBase<ScalarT> > oper;
00159 oper.initialize(preconditioner_.getNonconstObj()->getNonconstUnspecifiedPrecOp());
00160
00161 return oper;
00162 }
00163
00164 template <typename ScalarT>
00165 void PreconditionerLinearOp<ScalarT>::describe(Teuchos::FancyOStream & out_arg,
00166 const Teuchos::EVerbosityLevel verbLevel) const
00167 {
00168 using Teuchos::OSTab;
00169
00170 Teuchos::RCP<Teuchos::FancyOStream> out = rcp(&out_arg,false);
00171 OSTab tab(out);
00172 switch(verbLevel) {
00173 case Teuchos::VERB_DEFAULT:
00174 case Teuchos::VERB_LOW:
00175 *out << this->description() << " ( [Operator] = " << getOperator_cnoc()->description() << " )" << std::endl;
00176 break;
00177 case Teuchos::VERB_MEDIUM:
00178 case Teuchos::VERB_HIGH:
00179 case Teuchos::VERB_EXTREME:
00180 {
00181 *out << Teuchos::Describable::description() << "{"
00182 << "rangeDim=" << this->range()->dim()
00183 << ",domainDim=" << this->domain()->dim()
00184 << "}\n";
00185 {
00186 OSTab tab(out);
00187 *out << "[Operator] = ";
00188 *out << Teuchos::describe(*getOperator_cnoc(),verbLevel);
00189 }
00190 break;
00191 }
00192 default:
00193 TEUCHOS_TEST_FOR_EXCEPT(true);
00194 }
00195 }
00196
00197 inline Teko::LinearOp extractOperatorFromPrecOp(const Teko::LinearOp & lo)
00198 {
00199 Teuchos::RCP<const Teko::PreconditionerLinearOp<double> > plo =
00200 Teuchos::rcp_dynamic_cast<const Teko::PreconditionerLinearOp<double> >(lo);
00201 if(plo!=Teuchos::null)
00202 return plo->getOperator();
00203 else
00204 return lo;
00205 }
00206
00207 }
00208
00209 #endif