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_Adaptive.H"
00043 #include "NOX_Solver_Generic.H"
00044 #include "LOCA_MultiContinuation_AbstractStrategy.H"
00045 #include "LOCA_MultiContinuation_ExtendedVector.H"
00046 #include "LOCA_Stepper.H"
00047 #include "LOCA_Parameter_SublistParser.H"
00048
00049 LOCA::StepSize::Adaptive::Adaptive(
00050 const Teuchos::RCP<LOCA::GlobalData>& global_data,
00051 const Teuchos::RCP<LOCA::Parameter::SublistParser>& topParams,
00052 const Teuchos::RCP<Teuchos::ParameterList>& stepsizeParams) :
00053 LOCA::StepSize::Constant(global_data, topParams, stepsizeParams),
00054 agrValue(0.0),
00055 maxNonlinearSteps(0.0)
00056 {
00057 agrValue = stepsizeParams->get("Aggressiveness", 0.5);
00058
00059
00060 Teuchos::RCP<Teuchos::ParameterList> p =
00061 topParams->getSublist("Stepper");
00062 maxNonlinearSteps =
00063 static_cast<double>(p->get("Max Nonlinear Iterations", 15));
00064 }
00065
00066 LOCA::StepSize::Adaptive::~Adaptive()
00067 {
00068 }
00069
00070 NOX::Abstract::Group::ReturnType
00071 LOCA::StepSize::Adaptive::computeStepSize(
00072 LOCA::MultiContinuation::AbstractStrategy& curGroup,
00073 const LOCA::MultiContinuation::ExtendedVector& predictor,
00074 const NOX::Solver::Generic& solver,
00075 const LOCA::Abstract::Iterator::StepStatus& stepStatus,
00076 const LOCA::Stepper& stepper,
00077 double& stepSize)
00078 {
00079
00080 if (isFirstStep) {
00081 double dpds = predictor.getScalar(0);
00082 if (dpds != 0.0) {
00083 LOCA::StepSize::Constant::startStepSize /= dpds;
00084 LOCA::StepSize::Constant::maxStepSize /= dpds;
00085 LOCA::StepSize::Constant::minStepSize /= dpds;
00086 }
00087 LOCA::StepSize::Constant::isFirstStep = false;
00088 stepSize = LOCA::StepSize::Constant::startStepSize;
00089 prevStepSize = 0.0;
00090 }
00091 else {
00092
00093
00094 if (stepStatus == LOCA::Abstract::Iterator::Unsuccessful) {
00095 stepSize *= LOCA::StepSize::Constant::failedFactor;
00096 }
00097 else {
00098
00099 double ds_ratio = curGroup.getStepSizeScaleFactor();
00100 LOCA::StepSize::Constant::startStepSize *= ds_ratio;
00101 LOCA::StepSize::Constant::maxStepSize *= ds_ratio;
00102 LOCA::StepSize::Constant::minStepSize *= ds_ratio;
00103
00104
00105 double numNonlinearSteps =
00106 static_cast<double>(solver.getNumIterations());
00107
00108
00109 prevStepSize = stepSize;
00110
00111
00112 double factor = (maxNonlinearSteps - numNonlinearSteps)
00113 / (maxNonlinearSteps);
00114
00115 stepSize *= (1.0 + agrValue * factor * factor);
00116
00117 stepSize *= ds_ratio;
00118 }
00119 }
00120
00121
00122 NOX::Abstract::Group::ReturnType res = clipStepSize(stepSize);
00123
00124 return res;
00125 }
00126