MOAB: Mesh Oriented datABase
(version 5.4.1)
|
#include <TShapeSize3DB4.hpp>
Public Member Functions | |
MESQUITE_EXPORT | TShapeSize3DB4 (double gamma=2.0) |
virtual MESQUITE_EXPORT | ~TShapeSize3DB4 () |
virtual MESQUITE_EXPORT std::string | get_name () const |
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 Attributes | |
double | mGamma |
|T|^3 / (3 * sqrt(3) * tau) - 1 + gamma * (tau + 1/tau - 2)
Definition at line 42 of file TShapeSize3DB4.hpp.
MESQUITE_EXPORT MBMesquite::TShapeSize3DB4::TShapeSize3DB4 | ( | double | gamma = 2.0 | ) | [inline] |
Definition at line 49 of file TShapeSize3DB4.hpp.
: mGamma( gamma ) {}
MBMesquite::TShapeSize3DB4::~TShapeSize3DB4 | ( | ) | [virtual] |
Definition at line 47 of file TShapeSize3DB4.cpp.
{}
bool MBMesquite::TShapeSize3DB4::evaluate | ( | const MsqMatrix< 3, 3 > & | T, |
double & | result, | ||
MsqError & | err | ||
) | [virtual] |
Evaluate \(\mu(T)\).
T | 3x3 relative measure matrix (typically A W^-1) |
result | Output: value of function |
Reimplemented from MBMesquite::TMetric.
Definition at line 49 of file TShapeSize3DB4.cpp.
References MBMesquite::MsqError::BARRIER_VIOLATED, MBMesquite::barrier_violated_msg, MBMesquite::det(), MBMesquite::Frobenius(), MBMesquite::TMetricBarrier::invalid_determinant(), mGamma, MSQ_SETERR, and MBMesquite::MSQ_SQRT_THREE.
{ const double tau = det( T ); if( invalid_determinant( tau ) ) { // barrier MSQ_SETERR( err )( barrier_violated_msg, MsqError::BARRIER_VIOLATED ); return false; } const double norm = Frobenius( T ); result = norm * norm * norm / ( 3 * MSQ_SQRT_THREE * tau ) - 1 + mGamma * ( tau + 1 / tau - 2 ); return true; }
bool MBMesquite::TShapeSize3DB4::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.
T | 3x3 relative measure matrix (typically A W^-1) |
result | Output: value of function |
deriv_wrt_T | Output: 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]\] |
Reimplemented from MBMesquite::TMetric.
Definition at line 63 of file TShapeSize3DB4.cpp.
References MBMesquite::MsqError::BARRIER_VIOLATED, MBMesquite::barrier_violated_msg, MBMesquite::det(), MBMesquite::Frobenius(), MBMesquite::TMetricBarrier::invalid_determinant(), mGamma, MSQ_SETERR, MBMesquite::MSQ_SQRT_THREE, T, and MBMesquite::transpose_adj().
{ const double tau = det( T ); if( invalid_determinant( tau ) ) { // barrier MSQ_SETERR( err )( barrier_violated_msg, MsqError::BARRIER_VIOLATED ); return false; } const double norm = Frobenius( T ); const double f = norm * norm / 3.0; const double g = norm / ( MSQ_SQRT_THREE * tau ); const double inv_tau = 1.0 / tau; result = f * g - 1 + mGamma * ( tau + inv_tau - 2 ); deriv = g * T; deriv += ( mGamma * ( 1 - inv_tau * inv_tau ) - f * g * inv_tau ) * transpose_adj( T ); return true; }
bool MBMesquite::TShapeSize3DB4::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.
T | 3x3 relative measure matrix (typically A W^-1) |
result | Output: value of function |
deriv_wrt_T | Output: partial deriviatve of \(\mu\) wrt each term of T, evaluated at passed T. |
second_wrt_T | Output: 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]\] |
Reimplemented from MBMesquite::TMetric.
Definition at line 87 of file TShapeSize3DB4.cpp.
References MBMesquite::MsqError::BARRIER_VIOLATED, MBMesquite::barrier_violated_msg, MBMesquite::det(), MBMesquite::Frobenius(), MBMesquite::TMetricBarrier::invalid_determinant(), mGamma, 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().
{ const double tau = det( T ); if( invalid_determinant( tau ) ) { // barrier MSQ_SETERR( err )( barrier_violated_msg, MsqError::BARRIER_VIOLATED ); return false; } const double norm = Frobenius( T ); const double f = norm * norm / 3.0; const double h = 1 / ( MSQ_SQRT_THREE * tau ); const double g = norm * h; const double inv_tau = 1.0 / tau; result = f * g - 1 + mGamma * ( tau + inv_tau - 2 ); const double g1 = mGamma * ( 1 - inv_tau * inv_tau ); const MsqMatrix< 3, 3 > adjt = transpose_adj( T ); deriv = g * T; deriv += ( g1 - f * g * inv_tau ) * adjt; if( norm > 1e-50 ) { const double inv_norm = 1 / norm; set_scaled_outer_product( second, h * inv_norm, T ); pluseq_scaled_I( second, norm * h ); pluseq_scaled_2nd_deriv_of_det( second, g1 - f * g * inv_tau, T ); pluseq_scaled_outer_product( second, ( f * g + mGamma * inv_tau ) * 2 * inv_tau * inv_tau, adjt ); pluseq_scaled_sum_outer_product( second, -g * inv_tau, T, adjt ); } else { std::cout << "Warning: Division by zero avoided in TShapeSize3DB4::evaluate_with_hess()" << std::endl; } return true; }
std::string MBMesquite::TShapeSize3DB4::get_name | ( | ) | const [virtual] |
Reimplemented from MBMesquite::TMetricBarrier.
Definition at line 42 of file TShapeSize3DB4.cpp.
{ return "TShapeSize3DB4"; }
double MBMesquite::TShapeSize3DB4::mGamma [private] |
Definition at line 45 of file TShapeSize3DB4.hpp.
Referenced by evaluate(), evaluate_with_grad(), and evaluate_with_hess().