|
Rythmos - Transient Integration for Differential Equations
Version of the Day
|
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_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 00244 const Thyra::SolveStatus<Scalar>& getNonlinearSolveStatus() const; 00245 00246 private: 00247 00248 // 00249 // Private data members 00250 // 00251 00252 RCP<const Thyra::ModelEvaluator<Scalar> > model_; 00253 RCP<Thyra::NonlinearSolverBase<Scalar> > solver_; 00254 Rythmos::SingleResidualModelEvaluator<Scalar> neModel_; 00255 00256 RCP<Thyra::VectorBase<Scalar> > xn0_; 00257 RCP<Thyra::VectorBase<Scalar> > xpn0_; 00258 RCP<Thyra::VectorBase<Scalar> > x_dot_base_; 00259 Array<RCP<Thyra::VectorBase<Scalar> > > xHistory_; 00260 RCP<Thyra::VectorBase<Scalar> > ee_; 00261 RCP<Thyra::VectorBase<Scalar> > residual_; 00262 00263 RCP<StepControlStrategyBase<Scalar> > stepControl_; 00264 00265 Scalar time_; 00266 00267 Thyra::ModelEvaluatorBase::InArgs<Scalar> basePoint_; 00268 00269 Scalar hh_; // Current step-size 00270 int currentOrder_; // Current order of integration 00271 int maxOrder_; // maximum order = std::min(5,user option maxord) - see below. 00272 int usedOrder_; // order used in current step (used after currentOrder is updated) 00273 Array<Scalar> alpha_; // $\alpha_j(n)=h_n/\psi_j(n)$ coefficient used in local error test 00274 // note: $h_n$ = current step size, n = current time step 00275 Scalar LETvalue_; // ck * enorm 00276 EStepLETStatus stepLETStatus_; // Local Error Test Status 00277 Array<Scalar> gamma_; // $\gamma_j(n)=\sum_{l=1}^{j-1}1/\psi_l(n)$ coefficient used to 00278 // calculate time derivative of history array for predictor 00279 Array<Scalar> beta_; // coefficients used to evaluate predictor from history array 00280 Array<Scalar> psi_; // $\psi_j(n) = t_n-t_{n-j}$ intermediary variable used to 00281 // compute $\beta_j(n)$ 00282 Scalar alpha_s_; // $\alpha_s$ fixed-leading coefficient of this BDF method 00283 int numberOfSteps_;// number of total time integration steps taken 00284 int nef_; // number of error failures 00285 Scalar usedStep_; 00286 int nscsco_; 00287 bool haveInitialCondition_; 00288 bool isInitialized_; 00289 00290 Thyra::SolveStatus<Scalar> nonlinearSolveStatus_; 00291 int newtonConvergenceStatus_; 00292 00293 RCP<Teuchos::ParameterList> parameterList_; 00294 00295 // 00296 // Private member functions 00297 // 00298 00299 void defaultInitializeAll_(); 00300 void getInitialCondition_(); 00301 void obtainPredictor_(); 00302 void interpolateSolution_( 00303 const Scalar& timepoint, 00304 Thyra::VectorBase<Scalar>* x_ptr_, 00305 Thyra::VectorBase<Scalar>* xdot_ptr_, 00306 ScalarMag* accuracy_ptr_ 00307 ) const; 00308 void updateHistory_(); 00309 void restoreHistory_(); 00310 void updateCoeffs_(); 00311 void initialize_(); 00312 void completeStep_(); 00313 00314 }; 00315 00316 template<class Scalar> 00317 RCP<ImplicitBDFStepper<Scalar> > implicitBDFStepper(); 00318 00319 template<class Scalar> 00320 RCP<ImplicitBDFStepper<Scalar> > implicitBDFStepper( 00321 const RCP<Thyra::ModelEvaluator<Scalar> >& model, 00322 const RCP<Thyra::NonlinearSolverBase<Scalar> >& solver 00323 ); 00324 00325 template<class Scalar> 00326 RCP<ImplicitBDFStepper<Scalar> > implicitBDFStepper( 00327 const RCP<Thyra::ModelEvaluator<Scalar> >& model, 00328 const RCP<Thyra::NonlinearSolverBase<Scalar> >& solver, 00329 const RCP<Teuchos::ParameterList>& parameterList 00330 ); 00331 00332 } // namespace Rythmos 00333 00334 #endif // Rythmos_IMPLICITBDF_STEPPER_DECL_H
1.7.6.1