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

Public Member Functions

void test_lp_to_p_hex ()
void test_p_mean_p_hex ()
void test_lp_to_p_tet ()
void test_p_mean_p_tet ()

Private Member Functions

 CPPUNIT_TEST_SUITE (BCDTest)
 CPPUNIT_TEST (test_lp_to_p_hex)
 CPPUNIT_TEST (test_p_mean_p_hex)
 CPPUNIT_TEST (test_lp_to_p_tet)
 CPPUNIT_TEST (test_p_mean_p_tet)
 CPPUNIT_TEST_SUITE_END ()
void compare_bcd (ObjectiveFunction *of, string name, const char *file)

Private Attributes

IdealWeightInverseMeanRatio mMetric

Detailed Description

Definition at line 57 of file BCDTest.cpp.


Member Function Documentation

void BCDTest::compare_bcd ( ObjectiveFunction of,
string  name,
const char *  file 
) [private]

Definition at line 102 of file BCDTest.cpp.

References MBMesquite::TerminationCriterion::add_absolute_vertex_movement(), MBMesquite::TerminationCriterion::add_iteration_limit(), MBMesquite::QualityAssessor::add_quality_assessment(), MBMesquite::InstructionQueue::add_quality_assessor(), MBMesquite::arrptr(), ASSERT_NO_ERROR, CPPUNIT_ASSERT, CPPUNIT_ASSERT_VECTORS_EQUAL, MBMesquite::VertexMover::do_block_coordinate_descent_optimization(), MBMesquite::MeshImpl::get_all_vertices(), mesh, mMetric, MBMesquite::MeshImpl::read_vtk(), MBMesquite::IQInterface::run_instructions(), MBMesquite::QualityImprover::set_inner_termination_criterion(), MBMesquite::InstructionQueue::set_master_quality_improver(), MBMesquite::QualityImprover::set_outer_termination_criterion(), MBMesquite::PatchSetUser::use_element_on_vertex_patch(), MBMesquite::PatchSetUser::use_global_patch(), MBMesquite::MeshImpl::vertex_set_coordinates(), MBMesquite::MeshImpl::vertices_get_coordinates(), and MBMesquite::MeshImpl::write_vtk().

{
    MsqPrintError err( cout );
    size_t i;
    vector< MsqVertex > initial_coords, global_coords, bcd_coords;
    vector< Mesh::VertexHandle > vertex_list;

    // set up a smoother
    TerminationCriterion iterations, vertex_movement;
    iterations.add_iteration_limit( 2 );
    vertex_movement.add_absolute_vertex_movement( 1e-3 );

    SolverType global_solver( OF );
    SolverType bcd_solver( OF );
    global_solver.use_global_patch();
    bcd_solver.use_element_on_vertex_patch();
    bcd_solver.do_block_coordinate_descent_optimization();
    global_solver.set_inner_termination_criterion( &vertex_movement );
    bcd_solver.set_inner_termination_criterion( &iterations );
    bcd_solver.set_outer_termination_criterion( &vertex_movement );

    QualityAssessor qa;
    qa.add_quality_assessment( &mMetric );

    InstructionQueue global_q, bcd_q;
    global_q.add_quality_assessor( &qa, err );
    global_q.set_master_quality_improver( &global_solver, err );
    global_q.add_quality_assessor( &qa, err );
    bcd_q.set_master_quality_improver( &bcd_solver, err );
    bcd_q.add_quality_assessor( &qa, err );

    // read mesh
    MeshImpl mesh;
    mesh.read_vtk( mesh_file, err );
    ASSERT_NO_ERROR( err );
    mesh.get_all_vertices( vertex_list, err );
    ASSERT_NO_ERROR( err );
    CPPUNIT_ASSERT( !vertex_list.empty() );
    initial_coords.resize( vertex_list.size() );
    mesh.vertices_get_coordinates( arrptr( vertex_list ), arrptr( initial_coords ), vertex_list.size(), err );
    ASSERT_NO_ERROR( err );

    // run global smoother
    global_q.run_instructions( &mesh, err );
    ASSERT_NO_ERROR( err );
    mesh.write_vtk( ( name + "-gbl.vtk" ).c_str(), err );
    global_coords.resize( vertex_list.size() );
    mesh.vertices_get_coordinates( arrptr( vertex_list ), arrptr( global_coords ), vertex_list.size(), err );
    ASSERT_NO_ERROR( err );

    // restore initial vertex positions
    for( i = 0; i < vertex_list.size(); ++i )
    {
        mesh.vertex_set_coordinates( vertex_list[i], initial_coords[i], err );
        ASSERT_NO_ERROR( err );
    }

    // run local smoother
    bcd_q.run_instructions( &mesh, err );
    ASSERT_NO_ERROR( err );
    mesh.write_vtk( ( name + "-bcd.vtk" ).c_str(), err );
    bcd_coords.resize( vertex_list.size() );
    mesh.vertices_get_coordinates( arrptr( vertex_list ), arrptr( bcd_coords ), vertex_list.size(), err );
    ASSERT_NO_ERROR( err );

    // compare results
    for( i = 0; i < bcd_coords.size(); ++i )
        CPPUNIT_ASSERT_VECTORS_EQUAL( global_coords[i], bcd_coords[i], 1e-2 );
}
void BCDTest::test_lp_to_p_hex ( ) [inline]

Definition at line 74 of file BCDTest.cpp.

References HEX_MESH, and mMetric.

    {
        LPtoPTemplate OF( 1, &mMetric );
        compare_bcd( &OF, "LPtoP-hex", HEX_MESH );
    }
void BCDTest::test_lp_to_p_tet ( ) [inline]

Definition at line 86 of file BCDTest.cpp.

References mMetric, and TET_MESH.

    {
        LPtoPTemplate OF( 1, &mMetric );
        compare_bcd( &OF, "LPtoP-tet", TET_MESH );
    }
void BCDTest::test_p_mean_p_hex ( ) [inline]

Definition at line 80 of file BCDTest.cpp.

References HEX_MESH, and mMetric.

    {
        PMeanPTemplate OF( 1.0, &mMetric );
        compare_bcd( &OF, "PMeanP-hex", HEX_MESH );
    }
void BCDTest::test_p_mean_p_tet ( ) [inline]

Definition at line 92 of file BCDTest.cpp.

References mMetric, and TET_MESH.

    {
        PMeanPTemplate OF( 1.0, &mMetric );
        compare_bcd( &OF, "PMeanP-tet", TET_MESH );
    }

Member Data Documentation

Definition at line 69 of file BCDTest.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