MOAB: Mesh Oriented datABase
(version 5.4.1)
|
Raises a single quality metrics (qMetric1) to an arbitrary power (a double value, scaleAlpha) for two- and three-diminsional elements. More...
#include <PowerQualityMetric.hpp>
Public Member Functions | |
PowerQualityMetric (QualityMetric *qm1, double pow_double) | |
virtual | ~PowerQualityMetric () |
MetricType | get_metric_type () const |
std::string | get_name () const |
int | get_negate_flag () const |
1 if metric should be minimized, -1 if metric should be maximized. | |
QualityMetric * | get_metric () const |
virtual void | get_evaluations (PatchData &pd, std::vector< size_t > &handles, bool free_vertices_only, MsqError &err) |
Get locations at which metric can be evaluated. | |
virtual bool | evaluate (PatchData &pd, size_t handle, double &value, MsqError &err) |
Get metric value at a logical location in the patch. | |
virtual bool | evaluate_with_indices (PatchData &pd, size_t handle, double &value, std::vector< size_t > &indices, MsqError &err) |
Get metric value at a logical location in the patch. | |
virtual bool | evaluate_with_gradient (PatchData &pd, size_t handle, double &value, std::vector< size_t > &indices, std::vector< Vector3D > &gradient, MsqError &err) |
Get metric value and gradient at a logical location in the patch. | |
virtual bool | evaluate_with_Hessian (PatchData &pd, size_t handle, double &value, std::vector< size_t > &indices, std::vector< Vector3D > &gradient, std::vector< Matrix3D > &Hessian, MsqError &err) |
Get metric value and deravitives at a logical location in the patch. | |
Private Attributes | |
QualityMetric & | mMetric |
MBMesquite::Exponent | mPower |
Raises a single quality metrics (qMetric1) to an arbitrary power (a double value, scaleAlpha) for two- and three-diminsional elements.
Definition at line 55 of file PowerQualityMetric.hpp.
PowerQualityMetric::PowerQualityMetric | ( | QualityMetric * | qm1, |
double | pow_double | ||
) |
Ensures that qm1 is not NULL. If qm1 is only valid on a certain feasible, then the composite metric has the same constraint. The composite metric also has the same negate flag as qm1.
Definition at line 40 of file PowerQualityMetric.cpp.
PowerQualityMetric::~PowerQualityMetric | ( | ) | [virtual] |
Definition at line 42 of file PowerQualityMetric.cpp.
{}
bool PowerQualityMetric::evaluate | ( | PatchData & | pd, |
size_t | handle, | ||
double & | value, | ||
MsqError & | err | ||
) | [virtual] |
Get metric value at a logical location in the patch.
Evaluate the metric at one location in the PatchData.
pd | The patch. |
handle | The location in the patch (as passed back from get_evaluations). |
value | The output metric value. |
Implements MBMesquite::QualityMetric.
Definition at line 59 of file PowerQualityMetric.cpp.
References MBMesquite::QualityMetric::evaluate(), mMetric, mPower, MSQ_CHKERR, and MBMesquite::Exponent::raise().
bool PowerQualityMetric::evaluate_with_gradient | ( | PatchData & | pd, |
size_t | handle, | ||
double & | value, | ||
std::vector< size_t > & | indices, | ||
std::vector< Vector3D > & | gradient, | ||
MsqError & | err | ||
) | [virtual] |
Get metric value and gradient at a logical location in the patch.
Evaluate the metric at one location in the PatchData.
pd | The patch. |
handle | The location in the patch (as passed back from get_evaluations). |
value | The output metric value. |
indices | The free vertices that the evaluation is a function of, specified as vertex indices in the PatchData. |
gradient | The gradient of the metric as a function of the coordinates of the free vertices passed back in the indices list. |
Reimplemented from MBMesquite::QualityMetric.
Definition at line 77 of file PowerQualityMetric.cpp.
References MBMesquite::QualityMetric::evaluate_with_gradient(), mMetric, mPower, MSQ_CHKERR, MBMesquite::Exponent::raise(), and MBMesquite::Exponent::value().
{ bool rval = mMetric.evaluate_with_gradient( pd, handle, value, indices, gradient, err ); const double v = mPower.raise( value ); const double g = fabs( value ) > DBL_EPSILON ? mPower.value() * v / value : 0; value = v; for( std::vector< Vector3D >::iterator i = gradient.begin(); i != gradient.end(); ++i ) *i *= g; return !MSQ_CHKERR( err ) && rval; }
bool PowerQualityMetric::evaluate_with_Hessian | ( | PatchData & | pd, |
size_t | handle, | ||
double & | value, | ||
std::vector< size_t > & | indices, | ||
std::vector< Vector3D > & | gradient, | ||
std::vector< Matrix3D > & | Hessian, | ||
MsqError & | err | ||
) | [virtual] |
Get metric value and deravitives at a logical location in the patch.
Evaluate the metric at one location in the PatchData.
pd | The patch. |
handle | The location in the patch (as passed back from get_evaluations). |
value | The output metric value. |
indices | The free vertices that the evaluation is a function of, specified as vertex indices in the PatchData. |
gradient | The gradient of the metric as a function of the coordinates of the free vertices passed back in the indices list. |
Hessian | The Hessian of the metric as a function of the coordinates. The Hessian is passed back as the upper-triangular portion of the matrix in row-major order, where each Matrix3D is the portion of the Hessian with respect to the vertices at the corresponding positions in the indices list. |
Reimplemented from MBMesquite::QualityMetric.
Definition at line 93 of file PowerQualityMetric.cpp.
References MBMesquite::QualityMetric::evaluate_with_Hessian(), mMetric, mPower, MSQ_CHKERR, n, MBMesquite::Matrix3D::outer_product(), MBMesquite::Exponent::raise(), and MBMesquite::Exponent::value().
{ indices.clear(); bool rval = mMetric.evaluate_with_Hessian( pd, handle, value, indices, gradient, Hessian, err ); const double v = mPower.raise( value ); const double g = fabs( value ) > DBL_EPSILON ? mPower.value() * v / value : 0.0; const double h = fabs( value ) > DBL_EPSILON ? g * ( mPower.value() - 1 ) / value : 0.0; value = v; Matrix3D op; unsigned idx = 0; unsigned n = indices.size(); for( unsigned r = 0; r < n; ++r ) { for( unsigned c = r; c < n; ++c ) { Hessian[idx] *= g; op.outer_product( gradient[r], gradient[c] ); op *= h; Hessian[idx] += op; ++idx; } gradient[r] *= g; } return !MSQ_CHKERR( err ) && rval; }
bool PowerQualityMetric::evaluate_with_indices | ( | PatchData & | pd, |
size_t | handle, | ||
double & | value, | ||
std::vector< size_t > & | indices, | ||
MsqError & | err | ||
) | [virtual] |
Get metric value at a logical location in the patch.
Evaluate the metric at one location in the PatchData.
pd | The patch. |
handle | The location in the patch (as passed back from get_evaluations). |
value | The output metric value. |
indices | The free vertices that the evaluation is a function of, specified as vertex indices in the PatchData. |
Implements MBMesquite::QualityMetric.
Definition at line 66 of file PowerQualityMetric.cpp.
References MBMesquite::QualityMetric::evaluate_with_indices(), mMetric, mPower, MSQ_CHKERR, and MBMesquite::Exponent::raise().
{ bool rval = mMetric.evaluate_with_indices( pd, handle, value, indices, err ); value = mPower.raise( value ); return !MSQ_CHKERR( err ) && rval; }
void PowerQualityMetric::get_evaluations | ( | PatchData & | pd, |
std::vector< size_t > & | handles, | ||
bool | free_vertices_only, | ||
MsqError & | err | ||
) | [virtual] |
Get locations at which metric can be evaluated.
Different metrics are evaluated for different things within a patch. For example, an element-based metric will be evaluated once for each element in patch, a vertex-based metric once for each veretx, and a target/sample-point based metric will be evaluated once for each samle point in each element. This method returns a list of handles, one for each location in the patch at which the metric can be evaluated. The handle values are used as input to the evaluate methods.
pd | The patch |
handles | Output list of handles |
free_vertices_only | If true, only pass back evaluation points that depend on at least one free vertex. |
Implements MBMesquite::QualityMetric.
Definition at line 54 of file PowerQualityMetric.cpp.
References MBMesquite::QualityMetric::get_evaluations(), mMetric, and MSQ_CHKERR.
{ mMetric.get_evaluations( pd, handles, free_only, err );MSQ_CHKERR( err ); }
QualityMetric* MBMesquite::PowerQualityMetric::get_metric | ( | ) | const [inline] |
MetricType MBMesquite::PowerQualityMetric::get_metric_type | ( | ) | const [inline, virtual] |
Implements MBMesquite::QualityMetric.
Definition at line 68 of file PowerQualityMetric.hpp.
References MBMesquite::QualityMetric::get_metric_type(), and mMetric.
{ return mMetric.get_metric_type(); }
std::string PowerQualityMetric::get_name | ( | ) | const [virtual] |
Implements MBMesquite::QualityMetric.
Definition at line 44 of file PowerQualityMetric.cpp.
References MBMesquite::QualityMetric::get_name(), and mMetric.
int PowerQualityMetric::get_negate_flag | ( | ) | const [virtual] |
1 if metric should be minimized, -1 if metric should be maximized.
Implements MBMesquite::QualityMetric.
Definition at line 49 of file PowerQualityMetric.cpp.
References MBMesquite::QualityMetric::get_negate_flag(), mMetric, mPower, and MBMesquite::Exponent::value().
{ return mPower.value() < 0 ? mMetric.get_negate_flag() : -mMetric.get_negate_flag(); }
Definition at line 111 of file PowerQualityMetric.hpp.
Referenced by evaluate(), evaluate_with_gradient(), evaluate_with_Hessian(), evaluate_with_indices(), get_evaluations(), get_metric(), get_metric_type(), get_name(), and get_negate_flag().
Definition at line 112 of file PowerQualityMetric.hpp.
Referenced by evaluate(), evaluate_with_gradient(), evaluate_with_Hessian(), evaluate_with_indices(), and get_negate_flag().