|
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_STEPPER_BUILDER_NEWNEW_H 00030 #define Rythmos_STEPPER_BUILDER_NEWNEW_H 00031 00032 #include "Rythmos_Types.hpp" 00033 #include "Rythmos_StepperBase.hpp" 00034 00035 #include "Teuchos_ObjectBuilder.hpp" 00036 #include "Teuchos_ParameterList.hpp" 00037 00038 #include "Rythmos_BackwardEulerStepper.hpp" 00039 #include "Rythmos_ImplicitBDFStepper.hpp" 00040 #include "Rythmos_ForwardEulerStepper.hpp" 00041 #include "Rythmos_ExplicitRKStepper.hpp" 00042 #include "Rythmos_ImplicitRKStepper.hpp" 00043 #ifdef HAVE_THYRA_ME_POLYNOMIAL 00044 # include "Rythmos_ExplicitTaylorPolynomialStepper.hpp" 00045 #endif // HAVE_THYRA_ME_POLYNOMIAL 00046 #ifdef HAVE_RYTHMOS_EXPERIMENTAL 00047 #include "Rythmos_ThetaStepper.hpp" 00048 #endif // HAVE_RYTHMOS_EXPERIMENTAL 00049 00050 namespace Rythmos { 00051 00052 00053 template<class Scalar> 00054 class StepperBuilder : virtual public Teuchos::ParameterListAcceptor 00055 { 00056 public: 00057 00059 StepperBuilder(); 00060 00062 ~StepperBuilder(); 00063 00065 void setStepperFactory( 00066 const RCP<const Teuchos::AbstractFactory<StepperBase<Scalar> > > &stepperFactory, 00067 const std::string &stepperFactoryName 00068 ); 00069 00073 std::string getStepperName() const; 00074 00076 RCP<StepperBase<Scalar> > create( 00077 const std::string &stepperName = "" 00078 ) const; 00079 00082 00084 void setParameterList(const RCP<Teuchos::ParameterList> & paramList); 00085 00087 RCP<Teuchos::ParameterList> getNonconstParameterList(); 00088 00090 RCP<Teuchos::ParameterList> unsetParameterList(); 00091 00093 RCP<const ParameterList> getParameterList() const; 00094 00096 RCP<const Teuchos::ParameterList> getValidParameters() const; 00097 00099 00100 private: 00101 00102 // ////////////////////////////////////// 00103 // Private data members 00104 00105 Teuchos::ObjectBuilder<StepperBase<Scalar> > builder_; 00106 00107 // ////////////////////////////////////// 00108 // Private member functions 00109 00110 void initializeDefaults_(); 00111 00112 }; 00113 00114 00115 // Nonmember constructor 00116 template<class Scalar> 00117 RCP<StepperBuilder<Scalar> > stepperBuilder() 00118 { 00119 RCP<StepperBuilder<Scalar> > sb = rcp(new StepperBuilder<Scalar> ); 00120 return sb; 00121 } 00122 00123 template<class Scalar> 00124 StepperBuilder<Scalar>::StepperBuilder() 00125 { 00126 this->initializeDefaults_(); 00127 } 00128 00129 // Nonmember helper function 00130 template<class Scalar> 00131 RCP<StepperBase<Scalar> > createStepper(const std::string &stepperName) 00132 { 00133 RCP<StepperBuilder<Scalar> > sb = stepperBuilder<Scalar>(); 00134 RCP<StepperBase<Scalar> > stepper = sb->create(stepperName); 00135 return stepper; 00136 } 00137 00138 template<class Scalar> 00139 StepperBuilder<Scalar>::~StepperBuilder() 00140 { 00141 } 00142 00143 00144 template<class Scalar> 00145 void StepperBuilder<Scalar>::setStepperFactory( 00146 const RCP<const Teuchos::AbstractFactory<StepperBase<Scalar> > > &stepperFactory, 00147 const std::string &stepperName 00148 ) 00149 { 00150 builder_.setObjectFactory(stepperFactory, stepperName); 00151 } 00152 00153 00154 template<class Scalar> 00155 std::string 00156 StepperBuilder<Scalar>::getStepperName() const 00157 { 00158 return builder_.getObjectName(); 00159 } 00160 00161 00162 template<class Scalar> 00163 void StepperBuilder<Scalar>::setParameterList( 00164 RCP<Teuchos::ParameterList> const& paramList 00165 ) 00166 { 00167 builder_.setParameterList(paramList); 00168 } 00169 00170 00171 template<class Scalar> 00172 RCP<Teuchos::ParameterList> 00173 StepperBuilder<Scalar>::getNonconstParameterList() 00174 { 00175 return builder_.getNonconstParameterList(); 00176 } 00177 00178 00179 template<class Scalar> 00180 RCP<Teuchos::ParameterList> 00181 StepperBuilder<Scalar>::unsetParameterList() 00182 { 00183 return builder_.unsetParameterList(); 00184 } 00185 00186 00187 template<class Scalar> 00188 RCP<const Teuchos::ParameterList> 00189 StepperBuilder<Scalar>::getParameterList() const 00190 { 00191 return builder_.getParameterList(); 00192 } 00193 00194 00195 template<class Scalar> 00196 RCP<const Teuchos::ParameterList> 00197 StepperBuilder<Scalar>::getValidParameters() const 00198 { 00199 return builder_.getValidParameters(); 00200 } 00201 00202 00203 template<class Scalar> 00204 RCP<StepperBase<Scalar> > 00205 StepperBuilder<Scalar>::create( 00206 const std::string &stepperName 00207 ) const 00208 { 00209 return builder_.create(stepperName); 00210 } 00211 00212 00213 template<class Scalar> 00214 void StepperBuilder<Scalar>::initializeDefaults_() 00215 { 00216 00217 using Teuchos::abstractFactoryStd; 00218 00219 builder_.setObjectName("Rythmos::Stepper"); 00220 builder_.setObjectTypeName("Stepper Type"); 00221 00222 // 00223 // Steppers 00224 // 00225 00226 builder_.setObjectFactory( 00227 abstractFactoryStd< StepperBase<Scalar>, ForwardEulerStepper<Scalar> >(), 00228 "Forward Euler" 00229 ); 00230 00231 builder_.setObjectFactory( 00232 abstractFactoryStd< StepperBase<Scalar>, BackwardEulerStepper<Scalar> >(), 00233 "Backward Euler" 00234 ); 00235 00236 builder_.setObjectFactory( 00237 abstractFactoryStd< StepperBase<Scalar>, ImplicitBDFStepper<Scalar> >(), 00238 "Implicit BDF" 00239 ); 00240 00241 builder_.setObjectFactory( 00242 abstractFactoryStd< StepperBase<Scalar>, ExplicitRKStepper<Scalar> >(), 00243 "Explicit RK" 00244 ); 00245 00246 builder_.setObjectFactory( 00247 abstractFactoryStd< StepperBase<Scalar>, ImplicitRKStepper<Scalar> >(), 00248 "Implicit RK" 00249 ); 00250 00251 #ifdef HAVE_THYRA_ME_POLYNOMIAL 00252 builder_.setObjectFactory( 00253 abstractFactoryStd< StepperBase<Scalar>, ExplicitTaylorPolynomialStepper<Scalar> >(), 00254 "Explicit Taylor Polynomial" 00255 ); 00256 #endif // HAVE_THYRA_ME_POLYNOMIAL 00257 00258 #ifdef HAVE_RYTHMOS_EXPERIMENTAL 00259 builder_.setObjectFactory( 00260 abstractFactoryStd< StepperBase<Scalar>, ThetaStepper<Scalar> >(), 00261 "Theta" 00262 ); 00263 #endif // HAVE_RYTHMOS_EXPERIMENTAL 00264 00265 builder_.setDefaultObject("Backward Euler"); 00266 00267 } 00268 00269 00270 } // namespace Rythmos 00271 00272 00273 #endif //Rythmos_STEPPER_BUILDER_NEWNEW_H 00274
1.7.6.1