Rythmos - Transient Integration for Differential Equations  Version of the Day
 All Classes Functions Variables Typedefs Pages
Rythmos_ImplicitBDFStepper_decl.hpp
1 //@HEADER
2 // ***********************************************************************
3 //
4 // Rythmos Package
5 // Copyright (2006) Sandia Corporation
6 //
7 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
8 // license for use of this work by or on behalf of the U.S. Government.
9 //
10 // This library is free software; you can redistribute it and/or modify
11 // it under the terms of the GNU Lesser General Public License as
12 // published by the Free Software Foundation; either version 2.1 of the
13 // License, or (at your option) any later version.
14 //
15 // This library is distributed in the hope that it will be useful, but
16 // WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 // Lesser General Public License for more details.
19 //
20 // You should have received a copy of the GNU Lesser General Public
21 // License along with this library; if not, write to the Free Software
22 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
23 // USA
24 // Questions? Contact Todd S. Coffey (tscoffe@sandia.gov)
25 //
26 // ***********************************************************************
27 //@HEADER
28 
29 #ifndef Rythmos_IMPLICITBDF_STEPPER_DECL_H
30 #define Rythmos_IMPLICITBDF_STEPPER_DECL_H
31 
32 #include "Rythmos_StepperBase.hpp"
33 #include "Rythmos_SingleResidualModelEvaluator.hpp"
34 #include "Rythmos_SolverAcceptingStepperBase.hpp"
35 #include "Rythmos_StepControlStrategyAcceptingStepperBase.hpp"
36 
37 #include "Thyra_VectorBase.hpp"
38 #include "Thyra_ModelEvaluator.hpp"
39 #include "Thyra_ModelEvaluatorHelpers.hpp"
40 #include "Thyra_NonlinearSolverBase.hpp"
41 #include "Thyra_SolveSupportTypes.hpp"
42 
43 #include "Teuchos_RCP.hpp"
44 #include "Teuchos_VerboseObjectParameterListHelpers.hpp"
45 #include "Teuchos_as.hpp"
46 
47 
48 namespace Rythmos {
49 
51 template<class Scalar>
53  : virtual public SolverAcceptingStepperBase<Scalar>
54  , virtual public StepControlStrategyAcceptingStepperBase<Scalar>
55 {
56 public:
57 
59  typedef typename Teuchos::ScalarTraits<Scalar>::magnitudeType ScalarMag;
60 
63 
66 
69  const RCP<Thyra::ModelEvaluator<Scalar> >& model
70  ,const RCP<Thyra::NonlinearSolverBase<Scalar> > &solver
71  );
72 
75  const RCP<Thyra::ModelEvaluator<Scalar> >& model
76  ,const RCP<Thyra::NonlinearSolverBase<Scalar> >& solver
77  ,const RCP<Teuchos::ParameterList>& parameterList
78  );
79 
81  RCP<const Thyra::VectorBase<Scalar> > get_solution() const;
82 
84  RCP<const Thyra::VectorBase<Scalar> > get_residual() const;
85 
87  const Thyra::VectorBase<Scalar>& getxHistory(int index) const;
88 
90  void setStepControlData(const StepperBase<Scalar> & stepper);
91 
93 
96 
99  const RCP<StepControlStrategyBase<Scalar> >& stepControlStrategy
100  );
101 
103  RCP<StepControlStrategyBase<Scalar> >
105 
107  RCP<const StepControlStrategyBase<Scalar> >
108  getStepControlStrategy() const;
109 
111 
114 
116  void setSolver(
117  const RCP<Thyra::NonlinearSolverBase<Scalar> > &solver
118  );
119 
121  RCP<Thyra::NonlinearSolverBase<Scalar> >
123 
125  RCP<const Thyra::NonlinearSolverBase<Scalar> >
126  getSolver() const;
127 
129 
132 
134  bool isImplicit() const;
135 
137  bool supportsCloning() const;
138 
146  RCP<StepperBase<Scalar> > cloneStepperAlgorithm() const;
147 
149  void setModel(const RCP<const Thyra::ModelEvaluator<Scalar> >& model);
150 
152  void setNonconstModel(const RCP<Thyra::ModelEvaluator<Scalar> >& model);
153 
155  RCP<const Thyra::ModelEvaluator<Scalar> > getModel() const;
156 
158  RCP<Thyra::ModelEvaluator<Scalar> > getNonconstModel();
159 
161  void setInitialCondition(
162  const Thyra::ModelEvaluatorBase::InArgs<Scalar> &initialCondition
163  );
164 
166  Thyra::ModelEvaluatorBase::InArgs<Scalar> getInitialCondition() const;
167 
169  Scalar takeStep(Scalar dt, StepSizeType flag);
170 
172  const StepStatus<Scalar> getStepStatus() const;
173 
175 
178 
180  RCP<const Thyra::VectorSpaceBase<Scalar> >
181  get_x_space() const;
182 
184  void addPoints(
185  const Array<Scalar>& time_vec
186  ,const Array<RCP<const Thyra::VectorBase<Scalar> > >& x_vec
187  ,const Array<RCP<const Thyra::VectorBase<Scalar> > >& xdot_vec
188  );
189 
192 
194  void getPoints(
195  const Array<Scalar>& time_vec
196  ,Array<RCP<const Thyra::VectorBase<Scalar> > >* x_vec
197  ,Array<RCP<const Thyra::VectorBase<Scalar> > >* xdot_vec
198  ,Array<ScalarMag>* accuracy_vec
199  ) const;
200 
202  void getNodes(Array<Scalar>* time_vec) const;
203 
205  void removeNodes(Array<Scalar>& time_vec);
206 
208  int getOrder() const;
209 
211 
214 
216  void setParameterList(RCP<Teuchos::ParameterList> const& paramList);
217 
219  RCP<Teuchos::ParameterList> getNonconstParameterList();
220 
222  RCP<Teuchos::ParameterList> unsetParameterList();
223 
225  RCP<const Teuchos::ParameterList> getValidParameters() const;
226 
228 
231 
233  std::string description() const;
234 
236  void describe(
237  Teuchos::FancyOStream &out,
238  const Teuchos::EVerbosityLevel verbLevel
239  ) const;
240 
242 
244  const Thyra::SolveStatus<Scalar>& getNonlinearSolveStatus() const;
245 
246 private:
247 
248  //
249  // Private data members
250  //
251 
252  RCP<const Thyra::ModelEvaluator<Scalar> > model_;
253  RCP<Thyra::NonlinearSolverBase<Scalar> > solver_;
255 
256  RCP<Thyra::VectorBase<Scalar> > xn0_;
257  RCP<Thyra::VectorBase<Scalar> > xpn0_;
258  RCP<Thyra::VectorBase<Scalar> > x_dot_base_;
259  Array<RCP<Thyra::VectorBase<Scalar> > > xHistory_;
260  RCP<Thyra::VectorBase<Scalar> > ee_;
261  RCP<Thyra::VectorBase<Scalar> > residual_;
262 
263  RCP<StepControlStrategyBase<Scalar> > stepControl_;
264 
265  Scalar time_;
266 
267  Thyra::ModelEvaluatorBase::InArgs<Scalar> basePoint_;
268 
269  Scalar hh_; // Current step-size
270  int currentOrder_; // Current order of integration
271  int maxOrder_; // maximum order = std::min(5,user option maxord) - see below.
272  int usedOrder_; // order used in current step (used after currentOrder is updated)
273  Array<Scalar> alpha_; // $\alpha_j(n)=h_n/\psi_j(n)$ coefficient used in local error test
274  // note: $h_n$ = current step size, n = current time step
275  Scalar LETvalue_; // ck * enorm
276  EStepLETStatus stepLETStatus_; // Local Error Test Status
277  Array<Scalar> gamma_; // $\gamma_j(n)=\sum_{l=1}^{j-1}1/\psi_l(n)$ coefficient used to
278  // calculate time derivative of history array for predictor
279  Array<Scalar> beta_; // coefficients used to evaluate predictor from history array
280  Array<Scalar> psi_; // $\psi_j(n) = t_n-t_{n-j}$ intermediary variable used to
281  // compute $\beta_j(n)$
282  Scalar alpha_s_; // $\alpha_s$ fixed-leading coefficient of this BDF method
283  int numberOfSteps_;// number of total time integration steps taken
284  int nef_; // number of error failures
285  Scalar usedStep_;
286  int nscsco_;
287  bool haveInitialCondition_;
288  bool isInitialized_;
289 
290  Thyra::SolveStatus<Scalar> nonlinearSolveStatus_;
291  int newtonConvergenceStatus_;
292 
293  RCP<Teuchos::ParameterList> parameterList_;
294 
295  //
296  // Private member functions
297  //
298 
299  void defaultInitializeAll_();
300  void getInitialCondition_();
301  void obtainPredictor_();
302  void interpolateSolution_(
303  const Scalar& timepoint,
304  Thyra::VectorBase<Scalar>* x_ptr_,
305  Thyra::VectorBase<Scalar>* xdot_ptr_,
306  ScalarMag* accuracy_ptr_
307  ) const;
308  void updateHistory_();
309  void restoreHistory_();
310  void updateCoeffs_();
311  void initialize_();
312  void completeStep_();
313 
314 };
315 
316 template<class Scalar>
317 RCP<ImplicitBDFStepper<Scalar> > implicitBDFStepper();
318 
319 template<class Scalar>
320 RCP<ImplicitBDFStepper<Scalar> > implicitBDFStepper(
321  const RCP<Thyra::ModelEvaluator<Scalar> >& model,
322  const RCP<Thyra::NonlinearSolverBase<Scalar> >& solver
323  );
324 
325 template<class Scalar>
326 RCP<ImplicitBDFStepper<Scalar> > implicitBDFStepper(
327  const RCP<Thyra::ModelEvaluator<Scalar> >& model,
328  const RCP<Thyra::NonlinearSolverBase<Scalar> >& solver,
329  const RCP<Teuchos::ParameterList>& parameterList
330  );
331 
332 } // namespace Rythmos
333 
334 #endif // Rythmos_IMPLICITBDF_STEPPER_DECL_H
void describe(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel) const
Mix-in interface for stepper objects that accept a step control strategy object to be used for evalua...
bool isImplicit() const
Overridden from StepperBase.
Base class for defining stepper functionality.
void getPoints(const Array< Scalar > &time_vec, Array< RCP< const Thyra::VectorBase< Scalar > > > *x_vec, Array< RCP< const Thyra::VectorBase< Scalar > > > *xdot_vec, Array< ScalarMag > *accuracy_vec) const
RCP< Teuchos::ParameterList > getNonconstParameterList()
RCP< const Thyra::ModelEvaluator< Scalar > > getModel() const
void setInitialCondition(const Thyra::ModelEvaluatorBase::InArgs< Scalar > &initialCondition)
void setNonconstModel(const RCP< Thyra::ModelEvaluator< Scalar > > &model)
const Thyra::SolveStatus< Scalar > & getNonlinearSolveStatus() const
Returns the Thyra::SolveStatus object from the last nonlinear solve.
RCP< StepperBase< Scalar > > cloneStepperAlgorithm() const
Creates copies of all internal data (including the parameter list) except the model which is assumed ...
RCP< const StepControlStrategyBase< Scalar > > getStepControlStrategy() const
ImplicitBDFStepper()
Constructors, intializers, Misc.
RCP< const Thyra::VectorBase< Scalar > > get_solution() const
TimeRange< Scalar > getTimeRange() const
The member functions in the StepControlStrategyBase move you between these states in the following fa...
RCP< Thyra::NonlinearSolverBase< Scalar > > getNonconstSolver()
Thyra::ModelEvaluatorBase::InArgs< Scalar > getInitialCondition() const
void setModel(const RCP< const Thyra::ModelEvaluator< Scalar > > &model)
RCP< const Thyra::NonlinearSolverBase< Scalar > > getSolver() const
Decorator subclass for a steady-state version of a DAE for single-residual time stepper methods...
void getNodes(Array< Scalar > *time_vec) const
Scalar takeStep(Scalar dt, StepSizeType flag)
bool supportsCloning() const
Returns true.
void setParameterList(RCP< Teuchos::ParameterList > const &paramList)
void setStepControlData(const StepperBase< Scalar > &stepper)
RCP< StepControlStrategyBase< Scalar > > getNonconstStepControlStrategy()
void removeNodes(Array< Scalar > &time_vec)
RCP< Thyra::ModelEvaluator< Scalar > > getNonconstModel()
Mix-in interface all implicit stepper objects that accept a nonlinear solver to be used to compute th...
RCP< const Teuchos::ParameterList > getValidParameters() const
void addPoints(const Array< Scalar > &time_vec, const Array< RCP< const Thyra::VectorBase< Scalar > > > &x_vec, const Array< RCP< const Thyra::VectorBase< Scalar > > > &xdot_vec)
RCP< const Thyra::VectorSpaceBase< Scalar > > get_x_space() const
const StepStatus< Scalar > getStepStatus() const
void setSolver(const RCP< Thyra::NonlinearSolverBase< Scalar > > &solver)
RCP< Teuchos::ParameterList > unsetParameterList()
RCP< const Thyra::VectorBase< Scalar > > get_residual() const
void setStepControlStrategy(const RCP< StepControlStrategyBase< Scalar > > &stepControlStrategy)
const Thyra::VectorBase< Scalar > & getxHistory(int index) const
Teuchos::ScalarTraits< Scalar >::magnitudeType ScalarMag