MOAB: Mesh Oriented datABase  (version 5.3.1)
MBMesquite::TInverseMeanRatio Class Reference

#include <TInverseMeanRatio.hpp>

+ Inheritance diagram for MBMesquite::TInverseMeanRatio:
+ Collaboration diagram for MBMesquite::TInverseMeanRatio:

Public Member Functions

virtual MESQUITE_EXPORT ~TInverseMeanRatio ()
virtual MESQUITE_EXPORT std::string get_name () const
virtual MESQUITE_EXPORT bool evaluate (const MsqMatrix< 2, 2 > &T, double &result, MsqError &err)
 Evaluate \(\mu(T)\).
virtual MESQUITE_EXPORT bool evaluate_with_grad (const MsqMatrix< 2, 2 > &T, double &result, MsqMatrix< 2, 2 > &deriv_wrt_T, MsqError &err)
virtual MESQUITE_EXPORT bool evaluate_with_hess (const MsqMatrix< 2, 2 > &T, double &result, MsqMatrix< 2, 2 > &deriv_wrt_T, MsqMatrix< 2, 2 > second_wrt_T[3], MsqError &err)
 Hessian of \(\mu(T)\) with respect to components of T.
virtual MESQUITE_EXPORT bool evaluate (const MsqMatrix< 3, 3 > &T, double &result, MsqError &err)
 Evaluate \(\mu(T)\).
virtual MESQUITE_EXPORT bool evaluate_with_grad (const MsqMatrix< 3, 3 > &T, double &result, MsqMatrix< 3, 3 > &deriv_wrt_T, MsqError &err)
 Gradient of \(\mu(T)\) with respect to components of T.
virtual MESQUITE_EXPORT bool evaluate_with_hess (const MsqMatrix< 3, 3 > &T, double &result, MsqMatrix< 3, 3 > &deriv_wrt_T, MsqMatrix< 3, 3 > second_wrt_T[6], MsqError &err)
 Hessian of \(\mu(T)\) with respect to components of T.

Detailed Description

\( \frac{|T|^2}{2 det(T)} - 1 \)

Definition at line 43 of file TInverseMeanRatio.hpp.


Constructor & Destructor Documentation

Definition at line 45 of file TInverseMeanRatio.cpp.

{}

Member Function Documentation

bool MBMesquite::TInverseMeanRatio::evaluate ( const MsqMatrix< 2, 2 > &  T,
double &  result,
MsqError err 
) [virtual]

Evaluate \(\mu(T)\).

Parameters:
T2x2 relative measure matrix (typically A W^-1)
resultOutput: value of function
Returns:
false if function cannot be evaluated for given T (e.g. division by zero, etc.), true otherwise.

Reimplemented from MBMesquite::TMetric.

Definition at line 47 of file TInverseMeanRatio.cpp.

References MBMesquite::MsqError::BARRIER_VIOLATED, MBMesquite::barrier_violated_msg, MBMesquite::det(), MBMesquite::TMetricBarrier::invalid_determinant(), MSQ_SETERR, and MBMesquite::sqr_Frobenius().

{
    const double d = det( T );
    if( invalid_determinant( d ) )
    {
        MSQ_SETERR( err )( barrier_violated_msg, MsqError::BARRIER_VIOLATED );
        return false;
    }
    else
    {
        result = sqr_Frobenius( T ) / ( 2 * d ) - 1;
        return true;
    }
}
bool MBMesquite::TInverseMeanRatio::evaluate ( const MsqMatrix< 3, 3 > &  T,
double &  result,
MsqError err 
) [virtual]

Evaluate \(\mu(T)\).

Parameters:
T3x3 relative measure matrix (typically A W^-1)
resultOutput: value of function
Returns:
false if function cannot be evaluated for given T (e.g. division by zero, etc.), true otherwise.

Reimplemented from MBMesquite::TMetric.

Definition at line 127 of file TInverseMeanRatio.cpp.

References MBMesquite::MsqError::BARRIER_VIOLATED, MBMesquite::barrier_violated_msg, MBMesquite::cbrt(), MBMesquite::det(), MBMesquite::TMetricBarrier::invalid_determinant(), MSQ_SETERR, and MBMesquite::sqr_Frobenius().

{
    const double d = det( T );
    if( invalid_determinant( d ) )
    {
        MSQ_SETERR( err )( barrier_violated_msg, MsqError::BARRIER_VIOLATED );
        return false;
    }
    else
    {
        const double det_cbrt = MBMesquite::cbrt( d );
        result                = sqr_Frobenius( T ) / ( 3 * det_cbrt * det_cbrt ) - 1;
        return true;
    }
}
bool MBMesquite::TInverseMeanRatio::evaluate_with_grad ( const MsqMatrix< 2, 2 > &  T,
double &  result,
MsqMatrix< 2, 2 > &  deriv_wrt_T,
MsqError err 
) [virtual]

