MOAB: Mesh Oriented datABase  (version 5.3.1)
LinearMappingFunctionTest Class Reference
+ Inheritance diagram for LinearMappingFunctionTest:
+ Collaboration diagram for LinearMappingFunctionTest:

Public Member Functions

void setUp ()
void tearDown ()
void test_linear_hex_coeff_corners ()
void test_linear_hex_coeff_edges ()
void test_linear_hex_coeff_faces ()
void test_linear_hex_coeff_center ()
void test_linear_quad_coeff_corners ()
void test_linear_quad_coeff_edges ()
void test_linear_quad_coeff_center ()
void test_linear_tet_coeff_corners ()
void test_linear_tet_coeff_edges ()
void test_linear_tet_coeff_faces ()
void test_linear_tet_coeff_center ()
void test_linear_tri_coeff_corners ()
void test_linear_tri_coeff_edges ()
void test_linear_tri_coeff_faces ()
void test_linear_tri_coeff_center ()
void test_linear_prism_coeff_corners ()
void test_linear_prism_coeff_edges ()
void test_linear_prism_coeff_faces ()
void test_linear_prism_coeff_center ()
void test_linear_pyr_coeff_corners ()
void test_linear_pyr_coeff_edges ()
void test_linear_pyr_coeff_faces ()
void test_linear_pyr_coeff_center ()
void test_linear_hex_deriv_corners ()
void test_linear_hex_deriv_edges ()
void test_linear_hex_deriv_faces ()
void test_linear_hex_deriv_center ()
void test_linear_quad_deriv_corners ()
void test_linear_quad_deriv_edges ()
void test_linear_quad_deriv_center ()
void test_linear_tet_deriv_corners ()
void test_linear_tet_deriv_edges ()
void test_linear_tet_deriv_faces ()
void test_linear_tet_deriv_center ()
void test_linear_tri_deriv_corners ()
void test_linear_tri_deriv_edges ()
void test_linear_tri_deriv_center ()
void test_linear_prism_deriv_corners ()
void test_linear_prism_deriv_edges ()
void test_linear_prism_deriv_faces ()
void test_linear_prism_deriv_center ()
void test_linear_pyr_deriv_corners ()
void test_linear_pyr_deriv_edges ()
void test_linear_pyr_deriv_faces ()
void test_linear_pyr_deriv_center ()
void test_linear_hex_ideal ()
void test_linear_quad_ideal ()
void test_linear_tet_ideal ()
void test_linear_tri_ideal ()
void test_linear_prism_ideal ()

Private Types

typedef void(* map_func )(double *, double *)

Private Member Functions

 CPPUNIT_TEST_SUITE (LinearMappingFunctionTest)
 CPPUNIT_TEST (test_linear_hex_coeff_corners)
 CPPUNIT_TEST (test_linear_hex_coeff_edges)
 CPPUNIT_TEST (test_linear_hex_coeff_faces)
 CPPUNIT_TEST (test_linear_hex_coeff_center)
 CPPUNIT_TEST (test_linear_quad_coeff_corners)
 CPPUNIT_TEST (test_linear_quad_coeff_edges)
 CPPUNIT_TEST (test_linear_quad_coeff_center)
 CPPUNIT_TEST (test_linear_tet_coeff_corners)
 CPPUNIT_TEST (test_linear_tet_coeff_edges)
 CPPUNIT_TEST (test_linear_tet_coeff_faces)
 CPPUNIT_TEST (test_linear_tet_coeff_center)
 CPPUNIT_TEST (test_linear_tri_coeff_corners)
 CPPUNIT_TEST (test_linear_tri_coeff_edges)
 CPPUNIT_TEST (test_linear_tri_coeff_faces)
 CPPUNIT_TEST (test_linear_tri_coeff_center)
 CPPUNIT_TEST (test_linear_prism_coeff_corners)
 CPPUNIT_TEST (test_linear_prism_coeff_edges)
 CPPUNIT_TEST (test_linear_prism_coeff_faces)
 CPPUNIT_TEST (test_linear_prism_coeff_center)
 CPPUNIT_TEST (test_linear_pyr_coeff_corners)
 CPPUNIT_TEST (test_linear_pyr_coeff_edges)
 CPPUNIT_TEST (test_linear_pyr_coeff_faces)
 CPPUNIT_TEST (test_linear_pyr_coeff_center)
 CPPUNIT_TEST (test_linear_hex_deriv_corners)
 CPPUNIT_TEST (test_linear_hex_deriv_edges)
 CPPUNIT_TEST (test_linear_hex_deriv_faces)
 CPPUNIT_TEST (test_linear_hex_deriv_center)
 CPPUNIT_TEST (test_linear_quad_deriv_corners)
 CPPUNIT_TEST (test_linear_quad_deriv_edges)
 CPPUNIT_TEST (test_linear_quad_deriv_center)
 CPPUNIT_TEST (test_linear_tet_deriv_corners)
 CPPUNIT_TEST (test_linear_tet_deriv_edges)
 CPPUNIT_TEST (test_linear_tet_deriv_faces)
 CPPUNIT_TEST (test_linear_tet_deriv_center)
 CPPUNIT_TEST (test_linear_tri_deriv_corners)
 CPPUNIT_TEST (test_linear_tri_deriv_edges)
 CPPUNIT_TEST (test_linear_tri_deriv_center)
 CPPUNIT_TEST (test_linear_prism_deriv_corners)
 CPPUNIT_TEST (test_linear_prism_deriv_edges)
 CPPUNIT_TEST (test_linear_prism_deriv_faces)
 CPPUNIT_TEST (test_linear_prism_deriv_center)
 CPPUNIT_TEST (test_linear_pyr_deriv_corners)
 CPPUNIT_TEST (test_linear_pyr_deriv_edges)
 CPPUNIT_TEST (test_linear_pyr_deriv_faces)
 CPPUNIT_TEST (test_linear_pyr_deriv_center)
 CPPUNIT_TEST (test_linear_hex_ideal)
 CPPUNIT_TEST (test_linear_quad_ideal)
 CPPUNIT_TEST (test_linear_tet_ideal)
 CPPUNIT_TEST (test_linear_tri_ideal)
 CPPUNIT_TEST (test_linear_prism_ideal)
 CPPUNIT_TEST_SUITE_END ()
