NOX::Abstract::Group::ReturnType LOCA::MultiPredictor::Constant::compute( bool baseOnSecant, const std::vector<double>& stepSize, LOCA::MultiContinuation::ExtendedGroup& grp, const LOCA::MultiContinuation::ExtendedVector& prevXVec, const LOCA::MultiContinuation::ExtendedVector& xVec) { if (globalData->locaUtils->isPrintType(NOX::Utils::StepperDetails)) globalData->locaUtils->out() << "\n\tCalling Predictor with method: Constant" << std::endl; // Number of continuation parameters int numParams = stepSize.size(); if (!initialized) { // Allocate predictor vector predictor = Teuchos::rcp_dynamic_cast<LOCA::MultiContinuation::ExtendedMultiVector>(xVec.createMultiVector(numParams, NOX::ShapeCopy)); // Allocate secant secant = Teuchos::rcp_dynamic_cast<LOCA::MultiContinuation::ExtendedVector>(xVec.clone(NOX::ShapeCopy)); initialized = true; } predictor->init(0.0); for (int i=0; i<numParams; i++) predictor->getScalar(i,i) = 1.0; // Set orientation based on parameter change setPredictorOrientation(baseOnSecant, stepSize, grp, prevXVec, xVec, *secant, *predictor); return NOX::Abstract::Group::Ok; }
NOX::Abstract::Group::ReturnType LOCA::MultiPredictor::Secant::compute( bool baseOnSecant, const std::vector<double>& stepSize, LOCA::MultiContinuation::ExtendedGroup& grp, const LOCA::MultiContinuation::ExtendedVector& prevXVec, const LOCA::MultiContinuation::ExtendedVector& xVec) { if (globalData->locaUtils->isPrintType(NOX::Utils::StepperDetails)) globalData->locaUtils->out() << "\n\tCalling Predictor with method: Secant" << std::endl; // Number of continuation parameters int numParams = stepSize.size(); if (!initialized) { // Allocate predictor vector predictor = Teuchos::rcp_dynamic_cast<LOCA::MultiContinuation::ExtendedMultiVector>(xVec.createMultiVector(numParams, NOX::ShapeCopy)); // Allocate secant secant = Teuchos::rcp_dynamic_cast<LOCA::MultiContinuation::ExtendedVector>(xVec.clone(NOX::ShapeCopy)); initialized = true; } // Use first step predictor if this is the first step if (isFirstStep && !isFirstStepComputed) { isFirstStepComputed = true; return firstStepPredictor->compute(baseOnSecant, stepSize, grp, prevXVec, xVec); } if (isFirstStep && isFirstStepComputed) isFirstStep = false; // Compute x - xold (*predictor)[0].update(1.0, xVec, -1.0, prevXVec, 0.0); for (int i=0; i<numParams; i++) { (*predictor)[i] = (*predictor)[0]; // Rescale so parameter component = 1 (*predictor)[i].scale(1.0/fabs(predictor->getScalar(i,i))); // Set off-diagonal elements to 0 for (int j=0; j<numParams; j++) if (i != j) predictor->getScalar(i,j) = 0.0; } // Set orientation based on parameter change setPredictorOrientation(baseOnSecant, stepSize, grp, prevXVec, xVec, *secant, *predictor); return NOX::Abstract::Group::Ok; }