Rythmos - Transient Integration for Differential Equations  Version of the Day
 All Classes Functions Variables Typedefs Pages
Rythmos_ThetaStepper_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_THETA_STEPPER_DECL_H
30 #define Rythmos_THETA_STEPPER_DECL_H
31 
32 #define HAVE_RYTHMOS_EXPERIMENTAL
33 
34 #include "Rythmos_ConfigDefs.h"
35 #ifdef HAVE_RYTHMOS_EXPERIMENTAL
36 
37 #include "Rythmos_StepperBase.hpp"
38 #include "Rythmos_DataStore.hpp"
39 #include "Rythmos_LinearInterpolator.hpp"
40 #include "Rythmos_InterpolatorAcceptingObjectBase.hpp"
41 #include "Rythmos_InterpolatorBaseHelpers.hpp"
42 #include "Rythmos_SingleResidualModelEvaluator.hpp"
43 #include "Rythmos_SolverAcceptingStepperBase.hpp"
44 #include "Rythmos_StepperHelpers.hpp"
45 
46 #include "Thyra_VectorBase.hpp"
47 #include "Thyra_ModelEvaluator.hpp"
48 #include "Thyra_ModelEvaluatorHelpers.hpp"
49 #include "Thyra_AssertOp.hpp"
50 #include "Thyra_NonlinearSolverBase.hpp"
51 #include "Thyra_TestingTools.hpp"
52 
53 #include "Teuchos_VerboseObjectParameterListHelpers.hpp"
54 #include "Teuchos_as.hpp"
55 
56 
57 namespace {
58  const std::string ThetaStepperType_name = "Theta Stepper Type";
59  const std::string ThetaStepperType_default = "Implicit Euler";
60 
61  const std::string PredictorOrder_name = "Predictor Order";
62  const int PredictorOrder_default = 2;
63 }
64 
65 namespace Rythmos {
66 
67 enum ThetaStepperType
68 {
69  ImplicitEuler = 0,
70  Trapezoid,
71  INVALID_THETA_STEPPER_TYPE
72 };
73 
74 
78 template<class Scalar>
79 class ThetaStepper :
80  virtual public SolverAcceptingStepperBase<Scalar>,
81  virtual public InterpolatorAcceptingObjectBase<Scalar>
82 {
83 public:
84 
86  typedef typename Teuchos::ScalarTraits<Scalar>::magnitudeType ScalarMag;
87 
90 
92  ThetaStepper();
93 
94  bool isImplicit() const;
95 
98 
100  void setInterpolator(const RCP<InterpolatorBase<Scalar> >& interpolator);
101 
103  RCP<InterpolatorBase<Scalar> >
105 
107  RCP<const InterpolatorBase<Scalar> >
108  getInterpolator() const;
109 
111  RCP<InterpolatorBase<Scalar> > unSetInterpolator();
113 
115 
118 
120  void setSolver(
121  const RCP<Thyra::NonlinearSolverBase<Scalar> > &solver
122  );
123 
125  RCP<Thyra::NonlinearSolverBase<Scalar> >
127 
129  RCP<const Thyra::NonlinearSolverBase<Scalar> >
130  getSolver() const;
131 
133 
136 
138  bool supportsCloning() const;
139 
147  RCP<StepperBase<Scalar> > cloneStepperAlgorithm() const;
148 
150  void setModel(const RCP<const Thyra::ModelEvaluator<Scalar> >& model);
151 
153  void setNonconstModel(const RCP<Thyra::ModelEvaluator<Scalar> >& model);
154 
156  RCP<const Thyra::ModelEvaluator<Scalar> > getModel() const;
157 
159  RCP<Thyra::ModelEvaluator<Scalar> > getNonconstModel();
160 
162  void setInitialCondition(
163  const Thyra::ModelEvaluatorBase::InArgs<Scalar> &initialCondition
164  );
165 
167  Thyra::ModelEvaluatorBase::InArgs<Scalar> getInitialCondition() const;
168 
170  Scalar takeStep(Scalar dt, StepSizeType flag);
171 
173  const StepStatus<Scalar> getStepStatus() const;
174 
176 
179 
181  RCP<const Thyra::VectorSpaceBase<Scalar> >
182  get_x_space() const;
183 
185  void addPoints(
186  const Array<Scalar>& time_vec,
187  const Array<RCP<const Thyra::VectorBase<Scalar> > >& x_vec,
188  const Array<RCP<const Thyra::VectorBase<Scalar> > >& xdot_vec
189  );
190 
193 
195  void getPoints(
196  const Array<Scalar>& time_vec,
197  Array<RCP<const Thyra::VectorBase<Scalar> > >* x_vec,
198  Array<RCP<const Thyra::VectorBase<Scalar> > >* xdot_vec,
199  Array<ScalarMag>* accuracy_vec
200  ) const;
201 
203  void getNodes(Array<Scalar>* time_vec) const;
204 
206  void removeNodes(Array<Scalar>& time_vec);
207 
209  int getOrder() const;
210 
212 
215 
217  void setParameterList(RCP<Teuchos::ParameterList> const& paramList);
218 
220  RCP<Teuchos::ParameterList> getNonconstParameterList();
221 
223  RCP<Teuchos::ParameterList> unsetParameterList();
224 
226  RCP<const Teuchos::ParameterList> getValidParameters() const;
227 
229 
232 
234  void describe(
235  Teuchos::FancyOStream &out,
236  const Teuchos::EVerbosityLevel verbLevel
237  ) const;
238 
240 
241 private:
242 
243  // ///////////////////////
244  // Private date members
245 
246  bool isInitialized_;
247  bool haveInitialCondition_;
248  RCP<const Thyra::ModelEvaluator<Scalar> > model_;
249  RCP<Thyra::NonlinearSolverBase<Scalar> > solver_;
250 
251  Thyra::ModelEvaluatorBase::InArgs<Scalar> basePoint_;
252 
253  RCP<Thyra::VectorBase<Scalar> > x_;
254  RCP<Thyra::VectorBase<Scalar> > x_old_;
255  RCP<Thyra::VectorBase<Scalar> > x_pre_;
256 
257  RCP<Thyra::VectorBase<Scalar> > x_dot_;
258  RCP<Thyra::VectorBase<Scalar> > x_dot_old_;
259  RCP<Thyra::VectorBase<Scalar> > x_dot_really_old_;
260  RCP<Thyra::VectorBase<Scalar> > x_dot_base_;
261 
262  Scalar t_;
263  Scalar t_old_;
264 
265  Scalar dt_;
266  Scalar dt_old_;
267  int numSteps_;
268 
269  ThetaStepperType thetaStepperType_;
270  Scalar theta_;
271  int predictor_corrector_begin_after_step_;
272  int default_predictor_order_;
273 
274  RCP<Rythmos::SingleResidualModelEvaluator<Scalar> > neModel_;
275 
276  RCP<Teuchos::ParameterList> parameterList_;
277 
278  RCP<InterpolatorBase<Scalar> > interpolator_;
279 
280 
281  // //////////////////////////
282  // Private member functions
283 
284  void defaultInitializeAll_();
285  void initialize_();
286  void obtainPredictor_();
287 };
288 
289 
294 template<class Scalar>
295 RCP<ThetaStepper<Scalar> >
296 thetaStepper(
297  const RCP<Thyra::ModelEvaluator<Scalar> >& model,
298  const RCP<Thyra::NonlinearSolverBase<Scalar> >& solver,
299  RCP<Teuchos::ParameterList>& parameterList
300  );
301 
302 } // namespace Rythmos
303 
304 #endif // HAVE_RYTHMOS_EXPERIMENTAL
305 
306 #endif //Rythmos_THETA_STEPPER_DECL_H
bool supportsCloning() const
Returns true.
RCP< const Teuchos::ParameterList > getValidParameters() const
void describe(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel) const
RCP< InterpolatorBase< Scalar > > getNonconstInterpolator()
Base strategy class for interpolation functionality.
void removeNodes(Array< Scalar > &time_vec)
RCP< Teuchos::ParameterList > unsetParameterList()
Stepper class for theta integration scheme common in SNL thermal/fluids codes.
void setInterpolator(const RCP< InterpolatorBase< Scalar > > &interpolator)
Redefined from InterpolatorAcceptingObjectBase.
RCP< Teuchos::ParameterList > getNonconstParameterList()
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::NonlinearSolverBase< Scalar > > getSolver() const
Mix-in interface for objects that accept an interpolator object.
RCP< const InterpolatorBase< Scalar > > getInterpolator() 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)
void setModel(const RCP< const Thyra::ModelEvaluator< Scalar > > &model)
RCP< const Thyra::VectorSpaceBase< Scalar > > get_x_space() const
Teuchos::ScalarTraits< Scalar >::magnitudeType ScalarMag
void setParameterList(RCP< Teuchos::ParameterList > const &paramList)
void setInitialCondition(const Thyra::ModelEvaluatorBase::InArgs< Scalar > &initialCondition)
void setSolver(const RCP< Thyra::NonlinearSolverBase< Scalar > > &solver)
void getNodes(Array< Scalar > *time_vec) const
bool isImplicit() const
Return if this stepper is an implicit stepper.
int getOrder() const
RCP< Thyra::ModelEvaluator< Scalar > > getNonconstModel()
RCP< InterpolatorBase< Scalar > > unSetInterpolator()
Mix-in interface all implicit stepper objects that accept a nonlinear solver to be used to compute th...
TimeRange< Scalar > getTimeRange() const
RCP< Thyra::NonlinearSolverBase< Scalar > > getNonconstSolver()
Thyra::ModelEvaluatorBase::InArgs< Scalar > getInitialCondition() const
const StepStatus< Scalar > getStepStatus() const
Scalar takeStep(Scalar dt, StepSizeType flag)
RCP< StepperBase< Scalar > > cloneStepperAlgorithm() const
Creates copies of all internal data (including the parameter list) except the model which is assumed ...
RCP< const Thyra::ModelEvaluator< Scalar > > getModel() const
void setNonconstModel(const RCP< Thyra::ModelEvaluator< Scalar > > &model)