00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042 #include "LOCA_StepSize_Constant.H"
00043 #include "NOX_Solver_Generic.H"
00044 #include "LOCA_GlobalData.H"
00045 #include "NOX_Utils.H"
00046 #include "LOCA_MultiContinuation_AbstractStrategy.H"
00047 #include "LOCA_MultiContinuation_ExtendedVector.H"
00048 #include "LOCA_Stepper.H"
00049
00050 LOCA::StepSize::Constant::Constant(
00051 const Teuchos::RCP<LOCA::GlobalData>& global_data,
00052 const Teuchos::RCP<LOCA::Parameter::SublistParser>& topParams,
00053 const Teuchos::RCP<Teuchos::ParameterList>& stepsizeParams) :
00054 globalData(global_data),
00055 maxStepSize(1.0e+12),
00056 minStepSize(1.0e-12),
00057 startStepSize(1.0),
00058 failedFactor(0.5),
00059 successFactor(1.26),
00060 prevStepSize(0.0),
00061 isFirstStep(true)
00062 {
00063 maxStepSize = stepsizeParams->get("Max Step Size", 1.0e+12);
00064 minStepSize = stepsizeParams->get("Min Step Size", 1.0e-12);
00065 startStepSize = stepsizeParams->get("Initial Step Size", 1.0);
00066 failedFactor =
00067 stepsizeParams->get("Failed Step Reduction Factor", 0.5);
00068 successFactor =
00069 stepsizeParams->get("Successful Step Increase Factor", 1.26);
00070 }
00071
00072 LOCA::StepSize::Constant::~Constant()
00073 {
00074 }
00075
00076 NOX::Abstract::Group::ReturnType
00077 LOCA::StepSize::Constant::computeStepSize(
00078 LOCA::MultiContinuation::AbstractStrategy& curGroup,
00079 const LOCA::MultiContinuation::ExtendedVector& predictor,
00080 const NOX::Solver::Generic& solver,
00081 const LOCA::Abstract::Iterator::StepStatus& stepStatus,
00082 const LOCA::Stepper& stepper,
00083 double& stepSize)
00084 {
00085
00086
00087
00088 if (isFirstStep) {
00089 double dpds = predictor.getScalar(0);
00090 if (dpds != 0.0) {
00091 startStepSize /= dpds;
00092 maxStepSize /= dpds;
00093 minStepSize /= dpds;
00094 }
00095 stepSize = startStepSize;
00096 isFirstStep = false;
00097 prevStepSize = 0.0;
00098 }
00099 else {
00100
00101
00102
00103 if (stepStatus == LOCA::Abstract::Iterator::Unsuccessful) {
00104 stepSize *= failedFactor;
00105 }
00106 else {
00107
00108 double ds_ratio = curGroup.getStepSizeScaleFactor();
00109 startStepSize *= ds_ratio;
00110 maxStepSize *= ds_ratio;
00111 minStepSize *= ds_ratio;
00112
00113 prevStepSize = stepSize;
00114 stepSize *= ds_ratio;
00115
00116
00117
00118
00119
00120 if (stepSize != startStepSize) {
00121
00122 stepSize *= successFactor;
00123
00124 if (startStepSize > 0.0)
00125 stepSize = NOX_MIN(stepSize, startStepSize);
00126 else
00127 stepSize = NOX_MAX(stepSize, startStepSize);
00128 }
00129 }
00130 }
00131
00132
00133 NOX::Abstract::Group::ReturnType res = clipStepSize(stepSize);
00134
00135 return res;
00136 }
00137
00138 NOX::Abstract::Group::ReturnType
00139 LOCA::StepSize::Constant::clipStepSize(double& stepSize)
00140 {
00141 NOX::Abstract::Group::ReturnType res = NOX::Abstract::Group::Ok;
00142
00143
00144 double signStep = 1.0;
00145 if (stepSize < 0.0)
00146 signStep = -1.0;
00147
00148
00149 if (fabs(stepSize) > maxStepSize)
00150 stepSize = signStep*maxStepSize;
00151
00152
00153 if (fabs(stepSize) < minStepSize) {
00154 res = NOX::Abstract::Group::Failed;
00155 stepSize = signStep*minStepSize;
00156 if (globalData->locaUtils->isPrintType(NOX::Utils::Error)) {
00157 globalData->locaUtils->err() <<
00158 "\n\tStep size reached minimum step size bound" << std::endl;
00159 }
00160 }
00161
00162 return res;
00163 }
00164
00165 double
00166 LOCA::StepSize::Constant::getPrevStepSize() const {
00167 return prevStepSize;
00168 }
00169
00170 double
00171 LOCA::StepSize::Constant::getStartStepSize() const {
00172 return startStepSize;
00173 }