Thyra Version of the Day
Thyra_DelayedLinearOpWithSolveFactory_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 // Redistribution and use in source and binary forms, with or without
00011 // modification, are permitted provided that the following conditions are
00012 // met:
00013 //
00014 // 1. Redistributions of source code must retain the above copyright
00015 // notice, this list of conditions and the following disclaimer.
00016 //
00017 // 2. Redistributions in binary form must reproduce the above copyright
00018 // notice, this list of conditions and the following disclaimer in the
00019 // documentation and/or other materials provided with the distribution.
00020 //
00021 // 3. Neither the name of the Corporation nor the names of the
00022 // contributors may be used to endorse or promote products derived from
00023 // this software without specific prior written permission.
00024 //
00025 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
00026 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00027 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
00028 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
00029 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
00030 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
00031 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
00032 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
00033 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
00034 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00035 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00036 //
00037 // Questions? Contact Roscoe A. Bartlett (bartlettra@ornl.gov) 
00038 // 
00039 // ***********************************************************************
00040 // @HEADER
00041 
00042 #ifndef THYRA_DELAYED_LINEAR_OP_WITH_SOLVE_FACTORY_HPP
00043 #define THYRA_DELAYED_LINEAR_OP_WITH_SOLVE_FACTORY_HPP
00044 
00045 
00046 #include "Thyra_DelayedLinearOpWithSolveFactory_decl.hpp"
00047 #include "Thyra_LinearOpWithSolveBase.hpp"
00048 #include "Thyra_DelayedLinearOpWithSolve.hpp"
00049 
00050 
00051 namespace Thyra {
00052 
00053 
00054 // Overridden from Constructors/Initializers/Accessors
00055 
00056   
00057 template<class Scalar>
00058 DelayedLinearOpWithSolveFactory<Scalar>::DelayedLinearOpWithSolveFactory(
00059   const RCP<LinearOpWithSolveFactoryBase<Scalar> > &lowsf
00060   )
00061 {
00062 #ifdef TEUCHOS_DEBUG
00063   TEUCHOS_TEST_FOR_EXCEPT(is_null(lowsf));
00064 #endif
00065   lowsf_ = lowsf;
00066 }
00067 
00068 template<class Scalar>
00069 RCP<LinearOpWithSolveFactoryBase<Scalar> >
00070 DelayedLinearOpWithSolveFactory<Scalar>::getUnderlyingLOWSF()
00071 {
00072   return lowsf_;
00073 }
00074 
00075 
00076 template<class Scalar>
00077 RCP<const LinearOpWithSolveFactoryBase<Scalar> >
00078 DelayedLinearOpWithSolveFactory<Scalar>::getUnderlyingLOWSF() const
00079 {
00080   return lowsf_;
00081 }
00082 
00083 
00084 // Overridden from Teuchos::Describable
00085 
00086 
00087 template<class Scalar>
00088 std::string DelayedLinearOpWithSolveFactory<Scalar>::description() const
00089 {
00090   std::ostringstream oss;
00091   oss << this->Teuchos::Describable::description()
00092       << "{"
00093       << "lowsf=";
00094   if (!is_null(lowsf_))
00095     oss << lowsf_->description();
00096   else
00097     oss << "NULL";
00098   oss << "}";
00099   return oss.str();
00100 }
00101 
00102 
00103 // Overridden from ParameterListAcceptor
00104 
00105 
00106 template<class Scalar>
00107 void DelayedLinearOpWithSolveFactory<Scalar>::setParameterList(
00108   RCP<ParameterList> const& paramList
00109   )
00110 {
00111   lowsf_->setParameterList(paramList);
00112 }
00113 
00114 
00115 template<class Scalar>
00116 RCP<ParameterList>
00117 DelayedLinearOpWithSolveFactory<Scalar>::getNonconstParameterList()
00118 {
00119   return lowsf_->getNonconstParameterList();
00120 }
00121 
00122 
00123 template<class Scalar>
00124 RCP<ParameterList> 
00125 DelayedLinearOpWithSolveFactory<Scalar>::unsetParameterList()
00126 {
00127   return lowsf_->unsetParameterList();
00128 }
00129 
00130 
00131 template<class Scalar>
00132 RCP<const ParameterList>
00133 DelayedLinearOpWithSolveFactory<Scalar>::getParameterList() const
00134 {
00135   return lowsf_->getParameterList();
00136 }
00137 
00138 
00139 template<class Scalar>
00140 RCP<const ParameterList>
00141 DelayedLinearOpWithSolveFactory<Scalar>::getValidParameters() const
00142 {
00143   return lowsf_->getValidParameters();
00144 }
00145 
00146 
00147 // Overridden from LinearOpWithSolveFactoyBase
00148 
00149 
00150 template<class Scalar>
00151 bool DelayedLinearOpWithSolveFactory<Scalar>::acceptsPreconditionerFactory() const
00152 {
00153   return lowsf_->acceptsPreconditionerFactory();
00154 }
00155 
00156 
00157 template<class Scalar>
00158 void DelayedLinearOpWithSolveFactory<Scalar>::setPreconditionerFactory(
00159   const RCP<PreconditionerFactoryBase<Scalar> > &precFactory,
00160   const std::string &precFactoryName
00161   )
00162 {
00163   lowsf_->setPreconditionerFactory(precFactory,precFactoryName);
00164 }
00165 
00166 
00167 template<class Scalar>
00168 RCP<PreconditionerFactoryBase<Scalar> >
00169 DelayedLinearOpWithSolveFactory<Scalar>::getPreconditionerFactory() const
00170 {
00171   return lowsf_->getPreconditionerFactory();
00172 }
00173 
00174 
00175 template<class Scalar>
00176 void DelayedLinearOpWithSolveFactory<Scalar>::unsetPreconditionerFactory(
00177   RCP<PreconditionerFactoryBase<Scalar> > *precFactory,
00178   std::string *precFactoryName
00179   )
00180 {
00181   lowsf_->unsetPreconditionerFactory(precFactory);
00182 }
00183 
00184 
00185 template<class Scalar>
00186 bool DelayedLinearOpWithSolveFactory<Scalar>::isCompatible(
00187   const LinearOpSourceBase<Scalar> &fwdOpSrc
00188   ) const
00189 {
00190   return lowsf_->isCompatible(fwdOpSrc);
00191 }
00192 
00193 
00194 template<class Scalar>
00195 RCP<LinearOpWithSolveBase<Scalar> >
00196 DelayedLinearOpWithSolveFactory<Scalar>::createOp() const
00197 {
00198   RCP<LinearOpWithSolveBase<Scalar> >
00199     dlows = Teuchos::rcp(new DelayedLinearOpWithSolve<Scalar>());
00200   dlows->setVerbLevel(this->getVerbLevel());
00201   dlows->setOStream(this->getOStream());
00202   return dlows;
00203 }
00204 
00205 
00206 template<class Scalar>
00207 void DelayedLinearOpWithSolveFactory<Scalar>::initializeOp(
00208   const RCP<const LinearOpSourceBase<Scalar> > &fwdOpSrc,
00209   LinearOpWithSolveBase<Scalar> *Op,
00210   const ESupportSolveUse supportSolveUse
00211   ) const
00212 {
00213   using Teuchos::null;
00214 #ifdef TEUCHOS_DEBUG
00215   TEUCHOS_TEST_FOR_EXCEPT(is_null(fwdOpSrc));
00216   TEUCHOS_TEST_FOR_EXCEPT(0==Op);
00217 #endif
00218   DelayedLinearOpWithSolve<Scalar>
00219     &dlows = Teuchos::dyn_cast<DelayedLinearOpWithSolve<Scalar> >(*Op);
00220   dlows.initialize( fwdOpSrc, null, null, supportSolveUse, lowsf_ );
00221 }
00222 
00223 
00224 template<class Scalar>
00225 void DelayedLinearOpWithSolveFactory<Scalar>::initializeAndReuseOp(
00226   const RCP<const LinearOpSourceBase<Scalar> > &fwdOpSrc,
00227   LinearOpWithSolveBase<Scalar> *Op
00228   ) const
00229 {
00230   TEUCHOS_TEST_FOR_EXCEPT(true);
00231 }
00232 
00233 
00234 template<class Scalar>
00235 void DelayedLinearOpWithSolveFactory<Scalar>::uninitializeOp(
00236   LinearOpWithSolveBase<Scalar> *Op,
00237   RCP<const LinearOpSourceBase<Scalar> > *fwdOpSrc,
00238   RCP<const PreconditionerBase<Scalar> > *prec,
00239   RCP<const LinearOpSourceBase<Scalar> > *approxFwdOpSrc,
00240   ESupportSolveUse *supportSolveUse
00241   ) const
00242 {
00243 
00244   using Teuchos::dyn_cast;
00245 
00246 #ifdef TEUCHOS_DEBUG
00247   TEUCHOS_TEST_FOR_EXCEPT(0==Op);
00248 #endif
00249 
00250   DelayedLinearOpWithSolve<Scalar>
00251     &dlows = dyn_cast<DelayedLinearOpWithSolve<Scalar> >(*Op);
00252   
00253   if (fwdOpSrc)
00254     *fwdOpSrc = dlows.getFwdOpSrc();
00255   if (prec)
00256     *prec = dlows.getPrec();
00257   if (approxFwdOpSrc)
00258     *approxFwdOpSrc = dlows.getApproxFwdOpSrc();
00259   if (supportSolveUse)
00260     *supportSolveUse = dlows.getSupportSolveUse();
00261 
00262   // ToDo: 2007/08/16: rabartl: Consider uninitalizing dlows?
00263 
00264 }
00265 
00266 
00267 template<class Scalar>
00268 bool DelayedLinearOpWithSolveFactory<Scalar>::supportsPreconditionerInputType(
00269   const EPreconditionerInputType precOpType
00270   ) const
00271 {
00272   return lowsf_->supportsPreconditionerInputType(precOpType);
00273 }
00274 
00275 
00276 template<class Scalar>
00277 void DelayedLinearOpWithSolveFactory<Scalar>::initializePreconditionedOp(
00278   const RCP<const LinearOpSourceBase<Scalar> > &fwdOpSrc,
00279   const RCP<const PreconditionerBase<Scalar> > &prec,
00280   LinearOpWithSolveBase<Scalar> *Op,
00281   const ESupportSolveUse supportSolveUse
00282   ) const
00283 {
00284   using Teuchos::null;
00285 #ifdef TEUCHOS_DEBUG
00286   TEUCHOS_TEST_FOR_EXCEPT(is_null(fwdOpSrc));
00287   TEUCHOS_TEST_FOR_EXCEPT(0==Op);
00288 #endif
00289   DelayedLinearOpWithSolve<Scalar>
00290     &dlows = Teuchos::dyn_cast<DelayedLinearOpWithSolve<Scalar> >(*Op);
00291   dlows.initialize( fwdOpSrc, prec, null, supportSolveUse, lowsf_ );
00292 }
00293 
00294 
00295 template<class Scalar>
00296 void DelayedLinearOpWithSolveFactory<Scalar>::initializeApproxPreconditionedOp(
00297   const RCP<const LinearOpSourceBase<Scalar> > &fwdOpSrc,
00298   const RCP<const LinearOpSourceBase<Scalar> > &approxFwdOpSrc,
00299   LinearOpWithSolveBase<Scalar> *Op,
00300   const ESupportSolveUse supportSolveUse
00301   ) const
00302 {
00303   using Teuchos::null;
00304 #ifdef TEUCHOS_DEBUG
00305   TEUCHOS_TEST_FOR_EXCEPT(is_null(fwdOpSrc));
00306   TEUCHOS_TEST_FOR_EXCEPT(0==Op);
00307 #endif
00308   DelayedLinearOpWithSolve<Scalar>
00309     &dlows = Teuchos::dyn_cast<DelayedLinearOpWithSolve<Scalar> >(*Op);
00310   dlows.initialize( fwdOpSrc, null, approxFwdOpSrc, supportSolveUse, lowsf_ );
00311 }
00312 
00313 
00314 // protected
00315 
00316 
00317 template<class Scalar>
00318 void DelayedLinearOpWithSolveFactory<Scalar>::informUpdatedVerbosityState() const
00319 {
00320   lowsf_->setVerbLevel(this->getVerbLevel());
00321   lowsf_->setOStream(this->getOStream());
00322 }
00323 
00324 
00325 } // namespace Thyra
00326 
00327 
00328 #endif // THYRA_DELAYED_LINEAR_OP_WITH_SOLVE_FACTORY_HPP
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines