Rythmos - Transient Integration for Differential Equations  Version of the Day
 All Classes Functions Variables Typedefs Pages
Rythmos_FirstOrderErrorStepControlStrategy_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_FIRSTORDERERROR_STEP_CONTROL_STRATEGY_DECL_H
30 #define Rythmos_FIRSTORDERERROR_STEP_CONTROL_STRATEGY_DECL_H
31 
32 #include "Rythmos_StepControlStrategyBase.hpp"
33 #include "Thyra_VectorBase.hpp"
34 #include "Teuchos_VerboseObject.hpp"
35 
36 namespace Rythmos {
37 
38 // Step Control Strategy object for FirstOrderErrorStepControlStrategy
39 //
40 // Order of calls:
41 // setRequestedStepSize()
42 // nextStepSize()
43 // optional: nextStepOrder()
44 // setCorrection
45 // acceptStep
46 // completeStep or rejectStep
47 // repeat
48 //
100 template<class Scalar>
102  : virtual public StepControlStrategyBase<Scalar>
103 {
104  public:
105 
106  typedef typename Teuchos::ScalarTraits<Scalar>::magnitudeType ScalarMag;
107 
111  void setRequestedStepSize(const StepperBase<Scalar>& stepper,
112  const Scalar& stepSize, const StepSizeType& stepSizeType);
113 
115  void nextStepSize(const StepperBase<Scalar>& stepper, Scalar* stepSize,
116  StepSizeType* stepSizeType, int* order);
117 
119  void setCorrection(
120  const StepperBase<Scalar>& stepper
121  ,const RCP<const Thyra::VectorBase<Scalar> >& soln
122  ,const RCP<const Thyra::VectorBase<Scalar> >& ee
123  ,int solveStatus
124  );
125 
127  bool acceptStep(const StepperBase<Scalar>& stepper, Scalar* LETValue);
128 
130  void completeStep(const StepperBase<Scalar>& stepper);
131 
133  AttemptedStepStatusFlag rejectStep(const StepperBase<Scalar>& stepper);
134 
136  StepControlStrategyState getCurrentState();
137 
139  int getMaxOrder() const;
140 
142  void setStepControlData(const StepperBase<Scalar>& stepper);
143 
145  bool supportsCloning() const;
146 
148  RCP<StepControlStrategyBase<Scalar> > cloneStepControlStrategyAlgorithm() const;
149 
151 
153 
157  void describe(
158  Teuchos::FancyOStream &out,
159  const Teuchos::EVerbosityLevel verbLevel
160  ) const;
162 
166  void setParameterList(RCP<Teuchos::ParameterList> const& paramList);
167 
169  RCP<Teuchos::ParameterList> getNonconstParameterList();
170 
172  RCP<Teuchos::ParameterList> unsetParameterList();
173 
175  RCP<const Teuchos::ParameterList> getValidParameters() const;
176 
178 
179  void initialize(const StepperBase<Scalar>& stepper);
180 
181 
182  private:
183 
184  // Private data members
185 
186  void defaultInitializeAllData_();
187 
188  StepControlStrategyState stepControlState_;
189 
190  RCP<Teuchos::ParameterList> parameterList_;
191 
192  Scalar initialStepSize_;
193  Scalar requestedStepSize_;
194  Scalar currentStepSize_;
195  Scalar nextStepSize_;
196  Scalar stepSizeFactor_;
197  StepSizeType stepSizeType_;
198 
199  Scalar minStepSize_;
200  Scalar maxStepSize_;
201  Scalar maxStepSizeIncreaseFactor_;
202  Scalar minStepSizeDecreaseFactor_;
203  int numStepFailures_;
204  int maxStepFailures_;
205  int maxOrder_;
206  Scalar errorRelativeTolerance_;
207  Scalar errorAbsoluteTolerance_;
208  int solveStatus_;
209 
210  RCP<const Thyra::VectorBase<Scalar> > x_;
211  RCP<const Thyra::VectorBase<Scalar> > dx_;
212  RCP<Thyra::VectorBase<Scalar> > errWtVec_;
213 
214 
215  static const std::string initialStepSizeName_;
216  static const double initialStepSizeDefault_;
217 
218  static const std::string minStepSizeName_;
219  static const double minStepSizeDefault_;
220 
221  static const std::string maxStepSizeName_;
222  static const double maxStepSizeDefault_;
223 
224  static const std::string maxStepSizeIncreaseFactorName_;
225  static const double maxStepSizeIncreaseFactorDefault_;
226 
227  static const std::string minStepSizeDecreaseFactorName_;
228  static const double minStepSizeDecreaseFactorDefault_;
229 
230  static const std::string maxStepFailuresName_;
231  static const int maxStepFailuresDefault_;
232 
233  static const std::string errorRelativeToleranceName_;
234  static const double errorRelativeToleranceDefault_;
235 
236  static const std::string errorAbsoluteToleranceName_;
237  static const double errorAbsoluteToleranceDefault_;
238 
239 
240  // Private member functions
241 
242  void setStepControlState_(StepControlStrategyState state);
243 
244 };
245 
246 } // namespace Rythmos
247 
248 #endif // Rythmos_FIRSTORDERERROR_STEP_CONTROL_STRATEGY_DECL_H
249 
Base class for defining stepper functionality.
void setParameterList(RCP< Teuchos::ParameterList > const &paramList)
void nextStepSize(const StepperBase< Scalar > &stepper, Scalar *stepSize, StepSizeType *stepSizeType, int *order)
The member functions in the StepControlStrategyBase move you between these states in the following fa...
void describe(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel) const
void setCorrection(const StepperBase< Scalar > &stepper, const RCP< const Thyra::VectorBase< Scalar > > &soln, const RCP< const Thyra::VectorBase< Scalar > > &ee, int solveStatus)
Step Control Strategy for first-order time integration.
AttemptedStepStatusFlag rejectStep(const StepperBase< Scalar > &stepper)
bool acceptStep(const StepperBase< Scalar > &stepper, Scalar *LETValue)
RCP< StepControlStrategyBase< Scalar > > cloneStepControlStrategyAlgorithm() const
void setRequestedStepSize(const StepperBase< Scalar > &stepper, const Scalar &stepSize, const StepSizeType &stepSizeType)