本文整理汇总了C++中nox::abstract::Group::computeNewton方法的典型用法代码示例。如果您正苦于以下问题:C++ Group::computeNewton方法的具体用法?C++ Group::computeNewton怎么用?C++ Group::computeNewton使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nox::abstract::Group
的用法示例。
在下文中一共展示了Group::computeNewton方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
bool NOX::Direction::Newton::compute(NOX::Abstract::Vector& dir,
NOX::Abstract::Group& soln,
const NOX::Solver::Generic& solver)
{
NOX::Abstract::Group::ReturnType status;
// Compute F at current solution.
status = soln.computeF();
if (status != NOX::Abstract::Group::Ok)
NOX::Direction::Newton::throwError("compute", "Unable to compute F");
// Reset the linear solver tolerance.
if (useAdjustableForcingTerm) {
resetForcingTerm(soln, solver.getPreviousSolutionGroup(),
solver.getNumIterations(), solver);
}
else {
if (utils->isPrintType(Utils::Details)) {
utils->out() << " CALCULATING FORCING TERM" << endl;
utils->out() << " Method: Constant" << endl;
utils->out() << " Forcing Term: " << eta_k << endl;
}
}
// Compute Jacobian at current solution.
status = soln.computeJacobian();
if (status != NOX::Abstract::Group::Ok)
NOX::Direction::Newton::throwError("compute", "Unable to compute Jacobian");
// Compute the Newton direction
status = soln.computeNewton(paramsPtr->sublist("Newton").sublist("Linear Solver"));
// It didn't converge, but maybe we can recover.
if ((status != NOX::Abstract::Group::Ok) &&
(doRescue == false)) {
NOX::Direction::Newton::throwError("compute",
"Unable to solve Newton system");
}
else if ((status != NOX::Abstract::Group::Ok) &&
(doRescue == true)) {
if (utils->isPrintType(NOX::Utils::Warning))
utils->out() << "WARNING: NOX::Direction::Newton::compute() - Linear solve "
<< "failed to achieve convergence - using the step anyway "
<< "since \"Rescue Bad Newton Solve\" is true " << endl;
}
// Set search direction.
dir = soln.getNewton();
return true;
}
示例2: if
//.........这里部分代码省略.........
}
// Continue processing
#ifdef USE_INITIAL_GUESS_LOGIC
if (isInitialGuessGood)
{
tmpVecPtr->update(1.0, *tensorVecPtr, 1.0);
linearParams.set("Tolerance", tol);
}
#endif
// Save iteration count for comparison later
if (linearParams.sublist("Output").
isParameter("Number of Linear Iterations"))
tempVal1 = linearParams.sublist("Output").
get("Number of Linear Iterations",0);
#if DEBUG_LEVEL > 0
// Compute residual of linear system with initial guess...
soln.applyJacobian(*tmpVecPtr, *residualVecPtr);
numJvMults++;
residualVec.update(-1.0, solver.getPreviousSolutionGroup().getF(),1.0);
double residualNorm2 = residualVec.norm();
double residualNorm2Rel = residualNorm2 /
solver.getPreviousSolutionGroup().getNormF();
if (utilsPtr->isPrintType(NOX::Utils::Details))
utilsPtr->out() << " jifp norm of model residual = "
<< utilsPtr->sciformat(residualNorm2, 6) << " (abs) "
<< utilsPtr->sciformat(residualNorm2Rel, 6) << " (rel)" << std::endl;
#endif
}
// Compute the Newton direction
dir_status = soln.computeNewton(linearParams);
// If it didn't converge, maybe we can recover.
if (dir_status != NOX::Abstract::Group::Ok)
{
if (doRescue == false)
throwError("computeTensorDirection", "Unable to apply Jacobian inverse");
else if ((doRescue == true) &&
(utilsPtr->isPrintType(NOX::Utils::Warning)))
utilsPtr->out() << "WARNING: NOX::Solver::TensorBased::computeTensorDirection() - "
<< "Linear solve failed to achieve convergence - "
<< "using the step anyway "
<< "since \"Rescue Bad Newton Solve\" is true." << std::endl;
}
// Set Newton direction
*newtonVecPtr = soln.getNewton();
// Update counter
int tempVal2 = 0;
if (linearParams.sublist("Output").
isParameter("Number of Linear Iterations"))
tempVal2 = linearParams.sublist("Output").
get("Number of Linear Iterations",0);
numJ2vMults += (tempVal1 > tempVal2) ? tempVal1 : tempVal2;
#ifdef CHECK_RESIDUALS
printDirectionInfo("newtonVec", *newtonVecPtr, soln, false);
#endif // CHECK_RESIDUALS
// Continue processing the tensor step, if necessary
if ((nIter > 0) && (requestedBaseStep == TensorStep))
{