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

Composite untangle metric. More...

#include <TUntangleMu.hpp>

+ Inheritance diagram for MBMesquite::TUntangleMu:
+ Collaboration diagram for MBMesquite::TUntangleMu:

Public Member Functions

 TUntangleMu (TMetric *base, double sigma=1.0)
 TUntangleMu (TMetric *base, double sigma, double epsilon)
virtual MESQUITE_EXPORT ~TUntangleMu ()
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.
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.

Private Member Functions

template<unsigned D>
bool eval (const MsqMatrix< D, D > &T, double &result, MsqError &err)
template<unsigned D>
bool grad (const MsqMatrix< D, D > &T, double &result, MsqMatrix< D, D > &first, MsqError &err)
template<unsigned D>
bool hess (const MsqMatrix< D, D > &T, double &result, MsqMatrix< D, D > &first, MsqMatrix< D, D > *second, MsqError &err)

Private Attributes

TMetricmBaseMetric
double mConstant

Detailed Description

Composite untangle metric.

This metric should be combined with TRel2DSize or TRel2DShapeSize to produce a concrete untangle metric.

\( \mu^\prime(T) = \frac{1}{8}(|d| - d)^3 \) \( d(T) = \sigma - \epsilon - \mu(T()) \)

Definition at line 50 of file TUntangleMu.hpp.


Constructor & Destructor Documentation

MBMesquite::TUntangleMu::TUntangleMu ( TMetric base,
double  sigma = 1.0 
) [inline]

Definition at line 57 of file TUntangleMu.hpp.

        : mBaseMetric( base ), mConstant( 0.99 * sigma ) /* default epsilon is 0.01*sigma */
    {
    }
MBMesquite::TUntangleMu::TUntangleMu ( TMetric base,
double  sigma,
double  epsilon 
) [inline]

Definition at line 62 of file TUntangleMu.hpp.

: mBaseMetric( base ), mConstant( sigma - epsilon ) {}

Definition at line 42 of file TUntangleMu.cpp.

{}

Member Function Documentation

template<unsigned DIM>
bool MBMesquite::TUntangleMu::eval ( const MsqMatrix< DIM, DIM > &  T,
double &  result,
MsqError err 
) [inline, private]

Definition at line 50 of file TUntangleMu.cpp.

References MBMesquite::TMetric::evaluate(), mBaseMetric, mConstant, and MSQ_CHKERR.

{
    bool valid = mBaseMetric->evaluate( T, result, err );
    if( MSQ_CHKERR( err ) || !valid ) return false;

    const double d = mConstant - result;
    const double s = fabs( d ) - d;
    result         = 0.125 * s * s * s;
    return true;
}
virtual MESQUITE_EXPORT bool MBMesquite::TUntangleMu::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.

virtual MESQUITE_EXPORT bool MBMesquite::TUntangleMu::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.

virtual MESQUITE_EXPORT bool MBMesquite::TUntangleMu::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.

virtual MESQUITE_EXPORT bool MBMesquite::TUntangleMu::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.

virtual MESQUITE_EXPORT bool MBMesquite::TUntangleMu::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.

virtual MESQUITE_EXPORT bool MBMesquite::TUntangleMu::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.

std::string MBMesquite::TUntangleMu::get_name ( ) const [virtual]

Implements MBMesquite::TMetric.

Definition at line 44 of file TUntangleMu.cpp.

References MBMesquite::TMetric::get_name(), and mBaseMetric.

{
    return "untangle(" + mBaseMetric->get_name() + ")";
}
template<unsigned DIM>
bool MBMesquite::TUntangleMu::grad ( const MsqMatrix< DIM, DIM > &  T,
double &  result,
MsqMatrix< DIM, DIM > &  first,
MsqError err 
) [inline, private]

Definition at line 62 of file TUntangleMu.cpp.

References MBMesquite::TMetric::evaluate_with_grad(), mBaseMetric, mConstant, and MSQ_CHKERR.

{
    bool valid = mBaseMetric->evaluate_with_grad( T, result, deriv_wrt_T, err );
    if( MSQ_CHKERR( err ) || !valid ) return false;

    if( mConstant < result )
    {
        const double s = result - mConstant;
        result         = s * s * s;
        deriv_wrt_T *= 3 * s * s;
    }
    else
    {
        result      = 0;
        deriv_wrt_T = MsqMatrix< DIM, DIM >( 0.0 );
    }

    return true;
}
template<unsigned DIM>
bool MBMesquite::TUntangleMu::hess ( const MsqMatrix< DIM, DIM > &  T,
double &  result,
MsqMatrix< DIM, DIM > &  first,
MsqMatrix< DIM, DIM > *  second,
MsqError err 
) [inline, private]

Definition at line 86 of file TUntangleMu.cpp.

References MBMesquite::TMetric::evaluate_with_hess(), MBMesquite::hess_scale(), mBaseMetric, mConstant, MSQ_CHKERR, MBMesquite::pluseq_scaled_outer_product(), and MBMesquite::set_scaled_I().

{
    bool valid = mBaseMetric->evaluate_with_hess( T, result, deriv_wrt_T, second_wrt_T, err );
    if( MSQ_CHKERR( err ) || !valid ) return false;

    if( mConstant < result )
    {
        const double s = result - mConstant;
        result         = s * s * s;
        hess_scale( second_wrt_T, 3 * s * s );
        pluseq_scaled_outer_product( second_wrt_T, 6 * s, deriv_wrt_T );
        deriv_wrt_T *= 3 * s * s;
    }
    else
    {
        result      = 0;
        deriv_wrt_T = MsqMatrix< DIM, DIM >( 0.0 );
        set_scaled_I( second_wrt_T, 0.0 );  // zero everything
    }

    return true;
}

Member Data Documentation

Definition at line 53 of file TUntangleMu.hpp.

Referenced by eval(), get_name(), grad(), and hess().

Definition at line 54 of file TUntangleMu.hpp.

Referenced by eval(), grad(), and hess().

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