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