Rythmos_StepperBuilder.hpp

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

Generated on Wed May 12 21:25:44 2010 for Rythmos - Transient Integration for Differential Equations by  doxygen 1.4.7