Example #1
0
NOX::Abstract::Group::ReturnType 
LOCA::SingularJacobianSolve::Nic::compute(
				Teuchos::ParameterList& params,
				LOCA::Continuation::AbstractGroup& grp,
				const NOX::Abstract::Vector& input,
			        const NOX::Abstract::Vector& approxNullVec,
				const NOX::Abstract::Vector& jacApproxNullVec,
				NOX::Abstract::Vector& result) 
{
  string callingFunction = 
    "LOCA::SingularJacobianSolve::Nic::compute()";
  NOX::Abstract::Group::ReturnType finalStatus;

  double alpha = approxNullVec.innerProduct(input)
               / approxNullVec.innerProduct(jacApproxNullVec);

  NOX::Abstract::Vector* tmpInput  = input.clone(NOX::DeepCopy);
  tmpInput->update(-alpha, jacApproxNullVec, 1.0);

  finalStatus = grp.applyJacobianInverse(params, *tmpInput, result);
  LOCA::ErrorCheck::checkReturnType(finalStatus, callingFunction);

  delete tmpInput;

  result.update(alpha, approxNullVec, 1.0);

  return finalStatus;
}
NOX::Abstract::Group::ReturnType 
LOCA::SingularJacobianSolve::ItRef::compute(
				Teuchos::ParameterList& params,
				LOCA::Continuation::AbstractGroup& grp,
				const NOX::Abstract::Vector& input,
			        const NOX::Abstract::Vector& approxNullVec,
				const NOX::Abstract::Vector& jacApproxNullVec,
				NOX::Abstract::Vector& result) 
{
  std::string callingFunction = 
    "LOCA::SingularJacobianSolve::ItRef::compute()";
  NOX::Abstract::Group::ReturnType status, finalStatus;

  finalStatus = grp.applyJacobianInverse(params, input, result);
  LOCA::ErrorCheck::checkReturnType(finalStatus, callingFunction);

  NOX::Abstract::Vector* remainder = input.clone(NOX::ShapeCopy);

  status = grp.applyJacobian(result, *remainder);
  finalStatus = 
    LOCA::ErrorCheck::combineAndCheckReturnTypes(status, finalStatus,
						 callingFunction);

  // r = b-Ax
  remainder->update(1.0, input, -1.0);

  NOX::Abstract::Vector* refinement = input.clone(NOX::ShapeCopy);

  // Ay=r
  status = grp.applyJacobianInverse(params, *remainder, *refinement);
  finalStatus = 
    LOCA::ErrorCheck::combineAndCheckReturnTypes(status, finalStatus,
						 callingFunction);

  // x+=y
  result.update(1.0, *refinement, 1.0);
  
  delete remainder;
  delete refinement;

  return finalStatus;
}