Rythmos - Transient Integration for Differential Equations  Version of the Day
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 
35 namespace Rythmos {
36 
38 //enum BDFactionFlag { ACTION_UNSET, ACTION_LOWER, ACTION_MAINTAIN, ACTION_RAISE };
39 
67  template<class Scalar>
69  : virtual public ErrWtVecCalcAcceptingStepControlStrategyBase<Scalar>
70  {
71  public:
72 
73  typedef typename Teuchos::ScalarTraits<Scalar>::magnitudeType ScalarMag;
74 
76 
80  void setRequestedStepSize(const StepperBase<Scalar>& stepper,
81  const Scalar& stepSize, const StepSizeType& stepSizeType);
82 
84  void nextStepSize(const StepperBase<Scalar>& stepper, Scalar* stepSize,
85  StepSizeType* stepSizeType, int* order);
86 
88  void setCorrection(
89  const StepperBase<Scalar>& stepper
90  ,const RCP<const Thyra::VectorBase<Scalar> >& soln
91  ,const RCP<const Thyra::VectorBase<Scalar> >& ee
92  ,int solveStatus
93  );
94 
96  bool acceptStep(const StepperBase<Scalar>& stepper, Scalar* LETValue);
97 
99  void completeStep(const StepperBase<Scalar>& stepper);
100 
102  AttemptedStepStatusFlag rejectStep(const StepperBase<Scalar>& stepper);
103 
105  StepControlStrategyState getCurrentState();
106 
108  int getMinOrder() const;
109 
111  int getMaxOrder() const;
112 
114  void setStepControlData(const StepperBase<Scalar>& stepper);
115 
117  bool supportsCloning() const;
118 
120  RCP<StepControlStrategyBase<Scalar> > cloneStepControlStrategyAlgorithm() const;
121 
123 
126 
128  void setErrWtVecCalc(const RCP<ErrWtVecCalcBase<Scalar> >& errWtVecCalc);
129 
131  RCP<const ErrWtVecCalcBase<Scalar> > getErrWtVecCalc() const;
132 
134 
138  void describe(
139  Teuchos::FancyOStream &out,
140  const Teuchos::EVerbosityLevel verbLevel
141  ) const;
143 
147  void setParameterList(RCP<Teuchos::ParameterList> const& paramList);
148 
150  RCP<Teuchos::ParameterList> getNonconstParameterList();
151 
153  RCP<Teuchos::ParameterList> unsetParameterList();
154 
156  RCP<const Teuchos::ParameterList> getValidParameters() const;
157 
159 
161  void initialize(const StepperBase<Scalar>& stepper);
162 
165 
166  int numberOfSteps() const;
167 
168  int numberOfFailedSteps() const;
169 
170  Scalar currentStepSize() const;
171 
172  int currentOrder() const;
173 
175 
176  private:
177 
178  Scalar wRMSNorm_(
179  const Thyra::VectorBase<Scalar>& weight,
180  const Thyra::VectorBase<Scalar>& vector
181  ) const;
182 
183  void setStepControlState_(StepControlStrategyState state);
184 
185  void updateCoeffs_();
186 
187  //* returns true if the objects verbosity level is equal to or greater than level in verbLevel */
188  bool doOutput_(Teuchos::EVerbosityLevel verbLevel);
189 
190  protected:
191 
192  StepControlStrategyState stepControlState_;
193  RCP<ErrWtVecCalcBase<Scalar> > errWtVecCalc_;
194  RCP<Teuchos::ParameterList> parameterList_;
195 
196  StepSizeType stepSizeType_;
197  Scalar requestedStepSize_;
198  Scalar currentStepSize_;
199  int currentOrder_;
200  Scalar nextStepSize_;
201  int nextOrder_;
202 
203  int numberOfSteps_;
204  int totalNumberOfFailedSteps_;
205  int countOfConstantStepsAfterFailure_;
206  int newtonConvergenceStatus_;
207 
208  Scalar time_;
209  Scalar stopTime_;
210 
211  RCP<const Thyra::VectorBase<Scalar> > ee_; // Newton update
212  RCP<Thyra::VectorBase<Scalar> > errWtVec_; // error weight vector
213  RCP<Thyra::VectorBase<Scalar> > delta_;
214  ScalarMag relErrTol_; // relative error tolerance
215  ScalarMag absErrTol_; // absolute error tolerance
216 
217  // Validated parameters
218  int numConstantSteps_;
219  Scalar initialStepSize_;
220  Scalar maxStepSize_;
221  Scalar minStepSize_;
222  Scalar stepSizeIncreaseFactor_;
223  Scalar stepSizeDecreaseFactor_;
224  int minOrder_;
225  int maxOrder_;
226  bool useLETToDetermineConvergence_;
227  bool restrictStepSizeByNumberOfNonlinearIterations_;
228  int numberOfNonlinearIterationsForStepSizeRestriction_;
229  std::vector<Scalar> breakPoints_; // from user params (stor for reset)
230  std::list<Scalar> currentBreakPoints_; // break points left
231 
232  // Garbage to clean up for LET
233 
234  Array<Scalar> alpha_; // $\alpha_j(n)=h_n/\psi_j(n)$ coefficient used in local error test
235  // note: $h_n$ = current step size, n = current time step
236  Array<Scalar> sigma_; // $\sigma_j(n) = \frac{h_n^j(j-1)!}{\psi_1(n)*\cdots *\psi_j(n)}$
237  Array<Scalar> gamma_; // $\gamma_j(n)=\sum_{l=1}^{j-1}1/\psi_l(n)$ coefficient used to
238  // calculate time derivative of history array for predictor
239  Array<Scalar> beta_; // coefficients used to evaluate predictor from history array
240  Array<Scalar> psi_; // $\psi_j(n) = t_n-t_{n-j}$ intermediary variable used to
241  // compute $\beta_j(n)$
242  Scalar alpha_s_; // $\alpha_s$ fixed-leading coefficient of this BDF method
243  Scalar alpha_0_; // $-\sum_{j=1}^k \alpha_j(n)$ coefficient used in local error test
244  Scalar cj_ ; // $-\alpha_s/h_n$ coefficient used in local error test
245  Scalar ck_ ; // local error coefficient gamma[0] = 0;
246  Scalar ck_enorm_; // ck * enorm
247 
248  };
249 
250 } // namespace Rythmos
251 
252 #endif // Rythmos_IMPLICITBDF_STEPPER_STEP_CONTROL_DECL_H
253 
Base class for defining stepper functionality.
void setParameterList(RCP< Teuchos::ParameterList > const &paramList)
void describe(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel) const
RCP< StepControlStrategyBase< Scalar > > cloneStepControlStrategyAlgorithm() const
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)
void nextStepSize(const StepperBase< Scalar > &stepper, Scalar *stepSize, StepSizeType *stepSizeType, int *order)
AttemptedStepStatusFlag rejectStep(const StepperBase< Scalar > &stepper)