MOAB: Mesh Oriented datABase  (version 5.4.1)
MBMesquite::TShapeSize2DB2 Class Reference

#include <TShapeSize2DB2.hpp>

+ Inheritance diagram for MBMesquite::TShapeSize2DB2:
+ Collaboration diagram for MBMesquite::TShapeSize2DB2:

Public Member Functions

virtual MESQUITE_EXPORT ~TShapeSize2DB2 ()
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)
 Gradient of \(\mu(T)\) with respect to components of T.
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.

Detailed Description

\( \frac{ (|T|^2 - 2 sqrt(|T|^2 + 2 \tau) + 2) }{ (2 \tau) } \)

Definition at line 42 of file TShapeSize2DB2.hpp.


Constructor & Destructor Documentation

Definition at line 48 of file TShapeSize2DB2.cpp.

{}

Member Function Documentation

bool MBMesquite::TShapeSize2DB2::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 50 of file TShapeSize2DB2.cpp.

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

{
    const double two_det = 2.0 * det( T );
    if( invalid_determinant( two_det ) )
    {  // barrier
        MSQ_SETERR( err )( barrier_violated_msg, MsqError::BARRIER_VIOLATED );
        return false;
    }

    const double frob_sqr = sqr_Frobenius( T );
    result                = ( frob_sqr - 2.0 * sqrt( frob_sqr + two_det ) + 2.0 ) / two_det;
    return true;
}
bool MBMesquite::TShapeSize2DB2::evaluate_with_grad ( const MsqMatrix< 2, 2 > &  T,
double &  result,
MsqMatrix< 2, 2 > &  deriv_wrt_T,
MsqError err 
) [virtual]

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

Parameters:
T2x2 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}{cc} \frac{\partial\mu}{\partial T_{0,0}} & \frac{\partial\mu}{\partial T_{0,1}} \\ \frac{\partial\mu}{\partial T_{1,0}} & \frac{\partial\mu}{\partial T_{1,1}} \\ \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 64 of file TShapeSize2DB2.cpp.

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

{
    const double d = det( T );
    if( invalid_determinant( d ) )
    {  // barrier
        MSQ_SETERR( err )( barrier_violated_msg, MsqError::BARRIER_VIOLATED );
        return false;
    }
    const double frob_sqr = sqr_Frobenius( T );
    const double psi      = sqrt( frob_sqr + 2.0 * det( T ) );
    const double v        = frob_sqr - 2.0 * psi + 2.0;
    result                = v / ( 2 * d );

    // deriv of V wrt T
    MsqMatrix< 2, 2 > adjt = transpose_adj( T );
    MsqMatrix< 2, 2 > v_wrt_T( T );
    if( psi > 1e-50 )
    {
        v_wrt_T *= ( 1.0 - 1.0 / psi );
        v_wrt_T -= 1.0 / psi * adjt;
        v_wrt_T *= 2;
    }
    else
    {
        std::cout << "Warning: Division by zero avoided in TShapeSize2DB2::evaluate_with_grad()" << std::endl;
    }

    // deriv of mu wrt T
    deriv_wrt_T = v_wrt_T;
    deriv_wrt_T *= 0.5 / d;
    deriv_wrt_T -= v / ( 2 * d * d ) * adjt;

    return true;
}
bool MBMesquite::TShapeSize2DB2::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 102 of file TShapeSize2DB2.cpp.

References MBMesquite::MsqError::BARRIER_VIOLATED, MBMesquite::barrier_violated_msg, MBMesquite::det(), MBMesquite::TMetricBarrier::invalid_determinant(), MSQ_SETERR, MBMesquite::pluseq_scaled_2nd_deriv_of_det(), MBMesquite::pluseq_scaled_I(), MBMesquite::pluseq_scaled_outer_product(), MBMesquite::pluseq_scaled_sum_outer_product(), MBMesquite::sqr_Frobenius(), T, MBMesquite::trace(), and MBMesquite::transpose_adj().

{
    const double d = det( T );
    if( invalid_determinant( d ) )
    {  // barrier
        MSQ_SETERR( err )( barrier_violated_msg, MsqError::BARRIER_VIOLATED );
        return false;
    }
    const double frob_sqr = sqr_Frobenius( T );
    const double psi      = sqrt( frob_sqr + 2.0 * det( T ) );
    const double v        = frob_sqr - 2.0 * psi + 2.0;
    result                = v / ( 2 * d );

    // deriv of V wrt T
    MsqMatrix< 2, 2 > adjt = transpose_adj( T );
    MsqMatrix< 2, 2 > v_wrt_T( T );
    if( psi > 1e-50 )
    {
        v_wrt_T *= ( 1.0 - 1.0 / psi );
        v_wrt_T -= 1.0 / psi * adjt;
        v_wrt_T *= 2;
    }
    else
    {
        std::cout << "Warning: Division by zero avoided in TShapeSize2DB2::evaluate_with_hess()" << std::endl;
    }

    // deriv of mu wrt T
    deriv_wrt_T = v_wrt_T;
    deriv_wrt_T *= 0.5 / d;
    deriv_wrt_T -= v / ( 2 * d * d ) * adjt;

    // second of V wrt T
    const double s    = T( 0, 1 ) - T( 1, 0 );
    const double tr   = trace( T );
    const double f    = -2.0 / ( psi * psi * psi );
    second[0]( 0, 0 ) = second[1]( 0, 1 ) = second[2]( 1, 1 ) = f * s * s;
    second[0]( 0, 1 ) = second[0]( 1, 0 ) = second[1]( 1, 1 ) = -f * s * tr;
    second[1]( 0, 0 ) = second[2]( 0, 1 ) = second[2]( 1, 0 ) = f * s * tr;
    second[0]( 1, 1 ) = second[2]( 0, 0 ) = -( second[1]( 1, 0 ) = -f * tr * tr );
    pluseq_scaled_I( second, 2 );

    // second of mu wrt T
    const double x = 1.0 / ( 2 * d );
    second[0] *= x;
    second[1] *= x;
    second[2] *= x;
    pluseq_scaled_2nd_deriv_of_det( second, v / ( -2 * d * d ) );
    pluseq_scaled_outer_product( second, v / ( d * d * d ), adjt );
    pluseq_scaled_sum_outer_product( second, -1 / ( 2 * d * d ), v_wrt_T, adjt );

    return true;
}
std::string MBMesquite::TShapeSize2DB2::get_name ( ) const [virtual]

Reimplemented from MBMesquite::TMetricBarrier.

Definition at line 43 of file TShapeSize2DB2.cpp.

{
    return "TShapeSize2DB2";
}

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