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 Rythmos_IMPLICITBDF_STEPPER_ERR_WT_VEC_CALC_H
00030 #define Rythmos_IMPLICITBDF_STEPPER_ERR_WT_VEC_CALC_H
00031
00032 #include "Rythmos_ErrWtVecCalcBase.hpp"
00033
00034 namespace Rythmos {
00035
00036 template<class Scalar>
00037 class ImplicitBDFStepperErrWtVecCalc
00038 : virtual public ErrWtVecCalcBase<Scalar>
00039 {
00040 public:
00041
00043 void errWtVecSet(
00044 Thyra::VectorBase<Scalar>* weight
00045 ,const Thyra::VectorBase<Scalar>& vector
00046 ,Scalar relTol
00047 ,Scalar absTol
00048 ) const;
00049
00053 void setParameterList(RCP<Teuchos::ParameterList> const& paramList);
00054
00056 RCP<Teuchos::ParameterList> getParameterList();
00057
00059 RCP<Teuchos::ParameterList> unsetParameterList();
00060
00062 RCP<const Teuchos::ParameterList> getValidParameters() const;
00063
00065
00066 private:
00067 RCP<Teuchos::ParameterList> paramList_;
00068 };
00069
00070
00071 template<class Scalar>
00072 void ImplicitBDFStepperErrWtVecCalc<Scalar>::errWtVecSet(
00073 Thyra::VectorBase<Scalar>* weight
00074 ,const Thyra::VectorBase<Scalar>& vector
00075 ,Scalar relTol
00076 ,Scalar absTol
00077 ) const
00078 {
00079 typedef Teuchos::ScalarTraits<Scalar> ST;
00080 TEST_FOR_EXCEPT(weight==NULL);
00081 TEST_FOR_EXCEPTION(
00082 ( ( relTol == ST::zero() ) && ( absTol == ST::zero() ) ), std::logic_error,
00083 "Error, relTol and absTol cannot both be zero!\n"
00084 );
00085 Thyra::VectorBase<Scalar> &w = *weight;
00086 Thyra::abs(&w,vector);
00087 Vt_S(&w,relTol);
00088 Vp_S(&w,absTol);
00089 reciprocal(&w,w);
00090 Vt_StV(&w,ST::one(),w);
00091
00092 int N = vector.space()->dim();
00093 Vt_S(&w,Scalar(1.0/N));
00094
00095
00096
00097 using Teuchos::as;
00098 RCP<Teuchos::FancyOStream> out = this->getOStream();
00099 Teuchos::EVerbosityLevel verbLevel = this->getVerbLevel();
00100 Teuchos::OSTab ostab(out,1,"errWtVecSet");
00101
00102 if ( as<int>(verbLevel) >= as<int>(Teuchos::VERB_EXTREME) ) {
00103 *out << "weight = " << std::endl;
00104 weight->describe(*out,verbLevel);
00105 }
00106 }
00107
00108 template<class Scalar>
00109 void ImplicitBDFStepperErrWtVecCalc<Scalar>::setParameterList(
00110 RCP<Teuchos::ParameterList> const& paramList
00111 )
00112 {
00113 TEST_FOR_EXCEPT(paramList == Teuchos::null);
00114 paramList->validateParameters(*this->getValidParameters(),0);
00115 paramList_ = paramList;
00116 Teuchos::readVerboseObjectSublist(&*paramList_,this);
00117 }
00118
00119 template<class Scalar>
00120 RCP<Teuchos::ParameterList>
00121 ImplicitBDFStepperErrWtVecCalc<Scalar>::unsetParameterList()
00122 {
00123 RCP<Teuchos::ParameterList> temp_param_list = paramList_;
00124 paramList_ = Teuchos::null;
00125 return(temp_param_list);
00126 }
00127
00128 template<class Scalar>
00129 RCP<Teuchos::ParameterList> ImplicitBDFStepperErrWtVecCalc<Scalar>::getParameterList()
00130 {
00131 return(paramList_);
00132 }
00133
00134 template<class Scalar>
00135 RCP<const Teuchos::ParameterList>
00136 ImplicitBDFStepperErrWtVecCalc<Scalar>::getValidParameters() const
00137 {
00138 static RCP<Teuchos::ParameterList> validPL;
00139 if (is_null(validPL)) {
00140 RCP<Teuchos::ParameterList>
00141 pl = Teuchos::parameterList();
00142 Teuchos::setupVerboseObjectSublist(&*pl);
00143 validPL = pl;
00144 }
00145 return (validPL);
00146 }
00147
00148 }
00149
00150 #endif // Rythmos_IMPLICITBDF_STEPPER_ERR_WT_VEC_CALC_H
00151