Rythmos - Transient Integration for Differential Equations  Version of the Day
 All Classes Functions Variables Typedefs Pages
Rythmos_ImplicitRKStepper_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_IMPLICIT_RK_STEPPER_DECL_H
30 #define Rythmos_IMPLICIT_RK_STEPPER_DECL_H
31 
32 #include "Rythmos_Types.hpp"
33 #include "Rythmos_StepperBase.hpp"
34 #include "Rythmos_DataStore.hpp"
35 #include "Rythmos_SolverAcceptingStepperBase.hpp"
36 #include "Rythmos_RKButcherTableauAcceptingStepperBase.hpp"
37 #include "Rythmos_RKButcherTableauBase.hpp"
38 #include "Rythmos_StepControlStrategyAcceptingStepperBase.hpp"
39 #include "Rythmos_StepControlStrategyBase.hpp"
40 
41 #include "Thyra_ModelEvaluator.hpp"
42 #include "Thyra_ProductVectorBase.hpp"
43 #include "Thyra_NonlinearSolverBase.hpp"
44 
45 namespace Rythmos {
46 
47 
49 template<class Scalar>
51  virtual public SolverAcceptingStepperBase<Scalar>,
52  virtual public RKButcherTableauAcceptingStepperBase<Scalar>,
53  virtual public StepControlStrategyAcceptingStepperBase<Scalar>
54 {
55 public:
56 
58  typedef typename ScalarTraits<Scalar>::magnitudeType ScalarMag;
59 
62 
65 
66  void set_W_factory( const RCP<Thyra::LinearOpWithSolveFactoryBase<Scalar> > &irk_W_factory );
67 
69  RCP<const Thyra::LinearOpWithSolveFactoryBase<Scalar> > get_W_factory() const;
70 
73 
75  void setRKButcherTableau( const RCP<const RKButcherTableauBase<Scalar> > &rkButcherTableau );
76 
78  RCP<const RKButcherTableauBase<Scalar> > getRKButcherTableau() const;
79 
81 
83  // This function is mostly for testing purposes to explicitely over-ride the
84  // internal RKBT detection to allow testing of 1-stage RKBTs as both fully
85  // implicit RK and as DIRK methods.
86  void setDirk(bool isDirk);
87 
89 
92 
94  void setSolver(
95  const RCP<Thyra::NonlinearSolverBase<Scalar> > &solver
96  );
97 
99  RCP<Thyra::NonlinearSolverBase<Scalar> >
101 
103  RCP<const Thyra::NonlinearSolverBase<Scalar> >
104  getSolver() const;
105 
107 
110 
112  bool isImplicit() const;
113 
115  bool supportsCloning() const;
116 
118  RCP<StepperBase<Scalar> > cloneStepperAlgorithm() const;
119 
121  void setModel(const RCP<const Thyra::ModelEvaluator<Scalar> >& model);
122 
124  void setNonconstModel(const RCP<Thyra::ModelEvaluator<Scalar> >& model);
125 
127  RCP<const Thyra::ModelEvaluator<Scalar> > getModel() const;
128 
130  RCP<Thyra::ModelEvaluator<Scalar> > getNonconstModel();
131 
133  void setInitialCondition(
134  const Thyra::ModelEvaluatorBase::InArgs<Scalar> &initialCondition
135  );
136 
138  Thyra::ModelEvaluatorBase::InArgs<Scalar> getInitialCondition() const;
139 
142  Scalar takeStep(Scalar dt, StepSizeType flag);
143 
145  const StepStatus<Scalar> getStepStatus() const;
146 
149 
152  const RCP<StepControlStrategyBase<Scalar> >& stepControlStrategy
153  );
154 
156  RCP<StepControlStrategyBase<Scalar> >
158 
160  RCP<const StepControlStrategyBase<Scalar> >
161  getStepControlStrategy() const;
162 
164 
165 
167 
170 
172  RCP<const Thyra::VectorSpaceBase<Scalar> >
173  get_x_space() const;
174 
176  void addPoints(
177  const Array<Scalar>& time_vec,
178  const Array<RCP<const Thyra::VectorBase<Scalar> > >& x_vec,
179  const Array<RCP<const Thyra::VectorBase<Scalar> > >& xdot_vec
180  );
181 
184 
186  void getPoints(
187  const Array<Scalar>& time_vec,
188  Array<RCP<const Thyra::VectorBase<Scalar> > >* x_vec,
189  Array<RCP<const Thyra::VectorBase<Scalar> > >* xdot_vec,
190  Array<ScalarMag>* accuracy_vec
191  ) const;
192 
194  void getNodes(Array<Scalar>* time_vec) const;
195 
197  void removeNodes(Array<Scalar>& time_vec);
198 
200  int getOrder() const;
201 
203 
206 
208  void setParameterList(RCP<ParameterList> const& paramList);
209 
211  RCP<ParameterList> getNonconstParameterList();
212 
214  RCP<ParameterList> unsetParameterList();
215 
217  RCP<const ParameterList> getValidParameters() const;
218 
220 
223 
225  void describe(
226  FancyOStream &out,
227  const Teuchos::EVerbosityLevel verbLevel
228  ) const;
229 
231 
233  bool isEmbeddedRK_ = false; // Sidafa
234 
235 private:
236 
237  // ///////////////////////
238  // Private date members
239 
240  bool isInitialized_;
241  RCP<const Thyra::ModelEvaluator<Scalar> > model_;
242  RCP<Thyra::NonlinearSolverBase<Scalar> > solver_;
243  RCP<Thyra::LinearOpWithSolveFactoryBase<Scalar> > irk_W_factory_;
244  RCP<ParameterList> paramList_;
245 
246  Thyra::ModelEvaluatorBase::InArgs<Scalar> basePoint_;
247  RCP<Thyra::VectorBase<Scalar> > x_;
248  RCP<Thyra::VectorBase<Scalar> > x_old_;
249  RCP<Thyra::VectorBase<Scalar> > x_dot_;
250  RCP<Thyra::VectorBase<Scalar> > oldSolution_; // Sidafa
251  EStepLETStatus stepLETStatus_; // Local Error Test Status (Sidafa)
252  RCP<Thyra::VectorBase<Scalar> > xhat_; // Embedded solution (Sidafa)
253  RCP<Thyra::VectorBase<Scalar> > ee_; // error (Sidafa)
254 
255  TimeRange<Scalar> timeRange_;
256 
257  RCP<Thyra::ModelEvaluator<Scalar> > irkModel_;
258  RCP<const RKButcherTableauBase<Scalar> > irkButcherTableau_;
259 
260  bool isDirk_; // Used for Diagonal Implicit RK
261  bool isVariableStep_ = false;
262 
263  int numSteps_;
264  Scalar LETvalue_; // ck * e
265 
266  bool haveInitialCondition_;
267 
268  // Sidafa 9/4/15
269  Thyra::SolveStatus<Scalar> nonlinearSolveStatus_;
270  int rkNewtonConvergenceStatus_;
271  RCP<Rythmos::StepControlStrategyBase<Scalar> > stepControl_;
272 
273  // Cache
274  RCP<Thyra::ProductVectorBase<Scalar> > x_stage_bar_;
275 
276  // //////////////////////////
277  // Private member functions
278 
279  void defaultInitializeAll_();
280  void initialize_();
281 
282  Scalar takeVariableStep_(Scalar dt, StepSizeType flag);
283 
284  Scalar takeFixedStep_(Scalar dt, StepSizeType flag);
285 
286 
287 
288 };
289 
290 
295 template<class Scalar>
296 RCP<ImplicitRKStepper<Scalar> >
297 implicitRKStepper();
298 
299 template<class Scalar>
300 RCP<ImplicitRKStepper<Scalar> >
301 implicitRKStepper(
302  const RCP<const Thyra::ModelEvaluator<Scalar> >& model,
303  const RCP<Thyra::NonlinearSolverBase<Scalar> >& solver,
304  const RCP<Thyra::LinearOpWithSolveFactoryBase<Scalar> >& irk_W_factory,
305  const RCP<const RKButcherTableauBase<Scalar> >& irkbt
306  );
307 
308 
309 } // namespace Rythmos
310 
311 #endif //Rythmos_IMPLICIT_RK_STEPPER_DECL_H
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)
Mix-in interface for stepper objects that accept a step control strategy object to be used for evalua...
bool isImplicit() const
Returns true.
RCP< const Thyra::VectorSpaceBase< Scalar > > get_x_space() const
RCP< const RKButcherTableauBase< Scalar > > getRKButcherTableau() const
void describe(FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel) const
Scalar takeStep(Scalar dt, StepSizeType flag)
RCP< const ParameterList > getValidParameters() const
void setRKButcherTableau(const RCP< const RKButcherTableauBase< Scalar > > &rkButcherTableau)
RCP< StepperBase< Scalar > > cloneStepperAlgorithm() const
void setSolver(const RCP< Thyra::NonlinearSolverBase< Scalar > > &solver)
RCP< StepControlStrategyBase< Scalar > > getNonconstStepControlStrategy()
RCP< const StepControlStrategyBase< Scalar > > getStepControlStrategy() const
const StepStatus< Scalar > getStepStatus() const
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
The member functions in the StepControlStrategyBase move you between these states in the following fa...
RCP< const Thyra::LinearOpWithSolveFactoryBase< Scalar > > get_W_factory() const
ScalarTraits< Scalar >::magnitudeType ScalarMag
void removeNodes(Array< Scalar > &time_vec)
void setInitialCondition(const Thyra::ModelEvaluatorBase::InArgs< Scalar > &initialCondition)
void setModel(const RCP< const Thyra::ModelEvaluator< Scalar > > &model)
void setStepControlStrategy(const RCP< StepControlStrategyBase< Scalar > > &stepControlStrategy)
void setNonconstModel(const RCP< Thyra::ModelEvaluator< Scalar > > &model)
void getNodes(Array< Scalar > *time_vec) const
Mix-in interface stepper objects that accept an RK Butcher Tableau.
bool supportsCloning() const
Returns true.
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 Thyra::ModelEvaluator< Scalar > > getModel() const
TimeRange< Scalar > getTimeRange() const
Thyra::ModelEvaluatorBase::InArgs< Scalar > getInitialCondition() const
RCP< const Thyra::NonlinearSolverBase< Scalar > > getSolver() const
RCP< Thyra::NonlinearSolverBase< Scalar > > getNonconstSolver()
void setParameterList(RCP< ParameterList > const &paramList)