void do_coeff_test (MappingFunction &mf, unsigned subdim, map_func mf2, unsigned count, double *xi)
void do_deriv_test (MappingFunction2D &mf, unsigned subdim, map_func mf2, unsigned count, double *xi)
void do_deriv_test (MappingFunction3D &mf, unsigned subdim, map_func mf2, unsigned count, double *xi)
void do_ideal_test (MappingFunction2D &mf)
void do_ideal_test (MappingFunction3D &mf)
void test_coeff_fail (MappingFunction &mf, unsigned subdim)
void test_deriv_fail (MappingFunction2D &mf, unsigned subdim)
void test_deriv_fail (MappingFunction3D &mf, unsigned subdim)
void xi_at_corners (EntityTopology type, double *xi, const int *corners)
void xi_at_edges (EntityTopology type, double *xi, const int *corners)
void xi_at_faces (EntityTopology type, double *xi, const int *corners)

Static Private Member Functions

static void hex_coeff (double xi[3], double coeff[8])
static void tet_coeff (double xi[3], double coeff[4])
static void quad_coeff (double xi[2], double coeff[4])
static void tri_coeff (double xi[2], double coeff[3])
static void prism_coeff (double xi[3], double coeff[6])
static void pyr_coeff (double xi[3], double coeff[5])
static void hex_deriv (double xi[3], double coeff_deriv[24])
static void tet_deriv (double xi[3], double coeff_deriv[12])
static void quad_deriv (double xi[2], double coeff_deriv[8])
static void tri_deriv (double xi[2], double coeff_deriv[6])
static void prism_deriv (double xi[3], double coeff_deriv[18])
static void pyr_deriv (double xi[3], double coeff_deriv[15])

Private Attributes

LinearHexahedron hex
LinearQuadrilateral quad
LinearTetrahedron tet
LinearTriangle tri
LinearPrism prism
LinearPyramid pyr

Detailed Description

Definition at line 53 of file LinearMappingFunctionTest.cpp.


Member Typedef Documentation

typedef void( * LinearMappingFunctionTest::map_func)(double *, double *) [private]

Definition at line 147 of file LinearMappingFunctionTest.cpp.


Member Function Documentation

void LinearMappingFunctionTest::do_coeff_test ( MappingFunction mf,
unsigned  subdim,
map_func  mf2,
unsigned  count,
double *  xi 
) [private]

Definition at line 834 of file LinearMappingFunctionTest.cpp.

References ASSERT_MESSAGE, MBMesquite::MsqError::clear(), MBMesquite::MappingFunction::coefficients(), corners, CPPUNIT_ASSERT, dtostr(), MBMesquite::MappingFunction::element_topology(), itostr(), n, and MBMesquite::NodeSet::set_mid_edge_node().

{
    // make sure it fails if passed a nonlinear element
    MsqError err;
    double coeff[100];
    size_t indices[100];
    size_t num_coeff = 100;
    NodeSet tmp_set;
    tmp_set.set_mid_edge_node( 1 );
    mf.coefficients( Sample( 0, 1 ), tmp_set, coeff, indices, num_coeff, err );
    CPPUNIT_ASSERT( err );
    err.clear();

    // get number of vertices in element
    const unsigned n = TopologyInfo::corners( mf.element_topology() );
    const unsigned d = TopologyInfo::dimension( mf.element_topology() );

    // compare coefficients at each location
    vector< double > comp( n );
    for( unsigned i = 0; i < count; ++i )
    {
        num_coeff = 101;
        mf.coefficients( Sample( subdim, i ), NodeSet(), coeff, indices, num_coeff, err );
        CPPUNIT_ASSERT( !err );

        mf2( xi, &comp[0] );
        string xi_str;
        for( unsigned j = 0; j < d; ++j )
        {
            xi_str += !j ? "(" : ", ";
            xi_str += dtostr( xi[j] );
        }
        xi_str += ")";
        xi += d;

        for( unsigned j = 0; j < n; ++j )
        {
            double mf_val = 0.0;
            size_t idx    = std::find( indices, indices + num_coeff, j ) - indices;
            if( idx < num_coeff ) mf_val = coeff[idx];

            CppUnit::Message message( "Coefficients do not match." );
            message.addDetail( string( "Entity:             " ) + itostr( i ) );
            message.addDetail( string( "Coefficient number: " ) + itostr( j ) );
            message.addDetail( string( "Xi:             " ) + xi_str );
            message.addDetail( string( "Expected value: " ) + dtostr( comp[j] ) );
            message.addDetail( string( "Actual value:   " ) + dtostr( mf_val ) );
            ASSERT_MESSAGE( message, fabs( comp[j] - mf_val ) < DBL_EPSILON );
        }
    }
}
void LinearMappingFunctionTest::do_deriv_test ( MappingFunction2D mf,
unsigned  subdim,
map_func  mf2,
unsigned  count,
double *  xi 
) [private]

