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

Wrapper that implements several TMP-based untanglers. More...

#include <UntangleWrapper.hpp>

+ Inheritance diagram for MBMesquite::UntangleWrapper:
+ Collaboration diagram for MBMesquite::UntangleWrapper:

Public Types

enum  UntangleMetric { BETA, SIZE, SHAPESIZE }
 Which quality metric to use. More...

Public Member Functions

MESQUITE_EXPORT void set_untangle_metric (UntangleMetric metric)
 Specify which untangle metric to use.
MESQUITE_EXPORT void set_metric_constant (double value)
 Specify constant value for untangle metric.
MESQUITE_EXPORT void set_cpu_time_limit (double seconds)
 Specify timeout after which untangler will exit.
MESQUITE_EXPORT void set_outer_iteration_limit (int maxIt)
 Specify max number of outer iterations after which untangler will exit.
MESQUITE_EXPORT void set_vertex_movement_limit_factor (double f)
 Specify factor by which to minimum distance a vertex must move in an iteration to avoid termination of the untangler.
MESQUITE_EXPORT UntangleWrapper ()
MESQUITE_EXPORT UntangleWrapper (UntangleMetric m)
MESQUITE_EXPORT ~UntangleWrapper ()
bool is_culling_enabled () const
 Check if vertex culling will be used.
void enable_culling (bool yesno)
 Enable vertex culling.
bool is_jacobi_optimization () const
 Check if a Jacobi optimization strategy will be used.
bool is_gauss_optimization () const
 Check if a Gauss optimization strategy will be used.
void do_jacobi_optimization ()
 Use a Jacobi optimization strategy.
void do_gauss_optimization ()
 Use a Gauss optimization strategy.

Protected Member Functions

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

Private Attributes

UntangleMetric qualityMetric
double maxTime
double movementFactor
double metricConstant
int maxIterations
bool doCulling
bool doJacobi

Detailed Description

Wrapper that implements several TMP-based untanglers.

Definition at line 42 of file UntangleWrapper.hpp.


Member Enumeration Documentation

Which quality metric to use.

Enumerator:
BETA 

Use TMP UntangleBeta metric.

SIZE 

Use UntangleMu(TargetSize}.

SHAPESIZE 

Use UntangleMu(TargetShapeSize}.

Definition at line 47 of file UntangleWrapper.hpp.

    {
        BETA,      //!< Use TMP UntangleBeta metric
        SIZE,      //!< Use UntangleMu(TargetSize}
        SHAPESIZE  //!< Use UntangleMu(TargetShapeSize}
    };

Constructor & Destructor Documentation


Member Function Documentation

Use a Gauss optimization strategy.

Definition at line 115 of file UntangleWrapper.hpp.

References doJacobi.

    {
        doJacobi = false;
    }

Use a Jacobi optimization strategy.

Definition at line 109 of file UntangleWrapper.hpp.

References doJacobi.

    {
        doJacobi = true;
    }
void MBMesquite::UntangleWrapper::enable_culling ( bool  yesno) [inline]

Enable vertex culling.

Definition at line 91 of file UntangleWrapper.hpp.

References doCulling.

    {
        doCulling = yesno;
    }

Check if vertex culling will be used.

Definition at line 85 of file UntangleWrapper.hpp.

References doCulling.

    {
        return doCulling;
    }

Check if a Gauss optimization strategy will be used.

Definition at line 103 of file UntangleWrapper.hpp.

References doJacobi.

    {
        return !doJacobi;
    }

Check if a Jacobi optimization strategy will be used.

Definition at line 97 of file UntangleWrapper.hpp.

References doJacobi.

    {
        return doJacobi;
    }
void MBMesquite::UntangleWrapper::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 106 of file UntangleWrapper.cpp.

References MBMesquite::QualityAssessor::add_quality_assessment(), MBMesquite::InstructionQueue::add_quality_assessor(), MBMesquite::SimpleStats::average(), BETA, beta, MBMesquite::VertexMover::do_gauss_optimization(), MBMesquite::VertexMover::do_jacobi_optimization(), doCulling, doJacobi, eps, MBMesquite::MeshDomainAssoc::get_mesh(), MBMesquite::Instruction::initialize_vertex_byte(), MBMesquite::inner(), maxIterations, maxTime, mesh, metricConstant, movementFactor, MSQ_ERRRTN, NUM_INNER_ITERATIONS, MBMesquite::outer(), qualityMetric, MBMesquite::InstructionQueue::run_common(), MBMesquite::QualityImprover::set_inner_termination_criterion(), MBMesquite::InstructionQueue::set_master_quality_improver(), MBMesquite::QualityImprover::set_outer_termination_criterion(), SIZE, MBMesquite::SimpleStats::standard_deviation(), MBMesquite::TerminationCriterion::TYPE_INNER, MBMesquite::TerminationCriterion::TYPE_OUTER, and MBMesquite::PatchSetUser::use_element_on_vertex_patch().

