MOAB: Mesh Oriented datABase  (version 5.4.1)
CachingTargetTest Class Reference
+ Inheritance diagram for CachingTargetTest:
+ Collaboration diagram for CachingTargetTest:

Public Member Functions

void setUp ()
void tearDown ()
void test_surface_orient_flag ()
void test_3d_targets_cached ()
void test_2d_targets_cached ()
void test_surface_targets_cached ()
void test_3d_target_values ()
void test_2d_target_values ()
void test_surface_target_values ()
void test_3d_target_subpatch ()
void test_2d_target_subpatch ()
void test_surface_target_subpatch ()
void test_cache_cleared ()

Private Member Functions

 CPPUNIT_TEST_SUITE (CachingTargetTest)
 CPPUNIT_TEST (test_surface_orient_flag)
 CPPUNIT_TEST (test_3d_targets_cached)
 CPPUNIT_TEST (test_2d_targets_cached)
 CPPUNIT_TEST (test_surface_targets_cached)
 CPPUNIT_TEST (test_3d_target_values)
 CPPUNIT_TEST (test_2d_target_values)
 CPPUNIT_TEST (test_surface_target_values)
 CPPUNIT_TEST (test_3d_target_subpatch)
 CPPUNIT_TEST (test_2d_target_subpatch)
 CPPUNIT_TEST (test_surface_target_subpatch)
 CPPUNIT_TEST (test_cache_cleared)
 CPPUNIT_TEST_SUITE_END ()
unsigned request_all_targets_3d ()
unsigned request_all_targets_2d ()
unsigned request_all_targets_surf ()

Private Attributes

PatchData patch_3d
PatchData patch_2d
CachedTargetCalculatorcached
CachingTargetCalculatorcacher

Detailed Description

Definition at line 44 of file CachingTargetTest.cpp.


Member Function Documentation

Definition at line 216 of file CachingTargetTest.cpp.

References ASSERT_NO_ERROR, and CPPUNIT_ASSERT.

{
    unsigned total = 0;
    MsqMatrix< 2, 2 > W;
    MsqPrintError err( std::cout );
    std::vector< Sample > locations;

    for( size_t i = 0; i < patch_2d.num_elements(); ++i )
    {
        patch_2d.get_samples( i, locations, err );
        ASSERT_NO_ERROR( err );
        total += locations.size();
        for( unsigned j = 0; j < locations.size(); ++j )
        {
            bool rval = cacher->get_2D_target( patch_2d, i, locations[j], W, err );
            CPPUNIT_ASSERT( rval );
            CPPUNIT_ASSERT( !err );
        }
    }
    return total;
}

Definition at line 194 of file CachingTargetTest.cpp.

References ASSERT_NO_ERROR, and CPPUNIT_ASSERT.

{
    unsigned total = 0;
    MsqMatrix< 3, 3 > W;
    MsqPrintError err( std::cout );
    std::vector< Sample > locations;

    for( size_t i = 0; i < patch_3d.num_elements(); ++i )
    {
        patch_3d.get_samples( i, locations, err );
        ASSERT_NO_ERROR( err );
        total += locations.size();
        for( unsigned j = 0; j < locations.size(); ++j )
        {
            bool rval = cacher->get_3D_target( patch_3d, i, locations[j], W, err );
            CPPUNIT_ASSERT( rval );
            CPPUNIT_ASSERT( !err );
        }
    }
    return total;
}

Definition at line 238 of file CachingTargetTest.cpp.

References ASSERT_NO_ERROR, and CPPUNIT_ASSERT.

{
    unsigned total = 0;
    MsqMatrix< 3, 2 > W;
    MsqPrintError err( std::cout );
    std::vector< Sample > locations;

    for( size_t i = 0; i < patch_2d.num_elements(); ++i )
    {
        patch_2d.get_samples( i, locations, err );
        ASSERT_NO_ERROR( err );
        total += locations.size();
        for( unsigned j = 0; j < locations.size(); ++j )
        {
            bool rval = cacher->get_surface_target( patch_2d, i, locations[j], W, err );
            CPPUNIT_ASSERT( rval );
            CPPUNIT_ASSERT( !err );
        }
    }
    return total;
}

