MOAB: Mesh Oriented datABase  (version 5.2.1)
AveragingQMTest.cpp File Reference
#include "Mesquite.hpp"
#include "AveragingQM.hpp"
#include "IdealElements.hpp"
#include "UnitUtil.hpp"
#include "TopologyInfo.hpp"
#include "PatchData.hpp"
#include "cppunit/extensions/HelperMacros.h"
+ Include dependency graph for AveragingQMTest.cpp:

Go to the source code of this file.

Classes

class  AveragingQMTest

Functions

 CPPUNIT_TEST_SUITE_NAMED_REGISTRATION (AveragingQMTest,"AveragingQMTest")
 CPPUNIT_TEST_SUITE_NAMED_REGISTRATION (AveragingQMTest,"Unit")
static double pmean (const double *vals, unsigned n, double power)
static double list_min (const double *vals, unsigned n)
static double list_max (const double *vals, unsigned n)
static double sum_sqr (const double *vals, unsigned n)
static double sum_of_ratios_squared (const double *vals, unsigned n)
static double geometric_mean (const double *vals, unsigned n)
static double pmean_of_triangle_corner_hessians (double inner_power, double outer_power, const double *v, const Vector3D *cg, const Matrix3D *ch, Vector3D *tg, Matrix3D *th, bool scale)

Detailed Description

Unit testing for the AveragingQM class

Author:
Jasno Kraftcheck

Definition in file AveragingQMTest.cpp.


Function Documentation

static double geometric_mean ( const double *  vals,
unsigned  n 
) [static]

Definition at line 258 of file AveragingQMTest.cpp.

References n.

Referenced by AveragingQMTest::test_average_and_weights_geometric(), and AveragingQMTest::test_average_metrics_geometric().

{
    double result = 1.0;
    for( unsigned i = 0; i < n; ++i )
        result *= vals[i];
    return std::pow( result, 1.0 / n );
}
static double list_max ( const double *  vals,
unsigned  n 
) [static]

Definition at line 230 of file AveragingQMTest.cpp.

References n.

Referenced by AveragingQMTest::test_average_metrics_max_minus_min(), AveragingQMTest::test_average_metrics_max_over_min(), and AveragingQMTest::test_average_metrics_maximum().

{
    double result = vals[0];
    for( unsigned i = 1; i < n; ++i )
        if( vals[i] > result ) result = vals[i];
    return result;
}
static double list_min ( const double *  vals,
unsigned  n 
) [static]

Definition at line 222 of file AveragingQMTest.cpp.

References n.

Referenced by AveragingQMTest::test_average_metrics_max_minus_min(), AveragingQMTest::test_average_metrics_max_over_min(), and AveragingQMTest::test_average_metrics_minimum().

{
    double result = vals[0];
    for( unsigned i = 1; i < n; ++i )
        if( vals[i] < result ) result = vals[i];
    return result;
}
static double pmean ( const double *  vals,
unsigned  n,
double  power 
) [static]
static double pmean_of_triangle_corner_hessians ( double  inner_power,
double  outer_power,
const double *  v,
const Vector3D cg,
const Matrix3D ch,
Vector3D tg,
Matrix3D th,
bool  scale 
) [static]

Definition at line 794 of file AveragingQMTest.cpp.

References MBMesquite::Matrix3D::outer_product(), and MBMesquite::transpose().

Referenced by AveragingQMTest::check_pmean_hessian(), and AveragingQMTest::check_pmean_hessian_diagonals().

{
    Matrix3D op;
    double gf[3], hf[3];
    double nm, m = 0;
    double den = scale ? 3.0 : 1.0;
    for( unsigned i = 0; i < 3; ++i )
    {
        nm = pow( v[i], inner_power );
        m += nm;

        gf[i] = inner_power * nm / v[i] / den;
        hf[i] = ( inner_power - 1 ) * gf[i] / v[i];
    }

    nm = m / den;

    tg[0] = gf[0] * cg[0] + gf[1] * cg[5] + gf[2] * cg[7];
    tg[1] = gf[0] * cg[1] + gf[1] * cg[3] + gf[2] * cg[8];
    tg[2] = gf[0] * cg[2] + gf[1] * cg[4] + gf[2] * cg[6];

    th[0] = hf[0] * op.outer_product( cg[0], cg[0] ) + gf[0] * ch[0] + hf[1] * op.outer_product( cg[5], cg[5] ) +
            gf[1] * ch[11] + hf[2] * op.outer_product( cg[7], cg[7] ) + gf[2] * ch[15];
    th[3] = hf[0] * op.outer_product( cg[1], cg[1] ) + gf[0] * ch[3] + hf[1] * op.outer_product( cg[3], cg[3] ) +
            gf[1] * ch[6] + hf[2] * op.outer_product( cg[8], cg[8] ) + gf[2] * ch[17];
    th[5] = hf[0] * op.outer_product( cg[2], cg[2] ) + gf[0] * ch[5] + hf[1] * op.outer_product( cg[4], cg[4] ) +
            gf[1] * ch[9] + hf[2] * op.outer_product( cg[6], cg[6] ) + gf[2] * ch[12];
    th[1] = hf[0] * op.outer_product( cg[0], cg[1] ) + gf[0] * ch[1] + hf[1] * op.outer_product( cg[5], cg[3] ) +
            gf[1] * transpose( ch[8] ) + hf[2] * op.outer_product( cg[7], cg[8] ) + gf[2] * ch[16];
    th[2] = hf[0] * op.outer_product( cg[0], cg[2] ) + gf[0] * ch[2] + hf[1] * op.outer_product( cg[5], cg[4] ) +
            gf[1] * transpose( ch[10] ) + hf[2] * op.outer_product( cg[7], cg[6] ) + gf[2] * transpose( ch[13] );
    th[4] = hf[0] * op.outer_product( cg[1], cg[2] ) + gf[0] * ch[4] + hf[1] * op.outer_product( cg[3], cg[4] ) +
            gf[1] * ch[7] + hf[2] * op.outer_product( cg[8], cg[6] ) + gf[2] * transpose( ch[14] );

    m        = pow( nm, outer_power );
    double g = m * outer_power / nm;
    double h = ( outer_power - 1.0 ) * g / nm;
    for( unsigned r = 0; r < 3; ++r )
    {
        for( unsigned c = r; c < 3; ++c )
        {
            *th = g * *th + h * op.outer_product( tg[r], tg[c] );
            ++th;
        }
        tg[r] *= g;
    }

    return m;
}
static double sum_of_ratios_squared ( const double *  vals,
unsigned  n 
) [static]

Definition at line 246 of file AveragingQMTest.cpp.

References n.

Referenced by AveragingQMTest::test_average_metrics_sum_of_ratios_squared().

{
    double result = 0.0;
    for( unsigned i = 0; i < n; ++i )
        for( unsigned j = 0; j < n; ++j )
        {
            double ratio = vals[i] / vals[j];
            result += ratio * ratio;
        }
    return result / ( n * n );
}
static double sum_sqr ( const double *  vals,
unsigned  n 
) [static]

Definition at line 238 of file AveragingQMTest.cpp.

References n.

Referenced by AveragingQMTest::test_average_metrics_standard_deviation(), and AveragingQMTest::test_average_metrics_sum_squared().

{
    double result = 0.0;
    for( unsigned i = 0; i < n; ++i )
        result += vals[i] * vals[i];
    return result;
}
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines