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

Public Member Functions

void setUp ()
void tearDown ()
 PlanarGeometryTest ()
void test_plane_tri_tangled ()
void test_plane_quad_tangled ()
void test_plane_tri_xz ()
void test_fit_plane ()

Private Member Functions

 CPPUNIT_TEST_SUITE (PlanarGeometryTest)
 CPPUNIT_TEST (test_plane_tri_tangled)
 CPPUNIT_TEST (test_plane_quad_tangled)
 CPPUNIT_TEST (test_plane_tri_xz)
 CPPUNIT_TEST (test_fit_plane)
 CPPUNIT_TEST_SUITE_END ()

Private Attributes

double qualTol
int pF

Detailed Description

Definition at line 86 of file PlanarGeometryTest.cpp.


Constructor & Destructor Documentation

Definition at line 115 of file PlanarGeometryTest.cpp.

{}

Member Function Documentation

void PlanarGeometryTest::setUp ( ) [inline]

Definition at line 104 of file PlanarGeometryTest.cpp.

References MBMesquite::MSQ_MIN.

    {
        // pF=1;//PRINT_FLAG IS ON
        pF = 0;  // PRINT_FLAG IS OFF
                 // tolerance double
        qualTol = MSQ_MIN;
    }
void PlanarGeometryTest::tearDown ( ) [inline]

Definition at line 112 of file PlanarGeometryTest.cpp.

{}

Definition at line 394 of file PlanarGeometryTest.cpp.

References ASSERT_NO_ERROR, CPPUNIT_ASSERT_DOUBLES_EQUAL, CPPUNIT_ASSERT_VECTORS_EQUAL, epsilon, MBMesquite::PlanarDomain::fit_vertices(), MBMesquite::PlanarDomain::get_coeff(), MBMesquite::PlanarDomain::get_normal(), MBMesquite::MeshImpl::read_vtk(), and MBMesquite::PlanarDomain::XY.

{
    MsqPrintError err( std::cerr );
    PlanarDomain plane( PlanarDomain::XY, -1 );
    const double epsilon = 1e-8;

    MeshImpl mesh1;
    mesh1.read_vtk( MESH_FILES_DIR "2D/vtk/tris/untangled/bad_circle_tri.vtk", err );
    ASSERT_NO_ERROR( err );
    plane.fit_vertices( &mesh1, err, epsilon );
    ASSERT_NO_ERROR( err );
    CPPUNIT_ASSERT_VECTORS_EQUAL( Vector3D( 0, 0, 1 ), plane.get_normal(), epsilon );
    CPPUNIT_ASSERT_DOUBLES_EQUAL( 5, plane.get_coeff(), epsilon );

    MeshImpl mesh2;
    mesh2.read_vtk( MESH_FILES_DIR "2D/vtk/tris/untangled/equil_tri.vtk", err );
    ASSERT_NO_ERROR( err );
    plane.fit_vertices( &mesh2, err, epsilon );
    ASSERT_NO_ERROR( err );
    CPPUNIT_ASSERT_VECTORS_EQUAL( Vector3D( 0, 0, 1 ), plane.get_normal(), epsilon );
    CPPUNIT_ASSERT_DOUBLES_EQUAL( 0, plane.get_coeff(), epsilon );

    MeshImpl mesh3;
    mesh3.read_vtk( MESH_FILES_DIR "2D/vtk/quads/untangled/quads_4by2.vtk", err );
    ASSERT_NO_ERROR( err );
    plane.fit_vertices( &mesh3, err, epsilon );
    ASSERT_NO_ERROR( err );
    CPPUNIT_ASSERT_VECTORS_EQUAL( Vector3D( 0, 0, 1 ), plane.get_normal(), epsilon );
    CPPUNIT_ASSERT_DOUBLES_EQUAL( -2, plane.get_coeff(), epsilon );

    MeshImpl mesh4;
    mesh4.read_vtk( MESH_FILES_DIR "2D/vtk/tris/untangled/tri_5_xz.vtk", err );
    ASSERT_NO_ERROR( err );
    plane.fit_vertices( &mesh4, err, epsilon );
    ASSERT_NO_ERROR( err );
    CPPUNIT_ASSERT_VECTORS_EQUAL( Vector3D( 0, -1, 0 ), plane.get_normal(), epsilon );
    CPPUNIT_ASSERT_DOUBLES_EQUAL( -5, plane.get_coeff(), epsilon );
}

Definition at line 225 of file PlanarGeometryTest.cpp.