Definition at line 887 of file LinearMappingFunctionTest.cpp.

References ASSERT_MESSAGE, MBMesquite::MsqError::clear(), corners, CPPUNIT_ASSERT, MBMesquite::MappingFunction2D::derivatives(), dtostr(), MBMesquite::MappingFunction::element_topology(), itostr(), n, and MBMesquite::NodeSet::set_mid_edge_node().

{
    // make sure it fails if passed a nonlinear element
    MsqError err;
    MsqVector< 2 > derivs[100];
    size_t verts[100], num_vtx = 37;
    NodeSet tmp_set;
    tmp_set.set_mid_edge_node( 1 );
    mf.derivatives( Sample( subdim, 0 ), tmp_set, verts, derivs, num_vtx, err );
    CPPUNIT_ASSERT( err );
    err.clear();

    // get number of vertices in element
    const unsigned n = TopologyInfo::corners( mf.element_topology() );

    // compare coefficients at each location
    vector< double > comp( 2 * n );
    for( unsigned i = 0; i < count; ++i )
    {
        num_vtx = 33;
        mf.derivatives( Sample( subdim, i ), NodeSet(), verts, derivs, num_vtx, err );
        CPPUNIT_ASSERT( !err );
        CPPUNIT_ASSERT( num_vtx > 0 );
        CPPUNIT_ASSERT( num_vtx <= n );

        mf2( xi, &comp[0] );
        string xi_str;
        for( unsigned j = 0; j < 2; ++j )
        {
            xi_str += !j ? "(" : ", ";
            xi_str += dtostr( xi[j] );
        }
        xi_str += ")";
        xi += 2;

        for( unsigned j = 0; j < num_vtx; ++j )
        {
            bool all_zero = true;
            for( unsigned k = 0; k < 2; ++k )
            {
                CppUnit::Message message( "Coefficient derivatives do not match." );
                message.addDetail( string( "Entity:             " ) + itostr( i ) );
                message.addDetail( string( "Coefficient number: " ) + itostr( j ) );
                message.addDetail( string( "Xi:             " ) + xi_str );
                message.addDetail( string( "Axis:           " ) + itostr( k ) );
                message.addDetail( string( "Expected value: " ) + dtostr( comp[2 * verts[j] + k] ) );
                message.addDetail( string( "Actual value:   " ) + dtostr( derivs[j][k] ) );
                ASSERT_MESSAGE( message, fabs( comp[2 * verts[j] + k] - derivs[j][k] ) < DBL_EPSILON );
                if( fabs( derivs[j][k] ) > DBL_EPSILON ) all_zero = false;
            }

            // if vertex has all zero values, it shouldn't have been in the
            // vertex list at all, as the Jacobian will not depend on that vertex.
            CPPUNIT_ASSERT( !all_zero );
        }

        // If any vertex is not in the list, then its values must be zero.
        sort( verts, verts + num_vtx );
        for( unsigned j = 0; j < num_vtx; ++j )
        {
            if( !binary_search( verts, verts + num_vtx, j ) )
            {
                for( unsigned k = 0; k < 2; ++k )
                {
                    CppUnit::Message message( "Missing coefficient derivatives." );
                    message.addDetail( string( "Entity:              " ) + itostr( i ) );
                    message.addDetail( string( "Coefficient number:  " ) + itostr( j ) );
                    message.addDetail( string( "Axis:                " ) + itostr( k ) );
                    message.addDetail( string( "Expected derivative: " ) + dtostr( comp[2 * j + k] ) );
                    ASSERT_MESSAGE( message, fabs( comp[2 * j + k] ) < DBL_EPSILON );
                }
            }
        }
    }
}
void LinearMappingFunctionTest::do_deriv_test ( MappingFunction3D mf,
unsigned  subdim,
map_func  mf2,
unsigned  count,
double *  xi 
) [private]

Definition at line 964 of file LinearMappingFunctionTest.cpp.

References ASSERT_MESSAGE, MBMesquite::MsqError::clear(), corners, CPPUNIT_ASSERT, MBMesquite::MappingFunction3D::derivatives(), dtostr(), MBMesquite::MappingFunction::element_topology(), itostr(), n, and MBMesquite::NodeSet::set_mid_edge_node().

