|
Rythmos - Transient Integration for Differential Equations
Version of the Day
|
00001 //@HEADER 00002 // *********************************************************************** 00003 // 00004 // Rythmos Package 00005 // Copyright (2006) 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 Todd S. Coffey (tscoffe@sandia.gov) 00025 // 00026 // *********************************************************************** 00027 //@HEADER 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> getNonconstParameterList(); 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 using Teuchos::as; 00080 using Teuchos::ptrFromRef; 00081 typedef Teuchos::ScalarTraits<Scalar> ST; 00082 TEUCHOS_TEST_FOR_EXCEPT(weight==NULL); 00083 TEUCHOS_TEST_FOR_EXCEPTION( 00084 ( ( relTol == ST::zero() ) && ( absTol == ST::zero() ) ), std::logic_error, 00085 "Error, relTol and absTol cannot both be zero!\n" 00086 ); 00087 Thyra::VectorBase<Scalar> &w = *weight; 00088 Thyra::abs(vector, ptrFromRef(w)); 00089 Vt_S(ptrFromRef(w), relTol); 00090 Vp_S(ptrFromRef(w), absTol); 00091 reciprocal(w, ptrFromRef(w)); 00092 Vt_StV(ptrFromRef(w), ST::one(), w); // We square w because of how weighted norm_2 is computed. 00093 // divide by N to get RMS norm 00094 int N = vector.space()->dim(); 00095 Vt_S(ptrFromRef(w), as<Scalar>(1.0/N)); 00096 // Now you can compute WRMS norm as: 00097 // Scalar WRMSnorm = norm_2(w,y); // WRMS norm of y with respect to weights w. 00098 00099 RCP<Teuchos::FancyOStream> out = this->getOStream(); 00100 Teuchos::EVerbosityLevel verbLevel = this->getVerbLevel(); 00101 Teuchos::OSTab ostab(out,1,"errWtVecSet"); 00102 00103 if ( as<int>(verbLevel) >= as<int>(Teuchos::VERB_EXTREME) ) { 00104 *out << "weight = " << std::endl; 00105 weight->describe(*out,verbLevel); 00106 } 00107 } 00108 00109 template<class Scalar> 00110 void ImplicitBDFStepperErrWtVecCalc<Scalar>::setParameterList( 00111 RCP<Teuchos::ParameterList> const& paramList 00112 ) 00113 { 00114 TEUCHOS_TEST_FOR_EXCEPT(paramList == Teuchos::null); 00115 paramList->validateParameters(*this->getValidParameters(),0); 00116 paramList_ = paramList; 00117 Teuchos::readVerboseObjectSublist(&*paramList_,this); 00118 } 00119 00120 template<class Scalar> 00121 RCP<Teuchos::ParameterList> 00122 ImplicitBDFStepperErrWtVecCalc<Scalar>::unsetParameterList() 00123 { 00124 RCP<Teuchos::ParameterList> temp_param_list = paramList_; 00125 paramList_ = Teuchos::null; 00126 return(temp_param_list); 00127 } 00128 00129 template<class Scalar> 00130 RCP<Teuchos::ParameterList> 00131 ImplicitBDFStepperErrWtVecCalc<Scalar>::getNonconstParameterList() 00132 { 00133 return(paramList_); 00134 } 00135 00136 template<class Scalar> 00137 RCP<const Teuchos::ParameterList> 00138 ImplicitBDFStepperErrWtVecCalc<Scalar>::getValidParameters() const 00139 { 00140 static RCP<Teuchos::ParameterList> validPL; 00141 if (is_null(validPL)) { 00142 RCP<Teuchos::ParameterList> 00143 pl = Teuchos::parameterList(); 00144 Teuchos::setupVerboseObjectSublist(&*pl); 00145 validPL = pl; 00146 } 00147 return (validPL); 00148 } 00149 00150 } // namespace Rythmos 00151 00152 #endif // Rythmos_IMPLICITBDF_STEPPER_ERR_WT_VEC_CALC_H 00153
1.7.6.1