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

#include <TShapeSize2DNB1.hpp>

+ Inheritance diagram for MBMesquite::TShapeSize2DNB1:
+ Collaboration diagram for MBMesquite::TShapeSize2DNB1:

Public Member Functions

virtual MESQUITE_EXPORT ~TShapeSize2DNB1 ()
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

|T|^2 - 2*sqrt(|T|^2 + 2*det(T))+2

Definition at line 42 of file TShapeSize2DNB1.hpp.


Constructor & Destructor Documentation

Definition at line 47 of file TShapeSize2DNB1.cpp.

{}

Member Function Documentation

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

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

Reimplemented from MBMesquite::TMetric.

Definition at line 53 of file TShapeSize2DNB1.cpp.

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

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

    MsqMatrix< 2, 2 > Tdelta( T );
    while( fabs( psi ) < DBL_EPSILON )
    {
        Tdelta( 0, 0 ) += 1e-12;
        Tdelta( 1, 1 ) += 1e-12;
        frob_sqr = sqr_Frobenius( Tdelta );
        psi      = sqrt( frob_sqr + 2.0 * det( Tdelta ) );
    }

    result = frob_sqr - 2.0 * psi + 2.0;
    return true;
}
bool MBMesquite::TShapeSize2DNB1::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 71 of file TShapeSize2DNB1.cpp.

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

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

    MsqMatrix< 2, 2 > Tdelta( T );
    while( fabs( psi ) < DBL_EPSILON )
    {
        Tdelta( 0, 0 ) += 1e-12;
        Tdelta( 1, 1 ) += 1e-12;
        frob_sqr = sqr_Frobenius( Tdelta );
        psi      = sqrt( frob_sqr + 2.0 * det( Tdelta ) );
    }

    result = frob_sqr - 2.0 * psi + 2.0;

    deriv_wrt_T = T;
    if( psi > 1e-50 )
    {
        deriv_wrt_T *= ( 1.0 - 1.0 / psi );
        deriv_wrt_T -= 1.0 / psi * transpose_adj( T );
        deriv_wrt_T *= 2;
    }
    else
    {
        std::cout << "Warning: Division by zero avoided in TShapeSize2DNB2::evaluate_with_grad()" << std::endl;
    }

    return true;
}
bool MBMesquite::TShapeSize2DNB1::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 TShapeSize2DNB1.cpp.

References MBMesquite::det(), MBMesquite::pluseq_scaled_I(), 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 ) );

    MsqMatrix< 2, 2 > Tdelta( T );
    while( fabs( psi ) < DBL_EPSILON )
    {
        Tdelta( 0, 0 ) += 1e-12;
        Tdelta( 1, 1 ) += 1e-12;
        frob_sqr = sqr_Frobenius( Tdelta );
        psi      = sqrt( frob_sqr + 2.0 * det( Tdelta ) );
    }

    result = frob_sqr - 2.0 * psi + 2.0;

    deriv_wrt_T = T;
    if( psi > 1e-50 )
    {
        deriv_wrt_T *= ( 1.0 - 1.0 / psi );
        deriv_wrt_T -= 1.0 / psi * transpose_adj( T );
        deriv_wrt_T *= 2;
    }
    else
    {
        std::cout << "Warning: Division by zero avoided in TShapeSize2DNB2::evaluate_with_hess()" << std::endl;
    }

    set_scaled_2nd_deriv_wrt_psi( second, -2.0, psi, T );
    pluseq_scaled_I( second, 2 );

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

Implements MBMesquite::TMetric.

Definition at line 42 of file TShapeSize2DNB1.cpp.

{
    return "TShapeSize2DNB1";
}

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