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