Thyra_DefaultPreconditioner_def.hpp

00001 // @HEADER
00002 // ***********************************************************************
00003 // 
00004 //    Thyra: Interfaces and Support for Abstract Numerical Algorithms
00005 //                 Copyright (2004) Sandia Corporation
00006 // 
00007 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
00008 // license for use of this work by or on behalf of the U.S. Government.
00009 // 
00010 // This library is free software; you can redistribute it and/or modify
00011 // it under the terms of the GNU Lesser General Public License as
00012 // published by the Free Software Foundation; either version 2.1 of the
00013 // License, or (at your option) any later version.
00014 //  
00015 // This library is distributed in the hope that it will be useful, but
00016 // WITHOUT ANY WARRANTY; without even the implied warranty of
00017 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00018 // Lesser General Public License for more details.
00019 //  
00020 // You should have received a copy of the GNU Lesser General Public
00021 // License along with this library; if not, write to the Free Software
00022 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
00023 // USA
00024 // Questions? Contact Michael A. Heroux (maherou@sandia.gov) 
00025 // 
00026 // ***********************************************************************
00027 // @HEADER
00028 
00029 #ifndef THYRA_DEFUALT_PRECONDITIONER_DEF_HPP
00030 #define THYRA_DEFUALT_PRECONDITIONER_DEF_HPP
00031 
00032 #include "Thyra_DefaultPreconditioner_decl.hpp"
00033 #include "Thyra_LinearOpBase.hpp"
00034 
00035 
00036 namespace Thyra {
00037 
00038 
00039 // Constructors/initializers/accessors
00040 
00041 
00042 template <class Scalar>
00043 DefaultPreconditioner<Scalar>::DefaultPreconditioner()
00044 {}
00045 
00046 
00047 template <class Scalar>
00048 DefaultPreconditioner<Scalar>::DefaultPreconditioner(
00049   const Teuchos::RCP<LinearOpBase<Scalar> > &leftPrecOp,
00050   const Teuchos::RCP<LinearOpBase<Scalar> > &rightPrecOp
00051  )
00052 {
00053 #ifdef TEUCHOS_DEBUG
00054   TEST_FOR_EXCEPT( is_null(leftPrecOp) && is_null(rightPrecOp) );
00055 #endif
00056   if (!is_null(leftPrecOp))
00057     leftPrecOp_.initialize(leftPrecOp);
00058   if (!is_null(rightPrecOp))
00059     rightPrecOp_.initialize(rightPrecOp);
00060 }
00061 
00062 
00063 template <class Scalar>
00064 DefaultPreconditioner<Scalar>::DefaultPreconditioner(
00065   const Teuchos::RCP<const LinearOpBase<Scalar> > &leftPrecOp,
00066   const Teuchos::RCP<const LinearOpBase<Scalar> > &rightPrecOp
00067   )
00068 {
00069 #ifdef TEUCHOS_DEBUG
00070   TEST_FOR_EXCEPT( is_null(leftPrecOp) && is_null(rightPrecOp) );
00071 #endif
00072   if (!is_null(leftPrecOp))
00073     leftPrecOp_.initialize(leftPrecOp);
00074   if (!is_null(rightPrecOp))
00075     rightPrecOp_.initialize(rightPrecOp);
00076 }
00077 
00078 
00079 template <class Scalar>
00080 DefaultPreconditioner<Scalar>::DefaultPreconditioner(
00081   const Teuchos::RCP<LinearOpBase<Scalar> > &unspecifiedPrecOp
00082   )
00083 {
00084   unspecifiedPrecOp_.initialize(unspecifiedPrecOp);
00085 }
00086 
00087 
00088 template <class Scalar>
00089 DefaultPreconditioner<Scalar>::DefaultPreconditioner(
00090   const Teuchos::RCP<const LinearOpBase<Scalar> > &unspecifiedPrecOp
00091   )
00092 {
00093   unspecifiedPrecOp_.initialize(unspecifiedPrecOp);
00094 }
00095 
00096 
00097 template <class Scalar>
00098 void DefaultPreconditioner<Scalar>::initializeLeft(
00099   const Teuchos::RCP<LinearOpBase<Scalar> > &leftPrecOp
00100   )
00101 {
00102   uninitialize();
00103   leftPrecOp_.initialize(leftPrecOp);
00104 }
00105 
00106 
00107 template <class Scalar>
00108 void DefaultPreconditioner<Scalar>::initializeLeft(
00109   const Teuchos::RCP<const LinearOpBase<Scalar> > &leftPrecOp
00110   )
00111 {
00112   uninitialize();
00113   leftPrecOp_.initialize(leftPrecOp);
00114 }
00115 
00116 
00117 template <class Scalar>
00118 void DefaultPreconditioner<Scalar>::initializeRight(
00119   const Teuchos::RCP<LinearOpBase<Scalar> > &rightPrecOp
00120   )
00121 {
00122   uninitialize();
00123   rightPrecOp_.initialize(rightPrecOp);
00124 }
00125 
00126 
00127 template <class Scalar>
00128 void DefaultPreconditioner<Scalar>::initializeRight(
00129   const Teuchos::RCP<const LinearOpBase<Scalar> > &rightPrecOp
00130   )
00131 {
00132   uninitialize();
00133   rightPrecOp_.initialize(rightPrecOp);
00134 }
00135 
00136 
00137 template <class Scalar>
00138 void DefaultPreconditioner<Scalar>::initializeLeftRight(
00139   const Teuchos::RCP<LinearOpBase<Scalar> > &leftPrecOp,
00140   const Teuchos::RCP<LinearOpBase<Scalar> > &rightPrecOp
00141   )
00142 {
00143   uninitialize();
00144   rightPrecOp_.initialize(rightPrecOp);
00145   leftPrecOp_.initialize(leftPrecOp);
00146 }
00147 
00148 
00149 template <class Scalar>
00150 void DefaultPreconditioner<Scalar>::initializeLeftRight(
00151   const Teuchos::RCP<const LinearOpBase<Scalar> > &leftPrecOp,
00152   const Teuchos::RCP<const LinearOpBase<Scalar> > &rightPrecOp
00153   )
00154 {
00155   uninitialize();
00156   rightPrecOp_.initialize(rightPrecOp);
00157   leftPrecOp_.initialize(leftPrecOp);
00158 }
00159 
00160 
00161 template <class Scalar>
00162 void DefaultPreconditioner<Scalar>::initializeUnspecified(
00163   const Teuchos::RCP<LinearOpBase<Scalar> > &unspecifiedPrecOp
00164   )
00165 {
00166   uninitialize();
00167   unspecifiedPrecOp_.initialize(unspecifiedPrecOp);
00168 }
00169 
00170 
00171 template <class Scalar>
00172 void DefaultPreconditioner<Scalar>::initializeUnspecified(
00173   const Teuchos::RCP<const LinearOpBase<Scalar> > &unspecifiedPrecOp
00174   )
00175 {
00176   uninitialize();
00177   unspecifiedPrecOp_.initialize(unspecifiedPrecOp);
00178 }
00179 
00180 
00181 template <class Scalar>
00182 void DefaultPreconditioner<Scalar>::uninitialize()
00183 {
00184   leftPrecOp_.uninitialize();
00185   rightPrecOp_.uninitialize();
00186   unspecifiedPrecOp_.uninitialize();
00187 }
00188 
00189 
00190 // Overridden from PreconditionerBase
00191 
00192 
00193 template <class Scalar>
00194 bool DefaultPreconditioner<Scalar>::isLeftPrecOpConst() const
00195 {
00196   return leftPrecOp_.isConst();
00197 }
00198 
00199 
00200 template <class Scalar>
00201 Teuchos::RCP<LinearOpBase<Scalar> >
00202 DefaultPreconditioner<Scalar>::getNonconstLeftPrecOp()
00203 {
00204   return leftPrecOp_.getNonconstObj();
00205 }
00206 
00207 
00208 template <class Scalar>
00209 Teuchos::RCP<const LinearOpBase<Scalar> >
00210 DefaultPreconditioner<Scalar>::getLeftPrecOp() const
00211 {
00212   return leftPrecOp_.getConstObj();
00213 }
00214 
00215 
00216 template <class Scalar>
00217 bool DefaultPreconditioner<Scalar>::isRightPrecOpConst() const
00218 {
00219   return rightPrecOp_.isConst();
00220 }
00221 
00222 
00223 template <class Scalar>
00224 Teuchos::RCP<LinearOpBase<Scalar> >
00225 DefaultPreconditioner<Scalar>::getNonconstRightPrecOp()
00226 {
00227   return rightPrecOp_.getNonconstObj();
00228 }
00229 
00230 
00231 template <class Scalar>
00232 Teuchos::RCP<const LinearOpBase<Scalar> >
00233 DefaultPreconditioner<Scalar>::getRightPrecOp() const
00234 {
00235   return rightPrecOp_.getConstObj();
00236 }
00237 
00238 
00239 template <class Scalar>
00240 bool DefaultPreconditioner<Scalar>::isUnspecifiedPrecOpConst() const
00241 {
00242   return unspecifiedPrecOp_.isConst();
00243 }
00244 
00245 
00246 template <class Scalar>
00247 Teuchos::RCP<LinearOpBase<Scalar> >
00248 DefaultPreconditioner<Scalar>::getNonconstUnspecifiedPrecOp()
00249 {
00250   return unspecifiedPrecOp_.getNonconstObj();
00251 }
00252 
00253 
00254 template <class Scalar>
00255 Teuchos::RCP<const LinearOpBase<Scalar> >
00256 DefaultPreconditioner<Scalar>::getUnspecifiedPrecOp() const
00257 {
00258   return unspecifiedPrecOp_.getConstObj();
00259 }
00260 
00261 
00262 // Overridden from Teuchos::Describable
00263 
00264                                                 
00265 template <class Scalar>
00266 std::string DefaultPreconditioner<Scalar>::description() const
00267 {
00268   std::ostringstream oss;
00269   oss << Teuchos::Describable::description() << "{";
00270   bool wroteOne = false;
00271   if(!is_null(leftPrecOp_.getConstObj())) {
00272     if(wroteOne) oss << ",";
00273     oss << "leftPrecOp=" << leftPrecOp_.getConstObj()->description();
00274     wroteOne = true;
00275   }
00276   if(!is_null(rightPrecOp_.getConstObj())) {
00277     if(wroteOne) oss << ",";
00278     oss << "rightPrecOp=" << rightPrecOp_.getConstObj()->description();
00279     wroteOne = true;
00280   }
00281   if(!is_null(unspecifiedPrecOp_.getConstObj())) {
00282     if(wroteOne) oss << ",";
00283     oss << "unspecifiedPrecOp=" << unspecifiedPrecOp_.getConstObj()->description();
00284     wroteOne = true;
00285   }
00286   oss << "}";
00287   return oss.str();
00288 }
00289 
00290 
00291 template <class Scalar>
00292 void DefaultPreconditioner<Scalar>::describe(
00293   Teuchos::FancyOStream &out,
00294   const Teuchos::EVerbosityLevel verbLevel
00295   ) const
00296 {
00297   using Teuchos::FancyOStream;
00298   using Teuchos::OSTab;
00299   using Teuchos::describe;
00300   OSTab tab(out);
00301   switch(verbLevel) {
00302     case Teuchos::VERB_DEFAULT:
00303     case Teuchos::VERB_LOW:
00304       out << Teuchos::Describable::description() << std::endl;
00305       break;
00306     case Teuchos::VERB_MEDIUM:
00307     case Teuchos::VERB_HIGH:
00308     case Teuchos::VERB_EXTREME:
00309     {
00310       out
00311         << Teuchos::typeName(*this) << "\n";
00312       OSTab tab2(out);
00313       if(!is_null(leftPrecOp_.getConstObj()))
00314         out << "leftPrecOp=" << describe(*leftPrecOp_.getConstObj(),verbLevel);
00315       if(!is_null(rightPrecOp_.getConstObj()))
00316         out << "rig htPrecOp=" << describe(*rightPrecOp_.getConstObj(),verbLevel);
00317       if(!is_null(unspecifiedPrecOp_.getConstObj()))
00318         out << "unspecifiedPrecOp=" << describe(*unspecifiedPrecOp_.getConstObj(),verbLevel);
00319       break;
00320     }
00321     default:
00322       TEST_FOR_EXCEPT(true); // Should never get here!
00323   }
00324 }
00325 
00326 
00327 } // namespace Thyra
00328 
00329 
00330 #endif // THYRA_DEFUALT_PRECONDITIONER_DEF_HPP
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
Generated on Wed Apr 13 10:00:08 2011 for Thyra by  doxygen 1.6.3