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

Generated on Tue Oct 20 12:46:08 2009 for Rythmos - Transient Integration for Differential Equations by doxygen 1.4.7