\( \frac{1}{det(T)} [ T - \frac{|T|^2}{2 det(T)}adj(T) ] \)

Reimplemented from MBMesquite::TMetric.

Definition at line 62 of file TInverseMeanRatio.cpp.

References MBMesquite::MsqError::BARRIER_VIOLATED, MBMesquite::barrier_violated_msg, MBMesquite::det(), MBMesquite::TMetricBarrier::invalid_determinant(), MSQ_SETERR, MBMesquite::sqr_Frobenius(), T, and MBMesquite::transpose_adj().

{
    const double d = det( T );
    if( invalid_determinant( d ) )
    {
        MSQ_SETERR( err )( barrier_violated_msg, MsqError::BARRIER_VIOLATED );
        deriv_wrt_T = MsqMatrix< 2, 2 >( 0.0 );
        return false;
    }
    else
    {
        result      = sqr_Frobenius( T ) / ( 2 * d );
        deriv_wrt_T = transpose_adj( T );
        deriv_wrt_T *= -result;
        deriv_wrt_T += T;
        deriv_wrt_T *= 1.0 / d;
        result -= 1.0;
        return true;
    }
}
bool MBMesquite::TInverseMeanRatio::evaluate_with_grad ( const MsqMatrix< 3, 3 > &  T,
double &  result,
MsqMatrix< 3, 3 > &  deriv_wrt_T,
MsqError err 
) [virtual]

Gradient of \(\mu(T)\) with respect to components of T.

Parameters:
T3x3 relative measure matrix (typically A W^-1)
resultOutput: value of function
deriv_wrt_TOutput: partial deriviatve of \(\mu\) wrt each term of T, evaluated at passed T.

\[\left[\begin{array}{ccc} \frac{\partial\mu}{\partial T_{0,0}} & \frac{\partial\mu}{\partial T_{0,1}} & \frac{\partial\mu}{\partial T_{0,2}} \\ \frac{\partial\mu}{\partial T_{1,0}} & \frac{\partial\mu}{\partial T_{1,1}} & \frac{\partial\mu}{\partial T_{1,2}} \\ \frac{\partial\mu}{\partial T_{2,0}} & \frac{\partial\mu}{\partial T_{2,1}} & \frac{\partial\mu}{\partial T_{2,2}} \end{array}\right]\]

Returns:
false if function cannot be evaluated for given T (e.g. division by zero, etc.), true otherwise.

Reimplemented from MBMesquite::TMetric.

Definition at line 143 of file TInverseMeanRatio.cpp.

References MBMesquite::MsqError::BARRIER_VIOLATED, MBMesquite::barrier_violated_msg, MBMesquite::cbrt(), MBMesquite::det(), MBMesquite::TMetricBarrier::invalid_determinant(), MSQ_SETERR, MBMesquite::sqr_Frobenius(), T, and MBMesquite::transpose_adj().

{
    const double d = det( T );
    if( invalid_determinant( d ) )
    {
        MSQ_SETERR( err )( barrier_violated_msg, MsqError::BARRIER_VIOLATED );
        deriv_wrt_T = MsqMatrix< 3, 3 >( 0.0 );
        return false;
    }

    const double inv_det             = 1.0 / d;
    const double inv_det_cbrt        = MBMesquite::cbrt( inv_det );
    const double inv_3_det_twothirds = inv_det_cbrt * inv_det_cbrt / 3.0;
    const double fnorm               = sqr_Frobenius( T );
    result                           = fnorm * inv_3_det_twothirds - 1;
    deriv_wrt_T                      = transpose_adj( T );
    deriv_wrt_T *= -fnorm * inv_det / 3.0;
    deriv_wrt_T += T;
    deriv_wrt_T *= 2.0 * inv_3_det_twothirds;
    return true;
}
bool MBMesquite::TInverseMeanRatio::evaluate_with_hess ( const MsqMatrix< 2, 2 > &  T,
double &  result,
MsqMatrix< 2, 2 > &  deriv_wrt_T,
MsqMatrix< 2, 2 >  second_wrt_T[3],
MsqError err 
) [virtual]

Hessian of \(\mu(T)\) with respect to components of T.