{
    // make sure it fails if passed a nonlinear element
    MsqError err;
    MsqVector< 3 > derivs[100];
    size_t verts[100], num_vtx = 37;
    NodeSet tmp_set;
    tmp_set.set_mid_edge_node( 1 );
    mf.derivatives( Sample( subdim, 0 ), tmp_set, verts, derivs, num_vtx, err );
    CPPUNIT_ASSERT( err );
    err.clear();

    // get number of vertices in element
    const unsigned n = TopologyInfo::corners( mf.element_topology() );

    // compare coefficients at each location
    vector< double > comp( 3 * n );
    for( unsigned i = 0; i < count; ++i )
    {
        num_vtx = 33;
        mf.derivatives( Sample( subdim, i ), NodeSet(), verts, derivs, num_vtx, err );
        CPPUNIT_ASSERT( !err );
        CPPUNIT_ASSERT( num_vtx > 0 );
        CPPUNIT_ASSERT( num_vtx <= n );

        mf2( xi, &comp[0] );
        string xi_str;
        for( unsigned j = 0; j < 3; ++j )
        {
            xi_str += !j ? "(" : ", ";
            xi_str += dtostr( xi[j] );
        }
        xi_str += ")";
        xi += 3;

        for( unsigned j = 0; j < num_vtx; ++j )
        {
            bool all_zero = true;
            for( unsigned k = 0; k < 3; ++k )
            {
                CppUnit::Message message( "Coefficient derivatives do not match." );
                message.addDetail( string( "Entity:             " ) + itostr( i ) );
                message.addDetail( string( "Coefficient number: " ) + itostr( j ) );
                message.addDetail( string( "Xi:             " ) + xi_str );
                message.addDetail( string( "Axis:           " ) + itostr( k ) );
                message.addDetail( string( "Expected value: " ) + dtostr( comp[3 * verts[j] + k] ) );
                message.addDetail( string( "Actual value:   " ) + dtostr( derivs[j][k] ) );
                ASSERT_MESSAGE( message, fabs( comp[3 * verts[j] + k] - derivs[j][k] ) < DBL_EPSILON );
                if( fabs( derivs[j][k] ) > DBL_EPSILON ) all_zero = false;
            }

            // if vertex has all zero values, it shouldn't have been in the
            // vertex list at all, as the Jacobian will not depend on that vertex.
            CPPUNIT_ASSERT( !all_zero );
        }

        // If any vertex is not in the list, then its values must be zero.
        sort( verts, verts + num_vtx );
        for( unsigned j = 0; j < num_vtx; ++j )
        {
            if( !binary_search( verts, verts + num_vtx, j ) )
            {
                for( unsigned k = 0; k < 3; ++k )
                {
                    CppUnit::Message message( "Missing coefficient derivatives." );
                    message.addDetail( string( "Entity:              " ) + itostr( i ) );
                    message.addDetail( string( "Coefficient number:  " ) + itostr( j ) );
                    message.addDetail( string( "Axis:                " ) + itostr( k ) );
                    message.addDetail( string( "Expected derivative: " ) + dtostr( comp[3 * j + k] ) );
                    ASSERT_MESSAGE( message, fabs( comp[3 * j + k] ) < DBL_EPSILON );
                }
            }
        }
    }
}

Definition at line 1041 of file LinearMappingFunctionTest.cpp.

References ASSERT_MATRICES_EQUAL, ASSERT_NO_ERROR, corners, CPPUNIT_ASSERT, CPPUNIT_ASSERT_DOUBLES_EQUAL, MBMesquite::MsqMatrix< R, C >::data(), MBMesquite::det(), MBMesquite::MappingFunction::element_topology(), MBMesquite::JacobianCalculator::get_Jacobian_2D(), MBMesquite::MappingFunction2D::ideal(), MBMesquite::inverse(), moab::R, MBMesquite::transpose(), and MBMesquite::unit_edge_element().

{
    MsqError err;
    MsqMatrix< 3, 2 > W_prime;
    mf.ideal( Sample( 2, 0 ), W_prime, err );
    ASSERT_NO_ERROR( err );

    // for this test that everything is in the xy-plane
    CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0, W_prime( 2, 0 ), 1e-12 );
    CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0, W_prime( 2, 1 ), 1e-12 );
    MsqMatrix< 2, 2 > W( W_prime.data() );
    CPPUNIT_ASSERT_DOUBLES_EQUAL( 1.0, det( W ), 1e-6 );

    const Vector3D* verts = unit_edge_element( mf.element_topology() );
    CPPUNIT_ASSERT( verts );

    JacobianCalculator jc;
    jc.get_Jacobian_2D( &mf, NodeSet(), Sample( 2, 0 ), verts, TopologyInfo::corners( mf.element_topology() ), W_prime,
                        err );
    ASSERT_NO_ERROR( err );

    // for this test that everything is in the xy-plane
    CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0, W_prime( 2, 0 ), 1e-12 );
    CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0, W_prime( 2, 1 ), 1e-12 );
    MsqMatrix< 2, 2 > W_exp( W_prime.data() );
    W_exp /= sqrt( det( W_exp ) );

    // Matrices should be a rotation of each other.
    // First, calculate tentative rotation matrix
    MsqMatrix< 2, 2 > R = inverse( W_exp ) * W;
    // next check that it is a rotation
    CPPUNIT_ASSERT_DOUBLES_EQUAL( 1.0, det( R ), 1e-6 );          // no scaling
    ASSERT_MATRICES_EQUAL( transpose( R ), inverse( R ), 1e-6 );  // orthogonal
}

Definition at line 1076 of file LinearMappingFunctionTest.cpp.

