Rythmos - Transient Integration for Differential Equations Version of the Day
Rythmos_ImplicitBDFStepperRampingStepControl_decl.hpp
00001 //@HEADER
00002 // ***********************************************************************
00003 //
00004 //                           Rythmos Package
00005 //                 Copyright (2006) Sandia Corporation
00006 //
00007 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
00008 // license for use of this work by or on behalf of the U.S. Government.
00009 //
00010 // This library is free software; you can redistribute it and/or modify
00011 // it under the terms of the GNU Lesser General Public License as
00012 // published by the Free Software Foundation; either version 2.1 of the
00013 // License, or (at your option) any later version.
00014 //
00015 // This library is distributed in the hope that it will be useful, but
00016 // WITHOUT ANY WARRANTY; without even the implied warranty of
00017 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00018 // Lesser General Public License for more details.
00019 //
00020 // You should have received a copy of the GNU Lesser General Public
00021 // License along with this library; if not, write to the Free Software
00022 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
00023 // USA
00024 // Questions? Contact Todd S. Coffey (tscoffe@sandia.gov)
00025 //
00026 // ***********************************************************************
00027 //@HEADER
00028 
00029 #ifndef Rythmos_IMPLICITBDF_STEPPER_RAMPING_STEP_CONTROL_DECL_H
00030 #define Rythmos_IMPLICITBDF_STEPPER_RAMPING_STEP_CONTROL_DECL_H
00031 
00032 #include "Rythmos_ErrWtVecCalcAcceptingStepControlStrategyBase.hpp"
00033 #include "Rythmos_ImplicitBDFStepperStepControl.hpp" // for BDFactionFlag definition
00034 
00035 namespace Rythmos {
00036 
00038 //enum BDFactionFlag { ACTION_UNSET, ACTION_LOWER, ACTION_MAINTAIN, ACTION_RAISE };
00039 
00067   template<class Scalar>
00068   class ImplicitBDFStepperRampingStepControl
00069     : virtual public ErrWtVecCalcAcceptingStepControlStrategyBase<Scalar>
00070   {
00071   public:
00072 
00073     typedef typename Teuchos::ScalarTraits<Scalar>::magnitudeType ScalarMag;
00074 
00075     ImplicitBDFStepperRampingStepControl();
00076 
00080     void setRequestedStepSize(const StepperBase<Scalar>& stepper,
00081             const Scalar& stepSize, const StepSizeType& stepSizeType);
00082 
00084     void nextStepSize(const StepperBase<Scalar>& stepper, Scalar* stepSize,
00085           StepSizeType* stepSizeType, int* order);
00086 
00088     void setCorrection(
00089          const StepperBase<Scalar>& stepper
00090         ,const RCP<const Thyra::VectorBase<Scalar> >& soln
00091         ,const RCP<const Thyra::VectorBase<Scalar> >& ee
00092         ,int solveStatus
00093         );
00094 
00096     bool acceptStep(const StepperBase<Scalar>& stepper, Scalar* LETValue);
00097 
00099     void completeStep(const StepperBase<Scalar>& stepper);
00100 
00102     AttemptedStepStatusFlag rejectStep(const StepperBase<Scalar>& stepper);
00103 
00105     StepControlStrategyState getCurrentState();
00106 
00108     int getMinOrder() const;
00109 
00111     int getMaxOrder() const;
00112 
00114     void setStepControlData(const StepperBase<Scalar>& stepper);
00115 
00117     bool supportsCloning() const;
00118 
00120     RCP<StepControlStrategyBase<Scalar> > cloneStepControlStrategyAlgorithm() const;
00121 
00123 
00126 
00128     void setErrWtVecCalc(const RCP<ErrWtVecCalcBase<Scalar> >& errWtVecCalc);
00129 
00131     RCP<const ErrWtVecCalcBase<Scalar> > getErrWtVecCalc() const;
00132 
00134 
00138     void describe(
00139       Teuchos::FancyOStream &out,
00140       const Teuchos::EVerbosityLevel verbLevel
00141       ) const;
00143 
00147     void setParameterList(RCP<Teuchos::ParameterList> const& paramList);
00148 
00150     RCP<Teuchos::ParameterList> getNonconstParameterList();
00151 
00153     RCP<Teuchos::ParameterList> unsetParameterList();
00154 
00156     RCP<const Teuchos::ParameterList> getValidParameters() const;
00157 
00159 
00161     void initialize(const StepperBase<Scalar>& stepper);
00162 
00165 
00166     int numberOfSteps() const;
00167 
00168     int numberOfFailedSteps() const;
00169 
00170     Scalar currentStepSize() const;
00171 
00172     int currentOrder() const;
00173 
00175 
00176   private:
00177 
00178     Scalar wRMSNorm_(
00179         const Thyra::VectorBase<Scalar>& weight,
00180         const Thyra::VectorBase<Scalar>& vector
00181         ) const;
00182 
00183     void setStepControlState_(StepControlStrategyState state);
00184 
00185     void updateCoeffs_();
00186 
00187     //* returns true if the objects verbosity level is equal to or greater than level in verbLevel */
00188     bool doOutput_(Teuchos::EVerbosityLevel verbLevel);
00189 
00190   private:
00191 
00192     StepControlStrategyState stepControlState_;
00193     RCP<ErrWtVecCalcBase<Scalar> > errWtVecCalc_;
00194     RCP<Teuchos::ParameterList> parameterList_;
00195 
00196     StepSizeType stepSizeType_;
00197     Scalar requestedStepSize_;
00198     Scalar currentStepSize_;
00199     int currentOrder_;
00200     Scalar nextStepSize_;
00201     int nextOrder_;
00202 
00203     int numberOfSteps_;
00204     int totalNumberOfFailedSteps_;
00205     int countOfConstantStepsAfterFailure_;
00206     int newtonConvergenceStatus_;
00207 
00208     Scalar time_;
00209     Scalar stopTime_;
00210 
00211     RCP<const Thyra::VectorBase<Scalar> > ee_; // Newton update
00212     RCP<Thyra::VectorBase<Scalar> > errWtVec_; // error weight vector
00213     RCP<Thyra::VectorBase<Scalar> > delta_;
00214     ScalarMag relErrTol_; // relative error tolerance
00215     ScalarMag absErrTol_; // absolute error tolerance
00216 
00217     // Validated parameters
00218     int numConstantSteps_;
00219     Scalar initialStepSize_;
00220     Scalar maxStepSize_;
00221     Scalar minStepSize_;
00222     Scalar stepSizeIncreaseFactor_;
00223     Scalar stepSizeDecreaseFactor_;
00224     int minOrder_;
00225     int maxOrder_;
00226     bool useLETToDetermineConvergence_;
00227     bool restrictStepSizeByNumberOfNonlinearIterations_;
00228     int numberOfNonlinearIterationsForStepSizeRestriction_;
00229 
00230     // Garbage to clean up for LET
00231 
00232     Array<Scalar> alpha_;    // $\alpha_j(n)=h_n/\psi_j(n)$ coefficient used in local error test
00233     // note:   $h_n$ = current step size, n = current time step
00234     Array<Scalar> sigma_;    // $\sigma_j(n) = \frac{h_n^j(j-1)!}{\psi_1(n)*\cdots *\psi_j(n)}$
00235     Array<Scalar> gamma_;    // $\gamma_j(n)=\sum_{l=1}^{j-1}1/\psi_l(n)$ coefficient used to
00236     // calculate time derivative of history array for predictor
00237     Array<Scalar> beta_;     // coefficients used to evaluate predictor from history array
00238     Array<Scalar> psi_;      // $\psi_j(n) = t_n-t_{n-j}$ intermediary variable used to
00239     // compute $\beta_j(n)$
00240     Scalar alpha_s_;    // $\alpha_s$ fixed-leading coefficient of this BDF method
00241     Scalar alpha_0_;     // $-\sum_{j=1}^k \alpha_j(n)$ coefficient used in local error test
00242     Scalar cj_ ;        // $-\alpha_s/h_n$ coefficient used in local error test
00243     Scalar ck_ ;        // local error coefficient gamma[0] = 0;
00244     Scalar ck_enorm_;   // ck * enorm
00245 
00246   };
00247 
00248 } // namespace Rythmos
00249 
00250 #endif // Rythmos_IMPLICITBDF_STEPPER_STEP_CONTROL_DECL_H
00251 
 All Classes Functions Variables Typedefs Friends