Ejemplo n.º 1
0
void ImplicitStepper::solveUnconstrained( bool useNonLinearSolver, const bool& penaltyBefore )
{
    if( !penaltyBefore ){
        prepareDynamics();
    }

    if( useNonLinearSolver )
    {
        solveNonLinear();
    }
    else
    {
        solveLinear();

        m_notSPD = m_linearSolver.notSPD();
        if( m_notSPD )
        {
            if ( m_strand.requiresExactJacobian() ) // We are here for the first time, exact Jacobian gives non SPD LHS. Let's try with approximate Jacobian
            {
                std::cerr << "Strand " << m_strand.getGlobalIndex() << " has non spd lhs, using approximate Jacobian" << std::endl;
                m_strand.requireExactJacobian( false );
                solveUnconstrained();
                return;
            }
        }
        m_linearSolver.solve( m_futureVelocities, rhs() );
    }
} // Should call update so see computed changes from m_futureVelocities
  void ImplicitFunctionInternal::evaluate() {

    // Mark factorization as out-of-date. TODO: make this conditional
    fact_up_to_date_ = false;

    // Get initial guess
    output(iout_).set(input(iin_));

    // Solve the nonlinear system of equations
    solveNonLinear();
  }