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<const Thyra::ModelEvaluator<Scalar> >  &model
00070     ,const RCP<Thyra::NonlinearSolverBase<Scalar> >  &solver
00071     );
00072 
00074   ImplicitBDFStepper(
00075     const RCP<const 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   RCP<const Thyra::ModelEvaluator<Scalar> >
00153   getModel() const;
00154 
00156   void setInitialCondition(
00157     const Thyra::ModelEvaluatorBase::InArgs<Scalar> &initialCondition
00158     );
00159 
00161   Scalar takeStep(Scalar dt, StepSizeType flag);
00162 
00164   const StepStatus<Scalar> getStepStatus() const;
00165 
00167 
00170 
00172   RCP<const Thyra::VectorSpaceBase<Scalar> >
00173   get_x_space() const;
00174 
00176   void addPoints(
00177     const Array<Scalar>& time_vec
00178     ,const Array<RCP<const Thyra::VectorBase<Scalar> > >& x_vec
00179     ,const Array<RCP<const Thyra::VectorBase<Scalar> > >& xdot_vec
00180     );
00181 
00183   TimeRange<Scalar> getTimeRange() const;
00184     
00186   void getPoints(
00187     const Array<Scalar>& time_vec
00188     ,Array<RCP<const Thyra::VectorBase<Scalar> > >* x_vec
00189     ,Array<RCP<const Thyra::VectorBase<Scalar> > >* xdot_vec
00190     ,Array<ScalarMag>* accuracy_vec
00191     ) const;
00192 
00194   void getNodes(Array<Scalar>* time_vec) const;
00195 
00197   void removeNodes(Array<Scalar>& time_vec);
00198 
00200   int getOrder() const;
00201 
00203   
00206 
00208   void setParameterList(RCP<Teuchos::ParameterList> const& paramList);
00209 
00211   RCP<Teuchos::ParameterList> getNonconstParameterList();
00212 
00214   RCP<Teuchos::ParameterList> unsetParameterList();
00215 
00217   RCP<const Teuchos::ParameterList> getValidParameters() const;
00218 
00220 
00223 
00225   std::string description() const;
00226 
00228   void describe(
00229     Teuchos::FancyOStream &out,
00230     const Teuchos::EVerbosityLevel verbLevel
00231     ) const;
00232 
00234 
00235 private:
00236 
00237   //
00238   // Private data members
00239   //
00240 
00241   RCP<const Thyra::ModelEvaluator<Scalar> > model_;
00242   RCP<Thyra::NonlinearSolverBase<Scalar> > solver_;
00243   Rythmos::SingleResidualModelEvaluator<Scalar>   neModel_;
00244 
00245   RCP<Thyra::VectorBase<Scalar> > xn0_;
00246   RCP<Thyra::VectorBase<Scalar> > xpn0_;
00247   RCP<Thyra::VectorBase<Scalar> > x_dot_base_;
00248   Array<RCP<Thyra::VectorBase<Scalar> > > xHistory_;
00249   RCP<Thyra::VectorBase<Scalar> > ee_;
00250   RCP<Thyra::VectorBase<Scalar> > residual_;
00251 
00252   RCP<StepControlStrategyBase<Scalar> > stepControl_; 
00253 
00254   Scalar time_;
00255 
00256   Thyra::ModelEvaluatorBase::InArgs<Scalar> basePoint_;
00257 
00258   Scalar hh_;        // Current step-size
00259   int currentOrder_; // Current order of integration
00260   int maxOrder_;     // maximum order = std::min(5,user option maxord) - see below.
00261   int usedOrder_;    // order used in current step (used after currentOrder is updated)
00262   Array<Scalar> alpha_;    // $\alpha_j(n)=h_n/\psi_j(n)$ coefficient used in local error test
00263   // note:   $h_n$ = current step size, n = current time step
00264   Scalar LETvalue_;   // ck * enorm
00265   EStepLETStatus stepLETStatus_; // Local Error Test Status
00266   Array<Scalar> gamma_;    // $\gamma_j(n)=\sum_{l=1}^{j-1}1/\psi_l(n)$ coefficient used to
00267   // calculate time derivative of history array for predictor 
00268   Array<Scalar> beta_;     // coefficients used to evaluate predictor from history array
00269   Array<Scalar> psi_;      // $\psi_j(n) = t_n-t_{n-j}$ intermediary variable used to 
00270   // compute $\beta_j(n)$
00271   Scalar alpha_s_;    // $\alpha_s$ fixed-leading coefficient of this BDF method
00272   int numberOfSteps_;// number of total time integration steps taken
00273   int nef_; // number of error failures 
00274   Scalar usedStep_;
00275   int nscsco_;
00276   bool haveInitialCondition_;
00277   bool isInitialized_;
00278 
00279   int newtonConvergenceStatus_;
00280 
00281   RCP<Teuchos::ParameterList> parameterList_;
00282 
00283   //
00284   // Private member functions
00285   //
00286 
00287   void defaultInitializeAll_();
00288   void getInitialCondition_();
00289   void obtainPredictor_();
00290   void interpolateSolution_(
00291     const Scalar& timepoint,
00292     Thyra::VectorBase<Scalar>* x_ptr_,
00293     Thyra::VectorBase<Scalar>* xdot_ptr_,
00294     ScalarMag* accuracy_ptr_
00295     ) const;
00296   void updateHistory_();
00297   void restoreHistory_();
00298   void updateCoeffs_();
00299   void initialize_();
00300   void completeStep_();
00301 
00302 };
00303 
00304 template<class Scalar>
00305 RCP<ImplicitBDFStepper<Scalar> > implicitBDFStepper();
00306 
00307 template<class Scalar>
00308 RCP<ImplicitBDFStepper<Scalar> > implicitBDFStepper(
00309   const RCP<const Thyra::ModelEvaluator<Scalar> > &model,
00310   const RCP<Thyra::NonlinearSolverBase<Scalar> > &solver,
00311   const RCP<Teuchos::ParameterList> &parameterList
00312   );
00313 
00314 } // namespace Rythmos 
00315 
00316 #endif // Rythmos_IMPLICITBDF_STEPPER_DECL_H

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