References ASSERT_MATRICES_EQUAL, ASSERT_NO_ERROR, MBMesquite::cbrt(), corners, CPPUNIT_ASSERT, CPPUNIT_ASSERT_DOUBLES_EQUAL, MBMesquite::det(), MBMesquite::MappingFunction::element_topology(), MBMesquite::JacobianCalculator::get_Jacobian_3D(), MBMesquite::MappingFunction3D::ideal(), MBMesquite::inverse(), moab::R, MBMesquite::transpose(), and MBMesquite::unit_edge_element().

{
    MsqError err;
    MsqMatrix< 3, 3 > W, I( 1.0 );
    mf.ideal( Sample( 3, 0 ), W, err );
    ASSERT_NO_ERROR( err );
    CPPUNIT_ASSERT_DOUBLES_EQUAL( 1.0, det( W ), 1e-6 );

    const Vector3D* verts = unit_edge_element( mf.element_topology() );
    CPPUNIT_ASSERT( verts );

    JacobianCalculator jc;
    MsqMatrix< 3, 3 > W_exp;
    jc.get_Jacobian_3D( &mf, NodeSet(), Sample( 3, 0 ), verts, TopologyInfo::corners( mf.element_topology() ), W_exp,
                        err );
    ASSERT_NO_ERROR( err );
    W_exp /= MBMesquite::cbrt( det( W_exp ) );

    // Matrices should be a rotation of each other.
    // First, calculate tentative rotation matrix
    MsqMatrix< 3, 3 > R = W * inverse( W_exp );
    // next check that it is a rotation
    CPPUNIT_ASSERT_DOUBLES_EQUAL( 1.0, det( R ), 1e-6 );   // no scaling
    ASSERT_MATRICES_EQUAL( I, transpose( R ) * R, 1e-6 );  // orthogonal
}
void LinearMappingFunctionTest::hex_coeff ( double  xi[3],
double  coeff[8] 
) [static, private]

Definition at line 641 of file LinearMappingFunctionTest.cpp.

{
    coeff[0] = ( 1 - xi[0] ) * ( 1 - xi[1] ) * ( 1 - xi[2] );
    coeff[1] = xi[0] * ( 1 - xi[1] ) * ( 1 - xi[2] );
    coeff[2] = xi[0] * xi[1] * ( 1 - xi[2] );
    coeff[3] = ( 1 - xi[0] ) * xi[1] * ( 1 - xi[2] );
    coeff[4] = ( 1 - xi[0] ) * ( 1 - xi[1] ) * xi[2];
    coeff[5] = xi[0] * ( 1 - xi[1] ) * xi[2];
    coeff[6] = xi[0] * xi[1] * xi[2];
    coeff[7] = ( 1 - xi[0] ) * xi[1] * xi[2];
}
void LinearMappingFunctionTest::hex_deriv ( double  xi[3],
double  coeff_deriv[24] 
) [static, private]

Definition at line 699 of file LinearMappingFunctionTest.cpp.

{
    coeff[3 * 0 + 0] = -( 1 - xi[1] ) * ( 1 - xi[2] );
    coeff[3 * 0 + 1] = -( 1 - xi[0] ) * ( 1 - xi[2] );
    coeff[3 * 0 + 2] = -( 1 - xi[0] ) * ( 1 - xi[1] );

    coeff[3 * 1 + 0] = ( 1 - xi[1] ) * ( 1 - xi[2] );
    coeff[3 * 1 + 1] = -xi[0] * ( 1 - xi[2] );
    coeff[3 * 1 + 2] = -xi[0] * ( 1 - xi[1] );

    coeff[3 * 2 + 0] = xi[1] * ( 1 - xi[2] );
    coeff[3 * 2 + 1] = xi[0] * ( 1 - xi[2] );
    coeff[3 * 2 + 2] = -xi[0] * xi[1];

    coeff[3 * 3 + 0] = -xi[1] * ( 1 - xi[2] );
    coeff[3 * 3 + 1] = ( 1 - xi[0] ) * ( 1 - xi[2] );
    coeff[3 * 3 + 2] = -( 1 - xi[0] ) * xi[1];

    coeff[3 * 4 + 0] = -( 1 - xi[1] ) * xi[2];
    coeff[3 * 4 + 1] = -( 1 - xi[0] ) * xi[2];
    coeff[3 * 4 + 2] = ( 1 - xi[0] ) * ( 1 - xi[1] );

    coeff[3 * 5 + 0] = ( 1 - xi[1] ) * xi[2];
    coeff[3 * 5 + 1] = -xi[0] * xi[2];
    coeff[3 * 5 + 2] = xi[0] * ( 1 - xi[1] );

    coeff[3 * 6 + 0] = xi[1] * xi[2];
    coeff[3 * 6 + 1] = xi[0] * xi[2];
    coeff[3 * 6 + 2] = xi[0] * xi[1];

    coeff[3 * 7 + 0] = -xi[1] * xi[2];
    coeff[3 * 7 + 1] = ( 1 - xi[0] ) * xi[2];
    coeff[3 * 7 + 2] = ( 1 - xi[0] ) * xi[1];
}
void LinearMappingFunctionTest::prism_coeff ( double  xi[3],
double  coeff[6] 
) [static, private]