Parameters:
T3x3 relative measure matrix (typically A W^-1)
resultOutput: value of function
deriv_wrt_TOutput: partial deriviatve of \(\mu\) wrt each term of T, evaluated at passed T.
second_wrt_TOutput: 9x9 matrix of second partial deriviatve of \(\mu\) wrt each term of T, in row-major order. The symmetric matrix is decomposed into 3x3 blocks and only the upper diagonal blocks, in row-major order, are returned.

\[\left[\begin{array}{cc|cc} \frac{\partial^{2}\mu}{\partial T_{0,0}^2} & \frac{\partial^{2}\mu}{\partial T_{0,0}\partial A_{0,1}} & \frac{\partial^{2}\mu}{\partial T_{0,0}\partial A_{1,0}} & \frac{\partial^{2}\mu}{\partial T_{0,0}\partial A_{1,1}} \\ \frac{\partial^{2}\mu}{\partial T_{0,0}\partial A_{0,1}} & \frac{\partial^{2}\mu}{\partial T_{0,1}^2} & \frac{\partial^{2}\mu}{\partial T_{0,1}\partial A_{1,0}} & \frac{\partial^{2}\mu}{\partial T_{0,1}\partial A_{1,1}} \\ \hline & & \frac{\partial^{2}\mu}{\partial T_{1,0}^2} & \frac{\partial^{2}\mu}{\partial T_{1,0}\partial A_{1,1}} \\ & & \frac{\partial^{2}\mu}{\partial T_{1,0}\partial A_{1,1}} & \frac{\partial^{2}\mu}{\partial T_{1,1}^2} \\ \end{array}\right]\]

Returns:
false if function cannot be evaluated for given T (e.g. division by zero, etc.), true otherwise.

Reimplemented from MBMesquite::TMetric.

Definition at line 84 of file TInverseMeanRatio.cpp.

References MBMesquite::MsqError::BARRIER_VIOLATED, MBMesquite::barrier_violated_msg, MBMesquite::det(), MBMesquite::TMetricBarrier::invalid_determinant(), MSQ_SETERR, MBMesquite::outer(), MBMesquite::MsqMatrix< R, C >::row(), MBMesquite::sqr_Frobenius(), T, MBMesquite::transpose(), and MBMesquite::transpose_adj().

{
    const double d = det( T );
    if( invalid_determinant( d ) )
    {
        MSQ_SETERR( err )( barrier_violated_msg, MsqError::BARRIER_VIOLATED );
        dA = d2A[0] = d2A[1] = d2A[2] = MsqMatrix< 2, 2 >( 0.0 );
        return false;
    }
    else
    {
        const double inv_det = 1.0 / d;
        result               = sqr_Frobenius( T ) * 0.5 * inv_det;

        const MsqMatrix< 2, 2 > AT = transpose_adj( T );
        dA                         = AT;
        dA *= -result;
        dA += T;
        dA *= inv_det;

        const double p3                    = -result * inv_det;
        const double p1                    = -2.0 * p3 * inv_det;
        const double p2                    = -inv_det * inv_det;
        const MsqMatrix< 2, 2 > AT_T_op_00 = outer( AT.row( 0 ), T.row( 0 ) );
        const MsqMatrix< 2, 2 > AT_T_op_11 = outer( AT.row( 1 ), T.row( 1 ) );
        d2A[0] = p1 * outer( AT.row( 0 ), AT.row( 0 ) ) + p2 * ( AT_T_op_00 + transpose( AT_T_op_00 ) );
        d2A[1] = p1 * outer( AT.row( 0 ), AT.row( 1 ) ) +
                 p2 * ( outer( AT.row( 0 ), T.row( 1 ) ) + outer( T.row( 0 ), AT.row( 1 ) ) );
        d2A[2] = p1 * outer( AT.row( 1 ), AT.row( 1 ) ) + p2 * ( AT_T_op_11 + transpose( AT_T_op_11 ) );

        d2A[0]( 0, 0 ) += inv_det;
        d2A[0]( 1, 1 ) += inv_det;
        d2A[1]( 0, 1 ) += p3;
        d2A[1]( 1, 0 ) -= p3;
        d2A[2]( 0, 0 ) += inv_det;
        d2A[2]( 1, 1 ) += inv_det;

        result -= 1.0;
        return true;
    }
}
bool MBMesquite::TInverseMeanRatio::evaluate_with_hess ( const MsqMatrix< 3, 3 > &  T,
double &  result,
MsqMatrix< 3, 3 > &  deriv_wrt_T,
MsqMatrix< 3, 3 >  second_wrt_T[6],
MsqError err 
) [virtual]

Hessian of \(\mu(T)\) with respect to components of T.