Definition at line 177 of file CachingTargetTest.cpp.

References CPPUNIT_ASSERT, MBMesquite::create_four_quads_patch(), and MBMesquite::create_qm_two_hex_patch().

{
    // make sure these are null so that if we fail within setUp,
    // tearDown doesn't try to delete stale pointers
    cached = 0;
    cacher = 0;

    MsqError err;
    create_four_quads_patch( patch_2d, err );
    CPPUNIT_ASSERT( !err );
    create_qm_two_hex_patch( patch_3d, err );
    CPPUNIT_ASSERT( !err );

    cached = new CachedTargetCalculator();
    cacher = new CachingTargetCalculator( cached );
}

Definition at line 260 of file CachingTargetTest.cpp.

{
    delete cacher;
    delete cached;
}

Definition at line 442 of file CachingTargetTest.cpp.

References ASSERT_MATRICES_EQUAL, ASSERT_NO_ERROR, CPPUNIT_ASSERT, CPPUNIT_ASSERT_EQUAL, MBMesquite::PatchData::get_subpatch(), CachedTargetCalculator::make_2d(), and u.

{
    MsqPrintError err( std::cout );
    std::vector< Sample > locations;

    // cache some values on the main patch
    cached->surf_orient( false );
    request_all_targets_2d();

    // clear the count so we know if any additional
    // evalutions of the base target calculator are
    // done during subpatch creation.
    cached->clear();

    // create a sub-patch
    CPPUNIT_ASSERT( patch_2d.num_nodes() > 1 );
    PatchData subpatch;
    patch_2d.get_subpatch( 1, 1, subpatch, err );
    CPPUNIT_ASSERT( !err );

    // make sure we copied the cached values onto the subpatch
    CPPUNIT_ASSERT_EQUAL( cached->calls_2d(), 0u );

    // Test the values for each cached matrix on the subpatch
    // NOTE:  This test takes advantange of the fact that the
    // "handles" in the subpatch are indices into the main patch.

    // test each value
    for( size_t i = 0; i < subpatch.num_elements(); ++i )
    {
        subpatch.get_samples( i, locations, err );
        ASSERT_NO_ERROR( err );
        for( unsigned j = 0; j < locations.size(); ++j )
        {
            MsqMatrix< 2, 2 > W;
            bool rval = cacher->get_2D_target( subpatch, i, locations[j], W, err );
            CPPUNIT_ASSERT( rval && !err );

            Mesh::ElementHandle h      = subpatch.get_element_handles_array()[i];
            Mesh::ElementHandle* old_h = patch_2d.get_element_handles_array();
            size_t old_idx             = std::find( old_h, old_h + patch_2d.num_elements(), h ) - old_h;
            CPPUNIT_ASSERT( old_idx < patch_2d.num_elements() );
            MsqMatrix< 2, 2 > M = CachedTargetCalculator::make_2d( old_idx, locations[j] );
            ASSERT_MATRICES_EQUAL( W, M, DBL_EPSILON );
        }
    }
}

Definition at line 343 of file CachingTargetTest.cpp.

References ASSERT_MATRICES_EQUAL, ASSERT_NO_ERROR, CPPUNIT_ASSERT, and CachedTargetCalculator::make_2d().

{
    MsqPrintError err( std::cout );
    std::vector< Sample > locations;

    // evaluate all once to make sure we test the cached values
    cached->surf_orient( false );
    request_all_targets_2d();

    // test each value
    for( size_t i = 0; i < patch_2d.num_elements(); ++i )
    {
        patch_2d.get_samples( i, locations, err );
        ASSERT_NO_ERROR( err );
        for( unsigned j = 0; j < locations.size(); ++j )
        {
            MsqMatrix< 2, 2 > W;
            bool rval = cacher->get_2D_target( patch_2d, i, locations[j], W, err );
            CPPUNIT_ASSERT( rval && !err );

            MsqMatrix< 2, 2 > M = CachedTargetCalculator::make_2d( i, locations[j] );
            ASSERT_MATRICES_EQUAL( W, M, DBL_EPSILON );
        }
    }
}

