MOAB: Mesh Oriented datABase  (version 5.3.1)
MBMesquite::CompareQM Class Reference

Compare values for two supposedly equivalent quality metrics. More...

#include <CompareQM.hpp>

+ Inheritance diagram for MBMesquite::CompareQM:
+ Collaboration diagram for MBMesquite::CompareQM:

Classes

struct  GradStat
struct  HessStat

Public Member Functions

MESQUITE_EXPORT CompareQM (QualityMetric *primary, QualityMetric *other, const char *primary_name=0, const char *other_name=0)
MESQUITE_EXPORT void abort_on_mismatch (double tolerance_factor=1e-6)
MESQUITE_EXPORT void do_not_abort ()
MESQUITE_EXPORT bool will_abort_on_mismatch () const
MESQUITE_EXPORT void print_stats () const
virtual MESQUITE_EXPORT ~CompareQM ()
virtual MESQUITE_EXPORT MetricType get_metric_type () const
virtual MESQUITE_EXPORT std::string get_name () const
virtual MESQUITE_EXPORT int get_negate_flag () const
 1 if metric should be minimized, -1 if metric should be maximized.
virtual MESQUITE_EXPORT 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 MESQUITE_EXPORT bool evaluate (PatchData &pd, size_t handle, double &value, MsqError &err)
 Get metric value at a logical location in the patch.
virtual MESQUITE_EXPORT 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 MESQUITE_EXPORT 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 MESQUITE_EXPORT bool evaluate_with_Hessian_diagonal (PatchData &pd, size_t handle, double &value, std::vector< size_t > &indices, std::vector< Vector3D > &gradient, std::vector< SymMatrix3D > &Hessian_diagonal, MsqError &err)
 Get metric value and gradient at a logical location in the patch.
virtual MESQUITE_EXPORT 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 Member Functions

double epsilon (double val1, double val2)
bool check_valid (size_t handle, bool valid1, bool valid2)
void check_value (size_t handle, double value1, double value2)
void check_indices (size_t handle, const std::vector< size_t > &idx1, const std::vector< size_t > &idx2, std::vector< size_t > &map_out, MsqError &err)
void check_grad (size_t handle, const std::vector< size_t > &indices, const std::vector< size_t > &index_map, const std::vector< Vector3D > &grad1, const std::vector< Vector3D > &grad2)
void check_hess_diag (size_t handle, const std::vector< size_t > &indices, const std::vector< size_t > &index_map, const std::vector< SymMatrix3D > &hess1, const std::vector< SymMatrix3D > &hess2)
void check_hess (size_t handle, const std::vector< size_t > &indices, const std::vector< size_t > &index_map, const std::vector< Matrix3D > &hess1, const std::vector< Matrix3D > &hess2)
void index_mismatch (size_t handle, const std::vector< size_t > &idx1, const std::vector< size_t > &idx2, MsqError &err)

Private Attributes

std::string primaryName
std::string otherName
QualityMetricprimaryMetric
QualityMetricotherMetric
bool abortOnMismatch
double toleranceFactor
SimpleStats valPrimary
SimpleStats valOther
SimpleStats valDiff
GradStat gradPrimary
GradStat gradOther
GradStat gradDiff
HessStat hessPrimary
HessStat hessOther
HessStat hessDiff

Detailed Description

Compare values for two supposedly equivalent quality metrics.

Evaluate two different quality metrics during the evaluation, comparing the results with each other and passing the results of the primary one on to the objective function.

Both metrics must be of the same "type", meaning that they must be evaluated at the same sample locations in the mesh. For example, an error will be generated if one of the metrics is vertex based and one is element based. Further, both metrics must use the same handle values to indicate their list of sample locations such that the evaluation for a given same handle dependes on the same vertices for both metrics.

Definition at line 56 of file CompareQM.hpp.


Constructor & Destructor Documentation

MBMesquite::CompareQM::CompareQM ( QualityMetric primary,
QualityMetric other,
const char *  primary_name = 0,
const char *  other_name = 0 
)

Definition at line 41 of file CompareQM.cpp.

References otherName, and primaryName.

    : primaryMetric( primary ), otherMetric( other ), abortOnMismatch( false ), toleranceFactor( 1e-6 )
{
    if( primary_name ) primaryName = primary_name;
    if( other_name ) otherName = other_name;
}

Definition at line 48 of file CompareQM.cpp.

{}

Member Function Documentation

void MBMesquite::CompareQM::abort_on_mismatch ( double  tolerance_factor = 1e-6)

Definition at line 50 of file CompareQM.cpp.

References abortOnMismatch, tolerance, and toleranceFactor.

void MBMesquite::CompareQM::check_grad ( size_t  handle,
const std::vector< size_t > &  indices,
const std::vector< size_t > &  index_map,
const std::vector< Vector3D > &  grad1,
const std::vector< Vector3D > &  grad2 
) [private]

Definition at line 233 of file CompareQM.cpp.

References abortOnMismatch, MBMesquite::CompareQM::GradStat::add(), MBMesquite::CompareQM::GradStat::add_diff(), epsilon(), gradDiff, gradOther, gradPrimary, and MBMesquite::length().

Referenced by evaluate_with_gradient(), evaluate_with_Hessian(), and evaluate_with_Hessian_diagonal().

{
    assert( index_map.size() == indices.size() );
    assert( index_map.size() == grad1.size() );
    assert( index_map.size() == grad2.size() );
    for( size_t i = 0; i < index_map.size(); ++i )
    {
        gradPrimary.add( grad1[i] );
        gradOther.add( grad2[i] );
        gradDiff.add_diff( grad1[i], grad2[index_map[i]] );

        if( abortOnMismatch )
        {
            if( ( grad1[i] - grad2[index_map[i]] ).length() >
                epsilon( grad1[i].length(), grad2[index_map[i]].length() ) )
            {
                std::cerr << "Gradients differ for metric evaluation at " << std::hex << handle << std::dec << std::endl
                          << "Primary metric derivs with respect to vertex " << indices[i] << ": " << grad1[i]
                          << std::endl
                          << "Other metric derivs with presect to vertex " << indices[i] << ": " << grad2[index_map[i]]
                          << std::endl
                          << __FILE__ << ":" << __LINE__ << std::endl;
                abort();
            }
        }
    }
}
void MBMesquite::CompareQM::check_hess ( size_t  handle,
const std::vector< size_t > &  indices,
const std::vector< size_t > &  index_map,
const std::vector< Matrix3D > &  hess1,
const std::vector< Matrix3D > &  hess2 
) [private]

Definition at line 335 of file CompareQM.cpp.

References abortOnMismatch, MBMesquite::CompareQM::HessStat::add_diag(), MBMesquite::CompareQM::HessStat::add_diag_diff(), MBMesquite::CompareQM::HessStat::add_nondiag(), MBMesquite::CompareQM::HessStat::add_nondiag_diff(), eps, epsilon(), MBMesquite::Frobenius_2(), hessDiff, hessOther, hessPrimary, n, N, and MBMesquite::transpose().

Referenced by evaluate_with_Hessian().

{
    const size_t n = index_map.size();
    const size_t N = ( n + 1 ) * n / 2;
    assert( n == indices.size() );
    assert( N == hess1.size() );
    assert( N == hess2.size() );

    for( size_t r = 0; r < n; ++r )
    {
        const size_t r2 = index_map[r];
        for( size_t c = r; c < n; ++c )
        {
            const size_t c2 = index_map[c];
            size_t idx1     = n * r - r * ( r + 1 ) / 2 + c;
            Matrix3D h2;
            if( r2 <= c2 )
            {
                size_t idx2 = n * r2 - r2 * ( r2 + 1 ) / 2 + c2;
                h2          = hess2[idx2];
            }
            else
            {
                size_t idx2 = n * c2 - c2 * ( c2 + 1 ) / 2 + r2;
                h2          = transpose( hess2[idx2] );
            }

            if( r == c )
            {
                hessPrimary.add_diag( hess1[idx1] );
                hessOther.add_diag( h2 );
                hessDiff.add_diag_diff( hess1[idx1], h2 );
            }
            else
            {
                hessPrimary.add_nondiag( hess1[idx1] );
                hessOther.add_nondiag( h2 );
                hessDiff.add_nondiag_diff( hess1[idx1], h2 );
            }

            if( abortOnMismatch )
            {
                double eps = epsilon( sqrt( Frobenius_2( hess1[idx1] ) ), sqrt( Frobenius_2( h2 ) ) );
                if( sqrt( Frobenius_2( hess1[idx1] - h2 ) ) > eps )
                {
                    std::cerr << "Hessian blocks differ for metric evaluation at " << std::hex << handle << std::dec
                              << std::endl
                              << "For second derivatives with repsect to vertices " << indices[r] << " and "
                              << indices[c] << std::endl
                              << "Primary metric derivs: " << hess1[idx1] << std::endl
                              << "Other metric derivs: " << h2 << std::endl
                              << __FILE__ << ":" << __LINE__ << std::endl;
                    abort();
                }
            }
        }
    }
}
void MBMesquite::CompareQM::check_hess_diag ( size_t  handle,
const std::vector< size_t > &  indices,
const std::vector< size_t > &  index_map,
const std::vector< SymMatrix3D > &  hess1,
const std::vector< SymMatrix3D > &  hess2 
) [private]