Parameters:
T3x3 relative measure matrix (typically A W^-1)
resultOutput: value of function
deriv_wrt_TOutput: partial deriviatve of \(\mu\) wrt each term of T, evaluated at passed T.
second_wrt_TOutput: 9x9 matrix of second partial deriviatve of \(\mu\) wrt each term of T, in row-major order. The symmetric matrix is decomposed into 3x3 blocks and only the upper diagonal blocks, in row-major order, are returned.

\[\left[\begin{array}{ccc|ccc|ccc} \frac{\partial^{2}\mu}{\partial T_{0,0}^2} & \frac{\partial^{2}\mu}{\partial T_{0,0}\partial T_{0,1}} & \frac{\partial^{2}\mu}{\partial T_{0,0}\partial T_{0,2}} & \frac{\partial^{2}\mu}{\partial T_{0,0}\partial T_{1,0}} & \frac{\partial^{2}\mu}{\partial T_{0,0}\partial T_{1,1}} & \frac{\partial^{2}\mu}{\partial T_{0,0}\partial T_{1,2}} & \frac{\partial^{2}\mu}{\partial T_{0,0}\partial T_{2,0}} & \frac{\partial^{2}\mu}{\partial T_{0,0}\partial T_{2,1}} & \frac{\partial^{2}\mu}{\partial T_{0,0}\partial T_{2,2}} \\ \frac{\partial^{2}\mu}{\partial T_{0,0}\partial T_{0,1}} & \frac{\partial^{2}\mu}{\partial T_{0,1}^2} & \frac{\partial^{2}\mu}{\partial T_{0,1}\partial T_{0,2}} & \frac{\partial^{2}\mu}{\partial T_{0,1}\partial T_{1,0}} & \frac{\partial^{2}\mu}{\partial T_{0,1}\partial T_{1,1}} & \frac{\partial^{2}\mu}{\partial T_{0,1}\partial T_{1,2}} & \frac{\partial^{2}\mu}{\partial T_{0,1}\partial T_{2,0}} & \frac{\partial^{2}\mu}{\partial T_{0,1}\partial T_{2,1}} & \frac{\partial^{2}\mu}{\partial T_{0,1}\partial T_{2,2}} \\ \frac{\partial^{2}\mu}{\partial T_{0,0}\partial T_{0,2}} & \frac{\partial^{2}\mu}{\partial T_{0,1}\partial T_{0,2}} & \frac{\partial^{2}\mu}{\partial T_{0,2}^2} & \frac{\partial^{2}\mu}{\partial T_{0,2}\partial T_{1,0}} & \frac{\partial^{2}\mu}{\partial T_{0,2}\partial T_{1,1}} & \frac{\partial^{2}\mu}{\partial T_{0,2}\partial T_{1,2}} & \frac{\partial^{2}\mu}{\partial T_{0,2}\partial T_{2,0}} & \frac{\partial^{2}\mu}{\partial T_{0,2}\partial T_{2,1}} & \frac{\partial^{2}\mu}{\partial T_{0,2}\partial T_{2,2}} \\ \hline & & & \frac{\partial^{2}\mu}{\partial T_{1,0}^2} & \frac{\partial^{2}\mu}{\partial T_{1,0}\partial T_{1,1}} & \frac{\partial^{2}\mu}{\partial T_{1,0}\partial T_{1,2}} & \frac{\partial^{2}\mu}{\partial T_{1,0}\partial T_{2,0}} & \frac{\partial^{2}\mu}{\partial T_{1,0}\partial T_{2,1}} & \frac{\partial^{2}\mu}{\partial T_{1,0}\partial T_{2,2}} \\ & & & \frac{\partial^{2}\mu}{\partial T_{1,0}\partial T_{1,1}} & \frac{\partial^{2}\mu}{\partial T_{1,1}^2} & \frac{\partial^{2}\mu}{\partial T_{1,1}\partial T_{1,2}} & \frac{\partial^{2}\mu}{\partial T_{1,1}\partial T_{2,0}} & \frac{\partial^{2}\mu}{\partial T_{1,1}\partial T_{2,1}} & \frac{\partial^{2}\mu}{\partial T_{1,1}\partial T_{2,2}} \\ & & & \frac{\partial^{2}\mu}{\partial T_{1,0}\partial T_{1,2}} & \frac{\partial^{2}\mu}{\partial T_{1,1}\partial T_{1,2}} & \frac{\partial^{2}\mu}{\partial T_{1,2}^2} & \frac{\partial^{2}\mu}{\partial T_{1,2}\partial T_{2,0}} & \frac{\partial^{2}\mu}{\partial T_{1,2}\partial T_{2,1}} & \frac{\partial^{2}\mu}{\partial T_{1,2}\partial T_{2,2}} \\ \hline & & & & & & \frac{\partial^{2}\mu}{\partial T_{2,0}^2} & \frac{\partial^{2}\mu}{\partial T_{2,0}\partial T_{2,1}} & \frac{\partial^{2}\mu}{\partial T_{2,0}\partial T_{2,2}} \\ & & & & & & \frac{\partial^{2}\mu}{\partial T_{2,0}\partial T_{2,1}} & \frac{\partial^{2}\mu}{\partial T_{2,1}^2} & \frac{\partial^{2}\mu}{\partial T_{2,1}\partial T_{2,2}} \\ & & & & & & \frac{\partial^{2}\mu}{\partial T_{2,0}\partial T_{2,2}} & \frac{\partial^{2}\mu}{\partial T_{2,1}\partial T_{2,2}} & \frac{\partial^{2}\mu}{\partial T_{2,2}^2} \\ \end{array}\right]\]

