MOAB: Mesh Oriented datABase  (version 5.4.1)
FauxMetric< B > Class Template Reference

#include <TMPQualityMetricTest.hpp>

+ Inheritance diagram for FauxMetric< B >:
+ Collaboration diagram for FauxMetric< B >:

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

Detailed Description

template<typename B>
class FauxMetric< B >

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.


Constructor & Destructor Documentation

template<typename B>
FauxMetric< B >::FauxMetric ( double  v) [inline]

Definition at line 65 of file TMPQualityMetricTest.hpp.

: count( 0 ), value( v ), rval( true ) {}

Member Function Documentation

template<typename B>
bool FauxMetric< B >::evaluate ( const MsqMatrix< 2, 2 > &  A,
const MsqMatrix< 2, 2 > &  W,
double &  result,
MsqError  
) [inline]

Definition at line 72 of file TMPQualityMetricTest.hpp.

    {
        last_A_2D = A;
        result    = value;
        ++count;
        return rval;
    }
template<typename B>
bool FauxMetric< B >::evaluate ( const MsqMatrix< 3, 3 > &  A,
const MsqMatrix< 3, 3 > &  W,
double &  result,
MsqError  
) [inline]

Definition at line 80 of file TMPQualityMetricTest.hpp.

    {
        last_A_3D = A;
        result    = value;
        ++count;
        return rval;
    }
template<typename B>
bool FauxMetric< B >::evaluate ( const MsqMatrix< 2, 2 > &  T,
double &  result,
MsqError  
) [inline]

Definition at line 88 of file TMPQualityMetricTest.hpp.

    {
        last_A_2D = T;
        result    = value;
        ++count;
        return rval;
    }
template<typename B>
bool FauxMetric< B >::evaluate ( const MsqMatrix< 3, 3 > &  T,
double &  result,
MsqError  
) [inline]

Definition at line 96 of file TMPQualityMetricTest.hpp.

    {
        last_A_3D = T;
        result    = value;
        ++count;
        return rval;
    }
template<typename B>
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.

Parameters:
pdThe patch.
handleThe location in the patch (as passed back from get_evaluations).
valueThe 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;
}
template<typename B>
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.

Parameters:
pdThe patch.
handleThe location in the patch (as passed back from get_evaluations).
valueThe output metric value.
indicesThe free vertices that the evaluation is a function of, specified as vertex indices in the PatchData.
gradientThe 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;
}
template<typename B>
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.

Parameters:
pdThe patch.
handleThe location in the patch (as passed back from get_evaluations).
valueThe output metric value.
indicesThe free vertices that the evaluation is a function of, specified as vertex indices in the PatchData.
gradientThe gradient of the metric as a function of the coordinates of the free vertices passed back in the indices list.
HessianThe 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;
}
template<typename B>
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.

Parameters:
pdThe patch.
handleThe location in the patch (as passed back from get_evaluations).
valueThe output metric value.
indicesThe 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;
}
template<typename B>
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 ) );
}
template<typename B>
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.

Parameters:
pdThe patch
handlesOutput list of handles
free_vertices_onlyIf 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 );
}
template<typename B>
MetricType FauxMetric< B >::get_metric_type ( ) const [inline, virtual]

Reimplemented from MBMesquite::ElemSampleQM.

Definition at line 89 of file PMeanPMetricTest.cpp.

    {
        return ELEMENT_BASED;
    }
template<typename B>
std::string FauxMetric< B >::get_name ( ) const [inline, virtual]

Implements MBMesquite::QualityMetric.

Definition at line 67 of file TMPQualityMetricTest.hpp.

    {
        return "Faux";
    }
template<typename B>
std::string FauxMetric< B >::get_name ( ) const [inline, virtual]

Implements MBMesquite::QualityMetric.

Definition at line 93 of file PMeanPMetricTest.cpp.

    {
        return "FauxMetrix";
    }
template<typename B>
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;
    }

Member Data Documentation

template<typename B>
int FauxMetric< B >::count

Definition at line 59 of file TMPQualityMetricTest.hpp.

template<typename B>
MsqMatrix< 2, 2 > FauxMetric< B >::last_A_2D

Definition at line 62 of file TMPQualityMetricTest.hpp.

template<typename B>
MsqMatrix< 3, 3 > FauxMetric< B >::last_A_3D

Definition at line 63 of file TMPQualityMetricTest.hpp.

template<typename B>
bool FauxMetric< B >::rval

Definition at line 61 of file TMPQualityMetricTest.hpp.

template<typename B>
double FauxMetric< B >::value

Definition at line 60 of file TMPQualityMetricTest.hpp.

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