Rythmos - Transient Integration for Differential Equations Version of the Day
Rythmos_ThetaStepper_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., 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 #ifndef Rythmos_THETA_STEPPER_DECL_H
00030 #define Rythmos_THETA_STEPPER_DECL_H
00031 
00032 #include "Rythmos_ConfigDefs.h"
00033 #ifdef HAVE_RYTHMOS_EXPERIMENTAL
00034 
00035 #include "Rythmos_StepperBase.hpp"
00036 #include "Rythmos_DataStore.hpp"
00037 #include "Rythmos_LinearInterpolator.hpp"
00038 #include "Rythmos_InterpolatorAcceptingObjectBase.hpp"
00039 #include "Rythmos_InterpolatorBaseHelpers.hpp"
00040 #include "Rythmos_SingleResidualModelEvaluator.hpp"
00041 #include "Rythmos_SolverAcceptingStepperBase.hpp"
00042 #include "Rythmos_StepperHelpers.hpp"
00043 
00044 #include "Thyra_VectorBase.hpp"
00045 #include "Thyra_ModelEvaluator.hpp"
00046 #include "Thyra_ModelEvaluatorHelpers.hpp"
00047 #include "Thyra_AssertOp.hpp"
00048 #include "Thyra_NonlinearSolverBase.hpp"
00049 #include "Thyra_TestingTools.hpp"
00050 
00051 #include "Teuchos_VerboseObjectParameterListHelpers.hpp"
00052 #include "Teuchos_as.hpp"
00053 
00054 
00055 namespace {
00056   const std::string ThetaStepperType_name = "Theta Stepper Type";
00057   const std::string ThetaStepperType_default = "Implicit Euler";
00058 
00059   const std::string PredictorOrder_name = "Predictor Order";
00060   const int PredictorOrder_default = 2;
00061 }
00062 
00063 namespace Rythmos {
00064   
00065 enum ThetaStepperType 
00066 {
00067   ImplicitEuler = 0,
00068   Trapezoid,
00069   INVALID_THETA_STEPPER_TYPE
00070 };
00071   
00072 
00076 template<class Scalar>
00077 class ThetaStepper : 
00078   virtual public SolverAcceptingStepperBase<Scalar>,
00079   virtual public InterpolatorAcceptingObjectBase<Scalar>
00080 {
00081 public:
00082   
00084   typedef typename Teuchos::ScalarTraits<Scalar>::magnitudeType ScalarMag;
00085   
00088 
00090   ThetaStepper();
00091 
00092   bool isImplicit() const;
00093   
00096   
00098   void setInterpolator(const RCP<InterpolatorBase<Scalar> >& interpolator);
00099 
00101   RCP<InterpolatorBase<Scalar> >
00102     getNonconstInterpolator();
00103 
00105   RCP<const InterpolatorBase<Scalar> >
00106     getInterpolator() const;
00107   
00109   RCP<InterpolatorBase<Scalar> > unSetInterpolator();
00111 
00113 
00116 
00118   void setSolver(
00119     const RCP<Thyra::NonlinearSolverBase<Scalar> > &solver
00120     );
00121 
00123   RCP<Thyra::NonlinearSolverBase<Scalar> >
00124   getNonconstSolver();
00125 
00127   RCP<const Thyra::NonlinearSolverBase<Scalar> >
00128   getSolver() const;
00129 
00131 
00134  
00136   bool supportsCloning() const;
00137 
00145   RCP<StepperBase<Scalar> > cloneStepperAlgorithm() const;
00146 
00148   void setModel(const RCP<const Thyra::ModelEvaluator<Scalar> >& model);
00149 
00151   void setNonconstModel(const RCP<Thyra::ModelEvaluator<Scalar> >& model);
00152   
00154   RCP<const Thyra::ModelEvaluator<Scalar> > getModel() const;
00155 
00157   RCP<Thyra::ModelEvaluator<Scalar> > getNonconstModel();
00158 
00160   void setInitialCondition(
00161     const Thyra::ModelEvaluatorBase::InArgs<Scalar> &initialCondition
00162     );
00163 
00165   Thyra::ModelEvaluatorBase::InArgs<Scalar> getInitialCondition() const;
00166 
00168   Scalar takeStep(Scalar dt, StepSizeType flag);
00169   
00171   const StepStatus<Scalar> getStepStatus() const;
00172   
00174 
00177 
00179   RCP<const Thyra::VectorSpaceBase<Scalar> >
00180   get_x_space() const;
00181 
00183   void addPoints(
00184     const Array<Scalar>& time_vec,
00185     const Array<RCP<const Thyra::VectorBase<Scalar> > >& x_vec,
00186     const Array<RCP<const Thyra::VectorBase<Scalar> > >& xdot_vec
00187     );
00188   
00190   TimeRange<Scalar> getTimeRange() const;
00191   
00193   void getPoints(
00194     const Array<Scalar>& time_vec,
00195     Array<RCP<const Thyra::VectorBase<Scalar> > >* x_vec,
00196     Array<RCP<const Thyra::VectorBase<Scalar> > >* xdot_vec,
00197     Array<ScalarMag>* accuracy_vec
00198     ) const;
00199   
00201   void getNodes(Array<Scalar>* time_vec) const;
00202   
00204   void removeNodes(Array<Scalar>& time_vec);
00205 
00207   int getOrder() const;
00208 
00210   
00213 
00215   void setParameterList(RCP<Teuchos::ParameterList> const& paramList);
00216   
00218   RCP<Teuchos::ParameterList> getNonconstParameterList();
00219   
00221   RCP<Teuchos::ParameterList> unsetParameterList();
00222   
00224   RCP<const Teuchos::ParameterList> getValidParameters() const;
00225  
00227 
00230   
00232   void describe(
00233     Teuchos::FancyOStream  &out,
00234     const Teuchos::EVerbosityLevel verbLevel
00235     ) const;
00236 
00238 
00239 private:
00240 
00241   // ///////////////////////
00242   // Private date members
00243 
00244   bool isInitialized_;
00245   bool haveInitialCondition_;
00246   RCP<const Thyra::ModelEvaluator<Scalar> > model_;
00247   RCP<Thyra::NonlinearSolverBase<Scalar> > solver_;
00248 
00249   Thyra::ModelEvaluatorBase::InArgs<Scalar> basePoint_;
00250 
00251   RCP<Thyra::VectorBase<Scalar> > x_;
00252   RCP<Thyra::VectorBase<Scalar> > x_old_;
00253   RCP<Thyra::VectorBase<Scalar> > x_pre_;
00254 
00255   RCP<Thyra::VectorBase<Scalar> > x_dot_;
00256   RCP<Thyra::VectorBase<Scalar> > x_dot_old_;
00257   RCP<Thyra::VectorBase<Scalar> > x_dot_really_old_;
00258   RCP<Thyra::VectorBase<Scalar> > x_dot_base_;
00259 
00260   Scalar t_;
00261   Scalar t_old_;
00262 
00263   Scalar dt_;
00264   Scalar dt_old_;
00265   int numSteps_;
00266 
00267   ThetaStepperType thetaStepperType_;
00268   Scalar theta_;
00269   int predictor_corrector_begin_after_step_;
00270   int default_predictor_order_;
00271 
00272   RCP<Rythmos::SingleResidualModelEvaluator<Scalar> >  neModel_;
00273 
00274   RCP<Teuchos::ParameterList> parameterList_;
00275 
00276   RCP<InterpolatorBase<Scalar> > interpolator_;
00277 
00278 
00279   // //////////////////////////
00280   // Private member functions
00281 
00282   void defaultInitializeAll_();
00283   void initialize_();
00284   void obtainPredictor_();
00285 };
00286 
00287 
00292 template<class Scalar>
00293 RCP<ThetaStepper<Scalar> >
00294 thetaStepper(
00295   const RCP<Thyra::ModelEvaluator<Scalar> >& model,
00296   const RCP<Thyra::NonlinearSolverBase<Scalar> >& solver,
00297   RCP<Teuchos::ParameterList>& parameterList
00298   );
00299 
00300 } // namespace Rythmos
00301 
00302 #endif // HAVE_RYTHMOS_EXPERIMENTAL
00303 
00304 #endif //Rythmos_THETA_STEPPER_DECL_H
 All Classes Functions Variables Typedefs Friends