Definition at line 282 of file CompareQM.cpp.

References abortOnMismatch, MBMesquite::CompareQM::HessStat::add_diag(), MBMesquite::CompareQM::HessStat::add_diag_diff(), eps, epsilon(), MBMesquite::Frobenius(), hessDiff, hessOther, and hessPrimary.

Referenced by evaluate_with_Hessian_diagonal().

{
    assert( index_map.size() == indices.size() );
    assert( index_map.size() == hess1.size() );
    assert( index_map.size() == hess2.size() );
    for( size_t i = 0; i < index_map.size(); ++i )
    {
        hessPrimary.add_diag( hess1[i] );
        hessOther.add_diag( hess2[i] );
        hessDiff.add_diag_diff( hess1[i], hess2[index_map[i]] );

        if( abortOnMismatch )
        {
            double eps = epsilon( Frobenius( hess1[i] ), Frobenius( hess2[index_map[i]] ) );
            if( Frobenius( hess1[i] - hess2[index_map[i]] ) > eps )
            {
                std::cerr << "Hessian diagonal blocks differ for metric evaluation at " << std::hex << handle
                          << std::dec << std::endl
                          << "For second derivatives with repsect to vertex " << indices[i] << "twice" << std::endl
                          << "Primary metric derivs: " << hess1[i] << std::endl
                          << "Other metric derivs: " << hess2[index_map[i]] << std::endl
                          << __FILE__ << ":" << __LINE__ << std::endl;
                abort();
            }
        }
    }
}
void MBMesquite::CompareQM::check_indices ( size_t  handle,
const std::vector< size_t > &  idx1,
const std::vector< size_t > &  idx2,
std::vector< size_t > &  map_out,
MsqError err 
) [private]

Check that two index lists are equivalent and return in map_out for each index in idx1 the position of the same index in idx2.

Definition at line 194 of file CompareQM.cpp.

References index_mismatch(), and MSQ_ERRRTN.

Referenced by evaluate_with_gradient(), evaluate_with_Hessian(), evaluate_with_Hessian_diagonal(), and evaluate_with_indices().

{
    if( idx1.size() != idx2.size() )
    {
        index_mismatch( handle, idx1, idx2, err );MSQ_ERRRTN( err );
    }

    std::vector< size_t >::const_iterator i, j;
    map_out.clear();
    for( i = idx1.begin(); i != idx1.end(); ++i )
    {
        j = std::find( idx2.begin(), idx2.end(), *i );
        if( j == idx2.end() )
        {
            index_mismatch( handle, idx1, idx2, err );MSQ_ERRRTN( err );
        }
        map_out.push_back( j - idx2.begin() );
    }
}
bool MBMesquite::CompareQM::check_valid ( size_t  handle,
bool  valid1,
bool  valid2 
) [private]

Definition at line 108 of file CompareQM.cpp.

References abortOnMismatch.

Referenced by evaluate(), evaluate_with_gradient(), evaluate_with_Hessian(), evaluate_with_Hessian_diagonal(), and evaluate_with_indices().

{
    if( rval1 != rval2 )
    {
        std::cerr << "Metrics returned conflicting validity at location " << std::hex << handle << std::dec << std::endl
                  << __FILE__ << ":" << __LINE__ << std::endl;
        if( abortOnMismatch )
            abort();
        else
            return false;
    }

    return rval1;
}
void MBMesquite::CompareQM::check_value ( size_t  handle,
double  value1,
double  value2 
) [private]

Compare values, add to stats, etc.

Definition at line 128 of file CompareQM.cpp.

References abortOnMismatch, MBMesquite::SimpleStats::add_value(), epsilon(), valDiff, valOther, and valPrimary.

Referenced by evaluate(), evaluate_with_gradient(), evaluate_with_Hessian(), evaluate_with_Hessian_diagonal(), and evaluate_with_indices().