References MBMesquite::TerminationCriterion::add_iteration_limit(), CPPUNIT_ASSERT, MBMesquite::QualityAssessor::disable_printing_results(), MBMesquite::QualityAssessor::loop_over_mesh(), mesh, MBMesquite::MSQ_MIN, MBMesquite::print_timing_diagnostics(), 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(), and MBMesquite::PatchSetUser::use_global_patch().

    {
        MBMesquite::MeshImpl mesh;
        MsqPrintError err( cout );
        mesh.read_vtk( MESH_FILES_DIR "2D/vtk/quads/tangled/tangled_quad.vtk", err );
        CPPUNIT_ASSERT( !err );

        // create geometry: plane z=5, normal (0,0,1)
        Vector3D pnt( 0, 0, 5 );
        Vector3D s_norm( 0, 0, 1 );
        MBMesquite::PlanarDomain msq_geom( s_norm, pnt );

        // creates an intruction queue
        InstructionQueue queue1, queue2;

        // creates a mean ratio quality metric ...
        ConditionNumberQualityMetric shape;
        UntangleBetaQualityMetric untan( .1 );

        // ... and builds an objective function with it (untangle)
        LInfTemplate untan_func( &untan );
        LPtoPTemplate shape_func( &shape, 2, err );
        // Make sure no errors
        CPPUNIT_ASSERT( !err );
        // creates the cg optimization procedures
        ConjugateGradient pass1( &untan_func, err );
        ConjugateGradient pass2( &shape_func, err );
        pass1.use_element_on_vertex_patch();
        pass2.use_global_patch();
        // Make sure no errors
        CPPUNIT_ASSERT( !err );
        QualityAssessor stop_qa = QualityAssessor( &untan );
        QualityAssessor qa      = QualityAssessor( &shape );
        // turn off printing if print flag not set.
        if( pF == 0 )
        {
            stop_qa.disable_printing_results();
            qa.disable_printing_results();
        }
        //**********Set stopping criterion  untangle ver small ********
        // StoppingCriterion sc_qa(&stop_qa,-100,MSQ_MIN);
        // pass1->set_stopping_criterion(&sc_qa);
        TerminationCriterion sc_of;
        sc_of.add_iteration_limit( 10 );
        pass1.set_outer_termination_criterion( &sc_of );

        //**********Set stopping criterion  5 iterates ****************
        // StoppingCriterion sc5(StoppingCriterion::NUMBER_OF_PASSES,5);
        // pass2->set_stopping_criterion(&sc5);
        TerminationCriterion sc5;
        sc5.add_iteration_limit( 5 );
        pass2.set_inner_termination_criterion( &sc5 );
        // pass2->set_maximum_iteration(5);
        // TerminationCriterion sc_inner;
        // sc_inner.add_iteration_limit( 5 );
        // pass2->set_inner_termination_criterion(&sc_inner);
        queue1.set_master_quality_improver( &pass1, err );
        CPPUNIT_ASSERT( !err );
        queue2.set_master_quality_improver( &pass2, err );
        CPPUNIT_ASSERT( !err );
        //********************UNTANGLE*******************************
        // Make sure no errors
        CPPUNIT_ASSERT( !err );
        // launches optimization on mesh_set1
        MeshDomainAssoc mesh_and_domain = MeshDomainAssoc( &mesh, &msq_geom );
        double orig_qa_val              = stop_qa.loop_over_mesh( &mesh_and_domain, 0, err );
        // Make sure no errors
        CPPUNIT_ASSERT( !err );
        queue1.run_instructions( &mesh_and_domain, err );
        CPPUNIT_ASSERT( !err );
        // Make sure no errors
        CPPUNIT_ASSERT( !err );
        double fin_qa_val = stop_qa.loop_over_mesh( &mesh_and_domain, 0, err );
        // Make sure no errors
        CPPUNIT_ASSERT( !err );
        // make sure 'quality' improved
        CPPUNIT_ASSERT( ( fin_qa_val - orig_qa_val ) <= 0.0 );
        // make sure sc_qa really was satisfied
        CPPUNIT_ASSERT( fin_qa_val <= MSQ_MIN );

        //********************SMOOTH*******************************
        // Make sure no errors
        CPPUNIT_ASSERT( !err );
        // launches optimization on mesh_set1
        orig_qa_val = qa.loop_over_mesh( &mesh_and_domain, 0, err );
        // Make sure no errors
        CPPUNIT_ASSERT( !err );
        queue2.run_instructions( &mesh_and_domain, err );
        CPPUNIT_ASSERT( !err );
        // Make sure no errors
        CPPUNIT_ASSERT( !err );
        fin_qa_val = qa.loop_over_mesh( &mesh_and_domain, 0, err );
        // Make sure no errors
        CPPUNIT_ASSERT( !err );
        // make sure 'quality' improved
        CPPUNIT_ASSERT( ( fin_qa_val - orig_qa_val ) <= 0.0 );
        print_timing_diagnostics( cout );
    }

