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

Public Member Functions

 TCTFauxOptimizer (double pertubation_amount)
virtual ~TCTFauxOptimizer ()
virtual std::string get_name () const
 Get string name for use in diagnostic and status output.
virtual PatchSetget_patch_set ()
virtual void initialize (PatchData &pd, MsqError &err)
virtual void initialize_mesh_iteration (PatchData &pd, MsqError &err)
virtual void optimize_vertex_positions (PatchData &pd, MsqError &err)
virtual void terminate_mesh_iteration (PatchData &pd, MsqError &err)
virtual void cleanup ()
int num_passes () const
bool should_have_terminated () const

Private Attributes

std::set< Mesh::VertexHandleculled
std::set< Mesh::VertexHandlevisited
std::vector< Mesh::VertexHandleall
VertexPatches mPatchSet
int numPasses
 count number of outer iterations
int perturbFrac
 perturb 1/perturbFrac of the free vertices
double mDelta
 distance to perturb vertices

Detailed Description

Definition at line 671 of file TerminationCriterionTest.cpp.


Constructor & Destructor Documentation

TCTFauxOptimizer::TCTFauxOptimizer ( double  pertubation_amount) [inline]

Definition at line 674 of file TerminationCriterionTest.cpp.

: mDelta( pertubation_amount ) {}
virtual TCTFauxOptimizer::~TCTFauxOptimizer ( ) [inline, virtual]

Definition at line 675 of file TerminationCriterionTest.cpp.

{};

Member Function Documentation

virtual void TCTFauxOptimizer::cleanup ( ) [inline, virtual]

Implements MBMesquite::VertexMover.

Definition at line 688 of file TerminationCriterionTest.cpp.

    {
        all.clear();
    }
virtual std::string TCTFauxOptimizer::get_name ( ) const [inline, virtual]

Get string name for use in diagnostic and status output.

Implements MBMesquite::Instruction.

Definition at line 676 of file TerminationCriterionTest.cpp.

    {
        return "Optimizer for TerminationCriterionTest";
    }
virtual PatchSet* TCTFauxOptimizer::get_patch_set ( ) [inline, virtual]

Implements MBMesquite::QualityImprover.

Definition at line 680 of file TerminationCriterionTest.cpp.

    {
        return &mPatchSet;
    }
void TCTFauxOptimizer::initialize ( PatchData pd,
MsqError err 
) [virtual]

Implements MBMesquite::VertexMover.

Definition at line 710 of file TerminationCriterionTest.cpp.

References CPPUNIT_ASSERT, fixed, MBMesquite::Mesh::get_all_vertices(), MBMesquite::PatchData::get_mesh(), MSQ_ERRRTN, and MBMesquite::Mesh::vertices_get_fixed_flag().

{
    CPPUNIT_ASSERT( all.empty() );
    culled.clear();
    visited.clear();
    numPasses = 1;

    pd.get_mesh()->get_all_vertices( all, err );MSQ_ERRRTN( err );
    std::vector< bool > fixed;
    pd.get_mesh()->vertices_get_fixed_flag( &all[0], fixed, all.size(), err );
    size_t w = 0;
    for( size_t r = 0; r < all.size(); ++r )
        if( !fixed[r] ) all[w++] = all[r];
    all.resize( w );MSQ_ERRRTN( err );

    perturbFrac = 1;
}
virtual void TCTFauxOptimizer::initialize_mesh_iteration ( PatchData pd,
MsqError err 
) [inline, virtual]

Implements MBMesquite::VertexMover.

Definition at line 685 of file TerminationCriterionTest.cpp.

{}
int TCTFauxOptimizer::num_passes ( ) const [inline]
void TCTFauxOptimizer::optimize_vertex_positions ( PatchData pd,
MsqError err 
) [virtual]

Implements MBMesquite::VertexMover.

Definition at line 728 of file TerminationCriterionTest.cpp.

References ASSERT_NO_ERROR, CPPUNIT_ASSERT, MBMesquite::PatchData::get_vertex_handles_array(), MBMesquite::PatchData::move_vertex(), MBMesquite::PatchData::num_nodes(), and MBMesquite::sign.

{
    Mesh::VertexHandle free_vtx = pd.get_vertex_handles_array()[0];
    if( visited.insert( free_vtx ).second == false )
    {  // already visited this one
        // The inner termination criterion should include an iteration limit of 1.
        // So if we are seeing the same vertex again, this means that we *should*
        // be stating a new pass over the mesh.

        // We are presumably starting a new pass over the mesh.
        // Verify that we visisted all of the free, non-culled vertices
        for( size_t i = 0; i < all.size(); ++i )
        {
            if( culled.find( all[i] ) == culled.end() )
            {
                if( visited.find( all[i] ) == visited.end() )
                {
                    std::ostringstream str;
                    str << "Did not visit vertex " << i << " (handle " << all[i] << ") in pass " << numPasses
                        << std::endl;
                    CPPUNIT_FAIL( str.str() );
                }
            }
        }
        visited.clear();
        visited.insert( free_vtx );
        ++numPasses;

        // Check that we terminate when expected
        CPPUNIT_ASSERT( !should_have_terminated() );

        perturbFrac *= 2;  // for each pass, perturb half as many vertices
    }

    // check that we are not visiting a culled vertex
    CPPUNIT_ASSERT( culled.find( free_vtx ) == culled.end() );

    // for each pass, perturb half as many vertices
    size_t idx = std::find( all.begin(), all.end(), free_vtx ) - all.begin();
    CPPUNIT_ASSERT( idx < all.size() );  // not a free vertex????
    if( 0 == ( ( idx + 1 ) % perturbFrac ) )
    {
        // perturb vertex
        double sign = numPasses % 2 == 0 ? 1 : -1;
        Vector3D delta( sign * mDelta, 0, 0 );
        pd.move_vertex( delta, 0, err );
        ASSERT_NO_ERROR( err );
        // any adjacent vertices should not be culled
        for( size_t i = 0; i < pd.num_nodes(); ++i )
            culled.erase( pd.get_vertex_handles_array()[i] );
    }
    else
    {
        // If we're not moving this vertex, then it should get culled
        culled.insert( free_vtx );
    }
}

Definition at line 696 of file TerminationCriterionTest.cpp.

Referenced by TerminationCriterionTest::test_abs_vtx_movement_culling().

    {
        return perturbFrac > (int)all.size();
    }
virtual void TCTFauxOptimizer::terminate_mesh_iteration ( PatchData pd,
MsqError err 
) [inline, virtual]

Implements MBMesquite::VertexMover.

Definition at line 687 of file TerminationCriterionTest.cpp.

{}

Member Data Documentation

std::vector< Mesh::VertexHandle > TCTFauxOptimizer::all [private]

Definition at line 703 of file TerminationCriterionTest.cpp.

Definition at line 702 of file TerminationCriterionTest.cpp.

double TCTFauxOptimizer::mDelta [private]

distance to perturb vertices

Definition at line 707 of file TerminationCriterionTest.cpp.

count number of outer iterations

Definition at line 705 of file TerminationCriterionTest.cpp.

perturb 1/perturbFrac of the free vertices

Definition at line 706 of file TerminationCriterionTest.cpp.

Definition at line 702 of file TerminationCriterionTest.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