Definition at line 676 of file LinearMappingFunctionTest.cpp.

{
    coeff[0] = ( 1 - xi[0] ) * ( 1 - xi[1] - xi[2] );
    coeff[1] = ( 1 - xi[0] ) * xi[1];
    coeff[2] = ( 1 - xi[0] ) * xi[2];
    coeff[3] = xi[0] * ( 1 - xi[1] - xi[2] );
    coeff[4] = xi[0] * xi[1];
    coeff[5] = xi[0] * xi[2];
}
void LinearMappingFunctionTest::prism_deriv ( double  xi[3],
double  coeff_deriv[18] 
) [static, private]

Definition at line 761 of file LinearMappingFunctionTest.cpp.

{
    coeff[0] = xi[1] + xi[2] - 1.0;
    ;
    coeff[1] = xi[0] - 1.0;
    coeff[2] = xi[0] - 1.0;

    coeff[3] = -xi[1];
    coeff[4] = 1.0 - xi[0];
    coeff[5] = 0.0;

    coeff[6] = -xi[2];
    coeff[7] = 0.0;
    coeff[8] = 1.0 - xi[0];

    coeff[9]  = 1.0 - xi[1] - xi[2];
    coeff[10] = -xi[0];
    coeff[11] = -xi[0];

    coeff[12] = xi[1];
    coeff[13] = xi[0];
    coeff[14] = 0.0;

    coeff[15] = xi[2];
    coeff[16] = 0.0;
    coeff[17] = xi[0];
}
void LinearMappingFunctionTest::pyr_coeff ( double  xi[3],
double  coeff[5] 
) [static, private]

Definition at line 686 of file LinearMappingFunctionTest.cpp.

{
    coeff[0] = ( 1 - xi[0] ) * ( 1 - xi[1] ) * ( 1 - xi[2] );
    coeff[1] = xi[0] * ( 1 - xi[1] ) * ( 1 - xi[2] );
    coeff[2] = xi[0] * xi[1] * ( 1 - xi[2] );
    coeff[3] = ( 1 - xi[0] ) * xi[1] * ( 1 - xi[2] );
    coeff[4] = xi[2];
}
void LinearMappingFunctionTest::pyr_deriv ( double  xi[3],
double  coeff_deriv[15] 
) [static, private]

Definition at line 789 of file LinearMappingFunctionTest.cpp.

{
    coeff[3 * 0 + 0] = -( 1 - xi[1] ) * ( 1 - xi[2] );
    coeff[3 * 0 + 1] = -( 1 - xi[0] ) * ( 1 - xi[2] );
    coeff[3 * 0 + 2] = -( 1 - xi[0] ) * ( 1 - xi[1] );

    coeff[3 * 1 + 0] = ( 1 - xi[1] ) * ( 1 - xi[2] );
    coeff[3 * 1 + 1] = -xi[0] * ( 1 - xi[2] );
    coeff[3 * 1 + 2] = -xi[0] * ( 1 - xi[1] );

    coeff[3 * 2 + 0] = xi[1] * ( 1 - xi[2] );
    coeff[3 * 2 + 1] = xi[0] * ( 1 - xi[2] );
    coeff[3 * 2 + 2] = -xi[0] * xi[1];

    coeff[3 * 3 + 0] = -xi[1] * ( 1 - xi[2] );
    coeff[3 * 3 + 1] = ( 1 - xi[0] ) * ( 1 - xi[2] );
    coeff[3 * 3 + 2] = -xi[1] * ( 1 - xi[0] );

    coeff[3 * 4 + 0] = 0.0;
    coeff[3 * 4 + 1] = 0.0;
    coeff[3 * 4 + 2] = 1.0;
}
void LinearMappingFunctionTest::quad_coeff ( double  xi[2],
double  coeff[4] 
) [static, private]

Definition at line 661 of file LinearMappingFunctionTest.cpp.

{
    coeff[0] = ( 1 - xi[0] ) * ( 1 - xi[1] );
    coeff[1] = xi[0] * ( 1 - xi[1] );
    coeff[2] = xi[0] * xi[1];
    coeff[3] = ( 1 - xi[0] ) * xi[1];
}
void LinearMappingFunctionTest::quad_deriv ( double  xi[2],
double  coeff_deriv[8] 
) [static, private]

Definition at line 740 of file LinearMappingFunctionTest.cpp.

{
    coeff[2 * 0 + 0] = xi[1] - 1;
    coeff[2 * 0 + 1] = xi[0] - 1;

    coeff[2 * 1 + 0] = 1 - xi[1];
    coeff[2 * 1 + 1] = -xi[0];

    coeff[2 * 2 + 0] = xi[1];
    coeff[2 * 2 + 1] = xi[0];

    coeff[2 * 3 + 0] = -xi[1];
    coeff[2 * 3 + 1] = 1 - xi[0];
}

Definition at line 252 of file LinearMappingFunctionTest.cpp.

{}
void LinearMappingFunctionTest::test_coeff_fail ( MappingFunction mf,
unsigned  subdim 
) [private]

Definition at line 1102 of file LinearMappingFunctionTest.cpp.

References MBMesquite::MsqError::clear(), MBMesquite::MappingFunction::coefficients(), and CPPUNIT_ASSERT.

