MOAB: Mesh Oriented datABase
(version 5.4.1)
|
#include <TMPQualityMetricTest.hpp>
Public Member Functions | |
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. | |
void | get_evaluations (PatchData &pd, std::vector< size_t > &h, bool free, MsqError &) |
Get locations at which metric can be evaluated. | |
void | get_element_evaluations (PatchData &, size_t, std::vector< size_t > &, MsqError &) |
Get evaluation point handles for a given element. | |
bool | evaluate (PatchData &pd, size_t h, double &v, MsqError &err) |
Get metric value at a logical location in the patch. | |
bool | evaluate_with_indices (PatchData &pd, size_t h, double &v, std::vector< size_t > &indices, MsqError &err) |
Get metric value at a logical location in the patch. | |
bool | evaluate_with_gradient (PatchData &pd, size_t h, double &v, std::vector< size_t > &indices, std::vector< Vector3D > &grads, MsqError &err) |
Get metric value and gradient at a logical location in the patch. | |
bool | evaluate_with_Hessian (PatchData &pd, size_t h, double &v, std::vector< size_t > &indices, std::vector< Vector3D > &grad, std::vector< Matrix3D > &Hess, MsqError &err) |
Get metric value and deravitives at a logical location in the patch. | |
FauxMetric (double v) | |
std::string | get_name () const |
bool | evaluate (const MsqMatrix< 2, 2 > &A, const MsqMatrix< 2, 2 > &W, double &result, MsqError &) |
bool | evaluate (const MsqMatrix< 3, 3 > &A, const MsqMatrix< 3, 3 > &W, double &result, MsqError &) |
bool | evaluate (const MsqMatrix< 2, 2 > &T, double &result, MsqError &) |
bool | evaluate (const MsqMatrix< 3, 3 > &T, double &result, MsqError &) |
Public Attributes | |
int | count |
double | value |
bool | rval |
MsqMatrix< 2, 2 > | last_A_2D |
MsqMatrix< 3, 3 > | last_A_3D |
Target metric (templatized by dimension) for use in misc. tests. 'evaluate' method records input values and returns a constant.
Definition at line 86 of file PMeanPMetricTest.cpp.
FauxMetric< B >::FauxMetric | ( | double | v | ) | [inline] |
Definition at line 65 of file TMPQualityMetricTest.hpp.
bool FauxMetric< B >::evaluate | ( | const MsqMatrix< 2, 2 > & | A, |
const MsqMatrix< 2, 2 > & | W, | ||
double & | result, | ||
MsqError & | |||
) | [inline] |
bool FauxMetric< B >::evaluate | ( | const MsqMatrix< 3, 3 > & | A, |
const MsqMatrix< 3, 3 > & | W, | ||
double & | result, | ||
MsqError & | |||
) | [inline] |
bool FauxMetric< B >::evaluate | ( | const MsqMatrix< 2, 2 > & | T, |
double & | result, | ||
MsqError & | |||
) | [inline] |
bool FauxMetric< B >::evaluate | ( | const MsqMatrix< 3, 3 > & | T, |
double & | result, | ||
MsqError & | |||
) | [inline] |
bool FauxMetric< B >::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 134 of file PMeanPMetricTest.cpp.
References CPPUNIT_ASSERT_EQUAL, MBMesquite::Sample::dimension, MBMesquite::ElemSampleQM::elem(), MBMesquite::PatchData::element_by_index(), MBMesquite::MsqMeshEntity::get_vertex_index_array(), MBMesquite::Sample::number, and MBMesquite::ElemSampleQM::sample().
Referenced by PMeanPMetricTest::test_element_evaluate(), and PMeanPMetricTest::test_vertex_evaluate().
{ size_t e = ElemSampleQM::elem( h ); Sample s = ElemSampleQM::sample( h ); size_t* verts = pd.element_by_index( e ).get_vertex_index_array(); CPPUNIT_ASSERT_EQUAL( (unsigned short)0, s.dimension ); v = (double)( verts[s.number] ); return true; }
bool FauxMetric< B >::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 163 of file PMeanPMetricTest.cpp.
Referenced by PMeanPMetricTest::test_gradient().
{ evaluate_with_indices( pd, h, v, indices, err ); grads.clear(); for( unsigned i = 0; i < indices.size(); ++i ) grads.push_back( Vector3D( (double)indices[i], 0, 1 ) ); return true; }
bool FauxMetric< B >::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 177 of file PMeanPMetricTest.cpp.
Referenced by PMeanPMetricTest::test_hessian().
{ evaluate_with_gradient( pd, h, v, indices, grad, err ); hess.clear(); for( unsigned r = 0; r < indices.size(); ++r ) for( unsigned c = r; c < indices.size(); ++c ) hess.push_back( Matrix3D( indices[r], indices[c], indices[r] + indices[c], indices[r], 1.0, indices[r] + indices[c], 2 * indices[r], 2 * indices[c], indices[c] ) ); return true; }
bool FauxMetric< B >::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 144 of file PMeanPMetricTest.cpp.
References CPPUNIT_ASSERT_EQUAL, MBMesquite::Sample::dimension, MBMesquite::ElemSampleQM::elem(), MBMesquite::PatchData::element_by_index(), MBMesquite::MsqMeshEntity::get_vertex_index_array(), n, MBMesquite::Sample::number, MBMesquite::ElemSampleQM::sample(), and MBMesquite::MsqMeshEntity::vertex_count().
{ evaluate( pd, h, v, err ); indices.resize( 3 ); size_t e = ElemSampleQM::elem( h ); Sample s = ElemSampleQM::sample( h ); size_t* verts = pd.element_by_index( e ).get_vertex_index_array(); size_t n = pd.element_by_index( e ).vertex_count(); CPPUNIT_ASSERT_EQUAL( (unsigned short)0, s.dimension ); indices[0] = verts[s.number]; indices[1] = verts[( s.number + 1 ) % n]; indices[2] = verts[( s.number + n - 1 ) % n]; return true; }
void FauxMetric< B >::get_element_evaluations | ( | PatchData & | pd, |
size_t | elem_index, | ||
std::vector< size_t > & | handles, | ||
MsqError & | err | ||
) | [virtual] |
Get evaluation point handles for a given element.
Similar to QualityMetric::get_evaluations, this method returns a list of handles corresponding to sample points at which the metric may be evaluated. While QualityMetric::get_evaluations returns sample points for all elements in a PatchData, this method returns only the subset corresponding to a single element.
Implements MBMesquite::ElemSampleQM.
Definition at line 127 of file PMeanPMetricTest.cpp.
References MBMesquite::MsqMeshEntity::corner_count(), and MBMesquite::PatchData::element_by_index().
Referenced by PMeanPMetricTest::test_element_evaluate(), PMeanPMetricTest::test_gradient(), and PMeanPMetricTest::test_hessian().
{ MsqMeshEntity& elem = pd.element_by_index( h ); for( unsigned i = 0; i < elem.corner_count(); ++i ) list.push_back( handle( Sample( 0, i ), h ) ); }
void FauxMetric< B >::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 120 of file PMeanPMetricTest.cpp.
References MBMesquite::PatchData::num_elements().
{ h.clear(); for( size_t i = 0; i < pd.num_elements(); ++i ) get_element_evaluations( pd, i, h, err ); }
MetricType FauxMetric< B >::get_metric_type | ( | ) | const [inline, virtual] |
Reimplemented from MBMesquite::ElemSampleQM.
Definition at line 89 of file PMeanPMetricTest.cpp.
{ return ELEMENT_BASED; }
std::string FauxMetric< B >::get_name | ( | ) | const [inline, virtual] |
Implements MBMesquite::QualityMetric.
Definition at line 67 of file TMPQualityMetricTest.hpp.
{ return "Faux"; }
std::string FauxMetric< B >::get_name | ( | ) | const [inline, virtual] |
Implements MBMesquite::QualityMetric.
Definition at line 93 of file PMeanPMetricTest.cpp.
{ return "FauxMetrix"; }
int FauxMetric< B >::get_negate_flag | ( | ) | const [inline, virtual] |
1 if metric should be minimized, -1 if metric should be maximized.
Implements MBMesquite::QualityMetric.
Definition at line 97 of file PMeanPMetricTest.cpp.
{
return 1;
}
int FauxMetric< B >::count |
Definition at line 59 of file TMPQualityMetricTest.hpp.
MsqMatrix< 2, 2 > FauxMetric< B >::last_A_2D |
Definition at line 62 of file TMPQualityMetricTest.hpp.
MsqMatrix< 3, 3 > FauxMetric< B >::last_A_3D |
Definition at line 63 of file TMPQualityMetricTest.hpp.
bool FauxMetric< B >::rval |
Definition at line 61 of file TMPQualityMetricTest.hpp.
double FauxMetric< B >::value |
Definition at line 60 of file TMPQualityMetricTest.hpp.