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., 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_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   RCP<const Thyra::ModelEvaluator<Scalar> >
00152   getModel() const;
00153 
00155   void setInitialCondition(
00156     const Thyra::ModelEvaluatorBase::InArgs<Scalar> &initialCondition
00157     );
00158 
00160   Scalar takeStep(Scalar dt, StepSizeType flag);
00161   
00163   const StepStatus<Scalar> getStepStatus() const;
00164   
00166 
00169 
00171   RCP<const Thyra::VectorSpaceBase<Scalar> >
00172   get_x_space() const;
00173 
00175   void addPoints(
00176     const Array<Scalar>& time_vec,
00177     const Array<RCP<const Thyra::VectorBase<Scalar> > >& x_vec,
00178     const Array<RCP<const Thyra::VectorBase<Scalar> > >& xdot_vec
00179     );
00180   
00182   TimeRange<Scalar> getTimeRange() const;
00183   
00185   void getPoints(
00186     const Array<Scalar>& time_vec,
00187     Array<RCP<const Thyra::VectorBase<Scalar> > >* x_vec,
00188     Array<RCP<const Thyra::VectorBase<Scalar> > >* xdot_vec,
00189     Array<ScalarMag>* accuracy_vec
00190     ) const;
00191   
00193   void getNodes(Array<Scalar>* time_vec) const;
00194   
00196   void removeNodes(Array<Scalar>& time_vec);
00197 
00199   int getOrder() const;
00200 
00202   
00205 
00207   void setParameterList(RCP<Teuchos::ParameterList> const& paramList);
00208   
00210   RCP<Teuchos::ParameterList> getNonconstParameterList();
00211   
00213   RCP<Teuchos::ParameterList> unsetParameterList();
00214   
00216   RCP<const Teuchos::ParameterList> getValidParameters() const;
00217  
00219 
00222   
00224   void describe(
00225     Teuchos::FancyOStream  &out,
00226     const Teuchos::EVerbosityLevel verbLevel
00227     ) const;
00228 
00230 
00231 private:
00232 
00233   // ///////////////////////
00234   // Private date members
00235 
00236   bool isInitialized_;
00237   bool haveInitialCondition_;
00238   RCP<const Thyra::ModelEvaluator<Scalar> > model_;
00239   RCP<Thyra::NonlinearSolverBase<Scalar> > solver_;
00240 
00241   Thyra::ModelEvaluatorBase::InArgs<Scalar> basePoint_;
00242 
00243   RCP<Thyra::VectorBase<Scalar> > x_;
00244   RCP<Thyra::VectorBase<Scalar> > x_old_;
00245   RCP<Thyra::VectorBase<Scalar> > x_pre_;
00246 
00247   RCP<Thyra::VectorBase<Scalar> > x_dot_;
00248   RCP<Thyra::VectorBase<Scalar> > x_dot_old_;
00249   RCP<Thyra::VectorBase<Scalar> > x_dot_really_old_;
00250   RCP<Thyra::VectorBase<Scalar> > x_dot_base_;
00251 
00252   Scalar t_;
00253   Scalar t_old_;
00254 
00255   Scalar dt_;
00256   Scalar dt_old_;
00257   int numSteps_;
00258 
00259   ThetaStepperType thetaStepperType_;
00260   Scalar theta_;
00261   int predictor_corrector_begin_after_step_;
00262   int default_predictor_order_;
00263 
00264   RCP<Rythmos::SingleResidualModelEvaluator<Scalar> >  neModel_;
00265 
00266   RCP<Teuchos::ParameterList> parameterList_;
00267 
00268   RCP<InterpolatorBase<Scalar> > interpolator_;
00269 
00270 
00271   // //////////////////////////
00272   // Private member functions
00273 
00274   void defaultInitializeAll_();
00275   void initialize_();
00276   void obtainPredictor_();
00277 };
00278 
00279 
00284 template<class Scalar>
00285 RCP<ThetaStepper<Scalar> >
00286 thetaStepper(
00287   const RCP<const Thyra::ModelEvaluator<Scalar> > &model,
00288   const RCP<Thyra::NonlinearSolverBase<Scalar> > &solver,
00289   RCP<Teuchos::ParameterList> &parameterList
00290   );
00291 
00292 } // namespace Rythmos
00293 
00294 #endif // HAVE_RYTHMOS_EXPERIMENTAL
00295 
00296 #endif //Rythmos_THETA_STEPPER_DECL_H

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