Thyra Package Browser (Single Doxygen Collection) Version of the Day
Thyra_DefaultSerialDenseLinearOpWithSolveFactory_def.hpp
Go to the documentation of this file.
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_DEFAULT_SERIAL_DENSE_LINEAR_OP_WITH_SOLVE_FACTORY_HPP
00030 #define THYRA_DEFAULT_SERIAL_DENSE_LINEAR_OP_WITH_SOLVE_FACTORY_HPP
00031 
00032 
00033 #include "Thyra_DefaultSerialDenseLinearOpWithSolveFactory_decl.hpp"
00034 #include "Thyra_DefaultSerialDenseLinearOpWithSolve.hpp"
00035 #include "Thyra_LinearOpWithSolveFactoryHelpers.hpp"
00036 #include "Thyra_ScaledAdjointLinearOpBase.hpp"
00037 #include "Thyra_DefaultLinearOpSource.hpp"
00038 
00039 
00040 namespace Thyra {
00041 
00042 
00043 // Overridden from ParameterListAcceptor
00044 
00045 
00046 template<class Scalar>
00047 void DefaultSerialDenseLinearOpWithSolveFactory<Scalar>::setParameterList(
00048   RCP<ParameterList> const& paramList
00049   )
00050 {
00051   paramList->validateParameters(*this->getValidParameters());
00052   // Nothing to set because we have not parameters!
00053 }
00054 
00055 
00056 template<class Scalar>
00057 RCP<const ParameterList>
00058 DefaultSerialDenseLinearOpWithSolveFactory<Scalar>::getValidParameters() const
00059 {
00060   static RCP<const ParameterList> validPL = Teuchos::parameterList();
00061   return validPL;
00062 }
00063 
00064 
00065 // Overridden from LinearOpWithSolveFactoyBase
00066 
00067 
00068 template<class Scalar>
00069 bool DefaultSerialDenseLinearOpWithSolveFactory<Scalar>::acceptsPreconditionerFactory() const
00070 {
00071   return false;
00072 }
00073 
00074 
00075 template<class Scalar>
00076 void DefaultSerialDenseLinearOpWithSolveFactory<Scalar>::setPreconditionerFactory(
00077   const RCP<PreconditionerFactoryBase<Scalar> > &precFactory,
00078   const std::string &precFactoryName
00079   )
00080 {
00081   TEST_FOR_EXCEPT_MSG(true, "Error, we don't support a preconditioner factory!");
00082 }
00083 
00084 
00085 template<class Scalar>
00086 RCP<PreconditionerFactoryBase<Scalar> >
00087 DefaultSerialDenseLinearOpWithSolveFactory<Scalar>::getPreconditionerFactory() const
00088 {
00089   return Teuchos::null;
00090 }
00091 
00092 
00093 template<class Scalar>
00094 void DefaultSerialDenseLinearOpWithSolveFactory<Scalar>::unsetPreconditionerFactory(
00095   RCP<PreconditionerFactoryBase<Scalar> > *precFactory,
00096   std::string *precFactoryName
00097   )
00098 {
00099   TEST_FOR_EXCEPT_MSG(true, "Error, we don't support a preconditioner factory!");
00100 }
00101 
00102 
00103 template<class Scalar>
00104 bool DefaultSerialDenseLinearOpWithSolveFactory<Scalar>::isCompatible(
00105   const LinearOpSourceBase<Scalar> &fwdOpSrc
00106   ) const
00107 {
00108   return !is_null(
00109     Teuchos::rcp_dynamic_cast<const MultiVectorBase<Scalar> >(fwdOpSrc.getOp()));
00110 }
00111 
00112 
00113 template<class Scalar>
00114 RCP<LinearOpWithSolveBase<Scalar> >
00115 DefaultSerialDenseLinearOpWithSolveFactory<Scalar>::createOp() const
00116 {
00117   return defaultSerialDenseLinearOpWithSolve<Scalar>();
00118 }
00119 
00120 
00121 template<class Scalar>
00122 void DefaultSerialDenseLinearOpWithSolveFactory<Scalar>::initializeOp(
00123   const RCP<const LinearOpSourceBase<Scalar> > &fwdOpSrc,
00124   LinearOpWithSolveBase<Scalar> *Op,
00125   const ESupportSolveUse supportSolveUse
00126   ) const
00127 {
00128 
00129   using Teuchos::dyn_cast;
00130   using Teuchos::rcp_dynamic_cast;
00131 
00132 #ifdef TEUCHOS_DEBUG
00133   TEST_FOR_EXCEPT(0==Op);
00134 #endif
00135 
00136   const RCP<const LinearOpBase<Scalar> > tmpFwdOp = fwdOpSrc->getOp();
00137   RCP<const LinearOpBase<Scalar> > fwdOp;
00138   Scalar fwdOp_scalar = 0.0;
00139   EOpTransp fwdOp_transp;
00140   unwrap<Scalar>(tmpFwdOp, &fwdOp_scalar, &fwdOp_transp, &fwdOp);
00141 
00142   const RCP<const MultiVectorBase<Scalar> > fwdMv =
00143     rcp_dynamic_cast<const MultiVectorBase<Scalar> >(fwdOp, true);
00144 
00145   dyn_cast<DefaultSerialDenseLinearOpWithSolve<Scalar> >(*Op).initialize(fwdMv);
00146 
00147 }
00148 
00149 
00150 template<class Scalar>
00151 void DefaultSerialDenseLinearOpWithSolveFactory<Scalar>::initializeAndReuseOp(
00152   const RCP<const LinearOpSourceBase<Scalar> > &fwdOpSrc,
00153   LinearOpWithSolveBase<Scalar> *Op
00154   ) const
00155 {
00156   initializeOp(fwdOpSrc, Op, SUPPORT_SOLVE_UNSPECIFIED);
00157 }
00158 
00159 
00160 template<class Scalar>
00161 void DefaultSerialDenseLinearOpWithSolveFactory<Scalar>::uninitializeOp(
00162   LinearOpWithSolveBase<Scalar> *Op,
00163   RCP<const LinearOpSourceBase<Scalar> > *fwdOpSrc,
00164   RCP<const PreconditionerBase<Scalar> > *prec,
00165   RCP<const LinearOpSourceBase<Scalar> > *approxFwdOpSrc,
00166   ESupportSolveUse *supportSolveUse
00167   ) const
00168 {
00169   using Teuchos::dyn_cast;
00170   using Teuchos::is_null;
00171 #ifdef TEUCHOS_DEBUG
00172   TEST_FOR_EXCEPT(0==Op);
00173 #endif // TEUCHOS_DEBUG
00174   typedef DefaultSerialDenseLinearOpWithSolve<Scalar> DSDLOWS;
00175   DSDLOWS &dsdlows = dyn_cast<DSDLOWS>(*Op);
00176   if (fwdOpSrc) {
00177     // find a valid fwdOp
00178     const RCP<const LinearOpBase<Scalar> > fwdOp = dsdlows.getFwdOp();
00179     // pass out a valid fwsOpSrc
00180     if (!is_null(fwdOp)) {
00181       *fwdOpSrc = defaultLinearOpSource<Scalar>(fwdOp);
00182     } else {
00183       *fwdOpSrc = Teuchos::null;
00184     }
00185   }
00186   if (prec) *prec = Teuchos::null;
00187   if (approxFwdOpSrc) *approxFwdOpSrc = Teuchos::null;
00188 }
00189 
00190 
00191 template<class Scalar>
00192 bool DefaultSerialDenseLinearOpWithSolveFactory<Scalar>::supportsPreconditionerInputType(
00193   const EPreconditionerInputType precOpType
00194   ) const
00195 {
00196   // LAPACK does not support any external preconditioners!
00197   return false;
00198 }
00199 
00200 
00201 template<class Scalar>
00202 void DefaultSerialDenseLinearOpWithSolveFactory<Scalar>::initializePreconditionedOp(
00203   const RCP<const LinearOpSourceBase<Scalar> > &fwdOpSrc,
00204   const RCP<const PreconditionerBase<Scalar> > &prec,
00205   LinearOpWithSolveBase<Scalar> *Op,
00206   const ESupportSolveUse supportSolveUse
00207   ) const
00208 {
00209   TEST_FOR_EXCEPT_MSG(true, "Error, we don't support an external preconditioner!");
00210 }
00211 
00212 
00213 template<class Scalar>
00214 void DefaultSerialDenseLinearOpWithSolveFactory<Scalar>::initializeApproxPreconditionedOp(
00215   const RCP<const LinearOpSourceBase<Scalar> > &fwdOpSrc,
00216   const RCP<const LinearOpSourceBase<Scalar> > &approxFwdOpSrc,
00217   LinearOpWithSolveBase<Scalar> *Op,
00218   const ESupportSolveUse supportSolveUse
00219   ) const
00220 {
00221   TEST_FOR_EXCEPT_MSG(true, "Error, we don't support an external preconditioner!");
00222 }
00223 
00224 
00225 } // namespace Thyra
00226 
00227 
00228 #endif // THYRA_DEFAULT_SERIAL_DENSE_LINEAR_OP_WITH_SOLVE_FACTORY_HPP
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines