Esempio n. 1
0
void QK_find_N_opt_3D()
{
    using namespace Feel;
    typedef T value_type;

    Gauss<Hypercube<3,1>, N ,value_type > im;

    ublas::vector<value_type> x_i( ublas::row( im.points(),0 ) );
    ublas::vector<value_type> y_i( ublas::row( im.points(),1 ) );
    ublas::vector<value_type> z_i( ublas::row( im.points(),2 ) );

    const value_type tol = value_type( 2.5 )*type_traits<value_type>::epsilon();

    /* 1D number of Nodes */
    //@{
    uint16_type Q = ( uint16_type )pow( im.nPoints(),double( 1 )/3 );
    //@}

    value_type error = 0.0;
    value_type res;
    uint16_type i=1;
    value_type sum=0.0;

    ost << "Nbre of Points on the Hexaedra : " << Q << "^3 = "<< im.nPoints() <<  std::endl;

    do
    {
        if ( i%2 == 0 )
            res = value_type( 8.0 )/value_type( i+1.0 )/value_type( i+1.0 )/value_type( i+1.0 );

        else
            res = 0.0;

        sum = 0.0;

        for ( uint16_type l=0; l< x_i.size(); ++l )
        {
            sum += pow( x_i( l ), i )*pow( y_i( l ),i )*pow( z_i( l ),i )*im.weight( l );
        }

        error = math::abs( sum - res );
        ost << "i = " << i <<" Error = "<< error << "\n";
        ++i;
    }
    while ( error <= tol );

    if ( i-2 < 2*Q-1  )
        QK_log_3D << "Q = " << Q << " ; i = " << i << " ; Error" << error << std::endl;

    BOOST_CHECK( i-2 >= 2*Q-1  );
}
Esempio n. 2
0
void PK_find_N_opt()
//@}
{
    using namespace Feel;

    typedef T value_type;

    Gauss<Simplex<2,1> , N, value_type> im;

    ublas::vector<value_type> x_i( ublas::row( im.points(),0 ) );
    ublas::vector<value_type> y_i( ublas::row( im.points(),1 ) );

    const value_type tol = value_type( 7.0 )*type_traits<value_type>::epsilon();

    ost << "Tolerance = " << tol << "\n";

    uint16_type Q = ( uint16_type )sqrt( im.nPoints() );

    value_type error;
    value_type res;
    uint16_type i=1;
    value_type sum;

    ost << "Nbre of Points on the triangle : " << Q << "^2 = "<< im.nPoints() <<  std::endl;

    do
    {
        if ( i%2 == 0 )
            res = value_type( 2.0 )/value_type( double( i )+1.0 )/value_type( double( i )+1.0 );

        else
            res = value_type( 0.0 );

        sum = value_type( 0.0 );

        for ( uint16_type l=0; l< x_i.size(); ++l )
        {
            value_type p = pow( x_i( l ),i )*pow( y_i( l ),i )*im.weight( l );
            //        std::cout << "Contrib = " << p << "\n";
            sum += p;
        }

#if 0
        std::cout << "i = " << i << "\n";
        std::cout << "res = " << res << "\n";
        std::cout << "sum = " << sum << "\n";
#endif

        error = math::abs( sum - res );
        ost << "i = " << i <<" Error = "<< error << "\n";

        ++i;
    }
    while ( error <= tol );

    if ( i-2 < Q-1  )
        PK_log << "Q = " << Q << " ; i = " << i << " ; Error = " << error << std::endl;

    BOOST_CHECK( i-2 >= Q-1  );

}