Rythmos_ImplicitBDFStepperStepControlDecl.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 getMaxOrder() const;
00092 
00094     void setStepControlData(const StepperBase<Scalar>& stepper);
00095 
00097     bool supportsCloning() const;
00098 
00100     RCP<StepControlStrategyBase<Scalar> > cloneStepControlStrategyAlgorithm() const;
00101 
00103 
00106 
00108     void setErrWtVecCalc(const RCP<ErrWtVecCalcBase<Scalar> >& errWtVecCalc);
00109 
00111     RCP<const ErrWtVecCalcBase<Scalar> > getErrWtVecCalc() const;
00112 
00114 
00115     ImplicitBDFStepperStepControl();
00116 
00120     void describe(
00121       Teuchos::FancyOStream &out,
00122       const Teuchos::EVerbosityLevel verbLevel
00123       ) const;
00125 
00129     void setParameterList(RCP<Teuchos::ParameterList> const& paramList);
00130 
00132     RCP<Teuchos::ParameterList> getParameterList();
00133 
00135     RCP<Teuchos::ParameterList> unsetParameterList();
00136 
00138     RCP<const Teuchos::ParameterList> getValidParameters() const;
00139 
00141 
00143     void initialize(const StepperBase<Scalar>& stepper);
00144     
00145 
00146   private:
00147 
00148     // Private data members
00149 
00150     void defaultInitializeAllData_();
00151 
00152     StepControlStrategyState stepControlState_;
00153 
00154     RCP<ErrWtVecCalcBase<Scalar> > errWtVecCalc_;
00155 
00156     Scalar hh_;
00157     int numberOfSteps_;
00158     StepSizeType stepSizeType_;
00159     int maxOrder_;
00160     int  nef_;
00161     bool midStep_; // true after setStepSize and nextStepSize and nextStepOrder and setCorrection and acceptStep
00162                    // false after rejectStep and completeStep
00163     RCP<const Thyra::VectorBase<Scalar> > ee_; // Newton update
00164     RCP<Thyra::VectorBase<Scalar> > errWtVec_; // error weight vector
00165     RCP<Thyra::VectorBase<Scalar> > delta_;
00166 
00167     bool checkReduceOrderCalled_;
00168 
00169     RCP<Teuchos::ParameterList> parameterList_;
00170 
00171     Scalar time_;
00172 
00173     ScalarMag relErrTol_; // relative error tolerance
00174     ScalarMag absErrTol_; // absolute error tolerance
00175     Scalar usedStep_;
00176     int currentOrder_; // Current order of integration
00177     int usedOrder_;    // order used in current step (used after currentOrder is updated)
00178     int nscsco_;
00179     Array<Scalar> alpha_;    // $\alpha_j(n)=h_n/\psi_j(n)$ coefficient used in local error test
00180     // note:   $h_n$ = current step size, n = current time step
00181     Array<Scalar> sigma_;    // $\sigma_j(n) = \frac{h_n^j(j-1)!}{\psi_1(n)*\cdots *\psi_j(n)}$
00182     Array<Scalar> gamma_;    // $\gamma_j(n)=\sum_{l=1}^{j-1}1/\psi_l(n)$ coefficient used to
00183     // calculate time derivative of history array for predictor 
00184     Array<Scalar> beta_;     // coefficients used to evaluate predictor from history array
00185     Array<Scalar> psi_;      // $\psi_j(n) = t_n-t_{n-j}$ intermediary variable used to 
00186     // compute $\beta_j(n)$
00187     Scalar alpha_s_;    // $\alpha_s$ fixed-leading coefficient of this BDF method
00188     Scalar alpha_0_;     // $-\sum_{j=1}^k \alpha_j(n)$ coefficient used in local error test
00189     Scalar cj_ ;        // $-\alpha_s/h_n$ coefficient used in local error test
00190     Scalar ck_ ;        // local error coefficient gamma[0] = 0; 
00191     Scalar ck_enorm_;   // ck * enorm
00192 
00193     bool constantStepSize_;
00194     Scalar Ek_;
00195     Scalar Ekm1_;
00196     Scalar Ekm2_;
00197     Scalar Ekp1_;
00198     Scalar Est_;
00199     Scalar Tk_;
00200     Scalar Tkm1_;
00201     Scalar Tkm2_;
00202     Scalar Tkp1_;
00203     int newOrder_;
00204     int oldOrder_;
00205     bool initialPhase_;
00206     Scalar stopTime_;
00207     
00208     // Magic Numbers:
00209     Scalar h0_safety_;
00210     Scalar h0_max_factor_;
00211     Scalar h_phase0_incr_;
00212     Scalar h_max_inv_;
00213     Scalar Tkm1_Tk_safety_;
00214     Scalar Tkp1_Tk_safety_;
00215     Scalar r_factor_;
00216     Scalar r_safety_;
00217     Scalar r_fudge_;
00218     Scalar r_min_;
00219     Scalar r_max_;
00220     Scalar r_hincr_test_;
00221     Scalar r_hincr_;
00222     int    max_LET_fail_;
00223     Scalar minTimeStep_;
00224     Scalar maxTimeStep_;
00225 
00226     int newtonConvergenceStatus_;
00227 
00228     // Private member functions
00229 
00230     Scalar wRMSNorm_(
00231         const Thyra::VectorBase<Scalar>& weight, 
00232         const Thyra::VectorBase<Scalar>& vector
00233         ) const;
00234 
00235     Scalar checkReduceOrder_(const StepperBase<Scalar>& stepper);
00236   
00237     void getFirstTimeStep_(const StepperBase<Scalar>& stepper);
00238 
00239     void setStepControlState_(StepControlStrategyState state);
00240 
00241     void updateCoeffs_();
00242 
00243     void setDefaultMagicNumbers_(Teuchos::ParameterList &magicNumberList);
00244 
00245 };
00246 
00247 } // namespace Rythmos
00248 
00249 #endif // Rythmos_IMPLICITBDF_STEPPER_STEP_CONTROL_DECL_H
00250 

Generated on Tue Oct 20 12:46:08 2009 for Rythmos - Transient Integration for Differential Equations by doxygen 1.4.7