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

Public Member Functions

void setUp ()
void tearDown ()
void read_write_3D_targets ()
void read_write_2D_targets ()
void read_write_surface_targets ()
void read_write_weights ()

Private Member Functions

 CPPUNIT_TEST_SUITE (TargetReadWriteTest)
 CPPUNIT_TEST (read_write_3D_targets)
 CPPUNIT_TEST (read_write_2D_targets)
 CPPUNIT_TEST (read_write_surface_targets)
 CPPUNIT_TEST (read_write_weights)
 CPPUNIT_TEST_SUITE_END ()

Private Attributes

MeshImpl myMesh
PatchData myPatch
Settings linearMaps

Detailed Description

Definition at line 48 of file TargetReadWriteTest.cpp.


Member Function Documentation

Definition at line 291 of file TargetReadWriteTest.cpp.

References ASSERT_MATRICES_EQUAL, ASSERT_NO_ERROR, CPPUNIT_ASSERT, MBMesquite::TargetReader::get_2D_target(), FakeTargetCalc::get_2D_target(), and MBMesquite::TargetWriter::loop_over_mesh().

{
    const bool oriented = false;

    MsqPrintError err( std::cout );
    FakeTargetCalc tc( oriented );

    // Write the targets
    TargetWriter writer( &tc );
    MeshDomainAssoc mesh_and_domain = MeshDomainAssoc( &myMesh, 0 );
    writer.loop_over_mesh( &mesh_and_domain, &linearMaps, err );
    CPPUNIT_ASSERT( !err );

    // Compare all target matrices
    bool checked_something = false;  // make sure mesh actually contains surface elements
    TargetReader reader( oriented );
    for( size_t i = 0; i < myPatch.num_elements(); ++i )
    {
        const unsigned d = TopologyInfo::dimension( myPatch.element_by_index( i ).get_element_type() );
        if( d != 2 ) continue;

        checked_something = true;
        std::vector< Sample > samples;
        myPatch.get_samples( i, samples, err );
        ASSERT_NO_ERROR( err );
        for( size_t j = 0; j < samples.size(); ++j )
        {
            MsqMatrix< 2, 2 > expected, read;
            tc.get_2D_target( myPatch, i, samples[j], expected, err );
            CPPUNIT_ASSERT( !err );
            reader.get_2D_target( myPatch, i, samples[j], read, err );
            CPPUNIT_ASSERT( !err );
            ASSERT_MATRICES_EQUAL( expected, read, 1e-6 );
        }
    }

    CPPUNIT_ASSERT( checked_something );
}

Definition at line 213 of file TargetReadWriteTest.cpp.

References ASSERT_MATRICES_EQUAL, ASSERT_NO_ERROR, CPPUNIT_ASSERT, MBMesquite::TargetReader::get_3D_target(), FakeTargetCalc::get_3D_target(), and MBMesquite::TargetWriter::loop_over_mesh().

{
    const bool oriented = true;  // doesn't matter which value for 3D

    MsqPrintError err( std::cout );
    FakeTargetCalc tc( oriented );

    // Write the targets
    TargetWriter writer( &tc );
    MeshDomainAssoc mesh_and_domain = MeshDomainAssoc( &myMesh, 0 );
    writer.loop_over_mesh( &mesh_and_domain, &linearMaps, err );
    CPPUNIT_ASSERT( !err );

    // Compare all target matrices
    bool checked_something = false;  // make sure mesh actually contains volume elements
    TargetReader reader( oriented );
    for( size_t i = 0; i < myPatch.num_elements(); ++i )
    {
        const unsigned d = TopologyInfo::dimension( myPatch.element_by_index( i ).get_element_type() );
        if( d != 3 ) continue;

        checked_something = true;
        std::vector< Sample > samples;
        myPatch.get_samples( i, samples, err );
        ASSERT_NO_ERROR( err );
        for( size_t j = 0; j < samples.size(); ++j )
        {
            MsqMatrix< 3, 3 > expected, read;
            tc.get_3D_target( myPatch, i, samples[j], expected, err );
            CPPUNIT_ASSERT( !err );
            reader.get_3D_target( myPatch, i, samples[j], read, err );
            CPPUNIT_ASSERT( !err );
            ASSERT_MATRICES_EQUAL( expected, read, 1e-12 );
        }
    }

    CPPUNIT_ASSERT( checked_something );
}

Definition at line 252 of file TargetReadWriteTest.cpp.

References ASSERT_MATRICES_EQUAL, ASSERT_NO_ERROR, CPPUNIT_ASSERT, MBMesquite::TargetReader::get_surface_target(), FakeTargetCalc::get_surface_target(), and MBMesquite::TargetWriter::loop_over_mesh().

{
    const bool oriented = true;

    MsqPrintError err( std::cout );
    FakeTargetCalc tc( oriented );

    // Write the targets
    TargetWriter writer( &tc );
    MeshDomainAssoc mesh_and_domain = MeshDomainAssoc( &myMesh, 0 );
    writer.loop_over_mesh( &mesh_and_domain, &linearMaps, err );
    CPPUNIT_ASSERT( !err );

    // Compare all target matrices
    bool checked_something = false;  // make sure mesh actually contains surface elements
    TargetReader reader( oriented );
    for( size_t i = 0; i < myPatch.num_elements(); ++i )
    {
        const unsigned d = TopologyInfo::dimension( myPatch.element_by_index( i ).get_element_type() );
        if( d != 2 ) continue;

        checked_something = true;
        std::vector< Sample > samples;
        myPatch.get_samples( i, samples, err );
        ASSERT_NO_ERROR( err );
        for( size_t j = 0; j < samples.size(); ++j )
        {
            MsqMatrix< 3, 2 > expected, read;
            tc.get_surface_target( myPatch, i, samples[j], expected, err );
            CPPUNIT_ASSERT( !err );
            reader.get_surface_target( myPatch, i, samples[j], read, err );
            CPPUNIT_ASSERT( !err );
            ASSERT_MATRICES_EQUAL( expected, read, 1e-6 );
        }
    }

    CPPUNIT_ASSERT( checked_something );
}

Definition at line 330 of file TargetReadWriteTest.cpp.

References ASSERT_NO_ERROR, CPPUNIT_ASSERT, CPPUNIT_ASSERT_DOUBLES_EQUAL, MBMesquite::WeightReader::get_weight(), FakeTargetCalc::get_weight(), and MBMesquite::TargetWriter::loop_over_mesh().

{
    MsqPrintError err( std::cout );
    FakeTargetCalc tc;

    // Write the targets
    TargetWriter writer( 0, &tc );
    MeshDomainAssoc mesh_and_domain = MeshDomainAssoc( &myMesh, 0 );
    writer.loop_over_mesh( &mesh_and_domain, &linearMaps, err );
    CPPUNIT_ASSERT( !err );

    // Compare all target matrices
    WeightReader reader;
    for( size_t i = 0; i < myPatch.num_elements(); ++i )
    {
        std::vector< Sample > samples;
        myPatch.get_samples( i, samples, err );
        ASSERT_NO_ERROR( err );
        for( size_t j = 0; j < samples.size(); ++j )
        {
            double expected = tc.get_weight( myPatch, i, samples[j], err );
            CPPUNIT_ASSERT( !err );
            double read = reader.get_weight( myPatch, i, samples[j], err );
            CPPUNIT_ASSERT( !err );
            CPPUNIT_ASSERT_DOUBLES_EQUAL( expected, read, 1e-12 );
        }
    }
}

Definition at line 101 of file TargetReadWriteTest.cpp.

References CPPUNIT_ASSERT, filename, and vtk_file_data.

{
    // create input file
    const char filename[] = "target_reader_test.vtk";
    FILE* file            = fopen( filename, "w" );
    CPPUNIT_ASSERT( file );
    int rval = fputs( vtk_file_data, file );
    fclose( file );
    CPPUNIT_ASSERT( rval != EOF );

    // read input file
    MsqError err;
    myMesh.read_vtk( filename, err );
    remove( filename );
    if( err ) std::cout << err << std::endl;
    CPPUNIT_ASSERT( !err );

    // Construct global patch
    std::vector< Mesh::ElementHandle > elems;
    std::vector< Mesh::VertexHandle > verts;
    myMesh.get_all_elements( elems, err );
    CPPUNIT_ASSERT( !err );
    myMesh.get_all_vertices( verts, err );
    CPPUNIT_ASSERT( !err );
    myPatch.set_mesh( &myMesh );
    myPatch.attach_settings( &linearMaps );
    myPatch.set_mesh_entities( elems, verts, err );
    CPPUNIT_ASSERT( !err );
}

Definition at line 131 of file TargetReadWriteTest.cpp.

{
    myMesh.clear();
}

Member Data Documentation

Definition at line 60 of file TargetReadWriteTest.cpp.

Definition at line 58 of file TargetReadWriteTest.cpp.

Definition at line 59 of file TargetReadWriteTest.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