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 "Teuchos_ParameterList.hpp"
00043 #include "LOCA_MultiPredictor_Restart.H"
00044 #include "LOCA_GlobalData.H"
00045 #include "NOX_Utils.H"
00046 #include "LOCA_ErrorCheck.H"
00047 #include "LOCA_MultiContinuation_ExtendedVector.H"
00048 #include "LOCA_MultiContinuation_ExtendedMultiVector.H"
00049
00050 LOCA::MultiPredictor::Restart::Restart(
00051 const Teuchos::RCP<LOCA::GlobalData>& global_data,
00052 const Teuchos::RCP<Teuchos::ParameterList>& predParams) :
00053 globalData(global_data),
00054 predictor()
00055 {
00056 const char *func = "LOCA::MultiPredictor::Restart::Restart()";
00057
00058
00059 string name = "Restart Vector";
00060 if (!predParams->isParameter(name))
00061 globalData->locaErrorCheck->throwError(func, name + " is not set!");
00062
00063 if ((*predParams).INVALID_TEMPLATE_QUALIFIER
00064 isType< Teuchos::RCP<LOCA::MultiContinuation::ExtendedMultiVector> >(name))
00065 predictor = (*predParams).INVALID_TEMPLATE_QUALIFIER
00066 get< Teuchos::RCP<LOCA::MultiContinuation::ExtendedMultiVector> >(name);
00067
00068 else if ((*predParams).INVALID_TEMPLATE_QUALIFIER
00069 isType< Teuchos::RCP<LOCA::MultiContinuation::ExtendedVector> >(name)) {
00070 Teuchos::RCP<LOCA::MultiContinuation::ExtendedVector> v =
00071 (*predParams).INVALID_TEMPLATE_QUALIFIER
00072 get< Teuchos::RCP<LOCA::MultiContinuation::ExtendedVector> >(name);
00073 predictor = Teuchos::rcp_dynamic_cast<LOCA::MultiContinuation::ExtendedMultiVector>(v->createMultiVector(1, NOX::DeepCopy));
00074 }
00075 else
00076 globalData->locaErrorCheck->throwError(func, name + " is not a Teuchos::RCP to a LOCA::Extended::Vector nor a LOCA::Extended::MultiVector!");
00077
00078
00079
00080 }
00081
00082 LOCA::MultiPredictor::Restart::~Restart()
00083 {
00084 }
00085
00086 LOCA::MultiPredictor::Restart::Restart(
00087 const LOCA::MultiPredictor::Restart& source,
00088 NOX::CopyType type) :
00089 globalData(source.globalData),
00090 predictor(source.predictor)
00091 {
00092 }
00093
00094 LOCA::MultiPredictor::AbstractStrategy&
00095 LOCA::MultiPredictor::Restart::operator=(
00096 const LOCA::MultiPredictor::AbstractStrategy& s)
00097 {
00098 const LOCA::MultiPredictor::Restart& source =
00099 dynamic_cast<const LOCA::MultiPredictor::Restart&>(s);
00100
00101 if (this != &source) {
00102 globalData = source.globalData;
00103 predictor = source.predictor;
00104 }
00105
00106 return *this;
00107 }
00108
00109 Teuchos::RCP<LOCA::MultiPredictor::AbstractStrategy>
00110 LOCA::MultiPredictor::Restart::clone(NOX::CopyType type) const
00111 {
00112 return Teuchos::rcp(new Restart(*this, type));
00113 }
00114
00115 NOX::Abstract::Group::ReturnType
00116 LOCA::MultiPredictor::Restart::compute(
00117 bool baseOnSecant, const vector<double>& stepSize,
00118 LOCA::MultiContinuation::ExtendedGroup& grp,
00119 const LOCA::MultiContinuation::ExtendedVector& prevXVec,
00120 const LOCA::MultiContinuation::ExtendedVector& xVec)
00121 {
00122 if (globalData->locaUtils->isPrintType(NOX::Utils::StepperDetails))
00123 globalData->locaUtils->out() <<
00124 "\n\tCalling Predictor with method: Restart" << std::endl;
00125
00126 return NOX::Abstract::Group::Ok;
00127 }
00128
00129 NOX::Abstract::Group::ReturnType
00130 LOCA::MultiPredictor::Restart::evaluate(
00131 const vector<double>& stepSize,
00132 const LOCA::MultiContinuation::ExtendedVector& xVec,
00133 LOCA::MultiContinuation::ExtendedMultiVector& result) const
00134 {
00135
00136 int numParams = stepSize.size();
00137
00138 for (int i=0; i<numParams; i++)
00139 result[i].update(1.0, xVec, stepSize[i], (*predictor)[i], 0.0);
00140
00141 return NOX::Abstract::Group::Ok;
00142 }
00143
00144 NOX::Abstract::Group::ReturnType
00145 LOCA::MultiPredictor::Restart::computeTangent(
00146 LOCA::MultiContinuation::ExtendedMultiVector& v)
00147 {
00148 v = *predictor;
00149
00150 return NOX::Abstract::Group::Ok;
00151 }
00152
00153 bool
00154 LOCA::MultiPredictor::Restart::isTangentScalable() const
00155 {
00156 return false;
00157 }