void
MultiscaleAlgorithmNewton::subIterate()
{

#ifdef HAVE_LIFEV_DEBUG
    debugStream ( 8013 ) << "MultiscaleAlgorithmNewton::subIterate() \n";
#endif

    multiscaleAlgorithm_Type::subIterate();

    // Verify tolerance
    if ( checkResidual ( 0 ) )
    {
        return;
    }

    M_multiscale->exportCouplingVariables ( *M_couplingVariables );

    multiscaleVectorPtr_Type delta ( new multiscaleVector_Type ( *M_couplingResiduals, Unique ) );
    *delta = 0.0;

    for ( UInt subIT (1); subIT <= M_subiterationsMaximumNumber; ++subIT )
    {
        // Compute the Jacobian
        assembleJacobianMatrix();

        // Set matrix and RHS
        M_solver.setOperator ( M_jacobian );
        M_solver.setRightHandSide ( M_couplingResiduals );

        // Solve Newton (without changing the sign of the residual)
        M_solver.solve ( delta );

        // Changing the sign of the solution
        *delta *= -1;

        // Update Coupling Variables using the Newton Method
        *M_couplingVariables += *delta;

        // Import Coupling Variables inside the coupling blocks
        M_multiscale->importCouplingVariables ( *M_couplingVariables );

        // Verify tolerance
        if ( checkResidual ( subIT ) )
        {
            return;
        }
    }

    save ( M_subiterationsMaximumNumber, M_couplingResiduals->norm2() );

    multiscaleErrorCheck ( Tolerance, "Newton algorithm residual: " + number2string ( M_couplingResiduals->norm2() ) +
                           " (required: " + number2string ( M_tolerance ) + ")\n", M_multiscale->communicator() == 0 );
}
Beispiel #2
0
 /*!
  * TODO The area can be imposed to the 1-D model: need to be coded
  *
  * @param boundaryID ID of the boundary interface
  * @param function boundary condition function
  */
 void imposeBoundaryArea ( const multiscaleID_Type& /*boundaryID*/, const function_Type& /*function*/ )
 {
     multiscaleErrorCheck ( ModelInterface, "Invalid interface [Area] for model type [" + enum2String ( M_type, multiscaleModelsMap ) + "]", M_comm->MyPID() == 0 );
 }
void
MultiscaleAlgorithmAitken::subIterate()
{

#ifdef HAVE_LIFEV_DEBUG
    debugStream ( 8011 ) << "MultiscaleAlgorithmAitken::subIterate() \n";
#endif

    multiscaleAlgorithm_Type::subIterate();

    // Verify tolerance
    if ( checkResidual ( 0 ) )
    {
        return;
    }

    M_multiscale->exportCouplingVariables ( *M_couplingVariables );

    M_generalizedAitken.restart();

    // Temporary Computation of a Block Vector - Testing purpose
    //    VectorType blocksVector( M_couplingVariables ); blocksVector = 0.0;
    //    for ( UInt i = 1 ; i < blocksVector.size() ; i = i+2)
    //        blocksVector[i] = 1.0;
    //    std::cout << "blocksVector: " << std::endl;
    //    blocksVector.showMe();

    for ( UInt subIT = 1; subIT <= M_subiterationsMaximumNumber; ++subIT )
    {
        // Update Coupling Variables
        switch ( M_method )
        {
            case Scalar:

                *M_couplingVariables += M_generalizedAitken.computeDeltaLambdaScalar ( *M_couplingVariables, *M_couplingResiduals );

                break;

            case Vectorial:

                *M_couplingVariables += M_generalizedAitken.computeDeltaLambdaVector ( *M_couplingVariables, *M_couplingResiduals, true );

                break;

            case VectorialBlock:

                //*M_couplingVariables += M_generalizedAitken.computeDeltaLambdaVectorBlock( *M_couplingVariables, *M_couplingResiduals, blocksVector, 2 );

                break;
        }

        // Import Coupling Variables inside the coupling blocks
        M_multiscale->importCouplingVariables ( *M_couplingVariables );

        // Verify tolerance
        if ( checkResidual ( subIT ) )
        {
            return;
        }
    }

    save ( M_subiterationsMaximumNumber, M_couplingResiduals->norm2() );

    multiscaleErrorCheck ( Tolerance, "Aitken algorithm residual: " + number2string ( M_couplingResiduals->norm2() ) +
                           " (required: " + number2string ( M_tolerance ) + ")\n", M_multiscale->communicator() == 0  );
}
Beispiel #4
0
void
MultiscaleCoupling::switchErrorMessage ( const multiscaleModelPtr_Type& model )
{
    multiscaleErrorCheck ( ModelType, "Invalid model type ["  + enum2String ( model->type(), multiscaleModelsMap ) +
                           "] for coupling type [" + enum2String ( M_type, multiscaleCouplingsMap ) + "]\n", model->communicator()->MyPID() == 0 );
}