Definition at line 395 of file CachingTargetTest.cpp.

References ASSERT_MATRICES_EQUAL, ASSERT_NO_ERROR, CPPUNIT_ASSERT, CPPUNIT_ASSERT_EQUAL, MBMesquite::PatchData::get_subpatch(), CachedTargetCalculator::make_3d(), and u.

{
    MsqPrintError err( std::cout );
    std::vector< Sample > locations;

    // cache some values on the main patch
    request_all_targets_3d();

    // clear the count so we know if any additional
    // evalutions of the base target calculator are
    // done during subpatch creation.
    cached->clear();

    // create a sub-patch
    CPPUNIT_ASSERT( patch_3d.num_nodes() > 1 );
    PatchData subpatch;
    patch_3d.get_subpatch( 1, 1, subpatch, err );
    CPPUNIT_ASSERT( !err );

    // make sure we copied the cached values onto the subpatch
    CPPUNIT_ASSERT_EQUAL( cached->calls_3d(), 0u );

    // Test the values for each cached matrix on the subpatch
    // NOTE:  This test takes advantange of the fact that the
    // "handles" in the subpatch are indices into the main patch.

    // test each value
    for( size_t i = 0; i < subpatch.num_elements(); ++i )
    {
        subpatch.get_samples( i, locations, err );
        ASSERT_NO_ERROR( err );
        for( unsigned j = 0; j < locations.size(); ++j )
        {
            MsqMatrix< 3, 3 > W;
            bool rval = cacher->get_3D_target( subpatch, i, locations[j], W, err );
            CPPUNIT_ASSERT( rval && !err );

            Mesh::ElementHandle h      = subpatch.get_element_handles_array()[i];
            Mesh::ElementHandle* old_h = patch_3d.get_element_handles_array();
            size_t old_idx             = std::find( old_h, old_h + patch_3d.num_elements(), h ) - old_h;
            CPPUNIT_ASSERT( old_idx < patch_3d.num_elements() );
            MsqMatrix< 3, 3 > M = CachedTargetCalculator::make_3d( old_idx, locations[j] );
            ASSERT_MATRICES_EQUAL( W, M, DBL_EPSILON );
        }
    }
}

Definition at line 318 of file CachingTargetTest.cpp.

References ASSERT_MATRICES_EQUAL, ASSERT_NO_ERROR, CPPUNIT_ASSERT, and CachedTargetCalculator::make_3d().

{
    MsqPrintError err( std::cout );
    std::vector< Sample > locations;

    // evaluate all once to make sure we test the cached values
    request_all_targets_3d();

    // test each value
    for( size_t i = 0; i < patch_3d.num_elements(); ++i )
    {
        patch_3d.get_samples( i, locations, err );
        ASSERT_NO_ERROR( err );
        for( unsigned j = 0; j < locations.size(); ++j )
        {
            MsqMatrix< 3, 3 > W;
            bool rval = cacher->get_3D_target( patch_3d, i, locations[j], W, err );
            CPPUNIT_ASSERT( rval && !err );

            MsqMatrix< 3, 3 > M = CachedTargetCalculator::make_3d( i, locations[j] );
            ASSERT_MATRICES_EQUAL( W, M, DBL_EPSILON );
        }
    }
}

Definition at line 538 of file CachingTargetTest.cpp.

References CPPUNIT_ASSERT, CPPUNIT_ASSERT_EQUAL, and MBMesquite::create_twelve_hex_patch().

