Rythmos - Transient Integration for Differential Equations Version of the Day
Rythmos_ImplicitBDFStepper_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_IMPLICITBDF_STEPPER_DECL_H
00030 #define Rythmos_IMPLICITBDF_STEPPER_DECL_H
00031 
00032 #include "Rythmos_StepperBase.hpp"
00033 #include "Rythmos_SingleResidualModelEvaluator.hpp"
00034 #include "Rythmos_SolverAcceptingStepperBase.hpp"
00035 #include "Rythmos_StepControlStrategyAcceptingStepperBase.hpp"
00036 
00037 #include "Thyra_VectorBase.hpp"
00038 #include "Thyra_ModelEvaluator.hpp"
00039 #include "Thyra_ModelEvaluatorHelpers.hpp"
00040 #include "Thyra_NonlinearSolverBase.hpp"
00041 #include "Thyra_SolveSupportTypes.hpp"
00042 
00043 #include "Teuchos_RCP.hpp"
00044 #include "Teuchos_VerboseObjectParameterListHelpers.hpp"
00045 #include "Teuchos_as.hpp"
00046 
00047 
00048 namespace Rythmos {
00049 
00051 template<class Scalar>
00052 class ImplicitBDFStepper 
00053   : virtual public SolverAcceptingStepperBase<Scalar>
00054   , virtual public StepControlStrategyAcceptingStepperBase<Scalar>
00055 {
00056 public:
00057 
00059   typedef typename Teuchos::ScalarTraits<Scalar>::magnitudeType ScalarMag;
00060   
00063 
00065   ImplicitBDFStepper();
00066 
00068   ImplicitBDFStepper(
00069     const RCP<Thyra::ModelEvaluator<Scalar> >& model
00070     ,const RCP<Thyra::NonlinearSolverBase<Scalar> >  &solver
00071     );
00072 
00074   ImplicitBDFStepper(
00075     const RCP<Thyra::ModelEvaluator<Scalar> >& model
00076     ,const RCP<Thyra::NonlinearSolverBase<Scalar> >& solver
00077     ,const RCP<Teuchos::ParameterList>& parameterList
00078     );
00079 
00081   RCP<const Thyra::VectorBase<Scalar> > get_solution() const;
00082 
00084   RCP<const Thyra::VectorBase<Scalar> > get_residual() const;
00085 
00087   const Thyra::VectorBase<Scalar>& getxHistory(int index) const;
00088 
00090   void setStepControlData(const StepperBase<Scalar> & stepper);
00091 
00093 
00096 
00098   void setStepControlStrategy(
00099       const RCP<StepControlStrategyBase<Scalar> >& stepControlStrategy
00100       );
00101 
00103   RCP<StepControlStrategyBase<Scalar> > 
00104     getNonconstStepControlStrategy();
00105 
00107   RCP<const StepControlStrategyBase<Scalar> > 
00108     getStepControlStrategy() const;
00109 
00111 
00114 
00116   void setSolver(
00117     const RCP<Thyra::NonlinearSolverBase<Scalar> > &solver
00118     );
00119 
00121   RCP<Thyra::NonlinearSolverBase<Scalar> >
00122   getNonconstSolver();
00123 
00125   RCP<const Thyra::NonlinearSolverBase<Scalar> >
00126   getSolver() const;
00127 
00129 
00132  
00134   bool isImplicit() const;
00135 
00137   bool supportsCloning() const;
00138 
00146   RCP<StepperBase<Scalar> > cloneStepperAlgorithm() const;
00147 
00149   void setModel(const RCP<const Thyra::ModelEvaluator<Scalar> >& model);
00150 
00152   void setNonconstModel(const RCP<Thyra::ModelEvaluator<Scalar> >& model);
00153 
00155   RCP<const Thyra::ModelEvaluator<Scalar> > getModel() const;
00156 
00158   RCP<Thyra::ModelEvaluator<Scalar> > getNonconstModel();
00159 
00161   void setInitialCondition(
00162     const Thyra::ModelEvaluatorBase::InArgs<Scalar> &initialCondition
00163     );
00164 
00166   Thyra::ModelEvaluatorBase::InArgs<Scalar> getInitialCondition() const;
00167 
00169   Scalar takeStep(Scalar dt, StepSizeType flag);
00170 
00172   const StepStatus<Scalar> getStepStatus() const;
00173 
00175 
00178 
00180   RCP<const Thyra::VectorSpaceBase<Scalar> >
00181   get_x_space() const;
00182 
00184   void addPoints(
00185     const Array<Scalar>& time_vec
00186     ,const Array<RCP<const Thyra::VectorBase<Scalar> > >& x_vec
00187     ,const Array<RCP<const Thyra::VectorBase<Scalar> > >& xdot_vec
00188     );
00189 
00191   TimeRange<Scalar> getTimeRange() const;
00192     
00194   void getPoints(
00195     const Array<Scalar>& time_vec
00196     ,Array<RCP<const Thyra::VectorBase<Scalar> > >* x_vec
00197     ,Array<RCP<const Thyra::VectorBase<Scalar> > >* xdot_vec
00198     ,Array<ScalarMag>* accuracy_vec
00199     ) const;
00200 
00202   void getNodes(Array<Scalar>* time_vec) const;
00203 
00205   void removeNodes(Array<Scalar>& time_vec);
00206 
00208   int getOrder() const;
00209 
00211   
00214 
00216   void setParameterList(RCP<Teuchos::ParameterList> const& paramList);
00217 
00219   RCP<Teuchos::ParameterList> getNonconstParameterList();
00220 
00222   RCP<Teuchos::ParameterList> unsetParameterList();
00223 
00225   RCP<const Teuchos::ParameterList> getValidParameters() const;
00226 
00228 
00231 
00233   std::string description() const;
00234 
00236   void describe(
00237     Teuchos::FancyOStream &out,
00238     const Teuchos::EVerbosityLevel verbLevel
00239     ) const;
00240 
00242 
00243 private:
00244 
00245   //
00246   // Private data members
00247   //
00248 
00249   RCP<const Thyra::ModelEvaluator<Scalar> > model_;
00250   RCP<Thyra::NonlinearSolverBase<Scalar> > solver_;
00251   Rythmos::SingleResidualModelEvaluator<Scalar>   neModel_;
00252 
00253   RCP<Thyra::VectorBase<Scalar> > xn0_;
00254   RCP<Thyra::VectorBase<Scalar> > xpn0_;
00255   RCP<Thyra::VectorBase<Scalar> > x_dot_base_;
00256   Array<RCP<Thyra::VectorBase<Scalar> > > xHistory_;
00257   RCP<Thyra::VectorBase<Scalar> > ee_;
00258   RCP<Thyra::VectorBase<Scalar> > residual_;
00259 
00260   RCP<StepControlStrategyBase<Scalar> > stepControl_; 
00261 
00262   Scalar time_;
00263 
00264   Thyra::ModelEvaluatorBase::InArgs<Scalar> basePoint_;
00265 
00266   Scalar hh_;        // Current step-size
00267   int currentOrder_; // Current order of integration
00268   int maxOrder_;     // maximum order = std::min(5,user option maxord) - see below.
00269   int usedOrder_;    // order used in current step (used after currentOrder is updated)
00270   Array<Scalar> alpha_;    // $\alpha_j(n)=h_n/\psi_j(n)$ coefficient used in local error test
00271   // note:   $h_n$ = current step size, n = current time step
00272   Scalar LETvalue_;   // ck * enorm
00273   EStepLETStatus stepLETStatus_; // Local Error Test Status
00274   Array<Scalar> gamma_;    // $\gamma_j(n)=\sum_{l=1}^{j-1}1/\psi_l(n)$ coefficient used to
00275   // calculate time derivative of history array for predictor 
00276   Array<Scalar> beta_;     // coefficients used to evaluate predictor from history array
00277   Array<Scalar> psi_;      // $\psi_j(n) = t_n-t_{n-j}$ intermediary variable used to 
00278   // compute $\beta_j(n)$
00279   Scalar alpha_s_;    // $\alpha_s$ fixed-leading coefficient of this BDF method
00280   int numberOfSteps_;// number of total time integration steps taken
00281   int nef_; // number of error failures 
00282   Scalar usedStep_;
00283   int nscsco_;
00284   bool haveInitialCondition_;
00285   bool isInitialized_;
00286 
00287   int newtonConvergenceStatus_;
00288 
00289   RCP<Teuchos::ParameterList> parameterList_;
00290 
00291   //
00292   // Private member functions
00293   //
00294 
00295   void defaultInitializeAll_();
00296   void getInitialCondition_();
00297   void obtainPredictor_();
00298   void interpolateSolution_(
00299     const Scalar& timepoint,
00300     Thyra::VectorBase<Scalar>* x_ptr_,
00301     Thyra::VectorBase<Scalar>* xdot_ptr_,
00302     ScalarMag* accuracy_ptr_
00303     ) const;
00304   void updateHistory_();
00305   void restoreHistory_();
00306   void updateCoeffs_();
00307   void initialize_();
00308   void completeStep_();
00309 
00310 };
00311 
00312 template<class Scalar>
00313 RCP<ImplicitBDFStepper<Scalar> > implicitBDFStepper();
00314 
00315 template<class Scalar>
00316 RCP<ImplicitBDFStepper<Scalar> > implicitBDFStepper(
00317   const RCP<Thyra::ModelEvaluator<Scalar> >& model,
00318   const RCP<Thyra::NonlinearSolverBase<Scalar> >& solver,
00319   const RCP<Teuchos::ParameterList>& parameterList
00320   );
00321 
00322 } // namespace Rythmos 
00323 
00324 #endif // Rythmos_IMPLICITBDF_STEPPER_DECL_H
 All Classes Functions Variables Typedefs Friends