Rythmos_ImplicitRKStepper_decl.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_IMPLICIT_RK_STEPPER_DECL_H
00030 #define Rythmos_IMPLICIT_RK_STEPPER_DECL_H
00031 
00032 #include "Rythmos_Types.hpp"
00033 #include "Rythmos_StepperBase.hpp"
00034 #include "Rythmos_DataStore.hpp"
00035 #include "Rythmos_SolverAcceptingStepperBase.hpp"
00036 #include "Rythmos_RKButcherTableauAcceptingStepperBase.hpp"
00037 #include "Rythmos_RKButcherTableauBase.hpp"
00038 
00039 #include "Thyra_ModelEvaluator.hpp"
00040 #include "Thyra_ProductVectorBase.hpp"
00041 #include "Thyra_NonlinearSolverBase.hpp"
00042 
00043 namespace Rythmos {
00044 
00045 
00047 template<class Scalar>
00048 class ImplicitRKStepper : 
00049   virtual public SolverAcceptingStepperBase<Scalar>,
00050   virtual public RKButcherTableauAcceptingStepperBase<Scalar>
00051 {
00052 public:
00053   
00055   typedef typename ScalarTraits<Scalar>::magnitudeType ScalarMag;
00056   
00059 
00061   ImplicitRKStepper();
00062   
00063   void set_W_factory( const RCP<Thyra::LinearOpWithSolveFactoryBase<Scalar> > &irk_W_factory );
00064 
00066   RCP<const Thyra::LinearOpWithSolveFactoryBase<Scalar> > get_W_factory() const;
00067   
00070   
00072   void setRKButcherTableau( const RCP<const RKButcherTableauBase<Scalar> > &rkButcherTableau );
00073 
00075   RCP<const RKButcherTableauBase<Scalar> > getRKButcherTableau() const;
00076 
00078 
00080   // This function is mostly for testing purposes to explicitely over-ride the
00081   // internal RKBT detection to allow testing of 1-stage RKBTs as both fully
00082   // implicit RK and as DIRK methods.
00083   void setDirk(bool isDirk);
00084 
00086   
00089 
00091   void setSolver(
00092     const RCP<Thyra::NonlinearSolverBase<Scalar> > &solver
00093     );
00094 
00096   RCP<Thyra::NonlinearSolverBase<Scalar> >
00097   getNonconstSolver();
00098 
00100   RCP<const Thyra::NonlinearSolverBase<Scalar> >
00101   getSolver() const;
00102 
00104 
00107 
00109   bool isImplicit() const;
00110  
00112   bool supportsCloning() const;
00113 
00115   RCP<StepperBase<Scalar> > cloneStepperAlgorithm() const;
00116 
00118   void setModel(const RCP<const Thyra::ModelEvaluator<Scalar> > &model);
00119   
00121   RCP<const Thyra::ModelEvaluator<Scalar> >
00122   getModel() const;
00123 
00125   void setInitialCondition(
00126     const Thyra::ModelEvaluatorBase::InArgs<Scalar> &initialCondition
00127     );
00128 
00130   Scalar takeStep(Scalar dt, StepSizeType flag);
00131   
00133   const StepStatus<Scalar> getStepStatus() const;
00134   
00136 
00139 
00141   RCP<const Thyra::VectorSpaceBase<Scalar> >
00142   get_x_space() const;
00143 
00145   void addPoints(
00146     const Array<Scalar>& time_vec,
00147     const Array<RCP<const Thyra::VectorBase<Scalar> > >& x_vec,
00148     const Array<RCP<const Thyra::VectorBase<Scalar> > >& xdot_vec
00149     );
00150   
00152   TimeRange<Scalar> getTimeRange() const;
00153   
00155   void getPoints(
00156     const Array<Scalar>& time_vec,
00157     Array<RCP<const Thyra::VectorBase<Scalar> > >* x_vec,
00158     Array<RCP<const Thyra::VectorBase<Scalar> > >* xdot_vec,
00159     Array<ScalarMag>* accuracy_vec
00160     ) const;
00161   
00163   void getNodes(Array<Scalar>* time_vec) const;
00164   
00166   void removeNodes(Array<Scalar>& time_vec);
00167 
00169   int getOrder() const;
00170 
00172   
00175 
00177   void setParameterList(RCP<ParameterList> const& paramList);
00178   
00180   RCP<ParameterList> getNonconstParameterList();
00181   
00183   RCP<ParameterList> unsetParameterList();
00184   
00186   RCP<const ParameterList> getValidParameters() const;
00187  
00189 
00192   
00194   void describe(
00195     FancyOStream  &out,
00196     const Teuchos::EVerbosityLevel verbLevel
00197     ) const;
00198 
00200 
00201 private:
00202 
00203   // ///////////////////////
00204   // Private date members
00205 
00206   bool isInitialized_;
00207   RCP<const Thyra::ModelEvaluator<Scalar> > model_;
00208   RCP<Thyra::NonlinearSolverBase<Scalar> > solver_;
00209   RCP<Thyra::LinearOpWithSolveFactoryBase<Scalar> > irk_W_factory_;
00210   RCP<ParameterList> paramList_;
00211 
00212   Thyra::ModelEvaluatorBase::InArgs<Scalar> basePoint_;
00213   RCP<Thyra::VectorBase<Scalar> > x_;
00214   RCP<Thyra::VectorBase<Scalar> > x_old_;
00215   RCP<Thyra::VectorBase<Scalar> > x_dot_;
00216 
00217   TimeRange<Scalar> timeRange_;
00218 
00219   RCP<Thyra::ModelEvaluator<Scalar> > irkModel_;
00220   RCP<const RKButcherTableauBase<Scalar> > irkButcherTableau_;
00221 
00222   bool isDirk_; // Used for Diagonal Implicit RK 
00223 
00224   int numSteps_;
00225 
00226   bool haveInitialCondition_;
00227 
00228   // Cache
00229   RCP<Thyra::ProductVectorBase<Scalar> > x_stage_bar_;
00230 
00231   // //////////////////////////
00232   // Private member functions
00233 
00234   void defaultInitializeAll_();
00235   void initialize_();
00236 
00237 };
00238 
00239 
00244 template<class Scalar>
00245 RCP<ImplicitRKStepper<Scalar> >
00246 implicitRKStepper();
00247 
00248 template<class Scalar>
00249 RCP<ImplicitRKStepper<Scalar> >
00250 implicitRKStepper(
00251   const RCP<const Thyra::ModelEvaluator<Scalar> >  &model,
00252   const RCP<Thyra::NonlinearSolverBase<Scalar> >  &solver,
00253   const RCP<Thyra::LinearOpWithSolveFactoryBase<Scalar> > &irk_W_factory,
00254   const RCP<const RKButcherTableauBase<Scalar> > &irkbt
00255   );
00256 
00257 
00258 } // namespace Rythmos
00259 
00260 #endif //Rythmos_IMPLICIT_RK_STEPPER_DECL_H

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