{
    MsqPrintError err( std::cout );

    // cache some values on the main patch
    request_all_targets_3d();

    // clear the count so we know if any additional
    // evalutions of the base target calculator are
    // done.
    cached->clear();

    // now re-create the patch, which should result in the
    // cached data being notified that the mesh has changed
    create_twelve_hex_patch( patch_3d, err );
    CPPUNIT_ASSERT( !err );

    // now get cached values for each element
    unsigned count = request_all_targets_3d();

    // and check that they were all re-calculated
    CPPUNIT_ASSERT_EQUAL( cached->calls_3d(), count );
}

Definition at line 490 of file CachingTargetTest.cpp.

References ASSERT_MATRICES_EQUAL, ASSERT_NO_ERROR, CPPUNIT_ASSERT, CPPUNIT_ASSERT_EQUAL, MBMesquite::PatchData::get_subpatch(), CachedTargetCalculator::make_surf(), and u.

{
    MsqPrintError err( std::cout );
    std::vector< Sample > locations;

    // cache some values on the main patch
    cached->surf_orient( true );
    request_all_targets_surf();

    // clear the count so we know if any additional
    // evalutions of the base target calculator are
    // done during subpatch creation.
    cached->clear();

    // create a sub-patch
    CPPUNIT_ASSERT( patch_2d.num_nodes() > 1 );
    PatchData subpatch;
    patch_2d.get_subpatch( 1, 1, subpatch, err );
    CPPUNIT_ASSERT( !err );

    // make sure we copied the cached values onto the subpatch
    CPPUNIT_ASSERT_EQUAL( cached->calls_2d(), 0u );

    // Test the values for each cached matrix on the subpatch
    // NOTE:  This test takes advantange of the fact that the
    // "handles" in the subpatch are indices into the main patch.

    // test each value
    for( size_t i = 0; i < subpatch.num_elements(); ++i )
    {
        subpatch.get_samples( i, locations, err );
        ASSERT_NO_ERROR( err );
        for( unsigned j = 0; j < locations.size(); ++j )
        {
            MsqMatrix< 3, 2 > W;
            bool rval = cacher->get_surface_target( subpatch, i, locations[j], W, err );
            CPPUNIT_ASSERT( rval && !err );

            Mesh::ElementHandle h      = subpatch.get_element_handles_array()[i];
            Mesh::ElementHandle* old_h = patch_2d.get_element_handles_array();
            size_t old_idx             = std::find( old_h, old_h + patch_2d.num_elements(), h ) - old_h;
            CPPUNIT_ASSERT( old_idx < patch_2d.num_elements() );
            MsqMatrix< 3, 2 > M = CachedTargetCalculator::make_surf( old_idx, locations[j] );
            ASSERT_MATRICES_EQUAL( W, M, DBL_EPSILON );
        }
    }
}

Definition at line 369 of file CachingTargetTest.cpp.

References ASSERT_MATRICES_EQUAL, ASSERT_NO_ERROR, CPPUNIT_ASSERT, and CachedTargetCalculator::make_surf().

{
    MsqPrintError err( std::cout );
    std::vector< Sample > locations;

    // evaluate all once to make sure we test the cached values
    cached->surf_orient( true );
    request_all_targets_surf();

    // test each value
    for( size_t i = 0; i < patch_2d.num_elements(); ++i )
    {
        patch_2d.get_samples( i, locations, err );
        ASSERT_NO_ERROR( err );
        for( unsigned j = 0; j < locations.size(); ++j )
        {
            MsqMatrix< 3, 2 > W;
            bool rval = cacher->get_surface_target( patch_2d, i, locations[j], W, err );
            CPPUNIT_ASSERT( rval && !err );

            MsqMatrix< 3, 2 > M = CachedTargetCalculator::make_surf( i, locations[j] );
            ASSERT_MATRICES_EQUAL( W, M, DBL_EPSILON );
        }
    }
}

Member Data Documentation

Definition at line 61 of file CachingTargetTest.cpp.

Definition at line 61 of file CachingTargetTest.cpp.

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