Returns:
false if function cannot be evaluated for given T (e.g. division by zero, etc.), true otherwise.

Reimplemented from MBMesquite::TMetric.

Definition at line 166 of file TInverseMeanRatio.cpp.

References MBMesquite::MsqError::BARRIER_VIOLATED, MBMesquite::barrier_violated_msg, MBMesquite::cbrt(), MBMesquite::det(), MBMesquite::TMetricBarrier::invalid_determinant(), MSQ_SETERR, MBMesquite::outer(), MBMesquite::MsqMatrix< R, C >::row(), MBMesquite::sqr_Frobenius(), T, MBMesquite::transpose(), and MBMesquite::transpose_adj().

{
    const double d = det( T );
    if( invalid_determinant( d ) )
    {
        MSQ_SETERR( err )( barrier_violated_msg, MsqError::BARRIER_VIOLATED );
        dA = MsqMatrix< 3, 3 >( 0.0 );
        return false;
    }

    const double f0 = 1.0 / d;
    const double c  = MBMesquite::cbrt( f0 );
    const double f1 = 1.0 / 3.0 * c * c;
    const double f2 = sqr_Frobenius( T );
    result          = f1 * f2;

    const double f3 = 2 * f1;
    const double f4 = result * ( 10.0 / 9.0 ) * f0 * f0;
    const double f5 = ( 1.0 / 3.0 ) * f0 * f3;
    const double f6 = 2 * f5;
    const double f7 = f2 * f5;

    const MsqMatrix< 3, 3 > AT = transpose_adj( T );
    dA                         = AT;
    dA *= ( -1.0 / 3.0 ) * f0 * f2;
    dA += T;
    dA *= f3;

    MsqMatrix< 3, 3 > op;
    int i    = 0;
    double s = 1;
    for( int r = 0; r < 3; ++r )
    {
        d2A[i] = outer( AT.row( r ), AT.row( r ) );
        d2A[i] *= f4;
        op = outer( AT.row( r ), T.row( r ) );
        op += transpose( op );
        op *= f6;
        d2A[i] -= op;

        d2A[i]( 0, 0 ) += f3;
        d2A[i]( 1, 1 ) += f3;
        d2A[i]( 2, 2 ) += f3;

        ++i;

        for( int cc = r + 1; cc < 3; ++cc )
        {
            d2A[i] = outer( AT.row( r ), AT.row( cc ) );
            d2A[i] *= f4;
            op = outer( AT.row( r ), T.row( cc ) );
            op += outer( T.row( r ), AT.row( cc ) );
            op *= f6;
            d2A[i] -= op;

            MsqMatrix< 1, 3 > rt = T.row( 3 - r - cc );
            rt *= s * f7;
            d2A[i]( 0, 1 ) -= rt( 0, 2 );
            d2A[i]( 0, 2 ) += rt( 0, 1 );
            d2A[i]( 1, 0 ) += rt( 0, 2 );
            d2A[i]( 1, 2 ) -= rt( 0, 0 );
            d2A[i]( 2, 0 ) -= rt( 0, 1 );
            d2A[i]( 2, 1 ) += rt( 0, 0 );

            ++i;
            s = -s;
        }
    }

    result -= 1.0;
    return true;
}
std::string MBMesquite::TInverseMeanRatio::get_name ( ) const [virtual]

Reimplemented from MBMesquite::TMetricBarrier.

Definition at line 40 of file TInverseMeanRatio.cpp.

{
    return "TInverseMeanRatio";
}

List of all members.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines