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

Metric sensitive to shape. More...

#include <TShapeB1.hpp>

+ Inheritance diagram for MBMesquite::TShapeB1:
+ Collaboration diagram for MBMesquite::TShapeB1:

Public Member Functions

virtual MESQUITE_EXPORT std::string get_name () const
virtual MESQUITE_EXPORT ~TShapeB1 ()
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)
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

Metric sensitive to shape.

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

For 3D: \( \frac{ |T|^3 }{ 3 \sqrt{3} det(T) } - 1 \)

Definition at line 47 of file TShapeB1.hpp.


Constructor & Destructor Documentation

Definition at line 46 of file TShapeB1.cpp.

{}

Member Function Documentation

bool MBMesquite::TShapeB1::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 48 of file TShapeB1.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 ) )
    {  // barrier
        MSQ_SETERR( err )( barrier_violated_msg, MsqError::BARRIER_VIOLATED );
        return false;
    }

    result = 0.5 * sqr_Frobenius( T ) / d - 1;
    return true;
}
bool MBMesquite::TShapeB1::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 121 of file TShapeB1.cpp.

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

{
    double f   = Frobenius( T );
    double d   = det( T );
    double den = 3 * MSQ_SQRT_THREE * d;

    if( invalid_determinant( d ) )
    {
        MSQ_SETERR( err )( barrier_violated_msg, MsqError::BARRIER_VIOLATED );
        return false;
    }
    result = ( f * f * f ) / den - 1.0;
    return true;
}
bool MBMesquite::TShapeB1::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 61 of file TShapeB1.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 ) )
    {  // barrier
        MSQ_SETERR( err )( barrier_violated_msg, MsqError::BARRIER_VIOLATED );
        return false;
    }

    double inv_d = 1.0 / d;
    result       = 0.5 * sqr_Frobenius( T ) * inv_d;
    deriv_wrt_T  = T;
    deriv_wrt_T -= result * transpose_adj( T );
    deriv_wrt_T *= inv_d;

    result -= 1.0;
    return true;
}
bool MBMesquite::TShapeB1::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 136 of file TShapeB1.cpp.

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

{
    double d = det( T );
    if( invalid_determinant( d ) )
    {
        MSQ_SETERR( err )( barrier_violated_msg, MsqError::BARRIER_VIOLATED );
        return false;
    }

    double norm      = Frobenius( T );
    double den       = 1.0 / ( 3 * MSQ_SQRT_THREE * d );
    double norm_cube = norm * norm * norm;
    result           = norm_cube * den - 1.0;
    wrt_T            = T;
    wrt_T *= 3 * norm * den;
    wrt_T -= norm_cube * den / d * transpose_adj( T );
    return true;
}
bool MBMesquite::TShapeB1::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]

\( \frac{\partial^2 \mu}{\partial T^2} = \frac{1}{\tau} I_4 - \frac{1}{\tau^2} \left( T \otimes \frac{\partial \tau}{\partial T} + \frac{\partial \tau}{\partial T} \otimes T \right) + \frac{|T|^2}{\tau^3} \left( \frac{\partial \tau}{\partial T} \otimes \frac{\partial \tau}{\partial T} \right) - \frac{|T|^2}{2 \tau^3} \frac{\partial^2 \tau}{\partial T^2} \)

Reimplemented from MBMesquite::TMetric.

Definition at line 91 of file TShapeB1.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_sum_outer_product(), MBMesquite::set_scaled_outer_product(), MBMesquite::sqr_Frobenius(), T, 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;
    }

    double inv_d                 = 1.0 / d;
    double f1                    = sqr_Frobenius( T ) * inv_d;
    result                       = 0.5 * f1;
    const MsqMatrix< 2, 2 > adjt = transpose_adj( T );
    deriv_wrt_T                  = T;
    deriv_wrt_T -= result * adjt;
    deriv_wrt_T *= inv_d;

    set_scaled_outer_product( second_wrt_T, f1 * inv_d * inv_d, adjt );
    pluseq_scaled_sum_outer_product( second_wrt_T, -inv_d * inv_d, T, adjt );
    pluseq_scaled_I( second_wrt_T, inv_d );
    pluseq_scaled_2nd_deriv_of_det( second_wrt_T, -result * inv_d );

    result -= 1.0;
    return true;
}
bool MBMesquite::TShapeB1::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 155 of file TShapeB1.cpp.

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

{
    double d = det( T );
    if( invalid_determinant( d ) )
    {
        MSQ_SETERR( err )( barrier_violated_msg, MsqError::BARRIER_VIOLATED );
        return false;
    }

    double id              = 1.0 / d;
    double norm            = Frobenius( T );
    double den             = 1.0 / ( 3 * MSQ_SQRT_THREE * d );
    double norm_cube       = norm * norm * norm;
    result                 = norm_cube * den - 1.0;
    MsqMatrix< 3, 3 > adjt = transpose_adj( T );
    deriv_wrt_T            = T;
    deriv_wrt_T *= 3 * norm * den;
    deriv_wrt_T -= norm_cube * den * id * transpose_adj( T );

    set_scaled_outer_product( second_wrt_T, 3 * den / norm, T );
    pluseq_scaled_I( second_wrt_T, 3 * norm * den );
    pluseq_scaled_2nd_deriv_of_det( second_wrt_T, -den * norm_cube * id, T );
    pluseq_scaled_outer_product( second_wrt_T, 2 * den * norm_cube * id * id, adjt );
    pluseq_scaled_sum_outer_product( second_wrt_T, -3 * norm * den * id, T, adjt );

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

Reimplemented from MBMesquite::TMetricBarrier.

Definition at line 41 of file TShapeB1.cpp.

{
    return "TShapeB1";
}

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