{
    Instruction::initialize_vertex_byte( mesh_and_domain, settings, err );MSQ_ERRRTN( err );

    Mesh* mesh = mesh_and_domain->get_mesh();

    // get some global mesh properties
    SimpleStats edge_len, lambda;
    std::unique_ptr< MeshUtil > tool( new MeshUtil( mesh, settings ) );
    tool->edge_length_distribution( edge_len, err );MSQ_ERRRTN( err );
    tool->lambda_distribution( lambda, err );MSQ_ERRRTN( err );
    tool.reset( 0 );

    // get target metrics from user perferences
    TSizeNB1 mu_size;
    TShapeSize2DNB1 mu_shape_2d;
    TShapeSize3DNB1 mu_shape_3d;
    TMixed mu_shape( &mu_shape_2d, &mu_shape_3d );
    std::unique_ptr< TMetric > mu;
    if( qualityMetric == BETA )
    {
        double beta = metricConstant;
        if( beta < 0 ) beta = ( lambda.average() * lambda.average() ) / 20;
        // std::cout << "beta= " << beta << std::endl;
        mu.reset( new TUntangleBeta( beta ) );
    }
    else
    {
        TMetric* sub = 0;
        if( qualityMetric == SIZE )
            sub = &mu_size;
        else
            sub = &mu_shape;
        if( metricConstant >= 0 )
            mu.reset( new TUntangleMu( sub, metricConstant ) );
        else
            mu.reset( new TUntangleMu( sub ) );
    }

    // define objective function
    IdealShapeTarget base_target;
    LambdaConstant target( lambda.average(), &base_target );
    TQualityMetric metric_0( &target, mu.get() );
    ElementPMeanP metric( 1.0, &metric_0 );
    PMeanPTemplate objfunc( 1.0, &metric );

    // define termination criterion
    double eps = movementFactor * ( edge_len.average() - edge_len.standard_deviation() );
    TerminationCriterion inner( "<type:untangle_inner>", TerminationCriterion::TYPE_INNER ),
        outer( "<type:untangle_outer>", TerminationCriterion::TYPE_OUTER );
    outer.add_untangled_mesh();
    if( doCulling )
        inner.cull_on_absolute_vertex_movement( eps );
    else
        outer.add_absolute_vertex_movement( eps );
    if( maxTime > 0.0 ) outer.add_cpu_time( maxTime );
    inner.add_iteration_limit( NUM_INNER_ITERATIONS );
    if( maxIterations > 0 ) outer.add_iteration_limit( maxIterations );

    // construct solver
    SteepestDescent solver( &objfunc );
    solver.use_element_on_vertex_patch();
    solver.set_inner_termination_criterion( &inner );
    solver.set_outer_termination_criterion( &outer );
    if( doJacobi )
        solver.do_jacobi_optimization();
    else
        solver.do_gauss_optimization();

    // Run
    qa->add_quality_assessment( &metric );
    InstructionQueue q;
    q.add_quality_assessor( qa, err );MSQ_ERRRTN( err );
    q.set_master_quality_improver( &solver, err );MSQ_ERRRTN( err );
    q.add_quality_assessor( qa, err );MSQ_ERRRTN( err );
    q.run_common( mesh_and_domain, pmesh, settings, err );MSQ_ERRRTN( err );
}

Specify timeout after which untangler will exit.

Definition at line 91 of file UntangleWrapper.cpp.

References maxTime.

{
    maxTime = seconds;
}

Specify constant value for untangle metric.

Definition at line 86 of file UntangleWrapper.cpp.

References metricConstant, and value().

Referenced by uwt().

Specify max number of outer iterations after which untangler will exit.

Definition at line 96 of file UntangleWrapper.cpp.

References maxIterations.

{
    maxIterations = maxIt;
}

Specify which untangle metric to use.

Definition at line 81 of file UntangleWrapper.cpp.

References qualityMetric.

{
    qualityMetric = metric;
}

Specify factor by which to minimum distance a vertex must move in an iteration to avoid termination of the untangler.

Definition at line 101 of file UntangleWrapper.cpp.

References movementFactor.

Referenced by main(), and uwt().

{
    movementFactor = f;
}

Member Data Documentation

Definition at line 127 of file UntangleWrapper.hpp.

Referenced by run_wrapper(), and set_cpu_time_limit().

Definition at line 127 of file UntangleWrapper.hpp.

Referenced by run_wrapper(), and set_metric_constant().

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