Definition at line 117 of file PlanarGeometryTest.cpp.

References MBMesquite::TerminationCriterion::add_iteration_limit(), CPPUNIT_ASSERT, MBMesquite::QualityAssessor::disable_printing_results(), MBMesquite::QualityAssessor::loop_over_mesh(), mesh, MBMesquite::MSQ_MIN, MBMesquite::print_timing_diagnostics(), 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(), and MBMesquite::PatchSetUser::use_global_patch().

    {
        MBMesquite::MsqPrintError err( cout );
        MBMesquite::MeshImpl mesh;

        // This test doesn't use InstructionQueue, so
        // we need to set up trapping of floating-point
        // exceptions ourself.
        MsqFPE fpe_trap( true );

        mesh.read_vtk( MESH_FILES_DIR "2D/vtk/tris/tangled/tangled_tri.vtk", err );
        CPPUNIT_ASSERT( !err );

        // create geometry: plane z=5, normal (0,0,1)
        Vector3D pnt( 0, 0, 5 );
        Vector3D s_norm( 0, 0, 1 );
        MBMesquite::PlanarDomain msq_geom( s_norm, pnt );

        // creates an intruction queue
        InstructionQueue queue1, queue2;

        // creates a mean ratio quality metric ...
        ConditionNumberQualityMetric shape;
        UntangleBetaQualityMetric untan( .1 );

        // ... and builds an objective function with it (untangle)
        LInfTemplate untan_func( &untan );
        LPtoPTemplate shape_func( &shape, 2, err );
        // Make sure no errors
        CPPUNIT_ASSERT( !err );
        // creates the steepest descent optimization procedures
        SteepestDescent pass1( &untan_func );
        SteepestDescent pass2( &shape_func );
        pass1.use_element_on_vertex_patch();
        pass2.use_global_patch();
        // Make sure no errors
        CPPUNIT_ASSERT( !err );
        QualityAssessor stop_qa = QualityAssessor( &untan );
        QualityAssessor qa      = QualityAssessor( &shape );
        if( pF == 0 )
        {
            stop_qa.disable_printing_results();
            qa.disable_printing_results();
        }
        //**********Set stopping criterion  untangle ver small ********
        // StoppingCriterion sc_qa(&stop_qa,-100,MSQ_MIN);
        // pass1->set_stopping_criterion(&sc_qa);
        TerminationCriterion sc_of, sc_inner;
        sc_of.add_iteration_limit( 10 );
        pass1.set_outer_termination_criterion( &sc_of );
        sc_inner.add_iteration_limit( 6 );
        // sc_inner.add_absolute_gradient_L2_norm( 0.01 );
        pass1.set_inner_termination_criterion( &sc_inner );

        //**********Set stopping criterion  5 iterates ****************
        // StoppingCriterion sc5(StoppingCriterion::NUMBER_OF_PASSES,5);
        // pass2->set_stopping_criterion(&sc5);
        TerminationCriterion sc5;
        sc5.add_iteration_limit( 5 );
        pass2.set_inner_termination_criterion( &sc5 );
        // TerminationCriterion sc_inner;
        // sc_inner.add_iteration_limit( 5 );
        // pass2->set_inner_termination_criterion(&sc_inner);
        // pass2->set_maximum_iteration(5);

        queue1.set_master_quality_improver( &pass1, err );
        CPPUNIT_ASSERT( !err );
        queue2.set_master_quality_improver( &pass2, err );
        CPPUNIT_ASSERT( !err );
        //********************UNTANGLE*******************************
        // Make sure no errors
        CPPUNIT_ASSERT( !err );
        // launches optimization on mesh_set1
        MeshDomainAssoc mesh_and_domain = MeshDomainAssoc( &mesh, &msq_geom );
        double orig_qa_val              = stop_qa.loop_over_mesh( &mesh_and_domain, 0, err );
        // Make sure no errors
        CPPUNIT_ASSERT( !err );
        queue1.run_instructions( &mesh_and_domain, err );
        CPPUNIT_ASSERT( !err );
        // Make sure no errors
        CPPUNIT_ASSERT( !err );
        double fin_qa_val = stop_qa.loop_over_mesh( &mesh_and_domain, 0, err );
        // Make sure no errors
        CPPUNIT_ASSERT( !err );
        // make sure 'quality' improved
        CPPUNIT_ASSERT( ( fin_qa_val - orig_qa_val ) <= 0.0 );
        // make sure sc_qa really was satisfied
        CPPUNIT_ASSERT( fin_qa_val <= MSQ_MIN );

        //********************SMOOTH*******************************
        // Make sure no errors
        CPPUNIT_ASSERT( !err );
        // launches optimization on mesh_set1
        orig_qa_val = qa.loop_over_mesh( &mesh_and_domain, 0, err );
        // Make sure no errors
        CPPUNIT_ASSERT( !err );
        queue2.run_instructions( &mesh_and_domain, err );
        CPPUNIT_ASSERT( !err );
        // Make sure no errors
        CPPUNIT_ASSERT( !err );
        fin_qa_val = qa.loop_over_mesh( &mesh_and_domain, 0, err );
        // Make sure no errors
        CPPUNIT_ASSERT( !err );
        // make sure 'quality' improved
        CPPUNIT_ASSERT( ( fin_qa_val - orig_qa_val ) <= 0.0 );
        print_timing_diagnostics( cout );
    }

Definition at line 324 of file PlanarGeometryTest.cpp.

References MBMesquite::TerminationCriterion::add_iteration_limit(), CPPUNIT_ASSERT, MBMesquite::QualityAssessor::loop_over_mesh(), mesh, MBMesquite::print_timing_diagnostics(), MBMesquite::MeshImpl::read_vtk(), MBMesquite::IQInterface::run_instructions(), MBMesquite::ConjugateGradient::set_debugging_level(), MBMesquite::QualityImprover::set_inner_termination_criterion(), MBMesquite::InstructionQueue::set_master_quality_improver(), and MBMesquite::PatchSetUser::use_global_patch().

    {
        MsqPrintError err( cout );
        MBMesquite::MeshImpl mesh;
        mesh.read_vtk( MESH_FILES_DIR "2D/vtk/tris/untangled/tri_5_xz.vtk", err );
        CPPUNIT_ASSERT( !err );

        // create geometry: plane y=5, normal (0,1,0)
        Vector3D pnt( 0, -5, 0 );
        Vector3D s_norm( 0, -1, 0 );
        MBMesquite::PlanarDomain msq_geom( s_norm, pnt );

        // creates an intruction queue
        InstructionQueue queue1;

        // creates a asm quality metric ...
        ConditionNumberQualityMetric smooth;

        // ... and builds an objective function with it (untangle)
        LPtoPTemplate smooth_func( &smooth, 1, err );
        // Make sure no errors
        CPPUNIT_ASSERT( !err );
        // creates the cg optimization procedures
        ConjugateGradient pass1( &smooth_func, err );
        // pass1->set_patch_type(PatchData::ELEMENTS_ON_VERTEX_PATCH, err,1 ,1);
        pass1.use_global_patch();
        pass1.set_debugging_level( 1 );
        // Make sure no errors
        CPPUNIT_ASSERT( !err );
        QualityAssessor qa = QualityAssessor( &smooth );

        //**********Set stopping criterion  5 iterates ****************
        TerminationCriterion sc5;
        sc5.add_iteration_limit( 5 );
        pass1.set_inner_termination_criterion( &sc5 );
        // StoppingCriterion sc5(StoppingCriterion::NUMBER_OF_PASSES,5);
        // pass1->set_stopping_criterion(&sc5);
        TerminationCriterion sc_inner;
        sc_inner.add_iteration_limit( 5 );
        pass1.set_inner_termination_criterion( &sc_inner );
        // pass1->set_maximum_iteration(5);

        queue1.set_master_quality_improver( &pass1, err );
        CPPUNIT_ASSERT( !err );
        //********************UNTANGLE*******************************
        // Make sure no errors
        CPPUNIT_ASSERT( !err );
        // launches optimization on mesh_set1
        MeshDomainAssoc mesh_and_domain = MeshDomainAssoc( &mesh, &msq_geom );
        double orig_qa_val              = qa.loop_over_mesh( &mesh_and_domain, 0, err );
        // Make sure no errors
        CPPUNIT_ASSERT( !err );
        queue1.run_instructions( &mesh_and_domain, err );
        CPPUNIT_ASSERT( !err );
        // Make sure no errors
        CPPUNIT_ASSERT( !err );
        double fin_qa_val = qa.loop_over_mesh( &mesh_and_domain, 0, err );
        // Make sure no errors
        CPPUNIT_ASSERT( !err );
        // make sure 'quality' improved
        CPPUNIT_ASSERT( ( fin_qa_val - orig_qa_val ) <= 0.0 );
        print_timing_diagnostics( cout );
    }

Member Data Documentation

int PlanarGeometryTest::pF [private]

Definition at line 102 of file PlanarGeometryTest.cpp.

double PlanarGeometryTest::qualTol [private]

Definition at line 101 of file PlanarGeometryTest.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