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 #ifndef THYRA_LINEAR_OP_WITH_SOLVE_FACTORY_HELPERS_HPP
00030 #define THYRA_LINEAR_OP_WITH_SOLVE_FACTORY_HELPERS_HPP
00031
00032 #include "Thyra_LinearOpWithSolveFactoryBase.hpp"
00033 #include "Thyra_DefaultLinearOpSource.hpp"
00034 #include "Thyra_DefaultPreconditioner.hpp"
00035
00036 namespace Thyra {
00037
00043 template<class Scalar>
00044 bool isCompatible(
00045 const LinearOpWithSolveFactoryBase<Scalar> &lowsFactory
00046 ,const LinearOpBase<Scalar> &fwdOp
00047 )
00048 {
00049 return lowsFactory.isCompatible(*defaultLinearOpSource(fwdOp));
00050 }
00051
00056 template<class Scalar>
00057 Teuchos::RefCountPtr<LinearOpWithSolveBase<Scalar> >
00058 linearOpWithSolve(
00059 const LinearOpWithSolveFactoryBase<Scalar> &lowsFactory
00060 ,const Teuchos::RefCountPtr<const LinearOpBase<Scalar> > &fwdOp
00061 ,const ESupportSolveUse supportSolveUse = SUPPORT_SOLVE_UNSPECIFIED
00062 )
00063 {
00064 Teuchos::RefCountPtr<LinearOpWithSolveBase<Scalar> >
00065 Op = lowsFactory.createOp();
00066 lowsFactory.initializeOp(defaultLinearOpSource(fwdOp),&*Op,supportSolveUse);
00067 return Op;
00068 }
00069
00074 template<class Scalar>
00075 void initializeOp(
00076 const LinearOpWithSolveFactoryBase<Scalar> &lowsFactory
00077 ,const Teuchos::RefCountPtr<const LinearOpBase<Scalar> > &fwdOp
00078 ,LinearOpWithSolveBase<Scalar> *Op
00079 ,const ESupportSolveUse supportSolveUse = SUPPORT_SOLVE_UNSPECIFIED
00080 )
00081 {
00082 lowsFactory.initializeOp(defaultLinearOpSource(fwdOp),Op,supportSolveUse);
00083 }
00084
00090 template<class Scalar>
00091 void initializeAndReuseOp(
00092 const LinearOpWithSolveFactoryBase<Scalar> &lowsFactory
00093 ,const Teuchos::RefCountPtr<const LinearOpBase<Scalar> > &fwdOp
00094 ,LinearOpWithSolveBase<Scalar> *Op
00095 )
00096 {
00097 lowsFactory.initializeAndReuseOp(defaultLinearOpSource(fwdOp),Op);
00098 }
00099
00105 template<class Scalar>
00106 void initializePreconditionedOp(
00107 const LinearOpWithSolveFactoryBase<Scalar> &lowsFactory
00108 ,const Teuchos::RefCountPtr<const LinearOpBase<Scalar> > &fwdOp
00109 ,const Teuchos::RefCountPtr<const PreconditionerBase<Scalar> > &prec
00110 ,LinearOpWithSolveBase<Scalar> *Op
00111 ,const ESupportSolveUse supportSolveUse = SUPPORT_SOLVE_UNSPECIFIED
00112 )
00113 {
00114 lowsFactory.initializePreconditionedOp(defaultLinearOpSource(fwdOp),prec,Op,supportSolveUse);
00115 }
00116
00122 template<class Scalar>
00123 void initializeApproxPreconditionedOp(
00124 const LinearOpWithSolveFactoryBase<Scalar> &lowsFactory
00125 ,const Teuchos::RefCountPtr<const LinearOpBase<Scalar> > &fwdOp
00126 ,const Teuchos::RefCountPtr<const LinearOpBase<Scalar> > &approxFwdOp
00127 ,LinearOpWithSolveBase<Scalar> *Op
00128 ,const ESupportSolveUse supportSolveUse = SUPPORT_SOLVE_UNSPECIFIED
00129 )
00130 {
00131 lowsFactory.initializeApproxPreconditionedOp(
00132 defaultLinearOpSource(fwdOp),defaultLinearOpSource(approxFwdOp),Op,supportSolveUse
00133 );
00134 }
00135
00141 template<class Scalar>
00142 void uninitializeOp(
00143 const LinearOpWithSolveFactoryBase<Scalar> &lowsFactory
00144 ,LinearOpWithSolveBase<Scalar> *Op
00145 ,Teuchos::RefCountPtr<const LinearOpBase<Scalar> > *fwdOp = NULL
00146 ,Teuchos::RefCountPtr<const PreconditionerBase<Scalar> > *prec = NULL
00147 ,Teuchos::RefCountPtr<const LinearOpBase<Scalar> > *approxFwdOp = NULL
00148 ,ESupportSolveUse *supportSolveUse = NULL
00149 )
00150 {
00151 Teuchos::RefCountPtr<const LinearOpSourceBase<Scalar> > fwdOpSrc;
00152 Teuchos::RefCountPtr<const LinearOpSourceBase<Scalar> > approxFwdOpSrc;
00153 lowsFactory.uninitializeOp(Op,&fwdOpSrc,prec,&approxFwdOpSrc,supportSolveUse);
00154 if(fwdOp)
00155 *fwdOp = ( fwdOpSrc.get() ? fwdOpSrc->getOp() : Teuchos::null );
00156 if(approxFwdOp)
00157 *approxFwdOp = ( approxFwdOpSrc.get() ? approxFwdOpSrc->getOp() : Teuchos::null );
00158 }
00159
00160 }
00161
00162 #endif // THYRA_LINEAR_OP_WITH_SOLVE_FACTORY_HELPERS_HPP