MOAB: Mesh Oriented datABase  (version 5.4.1)
MBMesquite::ShapeImprovementWrapper Class Reference

Wrapper which performs a Feasible Newton solve using an \(\ell_2^2 \) objective function template with inverse mean ratio. More...

#include <ShapeImprovementWrapper.hpp>

+ Inheritance diagram for MBMesquite::ShapeImprovementWrapper:
+ Collaboration diagram for MBMesquite::ShapeImprovementWrapper:

Public Member Functions

MESQUITE_EXPORT ShapeImprovementWrapper (MsqError &err, double cpu_time=0.0, double grad_norm=1.e-6, int parallel_iterations=10)
MESQUITE_EXPORT ShapeImprovementWrapper (double cpu_time=0.0, double grad_norm=1.e-6, int parallel_iterations=10)

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 gradNorm
const double untBeta
const double successiveEps
int parallelIterations

Detailed Description

Wrapper which performs a Feasible Newton solve using an \(\ell_2^2 \) objective function template with inverse mean ratio.

Definition at line 61 of file ShapeImprovementWrapper.hpp.


Constructor & Destructor Documentation

MBMesquite::ShapeImprovementWrapper::ShapeImprovementWrapper ( MsqError err,
double  cpu_time = 0.0,
double  grad_norm = 1.e-6,
int  parallel_iterations = 10 
)

The consturctor allows for two values. The first is a time bound (in seconds) used as a termination criterion. If this value is non-positive, no time bound will be set. By default, the value is set to zero and no time bound is used. The second value is the tolerance for the gradient norm termination criteria. The default value is 1.e-6.

Definition at line 63 of file ShapeImprovementWrapper.cpp.

    : maxTime( cpu_time ), gradNorm( grad_norm ), untBeta( DEF_UNT_BETA ), successiveEps( DEF_SUC_EPS ),
      parallelIterations( parallel_iterations )
{
}
MBMesquite::ShapeImprovementWrapper::ShapeImprovementWrapper ( double  cpu_time = 0.0,
double  grad_norm = 1.e-6,
int  parallel_iterations = 10 
)

Definition at line 72 of file ShapeImprovementWrapper.cpp.

    : maxTime( cpu_time ), gradNorm( grad_norm ), untBeta( DEF_UNT_BETA ), successiveEps( DEF_SUC_EPS ),
      parallelIterations( parallel_iterations )
{
}

Member Function Documentation

void MBMesquite::ShapeImprovementWrapper::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 78 of file ShapeImprovementWrapper.cpp.

References MBMesquite::TerminationCriterion::add_absolute_gradient_L2_norm(), MBMesquite::TerminationCriterion::add_absolute_quality_improvement(), MBMesquite::TerminationCriterion::add_absolute_successive_improvement(), MBMesquite::TerminationCriterion::add_cpu_time(), MBMesquite::TerminationCriterion::add_iteration_limit(), MBMesquite::QualityAssessor::add_quality_assessment(), MBMesquite::InstructionQueue::add_quality_assessor(), MBMesquite::TerminationCriterion::add_relative_successive_improvement(), gradNorm, MBMesquite::QualityMetric::LINEAR, maxTime, MSQ_DBGOUT, MSQ_ERRRTN, parallelIterations, MBMesquite::InstructionQueue::run_common(), MBMesquite::AveragingQM::set_averaging_method(), MBMesquite::QualityImprover::set_inner_termination_criterion(), MBMesquite::InstructionQueue::set_master_quality_improver(), MBMesquite::QualityImprover::set_outer_termination_criterion(), MBMesquite::Timer::since_birth(), successiveEps, untBeta, and MBMesquite::PatchSetUser::use_global_patch().

{
    // Define an untangler
    UntangleBetaQualityMetric untangle_metric( untBeta );
    LPtoPTemplate untangle_func( 2, &untangle_metric );
    ConjugateGradient untangle_global( &untangle_func );
    TerminationCriterion untangle_inner, untangle_outer;
    untangle_global.use_global_patch();
    untangle_inner.add_absolute_quality_improvement( 0.0 );
    untangle_inner.add_absolute_successive_improvement( successiveEps );
    untangle_outer.add_iteration_limit( 1 );
    untangle_global.set_inner_termination_criterion( &untangle_inner );
    untangle_global.set_outer_termination_criterion( &untangle_outer );

    // define shape improver
    IdealWeightInverseMeanRatio inverse_mean_ratio;
    inverse_mean_ratio.set_averaging_method( QualityMetric::LINEAR );
    LPtoPTemplate obj_func( 2, &inverse_mean_ratio );
    FeasibleNewton feas_newt( &obj_func );
    TerminationCriterion term_inner, term_outer;
    feas_newt.use_global_patch();
    qa->add_quality_assessment( &inverse_mean_ratio );
    term_inner.add_absolute_gradient_L2_norm( gradNorm );
    term_inner.add_relative_successive_improvement( successiveEps );
    term_outer.add_iteration_limit( pmesh ? parallelIterations : 1 );
    feas_newt.set_inner_termination_criterion( &term_inner );
    feas_newt.set_outer_termination_criterion( &term_outer );

    // Apply CPU time limit to untangler
    if( maxTime > 0.0 ) untangle_inner.add_cpu_time( maxTime );

    // Run untangler
    InstructionQueue q1;
    Timer totalTimer;
    q1.set_master_quality_improver( &untangle_global, err );MSQ_ERRRTN( err );
    q1.add_quality_assessor( qa, err );MSQ_ERRRTN( err );
    q1.run_common( mesh_and_domain, pmesh, settings, err );MSQ_ERRRTN( err );

    // If limited by CPU time, limit next step to remaning time
    if( maxTime > 0.0 )
    {
        double remaining = maxTime - totalTimer.since_birth();
        if( remaining <= 0.0 )
        {
            MSQ_DBGOUT( 2 ) << "Optimization is terminating without perfoming shape improvement." << std::endl;
            remaining = 0.0;
        }
        term_inner.add_cpu_time( remaining );
    }

    // Run shape improver
    InstructionQueue q2;
    q2.set_master_quality_improver( &feas_newt, err );MSQ_ERRRTN( err );
    q2.add_quality_assessor( qa, err );MSQ_ERRRTN( err );
    q2.run_common( mesh_and_domain, pmesh, settings, err );MSQ_ERRRTN( err );
}

Member Data Documentation

Definition at line 84 of file ShapeImprovementWrapper.hpp.

Referenced by run_wrapper().

Definition at line 84 of file ShapeImprovementWrapper.hpp.

Referenced by run_wrapper().

Definition at line 87 of file ShapeImprovementWrapper.hpp.

Referenced by run_wrapper().

Definition at line 86 of file ShapeImprovementWrapper.hpp.

Referenced by run_wrapper().

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