Ejemplo n.º 1
0
/*===========================================================================*/
bool StreamlineBase::integrate_by_runge_kutta_2nd(
    const kvs::Vec3& current_vertex,
    const kvs::Vec3& current_direction,
    kvs::Vec3* next_vertex )
{
    if ( m_enable_boundary_condition )
    {
        if ( !this->check_for_inside_volume( current_vertex ) ) return false;
    }

    const float integration_direction = static_cast<float>( m_integration_direction );
    const kvs::Vec3 k1 = current_direction.normalized() * integration_direction;
    // Interpolate vector from vertex of cell.
    const kvs::Vec3 vertex = current_vertex + 0.5f * m_integration_interval * k1;

    if ( m_enable_boundary_condition )
    {
        if ( !this->check_for_inside_volume( vertex ) ) return false;
    }

    const kvs::Vec3 direction = this->interpolate_vector( vertex, current_direction );
    const kvs::Vec3 k2 = direction.normalized() * integration_direction;
    *next_vertex = vertex + m_integration_interval * k2;

    return true;
}
Ejemplo n.º 2
0
/*===========================================================================*/
bool StreamlineBase::integrate_by_runge_kutta_4th(
    const kvs::Vec3& current_vertex,
    const kvs::Vec3& current_direction,
    kvs::Vec3* next_vertex )
{
    if ( m_enable_boundary_condition )
    {
        if ( !this->check_for_inside_volume( current_vertex ) ) return false;
    }

    // Calculate integration interval.

    const float integration_direction = static_cast<float>( m_integration_direction );
    const kvs::Vec3 k1 = current_direction.normalized() * integration_direction;

    // Interpolate vector from vertex of cell.
    const kvs::Vec3 vertex2 = current_vertex + 0.5f * m_integration_interval * k1;

    if ( m_enable_boundary_condition )
    {
        if ( !this->check_for_inside_volume( vertex2 ) ) return false;
    }

    const kvs::Vec3 direction2 = this->interpolate_vector( vertex2, current_direction );
    const kvs::Vec3 k2 = direction2.normalized() * integration_direction;

    // Interpolate vector from vertex of cell.
    const kvs::Vec3 vertex3 = current_vertex + 0.5f * m_integration_interval * k2;

    if ( m_enable_boundary_condition )
    {
        if ( !this->check_for_inside_volume( vertex3 ) ) return false;
    }

    const kvs::Vec3 direction3 = this->interpolate_vector( vertex3, current_direction );
    const kvs::Vec3 k3 = direction3.normalized() * integration_direction;

    // Interpolate vector from vertex of cell.
    const kvs::Vec3 vertex4 = current_vertex + m_integration_interval * k3;

    if ( m_enable_boundary_condition )
    {
        if ( !this->check_for_inside_volume( vertex4 ) ) return false;
    }

    const kvs::Vec3 direction4 = this->interpolate_vector( vertex4, current_direction );
    const kvs::Vec3 k4 = direction4.normalized() * integration_direction;

    *next_vertex = current_vertex + integration_direction * ( k1 + 2.0f * ( k2 + k3 ) + k4 ) / 6.0f;

    return true;
}
Ejemplo n.º 3
0
/*===========================================================================*/
bool StreamlineBase::integrate_by_euler(
    const kvs::Vec3& current_vertex,
    const kvs::Vec3& current_direction,
    kvs::Vec3* next_vertex )
{
    if ( m_enable_boundary_condition )
    {
        if ( !this->check_for_inside_volume( current_vertex ) ) return false;
    }

    const float integration_direction = static_cast<float>( m_integration_direction );
    const kvs::Vec3 k1 = current_direction.normalized() * integration_direction;
    *next_vertex = current_vertex + m_integration_interval * k1;

    return true;
}