{
    // make sure it fails if called
    MsqError err;
    double coeff[100];
    size_t num_coeff, indices[100];
    mf.coefficients( Sample( subdim, 0 ), NodeSet(), coeff, indices, num_coeff, err );
    CPPUNIT_ASSERT( err );
    err.clear();
}
void LinearMappingFunctionTest::test_deriv_fail ( MappingFunction2D mf,
unsigned  subdim 
) [private]

Definition at line 1113 of file LinearMappingFunctionTest.cpp.

References MBMesquite::MsqError::clear(), CPPUNIT_ASSERT, and MBMesquite::MappingFunction2D::derivatives().

{
    // make sure it fails if called
    MsqError err;
    MsqVector< 2 > coeff[100];
    size_t verts[100], num_coeff;
    mf.derivatives( Sample( subdim, 0 ), NodeSet(), verts, coeff, num_coeff, err );
    CPPUNIT_ASSERT( err );
    err.clear();
}
void LinearMappingFunctionTest::test_deriv_fail ( MappingFunction3D mf,
unsigned  subdim 
) [private]

Definition at line 1124 of file LinearMappingFunctionTest.cpp.

References MBMesquite::MsqError::clear(), CPPUNIT_ASSERT, and MBMesquite::MappingFunction3D::derivatives().

{
    // make sure it fails if called
    MsqError err;
    MsqVector< 3 > coeff[100];
    size_t verts[100], num_coeff;
    mf.derivatives( Sample( subdim, 0 ), NodeSet(), verts, coeff, num_coeff, err );
    CPPUNIT_ASSERT( err );
    err.clear();
}

Definition at line 342 of file LinearMappingFunctionTest.cpp.

References MBMesquite::xi.

{
    double xi[3] = { 0.5, 0.5, 0.5 };
    do_coeff_test( hex, 3, hex_coeff, 1, xi );
}

Definition at line 502 of file LinearMappingFunctionTest.cpp.

References MBMesquite::xi.

{
    double xi[3] = { 0.5, 0.5, 0.5 };
    do_deriv_test( hex, 3, hex_deriv, 1, xi );
}

Definition at line 446 of file LinearMappingFunctionTest.cpp.

References MBMesquite::xi.

{
    double xi[3] = { 0.5, 1. / 3, 1. / 3 };
    do_coeff_test( prism, 3, prism_coeff, 1, xi );
}

Definition at line 606 of file LinearMappingFunctionTest.cpp.

References MBMesquite::xi.

{
    double xi[3] = { 0.5, 1. / 3, 1. / 3 };
    do_deriv_test( prism, 3, prism_deriv, 1, xi );
}

Definition at line 471 of file LinearMappingFunctionTest.cpp.

References MBMesquite::xi.

{
    double xi[3] = { 0.5, 0.5, 0.5 };
    do_coeff_test( pyr, 3, pyr_coeff, 1, xi );
}

Definition at line 452 of file LinearMappingFunctionTest.cpp.

References MBMesquite::xi.

{
    double xi[15] = { 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 0, 0, 1 };
    do_coeff_test( pyr, 0, pyr_coeff, 5, xi );
}

Definition at line 458 of file LinearMappingFunctionTest.cpp.

References MBMesquite::xi.

{
    double xi[24] = { 0.5, 0.0, 0.0, 1.0, 0.5, 0.0, 0.5, 1.0, 0.0, 0.0, 0.5, 0.0,
                      0.0, 0.0, 0.5, 1.0, 0.0, 0.5, 1.0, 1.0, 0.5, 0.0, 1.0, 0.5 };
    do_coeff_test( pyr, 1, pyr_coeff, 8, xi );
}

Definition at line 465 of file LinearMappingFunctionTest.cpp.

References MBMesquite::xi.

{
    double xi[15] = { 0.5, 0.0, 0.5, 1.0, 0.5, 0.5, 0.5, 1.0, 0.5, 0.0, 0.5, 0.5, 0.5, 0.5, 0.0 };
    do_coeff_test( pyr, 2, pyr_coeff, 5, xi );
}

Definition at line 631 of file LinearMappingFunctionTest.cpp.

References MBMesquite::xi.

{
    double xi[3] = { 0.5, 0.5, 0.5 };
    do_deriv_test( pyr, 3, pyr_deriv, 1, xi );
}

Definition at line 612 of file LinearMappingFunctionTest.cpp.

References MBMesquite::xi.

{
    double xi[15] = { 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 0.5, 0.5, 1 };
    do_deriv_test( pyr, 0, pyr_deriv, 5, xi );
}

Definition at line 618 of file LinearMappingFunctionTest.cpp.

References MBMesquite::xi.

{
    double xi[24] = { 0.5, 0.0, 0.0, 1.0, 0.5, 0.0, 0.5, 1.0, 0.0, 0.0, 0.5, 0.0,
                      0.0, 0.0, 0.5, 1.0, 0.0, 0.5, 1.0, 1.0, 0.5, 0.0, 1.0, 0.5 };
    do_deriv_test( pyr, 1, pyr_deriv, 8, xi );
}

Definition at line 625 of file LinearMappingFunctionTest.cpp.

References MBMesquite::xi.