{
    valPrimary.add_value( value );
    valOther.add_value( value2 );
    valDiff.add_value( fabs( value - value2 ) );

    if( abortOnMismatch )
    {
        if( fabs( value - value2 ) > epsilon( value, value2 ) )
        {
            std::cerr << "Metric values to not match at location " << std::hex << handle << std::dec << std::endl
                      << "Primary: " << value << std::endl
                      << "Other  : " << value2 << std::endl
                      << __FILE__ << ":" << __LINE__ << std::endl;
            abort();
        }
    }
}

Definition at line 56 of file CompareQM.cpp.

References abortOnMismatch.

{
    abortOnMismatch = false;
}
double MBMesquite::CompareQM::epsilon ( double  val1,
double  val2 
) [private]

Definition at line 123 of file CompareQM.cpp.

References toleranceFactor.

Referenced by check_grad(), check_hess(), check_hess_diag(), and check_value().

{
    return toleranceFactor * std::max( 1.0, std::max( a, b ) );
}
bool MBMesquite::CompareQM::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 147 of file CompareQM.cpp.

References check_valid(), check_value(), MBMesquite::QualityMetric::evaluate(), MSQ_ERRZERO, otherMetric, and primaryMetric.

{
    double value2;
    bool rval1, rval2;
    rval1 = primaryMetric->evaluate( pd, handle, value, err );
    MSQ_ERRZERO( err );
    rval2 = otherMetric->evaluate( pd, handle, value2, err );
    MSQ_ERRZERO( err );
    if( !check_valid( handle, rval1, rval2 ) ) return false;

    check_value( handle, value, value2 );
    return true;
}
bool MBMesquite::CompareQM::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 262 of file CompareQM.cpp.

References check_grad(), check_indices(), check_valid(), check_value(), MBMesquite::QualityMetric::evaluate_with_gradient(), MSQ_ERRZERO, otherMetric, and primaryMetric.

{
    bool valid1, valid2;
    double value2;
    std::vector< size_t > indices2, map;
    std::vector< Vector3D > grad2;
    valid1 = primaryMetric->evaluate_with_gradient( pd, handle, value, indices, grad, err );
    MSQ_ERRZERO( err );
    valid2 = otherMetric->evaluate_with_gradient( pd, handle, value2, indices2, grad2, err );
    MSQ_ERRZERO( err );
    if( !check_valid( handle, valid1, valid2 ) ) return false;

    check_value( handle, value, value2 );
    check_indices( handle, indices, indices2, map, err );
    MSQ_ERRZERO( err );
    check_grad( handle, indices, map, grad, grad2 );
    return true;
}
bool MBMesquite::CompareQM::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 395 of file CompareQM.cpp.

References check_grad(), check_hess(), check_indices(), check_valid(), check_value(), MBMesquite::QualityMetric::evaluate_with_Hessian(), MSQ_ERRZERO, otherMetric, and primaryMetric.

{
    bool valid1, valid2;
    double value2;
    std::vector< size_t > indices2, map;
    std::vector< Vector3D > grad2;
    std::vector< Matrix3D > hess2;
    valid1 = primaryMetric->evaluate_with_Hessian( pd, handle, value, indices, grad, hess, err );
    MSQ_ERRZERO( err );
    valid2 = otherMetric->evaluate_with_Hessian( pd, handle, value2, indices2, grad2, hess2, err );
    MSQ_ERRZERO( err );
    if( !check_valid( handle, valid1, valid2 ) ) return false;

    check_value( handle, value, value2 );
    check_indices( handle, indices, indices2, map, err );
    MSQ_ERRZERO( err );
    check_grad( handle, indices, map, grad, grad2 );
    check_hess( handle, indices, map, hess, hess2 );
    return true;
}
bool MBMesquite::CompareQM::evaluate_with_Hessian_diagonal ( PatchData pd,
size_t  handle,
double &  value,
std::vector< size_t > &  indices,
std::vector< Vector3D > &  gradient,
std::vector< SymMatrix3D > &  Hessian_diagonal,
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.
Hessian_diagonalThe 3x3 blocks along the diagonal of the Hessian matrix.

Reimplemented from MBMesquite::QualityMetric.

Definition at line 312 of file CompareQM.cpp.

References check_grad(), check_hess_diag(), check_indices(), check_valid(), check_value(), MBMesquite::QualityMetric::evaluate_with_Hessian_diagonal(), MSQ_ERRZERO, otherMetric, and primaryMetric.

{
    bool valid1, valid2;
    double value2;
    std::vector< size_t > indices2, map;
    std::vector< Vector3D > grad2;
    std::vector< SymMatrix3D > hess2;
    valid1 = primaryMetric->evaluate_with_Hessian_diagonal( pd, handle, value, indices, grad, hess, err );
    MSQ_ERRZERO( err );
    valid2 = otherMetric->evaluate_with_Hessian_diagonal( pd, handle, value2, indices2, grad2, hess2, err );
    MSQ_ERRZERO( err );
    if( !check_valid( handle, valid1, valid2 ) ) return false;

    check_value( handle, value, value2 );
    check_indices( handle, indices, indices2, map, err );
    MSQ_ERRZERO( err );
    check_grad( handle, indices, map, grad, grad2 );
    check_hess_diag( handle, indices, map, hess, hess2 );
    return true;
}
bool MBMesquite::CompareQM::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 215 of file CompareQM.cpp.

References check_indices(), check_valid(), check_value(), MBMesquite::QualityMetric::evaluate_with_indices(), MSQ_ERRZERO, otherMetric, and primaryMetric.

{
    bool valid1, valid2;
    double value2;
    std::vector< size_t > indices2, junk;
    valid1 = primaryMetric->evaluate_with_indices( pd, handle, value, indices, err );
    MSQ_ERRZERO( err );
    valid2 = otherMetric->evaluate_with_indices( pd, handle, value2, indices2, err );
    MSQ_ERRZERO( err );
    if( !check_valid( handle, valid1, valid2 ) ) return false;

    check_value( handle, value, value2 );
    check_indices( handle, indices, indices2, junk, err );
    MSQ_ERRZERO( err );
    return true;
}
void MBMesquite::CompareQM::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 92 of file CompareQM.cpp.

References MBMesquite::QualityMetric::get_evaluations(), MBMesquite::MsqError::INVALID_STATE, MSQ_ERRRTN, MSQ_SETERR, otherMetric, and primaryMetric.

{
    primaryMetric->get_evaluations( pd, handles, free_only, err );MSQ_ERRRTN( err );

    std::vector< size_t > handles2;
    otherMetric->get_evaluations( pd, handles2, free_only, err );MSQ_ERRRTN( err );

    std::vector< size_t > handles1( handles );
    std::sort( handles1.begin(), handles1.end() );
    std::sort( handles2.begin(), handles2.end() );
    if( handles1 != handles2 )
    {
        MSQ_SETERR( err )( "Incompatible metrics cannot be compared", MsqError::INVALID_STATE );
    }
}

Implements MBMesquite::QualityMetric.

Definition at line 66 of file CompareQM.cpp.

References abortOnMismatch, MBMesquite::QualityMetric::get_metric_type(), otherMetric, and primaryMetric.

{
    MetricType type1, type2;
    type1 = primaryMetric->get_metric_type();
    type2 = otherMetric->get_metric_type();
    if( type1 != type2 )
    {
        std::cerr << "Incompatible metric types in CompareQM" << std::endl << __FILE__ << ':' << __LINE__ << std::endl;
        if( abortOnMismatch ) abort();
        // otherwise just return some type because this function can't
        // flag an error.  The mismatch should cause get_evaluations
        // to fail anyway.
    }
    return type1;
}
std::string MBMesquite::CompareQM::get_name ( ) const [virtual]

Implements MBMesquite::QualityMetric.

Definition at line 82 of file CompareQM.cpp.

References MBMesquite::QualityMetric::get_name(), and primaryMetric.

{
    return primaryMetric->get_name();
}
int MBMesquite::CompareQM::get_negate_flag ( ) const [virtual]

1 if metric should be minimized, -1 if metric should be maximized.

Implements MBMesquite::QualityMetric.

Definition at line 87 of file CompareQM.cpp.

References MBMesquite::QualityMetric::get_negate_flag(), and primaryMetric.

void MBMesquite::CompareQM::index_mismatch ( size_t  handle,
const std::vector< size_t > &  idx1,
const std::vector< size_t > &  idx2,
MsqError err 
) [private]

Definition at line 161 of file CompareQM.cpp.

References abortOnMismatch, MBMesquite::MsqError::INVALID_STATE, and MSQ_SETERR.

Referenced by check_indices().

{
    std::vector< size_t >::const_iterator i;

    std::cerr << "Metrics cannot be compared at location " << std::hex << handle << std::dec
              << " because they are incompatible." << std::endl
              << "Primary metric vertices: ";
    if( idx1.empty() )
        std::cerr << "(empty)";
    else
    {
        i = idx1.begin();
        std::cerr << *i;
        for( ++i; i != idx1.end(); ++i )
            std::cerr << ',' << *i;
    }
    std::cerr << std::endl << "Other metric vertices: ";
    if( idx2.empty() )
        std::cerr << "(empty)";
    else
    {
        i = idx2.begin();
        std::cerr << *i;
        for( ++i; i != idx2.end(); ++i )
            std::cerr << ',' << *i;
    }
    std::cerr << std::endl;

    if( abortOnMismatch ) abort();
    MSQ_SETERR( err )( "Cannot compare incompatible metrics", MsqError::INVALID_STATE );
}

Definition at line 505 of file CompareQM.cpp.

References MBMesquite::QualityMetric::get_name(), gradDiff, gradOther, gradPrimary, hessDiff, hessOther, hessPrimary, otherMetric, otherName, primaryMetric, primaryName, MBMesquite::print(), valDiff, valOther, valPrimary, MBMesquite::CompareQM::GradStat::x, MBMesquite::CompareQM::HessStat::xx, MBMesquite::CompareQM::HessStat::xy, MBMesquite::CompareQM::HessStat::xz, MBMesquite::CompareQM::GradStat::y, MBMesquite::CompareQM::HessStat::yy, MBMesquite::CompareQM::HessStat::yz, MBMesquite::CompareQM::GradStat::z, and MBMesquite::CompareQM::HessStat::zz.

{
    std::string name1 = primaryName.empty() ? primaryMetric->get_name() : primaryName;
    std::string name2 = otherName.empty() ? otherMetric->get_name() : otherName;
    print( "Values", name1.c_str(), name2.c_str(), valPrimary, valOther, valDiff );
    print( "Gradient X", name1.c_str(), name2.c_str(), gradPrimary.x, gradOther.x, gradDiff.x );
    print( "Gradient Y", name1.c_str(), name2.c_str(), gradPrimary.y, gradOther.y, gradDiff.y );
    print( "Gradient Z", name1.c_str(), name2.c_str(), gradPrimary.z, gradOther.z, gradDiff.z );
    print( "Hessian XX", name1.c_str(), name2.c_str(), hessPrimary.xx, hessOther.xx, hessDiff.xx );
    print( "Hessian XY", name1.c_str(), name2.c_str(), hessPrimary.xy, hessOther.xy, hessDiff.xy );
    print( "Hessian XZ", name1.c_str(), name2.c_str(), hessPrimary.xz, hessOther.xz, hessDiff.xz );
    print( "Hessian YY", name1.c_str(), name2.c_str(), hessPrimary.yy, hessOther.yy, hessDiff.yy );
    print( "Hessian YZ", name1.c_str(), name2.c_str(), hessPrimary.yz, hessOther.yz, hessDiff.yz );
    print( "Hessian ZZ", name1.c_str(), name2.c_str(), hessPrimary.zz, hessOther.zz, hessDiff.zz );
}

Definition at line 61 of file CompareQM.cpp.

References abortOnMismatch.

{
    return abortOnMismatch;
}

Member Data Documentation

Definition at line 154 of file CompareQM.hpp.

Referenced by check_grad(), and print_stats().

Definition at line 154 of file CompareQM.hpp.

Referenced by check_grad(), and print_stats().

Definition at line 154 of file CompareQM.hpp.

Referenced by check_grad(), and print_stats().

Definition at line 155 of file CompareQM.hpp.

Referenced by check_hess(), check_hess_diag(), and print_stats().

Definition at line 155 of file CompareQM.hpp.

Referenced by check_hess(), check_hess_diag(), and print_stats().

Definition at line 155 of file CompareQM.hpp.

Referenced by check_hess(), check_hess_diag(), and print_stats().

std::string MBMesquite::CompareQM::otherName [private]

Definition at line 149 of file CompareQM.hpp.

Referenced by CompareQM(), and print_stats().

std::string MBMesquite::CompareQM::primaryName [private]

Definition at line 149 of file CompareQM.hpp.

Referenced by CompareQM(), and print_stats().

Definition at line 152 of file CompareQM.hpp.

Referenced by abort_on_mismatch(), and epsilon().

Definition at line 153 of file CompareQM.hpp.

Referenced by check_value(), and print_stats().

Definition at line 153 of file CompareQM.hpp.

Referenced by check_value(), and print_stats().

Definition at line 153 of file CompareQM.hpp.

Referenced by check_value(), and print_stats().

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