|
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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 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() ) ), 00085 std::logic_error, 00086 "Error, relTol and absTol cannot both be zero!\n"); 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 00093 // weighted norm_2 is computed. 00094 // divide by N to get RMS norm 00095 int N = vector.space()->dim(); 00096 Vt_S(ptrFromRef(w), as<Scalar>(1.0/N)); 00097 // Now you can compute WRMS norm as: 00098 // Scalar WRMSnorm = norm_2(w,y); // WRMS norm of y with respect to weights w. 00099 00100 RCP<Teuchos::FancyOStream> out = this->getOStream(); 00101 Teuchos::EVerbosityLevel verbLevel = this->getVerbLevel(); 00102 Teuchos::OSTab ostab(out,1,"errWtVecSet"); 00103 00104 if ( as<int>(verbLevel) >= as<int>(Teuchos::VERB_EXTREME) ) { 00105 *out << "weight = " << std::endl; 00106 weight->describe(*out,verbLevel); 00107 } 00108 } 00109 00110 template<class Scalar> 00111 void ImplicitBDFStepperErrWtVecCalc<Scalar>::setParameterList( 00112 RCP<Teuchos::ParameterList> const& paramList 00113 ) 00114 { 00115 TEUCHOS_TEST_FOR_EXCEPT(paramList == Teuchos::null); 00116 paramList->validateParameters(*this->getValidParameters(),0); 00117 paramList_ = paramList; 00118 Teuchos::readVerboseObjectSublist(&*paramList_,this); 00119 } 00120 00121 template<class Scalar> 00122 RCP<Teuchos::ParameterList> 00123 ImplicitBDFStepperErrWtVecCalc<Scalar>::unsetParameterList() 00124 { 00125 RCP<Teuchos::ParameterList> temp_param_list = paramList_; 00126 paramList_ = Teuchos::null; 00127 return(temp_param_list); 00128 } 00129 00130 template<class Scalar> 00131 RCP<Teuchos::ParameterList> 00132 ImplicitBDFStepperErrWtVecCalc<Scalar>::getNonconstParameterList() 00133 { 00134 return(paramList_); 00135 } 00136 00137 template<class Scalar> 00138 RCP<const Teuchos::ParameterList> 00139 ImplicitBDFStepperErrWtVecCalc<Scalar>::getValidParameters() const 00140 { 00141 static RCP<Teuchos::ParameterList> validPL; 00142 if (is_null(validPL)) { 00143 RCP<Teuchos::ParameterList> 00144 pl = Teuchos::parameterList(); 00145 Teuchos::setupVerboseObjectSublist(&*pl); 00146 validPL = pl; 00147 } 00148 return (validPL); 00149 } 00150 00151 } // namespace Rythmos 00152 00153 #endif // Rythmos_IMPLICITBDF_STEPPER_ERR_WT_VEC_CALC_H 00154
1.7.6.1