Beispiel #1
0
kvs::Mat3 PrismCell::gradient()
{
    const kvs::Mat3 t = this->localGradient();
    const kvs::Mat3 J = this->JacobiMatrix();

    kvs::Real32 det = 0.0f;
    const kvs::Mat3 T = 3.0f * J.inverted( &det ) * t;

    return kvs::Math::IsZero( det ) ? kvs::Mat3::Zero() : T;
}
Beispiel #2
0
/*===========================================================================*/
kvs::Vec3 TetrahedralCell::globalToLocal( const kvs::Vec3& global ) const
{
    const kvs::Vec3 v3( BaseClass::coord(3) );
    const kvs::Vec3 v03( BaseClass::coord(0) - v3 );
    const kvs::Vec3 v13( BaseClass::coord(1) - v3 );
    const kvs::Vec3 v23( BaseClass::coord(2) - v3 );

    const kvs::Mat3 M(
        v03.x(), v13.x(), v23.x(),
        v03.y(), v13.y(), v23.y(),
        v03.z(), v13.z(), v23.z() );

    return M.inverted() * ( global - v3 );
}
Beispiel #3
0
/*===========================================================================*/
const kvs::Vec3 CellBase::gradientVector() const
{
    KVS_ASSERT( m_veclen == 1 );

    // Calculate a gradient vector in the local coordinate.
    const kvs::UInt32 nnodes = m_nnodes;
    const float* dNdp = m_differential_functions;
    const float* dNdq = m_differential_functions + nnodes;
    const float* dNdr = m_differential_functions + nnodes + nnodes;
    const kvs::Real32* S = m_values;

    const float dSdp = this->interpolateValue( S, dNdp, nnodes );
    const float dSdq = this->interpolateValue( S, dNdq, nnodes );
    const float dSdr = this->interpolateValue( S, dNdr, nnodes );
    const kvs::Vec3 g( dSdp, dSdq, dSdr );

    // Calculate a gradient vector in the global coordinate.
    const kvs::Mat3 J = this->JacobiMatrix();

    float determinant = 0.0f;
    const kvs::Vec3 G = 3.0f * J.inverted( &determinant ) * g;
    return kvs::Math::IsZero( determinant ) ? kvs::Vec3::Zero() : G;
}