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., 59 Temple Place, Suite 330, Boston, MA 02111-1307
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 
39 #include "Thyra_ModelEvaluator.hpp"
40 #include "Thyra_ProductVectorBase.hpp"
41 #include "Thyra_NonlinearSolverBase.hpp"
42 
43 namespace Rythmos {
44 
45 
47 template<class Scalar>
49  virtual public SolverAcceptingStepperBase<Scalar>,
50  virtual public RKButcherTableauAcceptingStepperBase<Scalar>
51 {
52 public:
53 
55  typedef typename ScalarTraits<Scalar>::magnitudeType ScalarMag;
56 
59 
62 
63  void set_W_factory( const RCP<Thyra::LinearOpWithSolveFactoryBase<Scalar> > &irk_W_factory );
64 
66  RCP<const Thyra::LinearOpWithSolveFactoryBase<Scalar> > get_W_factory() const;
67 
70 
72  void setRKButcherTableau( const RCP<const RKButcherTableauBase<Scalar> > &rkButcherTableau );
73 
75  RCP<const RKButcherTableauBase<Scalar> > getRKButcherTableau() const;
76 
78 
80  // This function is mostly for testing purposes to explicitely over-ride the
81  // internal RKBT detection to allow testing of 1-stage RKBTs as both fully
82  // implicit RK and as DIRK methods.
83  void setDirk(bool isDirk);
84 
86 
89 
91  void setSolver(
92  const RCP<Thyra::NonlinearSolverBase<Scalar> > &solver
93  );
94 
96  RCP<Thyra::NonlinearSolverBase<Scalar> >
98 
100  RCP<const Thyra::NonlinearSolverBase<Scalar> >
101  getSolver() const;
102 
104 
107 
109  bool isImplicit() const;
110 
112  bool supportsCloning() const;
113 
115  RCP<StepperBase<Scalar> > cloneStepperAlgorithm() const;
116 
118  void setModel(const RCP<const Thyra::ModelEvaluator<Scalar> >& model);
119 
121  void setNonconstModel(const RCP<Thyra::ModelEvaluator<Scalar> >& model);
122 
124  RCP<const Thyra::ModelEvaluator<Scalar> > getModel() const;
125 
127  RCP<Thyra::ModelEvaluator<Scalar> > getNonconstModel();
128 
130  void setInitialCondition(
131  const Thyra::ModelEvaluatorBase::InArgs<Scalar> &initialCondition
132  );
133 
135  Thyra::ModelEvaluatorBase::InArgs<Scalar> getInitialCondition() const;
136 
138  Scalar takeStep(Scalar dt, StepSizeType flag);
139 
141  const StepStatus<Scalar> getStepStatus() const;
142 
144 
147 
149  RCP<const Thyra::VectorSpaceBase<Scalar> >
150  get_x_space() const;
151 
153  void addPoints(
154  const Array<Scalar>& time_vec,
155  const Array<RCP<const Thyra::VectorBase<Scalar> > >& x_vec,
156  const Array<RCP<const Thyra::VectorBase<Scalar> > >& xdot_vec
157  );
158 
161 
163  void getPoints(
164  const Array<Scalar>& time_vec,
165  Array<RCP<const Thyra::VectorBase<Scalar> > >* x_vec,
166  Array<RCP<const Thyra::VectorBase<Scalar> > >* xdot_vec,
167  Array<ScalarMag>* accuracy_vec
168  ) const;
169 
171  void getNodes(Array<Scalar>* time_vec) const;
172 
174  void removeNodes(Array<Scalar>& time_vec);
175 
177  int getOrder() const;
178 
180 
183 
185  void setParameterList(RCP<ParameterList> const& paramList);
186 
188  RCP<ParameterList> getNonconstParameterList();
189 
191  RCP<ParameterList> unsetParameterList();
192 
194  RCP<const ParameterList> getValidParameters() const;
195 
197 
200 
202  void describe(
203  FancyOStream &out,
204  const Teuchos::EVerbosityLevel verbLevel
205  ) const;
206 
208 
209 private:
210 
211  // ///////////////////////
212  // Private date members
213 
214  bool isInitialized_;
215  RCP<const Thyra::ModelEvaluator<Scalar> > model_;
216  RCP<Thyra::NonlinearSolverBase<Scalar> > solver_;
217  RCP<Thyra::LinearOpWithSolveFactoryBase<Scalar> > irk_W_factory_;
218  RCP<ParameterList> paramList_;
219 
220  Thyra::ModelEvaluatorBase::InArgs<Scalar> basePoint_;
221  RCP<Thyra::VectorBase<Scalar> > x_;
222  RCP<Thyra::VectorBase<Scalar> > x_old_;
223  RCP<Thyra::VectorBase<Scalar> > x_dot_;
224 
225  TimeRange<Scalar> timeRange_;
226 
227  RCP<Thyra::ModelEvaluator<Scalar> > irkModel_;
228  RCP<const RKButcherTableauBase<Scalar> > irkButcherTableau_;
229 
230  bool isDirk_; // Used for Diagonal Implicit RK
231 
232  int numSteps_;
233 
234  bool haveInitialCondition_;
235 
236  // Cache
237  RCP<Thyra::ProductVectorBase<Scalar> > x_stage_bar_;
238 
239  // //////////////////////////
240  // Private member functions
241 
242  void defaultInitializeAll_();
243  void initialize_();
244 
245 };
246 
247 
252 template<class Scalar>
253 RCP<ImplicitRKStepper<Scalar> >
254 implicitRKStepper();
255 
256 template<class Scalar>
257 RCP<ImplicitRKStepper<Scalar> >
258 implicitRKStepper(
259  const RCP<const Thyra::ModelEvaluator<Scalar> >& model,
260  const RCP<Thyra::NonlinearSolverBase<Scalar> >& solver,
261  const RCP<Thyra::LinearOpWithSolveFactoryBase<Scalar> >& irk_W_factory,
262  const RCP<const RKButcherTableauBase<Scalar> >& irkbt
263  );
264 
265 
266 } // namespace Rythmos
267 
268 #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)
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)
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
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 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)