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

#include <TShapeSize2DNB2.hpp>

+ Inheritance diagram for MBMesquite::TShapeSize2DNB2:
+ Collaboration diagram for MBMesquite::TShapeSize2DNB2:

Public Member Functions

virtual MESQUITE_EXPORT ~TShapeSize2DNB2 ()
virtual MESQUITE_EXPORT std::string get_name () const
virtual MESQUITE_EXPORT bool evaluate (const MsqMatrix< 2, 2 > &T, double &result, MsqError &err)
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

3.2.4: \( \frac{|T|^2+2}{2\psi(T)} - 1 \)

Definition at line 42 of file TShapeSize2DNB2.hpp.


Constructor & Destructor Documentation

Definition at line 45 of file TShapeSize2DNB2.cpp.

{}

Member Function Documentation

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

\( \mu(T) = \frac{|T|^2+2}{2\psi(T)} - 1 \) \( \psi(T) = \sqrt{|T|^2 + 2 \tau}\) \( \tau = det(T) \)

Reimplemented from MBMesquite::TMetric.

Definition at line 51 of file TShapeSize2DNB2.cpp.

References MBMesquite::det(), MBMesquite::divide(), and MBMesquite::sqr_Frobenius().

{
    double frob_sqr = sqr_Frobenius( T );
    double psi      = sqrt( frob_sqr + 2.0 * det( T ) );

    double a = 1e-12;
    while( !MBMesquite::divide( frob_sqr + 2, 2 * psi, result ) )
    {
        MsqMatrix< 2, 2 > Tdelta( T );
        Tdelta( 0, 0 ) += a;
        Tdelta( 1, 1 ) += a;
        a *= 2.0;
        frob_sqr = sqr_Frobenius( Tdelta );
        psi      = sqrt( frob_sqr + 2.0 * det( Tdelta ) );
        if( psi > 1e-50 ) result = ( frob_sqr + 2 ) / 2 * psi;
    }

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

References MBMesquite::det(), MBMesquite::divide(), MBMesquite::sqr_Frobenius(), and MBMesquite::transpose_adj().

{
    double frob_sqr = sqr_Frobenius( T );
    double psi      = sqrt( frob_sqr + 2.0 * det( T ) );

    double a = 1e-12;
    while( !MBMesquite::divide( frob_sqr + 2, 2 * psi, result ) )
    {
        MsqMatrix< 2, 2 > Tdelta( T );
        Tdelta( 0, 0 ) += a;
        Tdelta( 1, 1 ) += a;
        a *= 2.0;
        frob_sqr = sqr_Frobenius( Tdelta );
        psi      = sqrt( frob_sqr + 2.0 * det( Tdelta ) );
        if( psi > 1e-50 ) result = ( frob_sqr + 2 ) / 2 * psi;
    }

    // MsqMatrix<2,2> d_psi = 1.0/psi * (T + transpose_adj(T));
    // deriv_wrt_T = (1.0/psi) * (T - result * d_psi);
    if( psi > 1e-50 )
    {
        const double f = result / ( psi * psi );
        deriv_wrt_T    = transpose_adj( T );
        deriv_wrt_T *= -f;
        deriv_wrt_T += ( 1.0 / psi - f ) * T;
    }

    result -= 1.0;

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

References MBMesquite::det(), MBMesquite::divide(), MBMesquite::pluseq_scaled_I(), MBMesquite::pluseq_scaled_outer_product(), MBMesquite::pluseq_scaled_sum_outer_product(), MBMesquite::set_scaled_2nd_deriv_wrt_psi(), MBMesquite::sqr_Frobenius(), T, and MBMesquite::transpose_adj().

{
    double frob_sqr = sqr_Frobenius( T );
    double psi      = sqrt( frob_sqr + 2.0 * det( T ) );

    double a = 1e-12;
    while( !MBMesquite::divide( frob_sqr + 2, 2 * psi, result ) )
    {
        MsqMatrix< 2, 2 > Tdelta( T );
        Tdelta( 0, 0 ) += a;
        Tdelta( 1, 1 ) += a;
        a *= 2.0;
        frob_sqr = sqr_Frobenius( Tdelta );
        psi      = sqrt( frob_sqr + 2.0 * det( Tdelta ) );
        if( psi > 1e-50 ) result = ( frob_sqr + 2 ) / 2 * psi;
    }

    const double inv_psi    = 1.0 / psi;
    MsqMatrix< 2, 2 > d_psi = T + transpose_adj( T );
    d_psi *= inv_psi;

    deriv_wrt_T = d_psi;
    deriv_wrt_T *= -result;
    deriv_wrt_T += T;
    deriv_wrt_T *= inv_psi;

    set_scaled_2nd_deriv_wrt_psi( second, -result * inv_psi, psi, T );
    pluseq_scaled_outer_product( second, 2 * result * inv_psi * inv_psi, d_psi );
    pluseq_scaled_sum_outer_product( second, -inv_psi * inv_psi, d_psi, T );
    pluseq_scaled_I( second, inv_psi );

    result -= 1.0;

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

Implements MBMesquite::TMetric.

Definition at line 40 of file TShapeSize2DNB2.cpp.

{
    return "TShapeSize2DNB2";
}

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