MOAB: Mesh Oriented datABase
(version 5.4.1)
|
Base for most concrete objective functions. More...
#include <ObjectiveFunctionTemplate.hpp>
Public Member Functions | |
ObjectiveFunctionTemplate (QualityMetric *qm=0) | |
virtual | ~ObjectiveFunctionTemplate () |
QualityMetric * | get_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 | |
QualityMetric * | qualityMetric |
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.
MBMesquite::ObjectiveFunctionTemplate::ObjectiveFunctionTemplate | ( | QualityMetric * | qm = 0 | ) | [inline] |
Definition at line 49 of file ObjectiveFunctionTemplate.hpp.
: qualityMetric( qm ) {}
Definition at line 46 of file ObjectiveFunctionTemplate.cpp.
{}
QualityMetric* MBMesquite::ObjectiveFunctionTemplate::get_quality_metric | ( | ) | const [inline] |
Definition at line 53 of file ObjectiveFunctionTemplate.hpp.
Referenced by MBMesquite::LInfTemplate::clone(), MBMesquite::MaxTemplate::clone(), MBMesquite::LInfTemplate::evaluate(), MBMesquite::StdDevTemplate::evaluate(), MBMesquite::MaxTemplate::evaluate(), MBMesquite::PatchPowerMeanP::evaluate(), MBMesquite::VarianceTemplate::evaluate(), MBMesquite::LPtoPTemplate::evaluate(), MBMesquite::PMeanPTemplate::evaluate(), MBMesquite::StdDevTemplate::evaluate_with_gradient(), MBMesquite::PatchPowerMeanP::evaluate_with_gradient(), MBMesquite::VarianceTemplate::evaluate_with_gradient(), MBMesquite::LPtoPTemplate::evaluate_with_gradient(), MBMesquite::PMeanPTemplate::evaluate_with_gradient(), MBMesquite::PatchPowerMeanP::evaluate_with_Hessian(), MBMesquite::LPtoPTemplate::evaluate_with_Hessian(), MBMesquite::PMeanPTemplate::evaluate_with_Hessian(), MBMesquite::StdDevTemplate::evaluate_with_Hessian_diagonal(), MBMesquite::VarianceTemplate::evaluate_with_Hessian_diagonal(), MBMesquite::LPtoPTemplate::evaluate_with_Hessian_diagonal(), MBMesquite::PMeanPTemplate::evaluate_with_Hessian_diagonal(), initialize_block_coordinate_descent(), MBMesquite::VertexMover::loop_over_mesh(), and min_patch_layers().
{ return qualityMetric; }
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.
mesh | The Mesh |
domain | The MeshDomain |
user_set | User-defined patch set - not relevant for most OF templates. |
Implements MBMesquite::ObjectiveFunction.
Definition at line 55 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::unique_ptr< PatchSet > patch_set; switch( get_quality_metric()->get_metric_type() ) { case QualityMetric::VERTEX_BASED: patch_set = std::unique_ptr< PatchSet >( new VertexPatches( 1, false ) ); break; case QualityMetric::ELEMENT_BASED: patch_set = std::unique_ptr< PatchSet >( new ElementPatches ); break; default: 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(); clear(); 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 ); }
int MBMesquite::ObjectiveFunctionTemplate::min_patch_layers | ( | ) | const [virtual] |
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 98 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; else return 1; }
void MBMesquite::ObjectiveFunctionTemplate::set_quality_metric | ( | QualityMetric * | metric | ) | [inline] |
Definition at line 58 of file ObjectiveFunctionTemplate.hpp.
Referenced by ObjectiveFunctionTests::compare_diagonal_gradient(), ObjectiveFunctionTests::compare_hessian_diagonal(), ObjectiveFunctionTests::compare_hessian_gradient(), ObjectiveFunctionTests::compare_numerical_gradient(), ObjectiveFunctionTests::compare_numerical_hessian(), ObjectiveFunctionTests::compare_numerical_hessian_diagonal(), ObjectiveFunctionTests::test_clone(), ObjectiveFunctionTests::test_eval_type(), ObjectiveFunctionTests::test_handles_invalid_qm(), ObjectiveFunctionTests::test_handles_qm_error(), ObjectiveFunctionTest::test_max_negate_flag(), ObjectiveFunctionTests::test_negate_flag(), and ObjectiveFunctionTests::test_value().
{ qualityMetric = metric; }
Definition at line 77 of file ObjectiveFunctionTemplate.hpp.
Referenced by initialize_queue().