MOAB: Mesh Oriented datABase
(version 5.4.1)
|
Compare targets to affine map to ideal element. More...
#include <AffineMapMetric.hpp>
Public Member Functions | |
MESQUITE_EXPORT | AffineMapMetric (TargetCalculator *tc, WeightCalculator *wc, TMetric *target_metric) |
MESQUITE_EXPORT | AffineMapMetric (TargetCalculator *tc, TMetric *target_metric) |
virtual MESQUITE_EXPORT std::string | get_name () const |
virtual MESQUITE_EXPORT int | get_negate_flag () const |
1 if metric should be minimized, -1 if metric should be maximized. | |
virtual MESQUITE_EXPORT void | get_evaluations (PatchData &pd, std::vector< size_t > &handles, bool free_vertices_only, MsqError &err) |
Get locations at which metric can be evaluated. | |
virtual MESQUITE_EXPORT void | get_element_evaluations (PatchData &pd, size_t elem_index, std::vector< size_t > &handles, MsqError &err) |
Get evaluation point handles for a given element. | |
virtual MESQUITE_EXPORT bool | evaluate (PatchData &pd, size_t handle, double &value, MsqError &err) |
Get metric value at a logical location in the patch. | |
virtual MESQUITE_EXPORT bool | evaluate_with_indices (PatchData &pd, size_t handle, double &value, std::vector< size_t > &indices, MsqError &err) |
Get metric value at a logical location in the patch. | |
void | set_target_calculator (TargetCalculator *tc) |
void | set_weight_calculator (WeightCalculator *wc) |
TargetCalculator * | get_target_calculator () const |
WeightCalculator * | get_weight_calculator () const |
TMetric * | get_target_metric () const |
void | set_target_metric (TMetric *m) |
Private Attributes | |
TargetCalculator * | targetCalc |
WeightCalculator * | weightCalc |
TMetric * | targetMetric |
Compare targets to affine map to ideal element.
A quality metric defined using 2D and 3D target metrics, where the active (A) matrix is an affine map to the ideal, unit-side element.
Definition at line 53 of file AffineMapMetric.hpp.
MBMesquite::AffineMapMetric::AffineMapMetric | ( | TargetCalculator * | tc, |
WeightCalculator * | wc, | ||
TMetric * | target_metric | ||
) |
Definition at line 59 of file AffineMapMetric.cpp.
: targetCalc( tc ), weightCalc( wc ), targetMetric( target_metric ) { }
MBMesquite::AffineMapMetric::AffineMapMetric | ( | TargetCalculator * | tc, |
TMetric * | target_metric | ||
) |
Definition at line 64 of file AffineMapMetric.cpp.
: targetCalc( tc ), weightCalc( 0 ), targetMetric( target_metric ) { }
bool MBMesquite::AffineMapMetric::evaluate | ( | PatchData & | pd, |
size_t | handle, | ||
double & | value, | ||
MsqError & | err | ||
) | [virtual] |
Get metric value at a logical location in the patch.
Evaluate the metric at one location in the PatchData.
pd | The patch. |
handle | The location in the patch (as passed back from get_evaluations). |
value | The output metric value. |
Implements MBMesquite::QualityMetric.
Definition at line 92 of file AffineMapMetric.cpp.
References MBMesquite::adj(), conn, MBMesquite::Sample::dimension, MBMesquite::ElemSampleQM::elem(), MBMesquite::PatchData::element_by_index(), MBMesquite::TMetric::evaluate(), MBMesquite::TargetCalculator::get_3D_target(), MBMesquite::MsqMeshEntity::get_element_type(), MBMesquite::TargetCalculator::get_surface_target(), MBMesquite::MsqMeshEntity::get_vertex_index_array(), MBMesquite::WeightCalculator::get_weight(), MBMesquite::inverse(), MSQ_ERRZERO, MSQ_SETERR, n, MBMesquite::Sample::number, MBMesquite::ElemSampleQM::sample(), MBMesquite::MsqMatrix< R, C >::set_column(), MBMesquite::surface_to_2d(), targetCalc, targetMetric, MBMesquite::TET_XFORM, MBMesquite::TETRAHEDRON, MBMesquite::transpose(), MBMesquite::TRI_XFORM, MBMesquite::TRIANGLE, MBMesquite::MsqError::UNSUPPORTED_ELEMENT, MBMesquite::PatchData::vertex_by_index(), and weightCalc.
Referenced by evaluate_with_indices().
{ Sample s = ElemSampleQM::sample( p_handle ); size_t e = ElemSampleQM::elem( p_handle ); MsqMeshEntity& p_elem = pd.element_by_index( e ); EntityTopology type = p_elem.get_element_type(); unsigned edim = TopologyInfo::dimension( type ); const size_t* conn = p_elem.get_vertex_index_array(); // This metric only supports sampling at corners, except for simplices. // If element is a simpex, then the Jacobian is constant over a linear // element. In this case, always evaluate at any vertex. // unsigned corner = s.number; if( s.dimension != 0 ) { if( type == TRIANGLE || type == TETRAHEDRON ) /*corner = 0*/; else { MSQ_SETERR( err ) ( "Invalid sample point for AffineMapMetric", MsqError::UNSUPPORTED_ELEMENT ); return false; } } bool rval; if( edim == 3 ) { // 3x3 or 3x2 targets ? Vector3D c[3] = { Vector3D( 0, 0, 0 ), Vector3D( 0, 0, 0 ), Vector3D( 0, 0, 0 ) }; unsigned n; const unsigned* adj = TopologyInfo::adjacent_vertices( type, s.number, n ); c[0] = pd.vertex_by_index( conn[adj[0]] ) - pd.vertex_by_index( conn[s.number] ); c[1] = pd.vertex_by_index( conn[adj[1]] ) - pd.vertex_by_index( conn[s.number] ); c[2] = pd.vertex_by_index( conn[adj[2]] ) - pd.vertex_by_index( conn[s.number] ); MsqMatrix< 3, 3 > A; A.set_column( 0, MsqMatrix< 3, 1 >( c[0].to_array() ) ); A.set_column( 1, MsqMatrix< 3, 1 >( c[1].to_array() ) ); A.set_column( 2, MsqMatrix< 3, 1 >( c[2].to_array() ) ); if( type == TETRAHEDRON ) A = A * TET_XFORM; MsqMatrix< 3, 3 > W; targetCalc->get_3D_target( pd, e, s, W, err ); MSQ_ERRZERO( err ); rval = targetMetric->evaluate( A * inverse( W ), value, err ); MSQ_ERRZERO( err ); } else { Vector3D c[2] = { Vector3D( 0, 0, 0 ), Vector3D( 0, 0, 0 ) }; unsigned n; const unsigned* adj = TopologyInfo::adjacent_vertices( type, s.number, n ); c[0] = pd.vertex_by_index( conn[adj[0]] ) - pd.vertex_by_index( conn[s.number] ); c[1] = pd.vertex_by_index( conn[adj[1]] ) - pd.vertex_by_index( conn[s.number] ); MsqMatrix< 3, 2 > App; App.set_column( 0, MsqMatrix< 3, 1 >( c[0].to_array() ) ); App.set_column( 1, MsqMatrix< 3, 1 >( c[1].to_array() ) ); MsqMatrix< 3, 2 > Wp; targetCalc->get_surface_target( pd, e, s, Wp, err ); MSQ_ERRZERO( err ); MsqMatrix< 2, 2 > A, W; MsqMatrix< 3, 2 > RZ; surface_to_2d( App, Wp, W, RZ ); A = transpose( RZ ) * App; if( type == TRIANGLE ) A = A * TRI_XFORM; rval = targetMetric->evaluate( A * inverse( W ), value, err ); MSQ_ERRZERO( err ); } // apply target weight to value if( weightCalc ) { double ck = weightCalc->get_weight( pd, e, s, err ); MSQ_ERRZERO( err ); value *= ck; } return rval; }
bool MBMesquite::AffineMapMetric::evaluate_with_indices | ( | PatchData & | pd, |
size_t | handle, | ||
double & | value, | ||
std::vector< size_t > & | indices, | ||
MsqError & | err | ||
) | [virtual] |
Get metric value at a logical location in the patch.
Evaluate the metric at one location in the PatchData.
pd | The patch. |
handle | The location in the patch (as passed back from get_evaluations). |
value | The output metric value. |
indices | The free vertices that the evaluation is a function of, specified as vertex indices in the PatchData. |
Implements MBMesquite::QualityMetric.
Definition at line 173 of file AffineMapMetric.cpp.
References MBMesquite::adj(), conn, MBMesquite::Sample::dimension, MBMesquite::ElemSampleQM::elem(), MBMesquite::PatchData::element_by_index(), evaluate(), MBMesquite::MsqMeshEntity::get_element_type(), MBMesquite::MsqMeshEntity::get_vertex_index_array(), MSQ_SETERR, n, MBMesquite::PatchData::num_free_vertices(), MBMesquite::Sample::number, MBMesquite::ElemSampleQM::sample(), MBMesquite::TETRAHEDRON, MBMesquite::TRIANGLE, and MBMesquite::MsqError::UNSUPPORTED_ELEMENT.
{ Sample s = ElemSampleQM::sample( p_handle ); size_t e = ElemSampleQM::elem( p_handle ); MsqMeshEntity& p_elem = pd.element_by_index( e ); EntityTopology type = p_elem.get_element_type(); const size_t* conn = p_elem.get_vertex_index_array(); // this metric only supports sampling at corners if( s.dimension != 0 ) { if( type != TRIANGLE && type != TETRAHEDRON ) { MSQ_SETERR( err ) ( "Invalid sample point for AffineMapMetric", MsqError::UNSUPPORTED_ELEMENT ); return false; } s.dimension = 0; s.number = 0; } unsigned n; const unsigned* adj = TopologyInfo::adjacent_vertices( type, s.number, n ); indices.clear(); if( conn[s.number] < pd.num_free_vertices() ) indices.push_back( conn[s.number] ); for( unsigned i = 0; i < n; ++i ) if( conn[adj[i]] < pd.num_free_vertices() ) indices.push_back( conn[adj[i]] ); return evaluate( pd, p_handle, value, err ); }
void MBMesquite::AffineMapMetric::get_element_evaluations | ( | PatchData & | pd, |
size_t | elem_index, | ||
std::vector< size_t > & | handles, | ||
MsqError & | err | ||
) | [virtual] |
Get evaluation point handles for a given element.
Similar to QualityMetric::get_evaluations, this method returns a list of handles corresponding to sample points at which the metric may be evaluated. While QualityMetric::get_evaluations returns sample points for all elements in a PatchData, this method returns only the subset corresponding to a single element.
Implements MBMesquite::ElemSampleQM.
Definition at line 84 of file AffineMapMetric.cpp.
References MBMesquite::get_elem_sample_points().
{ get_elem_sample_points( pd, p_elem, handles, err ); }
void MBMesquite::AffineMapMetric::get_evaluations | ( | PatchData & | pd, |
std::vector< size_t > & | handles, | ||
bool | free_vertices_only, | ||
MsqError & | err | ||
) | [virtual] |
Get locations at which metric can be evaluated.
Different metrics are evaluated for different things within a patch. For example, an element-based metric will be evaluated once for each element in patch, a vertex-based metric once for each veretx, and a target/sample-point based metric will be evaluated once for each samle point in each element. This method returns a list of handles, one for each location in the patch at which the metric can be evaluated. The handle values are used as input to the evaluate methods.
pd | The patch |
handles | Output list of handles |
free_vertices_only | If true, only pass back evaluation points that depend on at least one free vertex. |
Implements MBMesquite::QualityMetric.
Definition at line 79 of file AffineMapMetric.cpp.
References MBMesquite::get_sample_pt_evaluations().
{ get_sample_pt_evaluations( pd, handles, free, err ); }
std::string MBMesquite::AffineMapMetric::get_name | ( | ) | const [virtual] |
Implements MBMesquite::QualityMetric.
Definition at line 74 of file AffineMapMetric.cpp.
References MBMesquite::TMetric::get_name(), and targetMetric.
{ return std::string( "AffineMap(" ) + targetMetric->get_name() + ')'; }
int MBMesquite::AffineMapMetric::get_negate_flag | ( | ) | const [virtual] |
1 if metric should be minimized, -1 if metric should be maximized.
Implements MBMesquite::QualityMetric.
Definition at line 69 of file AffineMapMetric.cpp.
{
return 1;
}
TargetCalculator* MBMesquite::AffineMapMetric::get_target_calculator | ( | ) | const [inline] |
TMetric* MBMesquite::AffineMapMetric::get_target_metric | ( | ) | const [inline] |
Definition at line 101 of file AffineMapMetric.hpp.
References targetMetric.
{ return targetMetric; }
WeightCalculator* MBMesquite::AffineMapMetric::get_weight_calculator | ( | ) | const [inline] |
void MBMesquite::AffineMapMetric::set_target_calculator | ( | TargetCalculator * | tc | ) | [inline] |
void MBMesquite::AffineMapMetric::set_target_metric | ( | TMetric * | m | ) | [inline] |
void MBMesquite::AffineMapMetric::set_weight_calculator | ( | WeightCalculator * | wc | ) | [inline] |
Definition at line 88 of file AffineMapMetric.hpp.
References weightCalc.
Referenced by run_test().
{ weightCalc = wc; }
Definition at line 111 of file AffineMapMetric.hpp.
Referenced by evaluate(), get_target_calculator(), and set_target_calculator().
TMetric* MBMesquite::AffineMapMetric::targetMetric [private] |
Definition at line 113 of file AffineMapMetric.hpp.
Referenced by evaluate(), get_name(), get_target_metric(), and set_target_metric().
Definition at line 112 of file AffineMapMetric.hpp.
Referenced by evaluate(), get_weight_calculator(), and set_weight_calculator().