Rythmos_ImplicitBDFStepperStepControl_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., 59 Temple Place, Suite 330, Boston, MA 02111-1307
00023 // USA
00024 // Questions? Contact Todd S. Coffey (tscoffe@sandia.gov)
00025 //
00026 // ***********************************************************************
00027 //@HEADER
00028 
00029 #ifndef Rythmos_IMPLICITBDF_STEPPER_STEP_CONTROL_DECL_H
00030 #define Rythmos_IMPLICITBDF_STEPPER_STEP_CONTROL_DECL_H
00031 
00032 #include "Rythmos_ErrWtVecCalcAcceptingStepControlStrategyBase.hpp"
00033 
00034 namespace Rythmos {
00035 
00037 enum BDFactionFlag { ACTION_UNSET, ACTION_LOWER, ACTION_MAINTAIN, ACTION_RAISE };
00038 
00039 // Step Control Strategy object for ImplicitBDFStpper
00040 //
00041 // Order of calls:
00042 // setRequestedStepSize()
00043 // nextStepSize()
00044 // optional:  nextStepOrder()
00045 // setCorrection
00046 // acceptStep
00047 // completeStep or rejectStep
00048 // repeat
00049 //
00050 // 08/16/07 tscoffe:  This order of operations must be enforced through
00051 // preconditions or I need to re-think how to set up the interface for this
00052 // strategy object.
00053 //
00054 template<class Scalar>
00055 class ImplicitBDFStepperStepControl 
00056   : virtual public ErrWtVecCalcAcceptingStepControlStrategyBase<Scalar>
00057 {
00058   public:
00059 
00060     typedef typename Teuchos::ScalarTraits<Scalar>::magnitudeType ScalarMag;
00061 
00065     void setRequestedStepSize(const StepperBase<Scalar>& stepper, const Scalar& stepSize, const StepSizeType& stepSizeType);
00066 
00068     void nextStepSize(const StepperBase<Scalar>& stepper, Scalar* stepSize, StepSizeType* stepSizeType, int* order);
00069 
00071     void setCorrection(
00072          const StepperBase<Scalar>& stepper
00073         ,const RCP<const Thyra::VectorBase<Scalar> >& soln
00074         ,const RCP<const Thyra::VectorBase<Scalar> >& ee
00075         ,int solveStatus
00076         ); 
00077 
00079     bool acceptStep(const StepperBase<Scalar>& stepper, Scalar* LETValue);
00080 
00082     void completeStep(const StepperBase<Scalar>& stepper);
00083     
00085     AttemptedStepStatusFlag rejectStep(const StepperBase<Scalar>& stepper);
00086 
00088     StepControlStrategyState getCurrentState();
00089 
00091     int getMinOrder() const;
00092 
00094     int getMaxOrder() const;
00095 
00097     void setStepControlData(const StepperBase<Scalar>& stepper);
00098 
00100     bool supportsCloning() const;
00101 
00103     RCP<StepControlStrategyBase<Scalar> > cloneStepControlStrategyAlgorithm() const;
00104 
00106 
00109 
00111     void setErrWtVecCalc(const RCP<ErrWtVecCalcBase<Scalar> >& errWtVecCalc);
00112 
00114     RCP<const ErrWtVecCalcBase<Scalar> > getErrWtVecCalc() const;
00115 
00117 
00118     ImplicitBDFStepperStepControl();
00119 
00123     void describe(
00124       Teuchos::FancyOStream &out,
00125       const Teuchos::EVerbosityLevel verbLevel
00126       ) const;
00128 
00132     void setParameterList(RCP<Teuchos::ParameterList> const& paramList);
00133 
00135     RCP<Teuchos::ParameterList> getNonconstParameterList();
00136 
00138     RCP<Teuchos::ParameterList> unsetParameterList();
00139 
00141     RCP<const Teuchos::ParameterList> getValidParameters() const;
00142 
00144 
00146     void initialize(const StepperBase<Scalar>& stepper);
00147     
00148 
00149   private:
00150 
00151     // Private data members
00152 
00153     void defaultInitializeAllData_();
00154 
00155     StepControlStrategyState stepControlState_;
00156 
00157     RCP<ErrWtVecCalcBase<Scalar> > errWtVecCalc_;
00158 
00159     Scalar hh_;
00160     int numberOfSteps_;
00161     StepSizeType stepSizeType_;
00162     int minOrder_;
00163     int maxOrder_;
00164     int  nef_;
00165     bool midStep_; // true after setStepSize and nextStepSize and nextStepOrder and setCorrection and acceptStep
00166                    // false after rejectStep and completeStep
00167     RCP<const Thyra::VectorBase<Scalar> > ee_; // Newton update
00168     RCP<Thyra::VectorBase<Scalar> > errWtVec_; // error weight vector
00169     RCP<Thyra::VectorBase<Scalar> > delta_;
00170 
00171     bool checkReduceOrderCalled_;
00172 
00173     RCP<Teuchos::ParameterList> parameterList_;
00174 
00175     Scalar time_;
00176 
00177     ScalarMag relErrTol_; // relative error tolerance
00178     ScalarMag absErrTol_; // absolute error tolerance
00179     Scalar usedStep_;
00180     int currentOrder_; // Current order of integration
00181     int usedOrder_;    // order used in current step (used after currentOrder is updated)
00182     int nscsco_;
00183     Array<Scalar> alpha_;    // $\alpha_j(n)=h_n/\psi_j(n)$ coefficient used in local error test
00184     // note:   $h_n$ = current step size, n = current time step
00185     Array<Scalar> sigma_;    // $\sigma_j(n) = \frac{h_n^j(j-1)!}{\psi_1(n)*\cdots *\psi_j(n)}$
00186     Array<Scalar> gamma_;    // $\gamma_j(n)=\sum_{l=1}^{j-1}1/\psi_l(n)$ coefficient used to
00187     // calculate time derivative of history array for predictor 
00188     Array<Scalar> beta_;     // coefficients used to evaluate predictor from history array
00189     Array<Scalar> psi_;      // $\psi_j(n) = t_n-t_{n-j}$ intermediary variable used to 
00190     // compute $\beta_j(n)$
00191     Scalar alpha_s_;    // $\alpha_s$ fixed-leading coefficient of this BDF method
00192     Scalar alpha_0_;     // $-\sum_{j=1}^k \alpha_j(n)$ coefficient used in local error test
00193     Scalar cj_ ;        // $-\alpha_s/h_n$ coefficient used in local error test
00194     Scalar ck_ ;        // local error coefficient gamma[0] = 0; 
00195     Scalar ck_enorm_;   // ck * enorm
00196 
00197     bool constantStepSize_;
00198     Scalar Ek_;
00199     Scalar Ekm1_;
00200     Scalar Ekm2_;
00201     Scalar Ekp1_;
00202     Scalar Est_;
00203     Scalar Tk_;
00204     Scalar Tkm1_;
00205     Scalar Tkm2_;
00206     Scalar Tkp1_;
00207     int newOrder_;
00208     int oldOrder_;
00209     bool initialPhase_;
00210     Scalar stopTime_;
00211     
00212     // Magic Numbers:
00213     Scalar h0_safety_;
00214     Scalar h0_max_factor_;
00215     Scalar h_phase0_incr_;
00216     Scalar h_max_inv_;
00217     Scalar Tkm1_Tk_safety_;
00218     Scalar Tkp1_Tk_safety_;
00219     Scalar r_factor_;
00220     Scalar r_safety_;
00221     Scalar r_fudge_;
00222     Scalar r_min_;
00223     Scalar r_max_;
00224     Scalar r_hincr_test_;
00225     Scalar r_hincr_;
00226     int    max_LET_fail_;
00227     Scalar minTimeStep_;
00228     Scalar maxTimeStep_;
00229 
00230     int newtonConvergenceStatus_;
00231 
00232     // Private member functions
00233 
00234     Scalar wRMSNorm_(
00235         const Thyra::VectorBase<Scalar>& weight, 
00236         const Thyra::VectorBase<Scalar>& vector
00237         ) const;
00238 
00239     Scalar checkReduceOrder_(const StepperBase<Scalar>& stepper);
00240   
00241     void getFirstTimeStep_(const StepperBase<Scalar>& stepper);
00242 
00243     void setStepControlState_(StepControlStrategyState state);
00244 
00245     void updateCoeffs_();
00246 
00247     void setDefaultMagicNumbers_(Teuchos::ParameterList &magicNumberList);
00248 
00249 };
00250 
00251 } // namespace Rythmos
00252 
00253 #endif // Rythmos_IMPLICITBDF_STEPPER_STEP_CONTROL_DECL_H
00254 

Generated on Tue Jul 13 09:23:53 2010 for Rythmos - Transient Integration for Differential Equations by  doxygen 1.4.7