Rythmos - Transient Integration for Differential Equations  Version of the Day
 All Classes Functions Variables Typedefs Pages
Rythmos_ImplicitBDFStepperRampingStepControl_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_RAMPING_STEP_CONTROL_DECL_H
30 #define Rythmos_IMPLICITBDF_STEPPER_RAMPING_STEP_CONTROL_DECL_H
31 
32 #include "Rythmos_ErrWtVecCalcAcceptingStepControlStrategyBase.hpp"
33 #include "Rythmos_ImplicitBDFStepperStepControl.hpp" // for BDFactionFlag definition
34 #include <list>
35 
36 namespace Rythmos {
37 
39 //enum BDFactionFlag { ACTION_UNSET, ACTION_LOWER, ACTION_MAINTAIN, ACTION_RAISE };
40 
68  template<class Scalar>
70  : virtual public ErrWtVecCalcAcceptingStepControlStrategyBase<Scalar>
71  {
72  public:
73 
74  typedef typename Teuchos::ScalarTraits<Scalar>::magnitudeType ScalarMag;
75 
77 
81  void setRequestedStepSize(const StepperBase<Scalar>& stepper,
82  const Scalar& stepSize, const StepSizeType& stepSizeType);
83 
85  void nextStepSize(const StepperBase<Scalar>& stepper, Scalar* stepSize,
86  StepSizeType* stepSizeType, int* order);
87 
89  void setCorrection(
90  const StepperBase<Scalar>& stepper
91  ,const RCP<const Thyra::VectorBase<Scalar> >& soln
92  ,const RCP<const Thyra::VectorBase<Scalar> >& ee
93  ,int solveStatus
94  );
95 
97  bool acceptStep(const StepperBase<Scalar>& stepper, Scalar* LETValue);
98 
100  void completeStep(const StepperBase<Scalar>& stepper);
101 
103  AttemptedStepStatusFlag rejectStep(const StepperBase<Scalar>& stepper);
104 
106  StepControlStrategyState getCurrentState();
107 
109  int getMinOrder() const;
110 
112  int getMaxOrder() const;
113 
115  void setStepControlData(const StepperBase<Scalar>& stepper);
116 
118  bool supportsCloning() const;
119 
121  RCP<StepControlStrategyBase<Scalar> > cloneStepControlStrategyAlgorithm() const;
122 
124 
127 
129  void setErrWtVecCalc(const RCP<ErrWtVecCalcBase<Scalar> >& errWtVecCalc);
130 
132  RCP<const ErrWtVecCalcBase<Scalar> > getErrWtVecCalc() const;
133 
135 
139  void describe(
140  Teuchos::FancyOStream &out,
141  const Teuchos::EVerbosityLevel verbLevel
142  ) const;
144 
148  void setParameterList(RCP<Teuchos::ParameterList> const& paramList);
149 
151  RCP<Teuchos::ParameterList> getNonconstParameterList();
152 
154  RCP<Teuchos::ParameterList> unsetParameterList();
155 
157  RCP<const Teuchos::ParameterList> getValidParameters() const;
158 
160 
162  void initialize(const StepperBase<Scalar>& stepper);
163 
166 
167  int numberOfSteps() const;
168 
169  int numberOfFailedSteps() const;
170 
171  Scalar currentStepSize() const;
172 
173  int currentOrder() const;
174 
176 
177  private:
178 
179  Scalar wRMSNorm_(
180  const Thyra::VectorBase<Scalar>& weight,
181  const Thyra::VectorBase<Scalar>& vector
182  ) const;
183 
184  void setStepControlState_(StepControlStrategyState state);
185 
186  void updateCoeffs_();
187 
188  //* returns true if the objects verbosity level is equal to or greater than level in verbLevel */
189  bool doOutput_(Teuchos::EVerbosityLevel verbLevel);
190 
191  protected:
192 
193  StepControlStrategyState stepControlState_;
194  RCP<ErrWtVecCalcBase<Scalar> > errWtVecCalc_;
195  RCP<Teuchos::ParameterList> parameterList_;
196 
197  StepSizeType stepSizeType_;
198  Scalar requestedStepSize_;
199  Scalar currentStepSize_;
200  int currentOrder_;
201  Scalar nextStepSize_;
202  int nextOrder_;
203 
204  int numberOfSteps_;
205  int totalNumberOfFailedSteps_;
206  int countOfConstantStepsAfterFailure_;
207  int newtonConvergenceStatus_;
208 
209  Scalar time_;
210  Scalar stopTime_;
211 
212  RCP<const Thyra::VectorBase<Scalar> > ee_; // Newton update
213  RCP<Thyra::VectorBase<Scalar> > errWtVec_; // error weight vector
214  RCP<Thyra::VectorBase<Scalar> > delta_;
215  ScalarMag relErrTol_; // relative error tolerance
216  ScalarMag absErrTol_; // absolute error tolerance
217 
218  // Validated parameters
219  int numConstantSteps_;
220  Scalar initialStepSize_;
221  Scalar maxStepSize_;
222  Scalar minStepSize_;
223  Scalar stepSizeIncreaseFactor_;
224  Scalar stepSizeDecreaseFactor_;
225  int minOrder_;
226  int maxOrder_;
227  bool useLETToDetermineConvergence_;
228  bool restrictStepSizeByNumberOfNonlinearIterations_;
229  int numberOfNonlinearIterationsForStepSizeRestriction_;
230  std::vector<Scalar> breakPoints_; // from user params (stor for reset)
231  std::list<Scalar> currentBreakPoints_; // break points left
232 
233  // Garbage to clean up for LET
234 
235  Array<Scalar> alpha_; // $\alpha_j(n)=h_n/\psi_j(n)$ coefficient used in local error test
236  // note: $h_n$ = current step size, n = current time step
237  Array<Scalar> sigma_; // $\sigma_j(n) = \frac{h_n^j(j-1)!}{\psi_1(n)*\cdots *\psi_j(n)}$
238  Array<Scalar> gamma_; // $\gamma_j(n)=\sum_{l=1}^{j-1}1/\psi_l(n)$ coefficient used to
239  // calculate time derivative of history array for predictor
240  Array<Scalar> beta_; // coefficients used to evaluate predictor from history array
241  Array<Scalar> psi_; // $\psi_j(n) = t_n-t_{n-j}$ intermediary variable used to
242  // compute $\beta_j(n)$
243  Scalar alpha_s_; // $\alpha_s$ fixed-leading coefficient of this BDF method
244  Scalar alpha_0_; // $-\sum_{j=1}^k \alpha_j(n)$ coefficient used in local error test
245  Scalar cj_ ; // $-\alpha_s/h_n$ coefficient used in local error test
246  Scalar ck_ ; // local error coefficient gamma[0] = 0;
247  Scalar ck_enorm_; // ck * enorm
248 
249  };
250 
251 } // namespace Rythmos
252 
253 #endif // Rythmos_IMPLICITBDF_STEPPER_STEP_CONTROL_DECL_H
254 
void describe(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel) const
Base class for defining stepper functionality.
void setParameterList(RCP< Teuchos::ParameterList > const &paramList)
bool acceptStep(const StepperBase< Scalar > &stepper, Scalar *LETValue)
void setRequestedStepSize(const StepperBase< Scalar > &stepper, const Scalar &stepSize, const StepSizeType &stepSizeType)
Mix-in interface for step control strategy objects that accept an external error weight calculation a...
void setErrWtVecCalc(const RCP< ErrWtVecCalcBase< Scalar > > &errWtVecCalc)
void setCorrection(const StepperBase< Scalar > &stepper, const RCP< const Thyra::VectorBase< Scalar > > &soln, const RCP< const Thyra::VectorBase< Scalar > > &ee, int solveStatus)
RCP< StepControlStrategyBase< Scalar > > cloneStepControlStrategyAlgorithm() const
void nextStepSize(const StepperBase< Scalar > &stepper, Scalar *stepSize, StepSizeType *stepSizeType, int *order)
AttemptedStepStatusFlag rejectStep(const StepperBase< Scalar > &stepper)