{
    double xi[15] = { 0.5, 0.0, 0.5, 1.0, 0.5, 0.5, 0.5, 1.0, 0.5, 0.0, 0.5, 0.5, 0.5, 0.5, 0.0 };
    do_deriv_test( pyr, 2, pyr_deriv, 5, xi );
}

Definition at line 367 of file LinearMappingFunctionTest.cpp.

References MBMesquite::xi.

{
    double xi[2] = { 0.5, 0.5 };
    do_coeff_test( quad, 2, quad_coeff, 1, xi );
}

Definition at line 527 of file LinearMappingFunctionTest.cpp.

References MBMesquite::xi.

{
    double xi[2] = { 0.5, 0.5 };
    do_deriv_test( quad, 2, quad_deriv, 1, xi );
}

Definition at line 394 of file LinearMappingFunctionTest.cpp.

References MBMesquite::xi.

{
    double xi[3] = { 0.25, 0.25, 0.25 };
    do_coeff_test( tet, 3, tet_coeff, 1, xi );
}

Definition at line 554 of file LinearMappingFunctionTest.cpp.

References MBMesquite::xi.

{
    double xi[3] = { 0.25, 0.25, 0.25 };
    do_deriv_test( tet, 3, tet_deriv, 1, xi );
}

Definition at line 419 of file LinearMappingFunctionTest.cpp.

References MBMesquite::xi.

{
    double xi[2] = { 1. / 3, 1. / 3 };
    do_coeff_test( tri, 2, tri_coeff, 1, xi );
}

Definition at line 579 of file LinearMappingFunctionTest.cpp.

References MBMesquite::xi.

{
    double xi[2] = { 1. / 3, 1. / 3 };
    do_deriv_test( tri, 2, tri_deriv, 1, xi );
}
void LinearMappingFunctionTest::tet_coeff ( double  xi[3],
double  coeff[4] 
) [static, private]

Definition at line 653 of file LinearMappingFunctionTest.cpp.

{
    coeff[0] = 1 - xi[0] - xi[1] - xi[2];
    coeff[1] = xi[0];
    coeff[2] = xi[1];
    coeff[3] = xi[2];
}
void LinearMappingFunctionTest::tet_deriv ( double  xi[3],
double  coeff_deriv[12] 
) [static, private]

Definition at line 734 of file LinearMappingFunctionTest.cpp.

{
    static const double derivs[] = { -1, -1, -1, 1, 0, 0, 0, 1, 0, 0, 0, 1 };
    memcpy( coeff, derivs, sizeof( derivs ) );
}
void LinearMappingFunctionTest::tri_coeff ( double  xi[2],
double  coeff[3] 
) [static, private]

Definition at line 669 of file LinearMappingFunctionTest.cpp.

{
    coeff[0] = 1 - xi[0] - xi[1];
    coeff[1] = xi[0];
    coeff[2] = xi[1];
}
void LinearMappingFunctionTest::tri_deriv ( double  xi[2],
double  coeff_deriv[6] 
) [static, private]

Definition at line 755 of file LinearMappingFunctionTest.cpp.

{
    static const double derivs[] = { -1, -1, 1, 0, 0, 1 };
    memcpy( coeff, derivs, sizeof( derivs ) );
}
void LinearMappingFunctionTest::xi_at_corners ( EntityTopology  type,
double *  xi,
const int *  corners 
) [private]

Definition at line 275 of file LinearMappingFunctionTest.cpp.

References corners.

{
    unsigned d = TopologyInfo::dimension( type );
    unsigned c = TopologyInfo::corners( type );
    for( unsigned i = 0; i < c * d; ++i )
        xi[i] = corners[i];
}
void LinearMappingFunctionTest::xi_at_edges ( EntityTopology  type,
double *  xi,
const int *  corners 
) [private]

Definition at line 283 of file LinearMappingFunctionTest.cpp.

References CPPUNIT_ASSERT, MBMesquite::edges, and vtx().

{
    MsqError err;
    unsigned d = TopologyInfo::dimension( type );
    unsigned e = TopologyInfo::edges( type );
    for( unsigned i = 0; i < e; ++i )
    {
        const unsigned* vtx = TopologyInfo::edge_vertices( type, i, err );
        CPPUNIT_ASSERT( !err );
        for( unsigned j = 0; j < d; ++j )
            xi[d * i + j] = ( corners[d * vtx[0] + j] + corners[d * vtx[1] + j] ) / 2.0;
    }
}
void LinearMappingFunctionTest::xi_at_faces ( EntityTopology  type,
double *  xi,
const int *  corners 
) [private]

Definition at line 297 of file LinearMappingFunctionTest.cpp.

References CPPUNIT_ASSERT, MBMesquite::faces, moab::sum(), and vtx().

{
    MsqError err;
    unsigned d = TopologyInfo::dimension( type );
    unsigned f = TopologyInfo::faces( type );
    for( unsigned i = 0; i < f; ++i )
    {
        unsigned c;
        const unsigned* vtx = TopologyInfo::face_vertices( type, i, c, err );
        CPPUNIT_ASSERT( !err );
        for( unsigned j = 0; j < d; ++j )
        {
            int sum = 0;
            for( unsigned k = 0; k < c; ++k )
                sum += corners[d * vtx[k] + j];
            xi[d * i + j] = (double)sum / c;
        }
    }
}

Member Data Documentation

List of all members.


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines