MOAB: Mesh Oriented datABase  (version 5.3.1)
MBMesquite::ShapeImprover Class Reference

Wrapper that implements TMP-based shape improvement. More...

#include <ShapeImprover.hpp>

+ Inheritance diagram for MBMesquite::ShapeImprover:
+ Collaboration diagram for MBMesquite::ShapeImprover:

Public Member Functions

MESQUITE_EXPORT ShapeImprover ()
MESQUITE_EXPORT void set_cpu_time_limit (double seconds)
MESQUITE_EXPORT void set_vertex_movement_limit_factor (double beta)
MESQUITE_EXPORT void set_parallel_iterations (int count)

Protected Member Functions

MESQUITE_EXPORT void run_wrapper (MeshDomainAssoc *mesh_and_domain, ParallelMesh *pmesh, Settings *settings, QualityAssessor *qa, MsqError &err)

Private Attributes

double maxTime
double mBeta
int parallelIterations

Detailed Description

Wrapper that implements TMP-based shape improvement.

Definition at line 43 of file ShapeImprover.hpp.


Constructor & Destructor Documentation


Member Function Documentation

void MBMesquite::ShapeImprover::run_wrapper ( MeshDomainAssoc mesh_and_domain,
ParallelMesh pmesh,
Settings settings,
QualityAssessor quality_assessor,
MsqError err 
) [protected, virtual]

Function that each wrapper must implement

Implements MBMesquite::Wrapper.

Definition at line 84 of file ShapeImprover.cpp.

References MBMesquite::TerminationCriterion::add_absolute_vertex_movement_edge_length(), MBMesquite::TerminationCriterion::add_cpu_time(), MBMesquite::QualityAssessor::add_quality_assessment(), MBMesquite::InstructionQueue::add_quality_assessor(), MBMesquite::PatchData::attach_settings(), MBMesquite::Mesh::get_all_elements(), MBMesquite::Mesh::get_all_vertices(), MBMesquite::MeshDomainAssoc::get_domain(), MBMesquite::QualityAssessor::get_inverted_element_count(), MBMesquite::MeshDomainAssoc::get_mesh(), MBMesquite::PatchData::get_minmax_edge_length(), maxTime, mBeta, mesh, MSQ_ERRRTN, MBMesquite::InstructionQueue::run_common(), MBMesquite::PatchData::set_domain(), MBMesquite::QualityImprover::set_inner_termination_criterion(), MBMesquite::InstructionQueue::set_master_quality_improver(), MBMesquite::PatchData::set_mesh(), MBMesquite::PatchData::set_mesh_entities(), and MBMesquite::PatchSetUser::use_global_patch().

{
    // Quality Metrics
    IdealShapeTarget target;
    Mesh* mesh         = mesh_and_domain->get_mesh();
    MeshDomain* domain = mesh_and_domain->get_domain();

    // only calc min edge length if user hasn't set the vertex_movement_limit_factor
    if( !mBeta )
    {
        // Calculate minimum edge length in mesh

        // create a temp global patch to get min edge len from
        PatchData patch;
        patch.set_mesh( mesh );
        patch.set_domain( domain );
        if( settings ) patch.attach_settings( settings );
        std::vector< Mesh::ElementHandle > patch_elems;
        std::vector< Mesh::VertexHandle > patch_verts;
        mesh->get_all_elements( patch_elems, err );
        mesh->get_all_vertices( patch_verts, err );
        patch.set_mesh_entities( patch_elems, patch_verts, err );

        // get min edge length from temp global patch
        double min_edge_len = 0.0, max_edge_len = 0.0;
        patch.get_minmax_edge_length( min_edge_len, max_edge_len );
        mBeta = min_edge_len / 10.0;
    }

    TerminationCriterion inner_b;

    // check for inverted elements

    // create QualityAssessor instance without a Quality Metric
    QualityAssessor check_inverted( false, false );
    InstructionQueue q_invert_check;
    // a QuallityAssessor without a metric will just check for inverted elements and samples
    q_invert_check.add_quality_assessor( &check_inverted, err );
    q_invert_check.run_common( mesh_and_domain, pmesh, settings, err );MSQ_ERRRTN( err );
    int inverted_elems = 0, inverted_samples = 0;
    check_inverted.get_inverted_element_count( inverted_elems, inverted_samples, err );
    if( inverted_elems || inverted_samples )
    {
        // use non barrier shape improvement on tangled mesh
        TShapeNB1 mu_no;
        TQualityMetric metric_no_0( &target, &mu_no );
        ElementPMeanP metric_no( 1.0, &metric_no_0 );

        // QualityAssessor
        qa->add_quality_assessment( &metric_no );

        PMeanPTemplate obj_func_no( 1.0, &metric_no );
        ConjugateGradient improver_no( &obj_func_no );
        improver_no.use_global_patch();
        TerminationCriterion inner_no;
        if( maxTime > 0.0 ) inner_no.add_cpu_time( maxTime );
        inner_no.add_absolute_vertex_movement_edge_length( mBeta );
        improver_no.set_inner_termination_criterion( &inner_no );
        InstructionQueue q_no;
        q_no.add_quality_assessor( qa, err );MSQ_ERRRTN( err );
        q_no.set_master_quality_improver( &improver_no, err );MSQ_ERRRTN( err );
        q_no.add_quality_assessor( qa, err );MSQ_ERRRTN( err );
        q_no.run_common( mesh_and_domain, pmesh, settings, err );MSQ_ERRRTN( err );
    }
    else
    {
        // use barrer metric on non-tangled mesh

        Timer totalTimer;
        TShapeB1 mu_b;
        TQualityMetric metric_b_0( &target, &mu_b );
        ElementPMeanP metric_b( 1.0, &metric_b_0 );
        qa->add_quality_assessment( &metric_b );
        PMeanPTemplate obj_func_b( 1.0, &metric_b );
        ConjugateGradient improver_b( &obj_func_b );
        improver_b.use_global_patch();

        if( maxTime > 0.0 ) inner_b.add_cpu_time( maxTime );
        inner_b.add_absolute_vertex_movement_edge_length( mBeta );

        improver_b.set_inner_termination_criterion( &inner_b );
        InstructionQueue q_b;
        q_b.add_quality_assessor( qa, err );MSQ_ERRRTN( err );
        q_b.set_master_quality_improver( &improver_b, err );MSQ_ERRRTN( err );
        q_b.add_quality_assessor( qa, err );MSQ_ERRRTN( err );
        q_b.run_common( mesh_and_domain, pmesh, settings, err );MSQ_ERRRTN( err );
    }
}

Definition at line 68 of file ShapeImprover.cpp.

References maxTime.

Referenced by main().

{
    assert( limit >= 0.0 );
    maxTime = limit;
}

Definition at line 74 of file ShapeImprover.cpp.

References parallelIterations.

{
    if( count < 1 )
    {
        assert( false );
        count = 1;
    }
    parallelIterations = count;
}

Definition at line 61 of file ShapeImprover.cpp.

References beta, and mBeta.

Referenced by main(), and run_example().

{
    assert( beta > 0.0 );
    assert( beta < 1.0 );
    mBeta = beta;
}

Member Data Documentation

Definition at line 80 of file ShapeImprover.hpp.

Referenced by run_wrapper(), and set_cpu_time_limit().

Definition at line 80 of file ShapeImprover.hpp.

Referenced by run_wrapper(), and set_vertex_movement_limit_factor().

Definition at line 81 of file ShapeImprover.hpp.

Referenced by set_parallel_iterations().

List of all members.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines