Rythmos - Transient Integration for Differential Equations Version of the Day
Rythmos_RKButcherTableauBuilder_def.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., 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 
00030 #ifndef RYTHMOS_RK_BUTCHER_TABLEAU_BUILDER_DEF_HPP
00031 #define RYTHMOS_RK_BUTCHER_TABLEAU_BUILDER_DEF_HPP
00032 
00033 #include "Rythmos_Types.hpp"
00034 
00035 #include "Rythmos_RKButcherTableauBuilder_decl.hpp"
00036 #include "Rythmos_RKButcherTableau.hpp"
00037 
00038 namespace Rythmos {
00039 
00040 // Nonmember constructor
00041 template<class Scalar>
00042 RCP<RKButcherTableauBuilder<Scalar> > rKButcherTableauBuilder()
00043 {
00044   RCP<RKButcherTableauBuilder<Scalar> > rkbtfn = rcp(new RKButcherTableauBuilder<Scalar>() );
00045   return rkbtfn;
00046 }
00047 // Nonmember helper function
00048 template<class Scalar>
00049 RCP<RKButcherTableauBase<Scalar> > createRKBT(const std::string& rkbt_name)
00050 {
00051   RCP<RKButcherTableauBuilder<Scalar> > rkbtfn = rKButcherTableauBuilder<Scalar>();
00052   RCP<RKButcherTableauBase<Scalar> > rkbt = rkbtfn->create(rkbt_name);
00053   return rkbt;
00054 }
00055 
00056 template<class Scalar>
00057 RKButcherTableauBuilder<Scalar>::RKButcherTableauBuilder()
00058 {
00059   this->initializeDefaults_();
00060 }
00061 
00062 template<class Scalar>
00063 void RKButcherTableauBuilder<Scalar>::setRKButcherTableauFactory(
00064     const RCP<const Teuchos::AbstractFactory<RKButcherTableauBase<Scalar> > > &rkbtFactory,
00065     const std::string &rkbtFactoryName
00066     )
00067 {
00068   builder_.setObjectFactory(rkbtFactory, rkbtFactoryName);
00069 }
00070 
00071 template<class Scalar>
00072 void RKButcherTableauBuilder<Scalar>::setParameterList(
00073   RCP<Teuchos::ParameterList> const& paramList
00074   )
00075 {
00076   builder_.setParameterList(paramList);
00077 }
00078 
00079 template<class Scalar>
00080 RCP<Teuchos::ParameterList>
00081 RKButcherTableauBuilder<Scalar>::getNonconstParameterList()
00082 {
00083   return builder_.getNonconstParameterList();
00084 }
00085 
00086 
00087 template<class Scalar>
00088 RCP<Teuchos::ParameterList>
00089 RKButcherTableauBuilder<Scalar>::unsetParameterList()
00090 {
00091   return builder_.unsetParameterList();
00092 }
00093 
00094 
00095 template<class Scalar>
00096 RCP<const Teuchos::ParameterList>
00097 RKButcherTableauBuilder<Scalar>::getParameterList() const
00098 {
00099   return builder_.getParameterList();
00100 }
00101 
00102 
00103 template<class Scalar>
00104 RCP<const Teuchos::ParameterList>
00105 RKButcherTableauBuilder<Scalar>::getValidParameters() const
00106 {
00107   return builder_.getValidParameters();
00108 }
00109 
00110 template<class Scalar>
00111 RCP<RKButcherTableauBase<Scalar> >
00112 RKButcherTableauBuilder<Scalar>::create(
00113     const std::string &rkbt_name
00114     ) const
00115 {
00116   return builder_.create(rkbt_name);
00117 }
00118 
00119 template<class Scalar>
00120 void RKButcherTableauBuilder<Scalar>::initializeDefaults_()
00121 {
00122 
00123   using Teuchos::abstractFactoryStd;
00124 
00125   builder_.setObjectName("Rythmos::RKButcherTableau");
00126   builder_.setObjectTypeName("Runge Kutta Butcher Tableau Type");
00127 
00128   //
00129   // RK Butcher Tableaus:
00130   //
00131 
00132   // Explicit
00133   builder_.setObjectFactory(
00134       abstractFactoryStd< RKButcherTableauBase<Scalar>,
00135                           ForwardEuler_RKBT<Scalar> >(),
00136       RKBT_ForwardEuler_name());
00137 
00138   builder_.setObjectFactory(
00139       abstractFactoryStd< RKButcherTableauBase<Scalar>,
00140                           Explicit2Stage2ndOrderRunge_RKBT<Scalar> >(),
00141       Explicit2Stage2ndOrderRunge_name());
00142 
00143   builder_.setObjectFactory(
00144       abstractFactoryStd< RKButcherTableauBase<Scalar>,
00145                           ExplicitTrapezoidal_RKBT<Scalar> >(),
00146       ExplicitTrapezoidal_name());
00147 
00148   builder_.setObjectFactory(
00149       abstractFactoryStd< RKButcherTableauBase<Scalar>,
00150                           Explicit3Stage3rdOrder_RKBT<Scalar> >(),
00151       Explicit3Stage3rdOrder_name());
00152 
00153   builder_.setObjectFactory(
00154       abstractFactoryStd< RKButcherTableauBase<Scalar>,
00155                           Explicit3Stage3rdOrderHeun_RKBT<Scalar> >(),
00156       Explicit3Stage3rdOrderHeun_name());
00157 
00158   builder_.setObjectFactory(
00159       abstractFactoryStd< RKButcherTableauBase<Scalar>,
00160                           Explicit3Stage3rdOrderTVD_RKBT<Scalar> >(),
00161       Explicit3Stage3rdOrderTVD_name());
00162 
00163   builder_.setObjectFactory(
00164       abstractFactoryStd< RKButcherTableauBase<Scalar>,
00165                           Explicit4Stage3rdOrderRunge_RKBT<Scalar> >(),
00166       Explicit4Stage3rdOrderRunge_name());
00167 
00168   builder_.setObjectFactory(
00169       abstractFactoryStd< RKButcherTableauBase<Scalar>,
00170                           Explicit4Stage4thOrder_RKBT<Scalar> >(),
00171       Explicit4Stage_name());
00172 
00173   builder_.setObjectFactory(
00174       abstractFactoryStd< RKButcherTableauBase<Scalar>,
00175                           Explicit3_8Rule_RKBT<Scalar> >(),
00176       Explicit3_8Rule_name());
00177 
00178   // Implicit
00179   builder_.setObjectFactory(
00180       abstractFactoryStd< RKButcherTableauBase<Scalar>,
00181                           BackwardEuler_RKBT<Scalar> >(),
00182       RKBT_BackwardEuler_name());
00183 
00184   builder_.setObjectFactory(
00185       abstractFactoryStd< RKButcherTableauBase<Scalar>,
00186                           IRK1StageTheta_RKBT<Scalar> >(),
00187       IRK1StageTheta_name());
00188 
00189   builder_.setObjectFactory(
00190       abstractFactoryStd< RKButcherTableauBase<Scalar>,
00191                           IRK2StageTheta_RKBT<Scalar> >(),
00192       IRK2StageTheta_name());
00193 
00194   // SDIRK
00195   builder_.setObjectFactory(
00196       abstractFactoryStd< RKButcherTableauBase<Scalar>,
00197                           SDIRK2Stage2ndOrder_RKBT<Scalar> >(),
00198       SDIRK2Stage2ndOrder_name());
00199 
00200   builder_.setObjectFactory(
00201       abstractFactoryStd< RKButcherTableauBase<Scalar>,
00202                           SDIRK2Stage3rdOrder_RKBT<Scalar> >(),
00203       SDIRK2Stage3rdOrder_name());
00204 
00205   builder_.setObjectFactory(
00206       abstractFactoryStd< RKButcherTableauBase<Scalar>,
00207                           SDIRK3Stage4thOrder_RKBT<Scalar> >(),
00208       SDIRK3Stage4thOrder_name());
00209 
00210   builder_.setObjectFactory(
00211       abstractFactoryStd< RKButcherTableauBase<Scalar>,
00212                           SDIRK5Stage4thOrder_RKBT<Scalar> >(),
00213       SDIRK5Stage4thOrder_name());
00214 
00215   builder_.setObjectFactory(
00216       abstractFactoryStd< RKButcherTableauBase<Scalar>,
00217                           SDIRK5Stage5thOrder_RKBT<Scalar> >(),
00218       SDIRK5Stage5thOrder_name());
00219 
00220   // DIRK
00221   builder_.setObjectFactory(
00222       abstractFactoryStd< RKButcherTableauBase<Scalar>,
00223                           DIRK2Stage3rdOrder_RKBT<Scalar> >(),
00224       DIRK2Stage3rdOrder_name());
00225 
00226   // IRK
00227   builder_.setObjectFactory(
00228       abstractFactoryStd< RKButcherTableauBase<Scalar>,
00229                           Implicit1Stage2ndOrderGauss_RKBT<Scalar> >(),
00230       Implicit1Stage2ndOrderGauss_name());
00231 
00232   builder_.setObjectFactory(
00233       abstractFactoryStd< RKButcherTableauBase<Scalar>,
00234                           Implicit2Stage4thOrderGauss_RKBT<Scalar> >(),
00235       Implicit2Stage4thOrderGauss_name());
00236 
00237   builder_.setObjectFactory(
00238       abstractFactoryStd< RKButcherTableauBase<Scalar>,
00239                           Implicit3Stage6thOrderGauss_RKBT<Scalar> >(),
00240       Implicit3Stage6thOrderGauss_name());
00241 
00242   builder_.setObjectFactory(
00243       abstractFactoryStd< RKButcherTableauBase<Scalar>,
00244                           Implicit2Stage4thOrderHammerHollingsworth_RKBT<Scalar> >(),
00245       Implicit2Stage4thOrderHammerHollingsworth_name());
00246 
00247   builder_.setObjectFactory(
00248       abstractFactoryStd< RKButcherTableauBase<Scalar>,
00249                           Implicit3Stage6thOrderKuntzmannButcher_RKBT<Scalar> >(),
00250       Implicit3Stage6thOrderKuntzmannButcher_name());
00251 
00252   //  This RKBT does not pass convergence testing, so we're disbaling it for now.
00253 //  builder_.setObjectFactory(
00254 //      abstractFactoryStd< RKButcherTableauBase<Scalar>, Implicit4Stage8thOrderKuntzmannButcher_RKBT<Scalar> >(),
00255 //      Implicit4Stage8thOrderKuntzmannButcher_name());
00256 
00257   builder_.setObjectFactory(
00258       abstractFactoryStd< RKButcherTableauBase<Scalar>,
00259                           Implicit1Stage1stOrderRadauA_RKBT<Scalar> >(),
00260       Implicit1Stage1stOrderRadauA_name());
00261 
00262   builder_.setObjectFactory(
00263       abstractFactoryStd< RKButcherTableauBase<Scalar>,
00264                           Implicit2Stage3rdOrderRadauA_RKBT<Scalar> >(),
00265       Implicit2Stage3rdOrderRadauA_name());
00266 
00267   builder_.setObjectFactory(
00268       abstractFactoryStd< RKButcherTableauBase<Scalar>,
00269                           Implicit3Stage5thOrderRadauA_RKBT<Scalar> >(),
00270       Implicit3Stage5thOrderRadauA_name());
00271 
00272   builder_.setObjectFactory(
00273       abstractFactoryStd< RKButcherTableauBase<Scalar>,
00274                           Implicit1Stage1stOrderRadauB_RKBT<Scalar> >(),
00275       Implicit1Stage1stOrderRadauB_name());
00276 
00277   builder_.setObjectFactory(
00278       abstractFactoryStd< RKButcherTableauBase<Scalar>,
00279                           Implicit2Stage3rdOrderRadauB_RKBT<Scalar> >(),
00280       Implicit2Stage3rdOrderRadauB_name());
00281 
00282   builder_.setObjectFactory(
00283       abstractFactoryStd< RKButcherTableauBase<Scalar>,
00284                           Implicit3Stage5thOrderRadauB_RKBT<Scalar> >(),
00285       Implicit3Stage5thOrderRadauB_name());
00286 
00287   builder_.setObjectFactory(
00288       abstractFactoryStd< RKButcherTableauBase<Scalar>,
00289                           Implicit2Stage2ndOrderLobattoA_RKBT<Scalar> >(),
00290       Implicit2Stage2ndOrderLobattoA_name());
00291 
00292   builder_.setObjectFactory(
00293       abstractFactoryStd< RKButcherTableauBase<Scalar>,
00294                           Implicit3Stage4thOrderLobattoA_RKBT<Scalar> >(),
00295       Implicit3Stage4thOrderLobattoA_name());
00296 
00297   builder_.setObjectFactory(
00298       abstractFactoryStd< RKButcherTableauBase<Scalar>,
00299                           Implicit4Stage6thOrderLobattoA_RKBT<Scalar> >(),
00300       Implicit4Stage6thOrderLobattoA_name());
00301 
00302   builder_.setObjectFactory(
00303       abstractFactoryStd< RKButcherTableauBase<Scalar>,
00304                           Implicit2Stage2ndOrderLobattoB_RKBT<Scalar> >(),
00305       Implicit2Stage2ndOrderLobattoB_name());
00306 
00307   builder_.setObjectFactory(
00308       abstractFactoryStd< RKButcherTableauBase<Scalar>,
00309                           Implicit3Stage4thOrderLobattoB_RKBT<Scalar> >(),
00310       Implicit3Stage4thOrderLobattoB_name());
00311 
00312   builder_.setObjectFactory(
00313       abstractFactoryStd< RKButcherTableauBase<Scalar>,
00314                           Implicit4Stage6thOrderLobattoB_RKBT<Scalar> >(),
00315       Implicit4Stage6thOrderLobattoB_name());
00316 
00317   builder_.setObjectFactory(
00318       abstractFactoryStd< RKButcherTableauBase<Scalar>,
00319                           Implicit2Stage2ndOrderLobattoC_RKBT<Scalar> >(),
00320       Implicit2Stage2ndOrderLobattoC_name());
00321 
00322   builder_.setObjectFactory(
00323       abstractFactoryStd< RKButcherTableauBase<Scalar>,
00324                           Implicit3Stage4thOrderLobattoC_RKBT<Scalar> >(),
00325       Implicit3Stage4thOrderLobattoC_name());
00326 
00327   builder_.setObjectFactory(
00328       abstractFactoryStd< RKButcherTableauBase<Scalar>,
00329                           Implicit4Stage6thOrderLobattoC_RKBT<Scalar> >(),
00330       Implicit4Stage6thOrderLobattoC_name());
00331 
00332   builder_.setDefaultObject("None");
00333 
00334 }
00335 
00336 //
00337 // Explicit Instantiation macro
00338 //
00339 // Must be expanded from within the Rythmos namespace!
00340 //
00341 
00342 #define RYTHMOS_RK_BUTCHER_TABLEAU_BUILDER_INSTANT(SCALAR) \
00343   \
00344   template class RKButcherTableauBuilder< SCALAR >; \
00345   \
00346   template RCP<RKButcherTableauBuilder< SCALAR > > rKButcherTableauBuilder(); \
00347   \
00348   template RCP<RKButcherTableauBase< SCALAR > > createRKBT(const std::string& rkbt_name);
00349 
00350 
00351 } // namespace Rythmos
00352 
00353 
00354 #endif // RYTHMOS_RK_BUTCHER_TABLEAU_BUILDER_DEF_HPP
 All Classes Functions Variables Typedefs Friends