MOAB: Mesh Oriented datABase  (version 5.2.1)
MBMesquite::ObjectiveFunctionTemplate Class Reference

Base for most concrete objective functions. More...

#include <ObjectiveFunctionTemplate.hpp>

+ Inheritance diagram for MBMesquite::ObjectiveFunctionTemplate:
+ Collaboration diagram for MBMesquite::ObjectiveFunctionTemplate:

Public Member Functions

 ObjectiveFunctionTemplate (QualityMetric *qm=0)
virtual ~ObjectiveFunctionTemplate ()
QualityMetricget_quality_metric () const
void set_quality_metric (QualityMetric *metric)
virtual bool initialize_block_coordinate_descent (MeshDomainAssoc *mesh_and_domain, const Settings *settings, PatchSet *user_set, MsqError &err)
 Initial accumulated value for block coordinate descent algorithms.
virtual int min_patch_layers () const
virtual void initialize_queue (MeshDomainAssoc *mesh_and_domain, const Settings *settings, MsqError &err)
 Called at start of instruction queue processing.

Private Attributes


Detailed Description

Base for most concrete objective functions.

Base class for objective functions which are a function of a quality metric.

Definition at line 46 of file ObjectiveFunctionTemplate.hpp.

Constructor & Destructor Documentation

Member Function Documentation

bool MBMesquite::ObjectiveFunctionTemplate::initialize_block_coordinate_descent ( MeshDomainAssoc mesh_and_domain,
const Settings settings,
PatchSet user_set,
MsqError err 
) [virtual]

Initial accumulated value for block coordinate descent algorithms.

Set accumulated value of objective function to the value for the entire, unmodified mesh. This is the initial state for a block coordinate descent algorithm. The ObjectiveFunction will asked to add or remove values for a specific patch of the mesh during the optimization.

meshThe Mesh
domainThe MeshDomain
user_setUser-defined patch set - not relevant for most OF templates.

Implements MBMesquite::ObjectiveFunction.

Definition at line 54 of file ObjectiveFunctionTemplate.cpp.

References MBMesquite::ObjectiveFunction::ACCUMULATE, b, MBMesquite::ObjectiveFunction::clear(), MBMesquite::QualityMetric::ELEMENT_BASED, MBMesquite::ObjectiveFunction::evaluate(), MBMesquite::MeshDomainAssoc::get_domain(), MBMesquite::MeshDomainAssoc::get_mesh(), get_quality_metric(), MBMesquite::MsqError::INVALID_STATE, mesh, MSQ_CHKERR, MSQ_ERRZERO, MSQ_SETERR, MBMesquite::PatchData::set_mesh(), value(), and MBMesquite::QualityMetric::VERTEX_BASED.

    std::auto_ptr< PatchSet > patch_set;
    switch( get_quality_metric()->get_metric_type() )
        case QualityMetric::VERTEX_BASED:
            patch_set = std::auto_ptr< PatchSet >( new VertexPatches( 1, false ) );
        case QualityMetric::ELEMENT_BASED:
            patch_set = std::auto_ptr< PatchSet >( new ElementPatches );
            MSQ_SETERR( err )
            ( "Cannot initialize for BCD for unknown metric type", MsqError::INVALID_STATE );
            return false;

    Mesh* mesh         = mesh_and_domain->get_mesh();
    MeshDomain* domain = mesh_and_domain->get_domain();

    patch_set->set_mesh( mesh );
    PatchIterator patches( patch_set.get() );

    PatchData pd;
    pd.set_mesh( mesh );
    pd.set_domain( domain );
    if( settings ) pd.attach_settings( settings );

    bool result = true;
    while( patches.get_next_patch( pd, err ) && !MSQ_CHKERR( err ) )
        double value;
        bool b = evaluate( ObjectiveFunction::ACCUMULATE, pd, value, false, err );
        MSQ_ERRZERO( err );
        result = result && b;
    return result;
void MBMesquite::ObjectiveFunctionTemplate::initialize_queue ( MeshDomainAssoc mesh_and_domain,
const Settings settings,
MsqError err 
) [virtual]

Called at start of instruction queue processing.

Do any preliminary global initialization, consistency checking, etc. Default implementation does nothing.

Implements MBMesquite::ObjectiveFunction.

Definition at line 48 of file ObjectiveFunctionTemplate.cpp.

References MBMesquite::QualityMetric::initialize_queue(), MSQ_ERRRTN, and qualityMetric.

    qualityMetric->initialize_queue( mesh_and_domain, settings, err );MSQ_ERRRTN( err );

Get the minimum number of layers of adjacent elements required in a patch to evaluate the objective function for a single free vertex.

Implements MBMesquite::ObjectiveFunction.

Definition at line 96 of file ObjectiveFunctionTemplate.cpp.

References get_quality_metric(), and MBMesquite::QualityMetric::VERTEX_BASED.

    if( !get_quality_metric() )
        return 0;
    else if( get_quality_metric()->get_metric_type() == QualityMetric::VERTEX_BASED )
        return 2;
        return 1;

Member Data Documentation

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