MOAB: Mesh Oriented datABase
(version 5.4.1)
|
#include <TMPQualityMetricTest.hpp>
Definition at line 365 of file TMPQualityMetricTest.hpp.
TMPQualityMetricTest< QMType >::TMPQualityMetricTest | ( | ) | [inline] |
Definition at line 384 of file TMPQualityMetricTest.hpp.
: tester( QualityMetricTester::ALL_FE_EXCEPT_SEPTAHEDRON, &settings ), e_weight( 2.7182818284590451 ), faux_pi( 3.14159 ), faux_zero( 0.0 ), faux_two( 2.0 ), num_metric( &test_metric ), test_qm( &ideal, &num_metric ), test_qm_surf( &surf_target, &num_metric ), zero_qm( &ideal, &faux_zero ), weight_qm( &ideal, &e_weight, &test_metric ), center_qm( &ideal, &test_metric ), triCenter( centerOnly.get_mapping_function_2D( TRIANGLE ) ), quadCenter( centerOnly.get_mapping_function_2D( QUADRILATERAL ) ), tetCenter( centerOnly.get_mapping_function_3D( TETRAHEDRON ) ), pyrCenter( centerOnly.get_mapping_function_3D( PYRAMID ) ), priCenter( centerOnly.get_mapping_function_3D( PRISM ) ), hexCenter( centerOnly.get_mapping_function_3D( HEXAHEDRON ) ) { centerOnly.set_mapping_function( &triCenter ); centerOnly.set_mapping_function( &quadCenter ); centerOnly.set_mapping_function( &tetCenter ); centerOnly.set_mapping_function( &pyrCenter ); centerOnly.set_mapping_function( &priCenter ); centerOnly.set_mapping_function( &hexCenter ); tester.ideal_pyramid_base_equals_height( true ); }
void TMPQualityMetricTest< QMType >::compare_analytical_and_numerical_diagonals | ( | ) | [inline] |
Definition at line 623 of file TMPQualityMetricTest.hpp.
void TMPQualityMetricTest< QMType >::compare_analytical_and_numerical_diagonals | ( | QualityMetric * | qm | ) | [inline] |
Definition at line 1098 of file TMPQualityMetricTest.hpp.
References CPPUNIT_ASSERT, CPPUNIT_ASSERT_DOUBLES_EQUAL, CPPUNIT_ASSERT_EQUAL, CPPUNIT_ASSERT_MATRICES_EQUAL, MBMesquite::QualityMetric::evaluate_with_Hessian_diagonal(), MBMesquite::QualityMetric::get_evaluations(), MBMesquite::HEXAHEDRON, MSQ_CHKERR, MBMesquite::PRISM, MBMesquite::PYRAMID, MBMesquite::QUADRILATERAL, MBMesquite::TETRAHEDRON, and MBMesquite::TRIANGLE.
{ MsqPrintError err( std::cout ); PatchData pd; const EntityTopology types[] = { TRIANGLE, QUADRILATERAL, TETRAHEDRON, PYRAMID, PRISM, HEXAHEDRON }; const int num_types = sizeof( types ) / sizeof( types[0] ); for( int i = 0; i < num_types; ++i ) { get_nonideal_element( types[i], pd ); std::vector< size_t > handles, indices1, indices2; std::vector< Vector3D > grad1, grad2; std::vector< Matrix3D > Hess1; std::vector< SymMatrix3D > Hess2; double qm_val1, qm_val2; bool rval; qm->get_evaluations( pd, handles, false, err ); CPPUNIT_ASSERT( !MSQ_CHKERR( err ) ); CPPUNIT_ASSERT( !handles.empty() ); for( size_t j = 0; j < handles.size(); ++j ) { rval = qm->QualityMetric::evaluate_with_Hessian( pd, handles[j], qm_val1, indices1, grad1, Hess1, err ); CPPUNIT_ASSERT( !MSQ_CHKERR( err ) ); CPPUNIT_ASSERT( rval ); // For analytical gradient of a 2D element in the XY plane, // we expect all Z terms to be zero. #ifdef PLANAR_HESSIAN if( TopologyInfo::dimension( types[i] ) == 2 ) for( size_t k = 0; k < Hess1.size(); ++k ) Hess1[k]( 0, 2 ) = Hess1[k]( 1, 2 ) = Hess1[k]( 2, 0 ) = Hess1[k]( 2, 1 ) = Hess1[k]( 2, 2 ) = 0.0; #endif rval = qm->evaluate_with_Hessian_diagonal( pd, handles[j], qm_val2, indices2, grad2, Hess2, err ); CPPUNIT_ASSERT( !MSQ_CHKERR( err ) ); CPPUNIT_ASSERT( rval ); CPPUNIT_ASSERT_DOUBLES_EQUAL( qm_val1, qm_val2, 1e-6 ); CPPUNIT_ASSERT_EQUAL( indices1.size(), indices2.size() ); CPPUNIT_ASSERT( !indices1.empty() ); CPPUNIT_ASSERT_EQUAL( indices1.size() * ( indices1.size() + 1 ) / 2, Hess1.size() ); CPPUNIT_ASSERT_EQUAL( indices2.size(), Hess2.size() ); size_t h = 0; std::vector< size_t >::iterator it; for( unsigned r = 0; r < indices1.size(); ++r ) { it = std::find( indices2.begin(), indices2.end(), indices1[r] ); CPPUNIT_ASSERT( it != indices2.end() ); unsigned r2 = it - indices2.begin(); // if (!utest_mat_equal(Hess1[h],Hess2[r2],0.001)) // assert(false); CPPUNIT_ASSERT_MATRICES_EQUAL( Hess1[h], Hess2[r2], 0.05 ); h += indices1.size() - r; } } } }
void TMPQualityMetricTest< QMType >::compare_analytical_and_numerical_gradient | ( | ) | [inline] |
Definition at line 570 of file TMPQualityMetricTest.hpp.
void TMPQualityMetricTest< QMType >::compare_analytical_and_numerical_gradients | ( | QualityMetric * | qm | ) | [inline] |
Definition at line 659 of file TMPQualityMetricTest.hpp.
{ PatchData pd; const EntityTopology types[] = { TRIANGLE, QUADRILATERAL, TETRAHEDRON, PYRAMID, PRISM, HEXAHEDRON }; const int num_types = sizeof( types ) / sizeof( types[0] ); for( int i = 0; i < num_types; ++i ) { get_nonideal_element( types[i], pd ); compare_analytical_and_numerical_gradients( qm, pd, TopologyInfo::dimension( types[i] ) ); } }
void TMPQualityMetricTest< QMType >::compare_analytical_and_numerical_gradients | ( | QualityMetric * | qm, |
PatchData & | pd, | ||
int | dim | ||
) | [inline] |
Definition at line 965 of file TMPQualityMetricTest.hpp.
References CPPUNIT_ASSERT, CPPUNIT_ASSERT_DOUBLES_EQUAL, CPPUNIT_ASSERT_EQUAL, CPPUNIT_ASSERT_VECTORS_EQUAL, MBMesquite::QualityMetric::evaluate_with_gradient(), MBMesquite::QualityMetric::get_evaluations(), and MSQ_CHKERR.
{ MsqPrintError err( std::cout ); std::vector< size_t > handles, indices1, indices2; std::vector< Vector3D > grad1, grad2; double qm_val1, qm_val2; bool rval; qm->get_evaluations( pd, handles, false, err ); CPPUNIT_ASSERT( !MSQ_CHKERR( err ) ); CPPUNIT_ASSERT( !handles.empty() ); for( size_t j = 0; j < handles.size(); ++j ) { rval = qm->QualityMetric::evaluate_with_gradient( pd, handles[j], qm_val1, indices1, grad1, err ); CPPUNIT_ASSERT( !MSQ_CHKERR( err ) ); CPPUNIT_ASSERT( rval ); // For analytical gradient of a 2D element in the XY plane, // we expect all Z terms to be zero. if( dim == 2 ) for( size_t k = 0; k < grad1.size(); ++k ) grad1[k][2] = 0.0; rval = qm->evaluate_with_gradient( pd, handles[j], qm_val2, indices2, grad2, err ); CPPUNIT_ASSERT( !MSQ_CHKERR( err ) ); CPPUNIT_ASSERT( rval ); CPPUNIT_ASSERT_DOUBLES_EQUAL( qm_val1, qm_val2, 1e-6 ); CPPUNIT_ASSERT_EQUAL( indices1.size(), indices2.size() ); CPPUNIT_ASSERT( !indices1.empty() ); std::vector< size_t >::iterator it1, it2; for( it1 = indices1.begin(); it1 != indices1.end(); ++it1 ) { it2 = std::find( indices2.begin(), indices2.end(), *it1 ); CPPUNIT_ASSERT( it2 != indices2.end() ); size_t idx1 = it1 - indices1.begin(); size_t idx2 = it2 - indices2.begin(); CPPUNIT_ASSERT_VECTORS_EQUAL( grad1[idx1], grad2[idx2], 0.01 ); } } }
void TMPQualityMetricTest< QMType >::compare_analytical_and_numerical_hessians | ( | ) | [inline] |
Definition at line 594 of file TMPQualityMetricTest.hpp.
void TMPQualityMetricTest< QMType >::compare_analytical_and_numerical_hessians | ( | QualityMetric * | qm | ) | [inline] |
Definition at line 1020 of file TMPQualityMetricTest.hpp.
References CPPUNIT_ASSERT, CPPUNIT_ASSERT_DOUBLES_EQUAL, CPPUNIT_ASSERT_EQUAL, CPPUNIT_ASSERT_MATRICES_EQUAL, MBMesquite::QualityMetric::evaluate_with_Hessian(), MBMesquite::QualityMetric::get_evaluations(), MBMesquite::HEXAHEDRON, MSQ_CHKERR, MBMesquite::PRISM, MBMesquite::PYRAMID, MBMesquite::QUADRILATERAL, MBMesquite::TETRAHEDRON, and MBMesquite::TRIANGLE.
{ MsqPrintError err( std::cout ); PatchData pd; const EntityTopology types[] = { TRIANGLE, QUADRILATERAL, TETRAHEDRON, PYRAMID, PRISM, HEXAHEDRON }; const int num_types = sizeof( types ) / sizeof( types[0] ); for( int i = 0; i < num_types; ++i ) { get_nonideal_element( types[i], pd ); std::vector< size_t > handles, indices1, indices2; std::vector< Vector3D > grad1, grad2; std::vector< Matrix3D > Hess1, Hess2; double qm_val1, qm_val2; bool rval; qm->get_evaluations( pd, handles, false, err ); CPPUNIT_ASSERT( !MSQ_CHKERR( err ) ); CPPUNIT_ASSERT( !handles.empty() ); for( size_t j = 0; j < handles.size(); ++j ) { rval = qm->QualityMetric::evaluate_with_Hessian( pd, handles[j], qm_val1, indices1, grad1, Hess1, err ); CPPUNIT_ASSERT( !MSQ_CHKERR( err ) ); CPPUNIT_ASSERT( rval ); // For analytical gradient of a 2D element in the XY plane, // we expect all Z terms to be zero. #ifdef PLANAR_HESSIAN if( TopologyInfo::dimension( types[i] ) == 2 ) for( size_t k = 0; k < Hess1.size(); ++k ) Hess1[k]( 0, 2 ) = Hess1[k]( 1, 2 ) = Hess1[k]( 2, 0 ) = Hess1[k]( 2, 1 ) = Hess1[k]( 2, 2 ) = 0.0; #endif rval = qm->evaluate_with_Hessian( pd, handles[j], qm_val2, indices2, grad2, Hess2, err ); CPPUNIT_ASSERT( !MSQ_CHKERR( err ) ); CPPUNIT_ASSERT( rval ); CPPUNIT_ASSERT_DOUBLES_EQUAL( qm_val1, qm_val2, 1e-6 ); CPPUNIT_ASSERT_EQUAL( indices1.size(), indices2.size() ); CPPUNIT_ASSERT( !indices1.empty() ); std::vector< size_t >::iterator it; unsigned h = 0; for( unsigned r = 0; r < indices1.size(); ++r ) { it = std::find( indices2.begin(), indices2.end(), indices1[r] ); CPPUNIT_ASSERT( it != indices2.end() ); unsigned r2 = it - indices2.begin(); for( unsigned c = r; c < indices1.size(); ++c, ++h ) { it = std::find( indices2.begin(), indices2.end(), indices1[c] ); CPPUNIT_ASSERT( it != indices2.end() ); unsigned c2 = it - indices2.begin(); unsigned h2; if( r2 <= c2 ) h2 = indices2.size() * r - r * ( r + 1 ) / 2 + c; else h2 = indices2.size() * c - c * ( c + 1 ) / 2 + r; // if (!utest_mat_equal(Hess1[h],Hess2[h2],0.001)) // assert(false); CPPUNIT_ASSERT_MATRICES_EQUAL( Hess1[h], Hess2[h2], 0.05 ); } } } } }
void TMPQualityMetricTest< QMType >::compare_gradient_and_diagonal | ( | ) | [inline] |
Definition at line 618 of file TMPQualityMetricTest.hpp.
void TMPQualityMetricTest< QMType >::compare_gradient_and_hessian | ( | ) | [inline] |
Definition at line 589 of file TMPQualityMetricTest.hpp.
void TMPQualityMetricTest< QMType >::compare_indices_and_diagonal | ( | ) | [inline] |
Definition at line 613 of file TMPQualityMetricTest.hpp.
void TMPQualityMetricTest< QMType >::compare_indices_and_gradient | ( | ) | [inline] |
Definition at line 560 of file TMPQualityMetricTest.hpp.
void TMPQualityMetricTest< QMType >::compare_indices_and_hessian | ( | ) | [inline] |
Definition at line 584 of file TMPQualityMetricTest.hpp.
void TMPQualityMetricTest< QMType >::get_nonideal_element | ( | EntityTopology | type, |
PatchData & | pd | ||
) | [inline] |
Definition at line 645 of file TMPQualityMetricTest.hpp.
{ tester.get_nonideal_element( type, pd, true ); // Callers assume surface elements are in XY plane. // Verify this assumption. if( TopologyInfo::dimension( type ) == 2 ) { for( size_t i = 0; i < pd.num_nodes(); ++i ) { CPPUNIT_ASSERT_DOUBLES_EQUAL( pd.vertex_by_index( i )[2], 0.0, 1e-6 ); } } }
void TMPQualityMetricTest< QMType >::test_2d_eval_ortho_quad | ( | ) | [inline] |
Definition at line 477 of file TMPQualityMetricTest.hpp.
{ MsqPrintError err( cout ); PatchData pd; bool rval; double value; QMType m( &ideal, &faux_zero ); faux_zero.count = 0; tester.get_ideal_element( QUADRILATERAL, true, pd ); rval = m.evaluate( pd, 0, value, err ); CPPUNIT_ASSERT( !MSQ_CHKERR( err ) ); CPPUNIT_ASSERT( rval ); CPPUNIT_ASSERT_EQUAL( 1, faux_zero.count ); CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0, col_dot_prod( faux_zero.last_A_2D ), DBL_EPSILON ); }
void TMPQualityMetricTest< QMType >::test_3d_eval_ortho_hex | ( | ) | [inline] |
Definition at line 513 of file TMPQualityMetricTest.hpp.
{ MsqPrintError err( cout ); PatchData pd; bool rval; double value; QMType m( &ideal, &faux_zero ); faux_zero.count = 0; tester.get_ideal_element( HEXAHEDRON, true, pd ); rval = m.evaluate( pd, 0, value, err ); CPPUNIT_ASSERT( !MSQ_CHKERR( err ) ); CPPUNIT_ASSERT( rval ); CPPUNIT_ASSERT_EQUAL( 1, faux_zero.count ); // test that columns are orthogonal for ideal hex element MsqMatrix< 3, 3 > A = faux_zero.last_A_3D; CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0, A.column( 0 ) % A.column( 1 ), 1e-6 ); CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0, A.column( 0 ) % A.column( 2 ), 1e-6 ); CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0, A.column( 1 ) % A.column( 2 ), 1e-6 ); }
void TMPQualityMetricTest< QMType >::test_diagonal_with_fixed_vertices | ( | ) | [inline] |
Definition at line 632 of file TMPQualityMetricTest.hpp.
{ tester.test_diagonal_with_fixed_vertex( ¢er_qm, ¢erOnly ); }
void TMPQualityMetricTest< QMType >::test_evaluate_2D | ( | ) | [inline] |
Definition at line 680 of file TMPQualityMetricTest.hpp.
References col_dot_prod(), CPPUNIT_ASSERT, CPPUNIT_ASSERT_DOUBLES_EQUAL, CPPUNIT_ASSERT_EQUAL, MSQ_CHKERR, MBMesquite::PatchData::num_nodes(), MBMesquite::QUADRILATERAL, MBMesquite::PatchData::set_vertex_coordinates(), MBMesquite::TRIANGLE, value(), and MBMesquite::PatchData::vertex_by_index().
{ MsqPrintError err( cout ); PatchData pd; bool rval; double value; QMType m( &ideal, &faux_pi ); // test with aligned elements faux_pi.count = 0; tester.get_ideal_element( QUADRILATERAL, true, pd ); rval = m.evaluate( pd, 0, value, err ); CPPUNIT_ASSERT( !MSQ_CHKERR( err ) ); CPPUNIT_ASSERT( rval ); CPPUNIT_ASSERT_DOUBLES_EQUAL( faux_pi.value, value, DBL_EPSILON ); CPPUNIT_ASSERT_EQUAL( 1, faux_pi.count ); // test that columns are orthogonal for ideal quad element CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0, col_dot_prod( faux_pi.last_A_2D ), 1e-6 ); // test with an element rotated about X-axis faux_pi.count = 0; tester.get_ideal_element( QUADRILATERAL, true, pd ); // rotate by 90 degrees about X axis for( size_t i = 0; i < pd.num_nodes(); ++i ) { Vector3D orig = pd.vertex_by_index( i ); Vector3D newp( orig[0], -orig[2], orig[1] ); pd.set_vertex_coordinates( newp, i, err ); } rval = m.evaluate( pd, 0, value, err ); CPPUNIT_ASSERT( !MSQ_CHKERR( err ) ); CPPUNIT_ASSERT( rval ); CPPUNIT_ASSERT_DOUBLES_EQUAL( faux_pi.value, value, DBL_EPSILON ); CPPUNIT_ASSERT_EQUAL( 1, faux_pi.count ); // test with an element rotated about Y-axis faux_pi.count = 0; tester.get_ideal_element( TRIANGLE, true, pd ); // rotate by -90 degrees about Y axis for( size_t i = 0; i < pd.num_nodes(); ++i ) { Vector3D orig = pd.vertex_by_index( i ); Vector3D newp( orig[2], orig[1], -orig[0] ); pd.set_vertex_coordinates( newp, i, err ); } rval = m.evaluate( pd, 0, value, err ); CPPUNIT_ASSERT( !MSQ_CHKERR( err ) ); CPPUNIT_ASSERT( rval ); CPPUNIT_ASSERT_DOUBLES_EQUAL( faux_pi.value, value, DBL_EPSILON ); CPPUNIT_ASSERT_EQUAL( 1, faux_pi.count ); }
void TMPQualityMetricTest< QMType >::test_evaluate_2D_weight | ( | ) | [inline] |
Definition at line 430 of file TMPQualityMetricTest.hpp.
{ MsqPrintError err( cout ); PatchData pd; bool rval; double value; QMType m( &ideal, &e_weight, &faux_pi ); tester.get_ideal_element( TRIANGLE, true, pd ); rval = m.evaluate( pd, 0, value, err ); CPPUNIT_ASSERT( !MSQ_CHKERR( err ) ); CPPUNIT_ASSERT( rval ); CPPUNIT_ASSERT_DOUBLES_EQUAL( faux_pi.value * e_weight.value, value, DBL_EPSILON ); }
void TMPQualityMetricTest< QMType >::test_evaluate_3D | ( | ) | [inline] |
Definition at line 790 of file TMPQualityMetricTest.hpp.
References MBMesquite::MsqMatrix< R, C >::column(), CPPUNIT_ASSERT, CPPUNIT_ASSERT_DOUBLES_EQUAL, CPPUNIT_ASSERT_EQUAL, MBMesquite::HEXAHEDRON, MSQ_CHKERR, MBMesquite::PatchData::num_nodes(), MBMesquite::PatchData::set_vertex_coordinates(), MBMesquite::TETRAHEDRON, value(), and MBMesquite::PatchData::vertex_by_index().
{ MsqPrintError err( cout ); PatchData pd; bool rval; double value; QMType m( &ideal, &faux_two ); // test with aligned elements faux_two.count = 0; tester.get_ideal_element( HEXAHEDRON, true, pd ); rval = m.evaluate( pd, 0, value, err ); CPPUNIT_ASSERT( !MSQ_CHKERR( err ) ); CPPUNIT_ASSERT( rval ); CPPUNIT_ASSERT_DOUBLES_EQUAL( faux_two.value, value, DBL_EPSILON ); CPPUNIT_ASSERT_EQUAL( 1, faux_two.count ); // test that columns are orthogonal for ideal hex element MsqMatrix< 3, 3 > A = faux_two.last_A_3D; CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0, A.column( 0 ) % A.column( 1 ), 1e-6 ); CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0, A.column( 0 ) % A.column( 2 ), 1e-6 ); CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0, A.column( 1 ) % A.column( 2 ), 1e-6 ); // test with rotated element faux_two.count = 0; tester.get_ideal_element( TETRAHEDRON, true, pd ); // rotate by 90-degrees about X axis for( size_t i = 0; i < pd.num_nodes(); ++i ) { Vector3D orig = pd.vertex_by_index( i ); Vector3D newp( orig[0], -orig[2], orig[1] ); pd.set_vertex_coordinates( newp, i, err ); } rval = m.evaluate( pd, 0, value, err ); CPPUNIT_ASSERT( !MSQ_CHKERR( err ) ); CPPUNIT_ASSERT( rval ); CPPUNIT_ASSERT_DOUBLES_EQUAL( faux_two.value, value, DBL_EPSILON ); CPPUNIT_ASSERT_EQUAL( 1, faux_two.count ); }
void TMPQualityMetricTest< QMType >::test_evaluate_3D_weight | ( | ) | [inline] |
Definition at line 461 of file TMPQualityMetricTest.hpp.
{ MsqPrintError err( cout ); PatchData pd; bool rval; double value; QMType m( &ideal, &e_weight, &faux_two ); tester.get_ideal_element( PRISM, true, pd ); rval = m.evaluate( pd, 0, value, err ); CPPUNIT_ASSERT( !MSQ_CHKERR( err ) ); CPPUNIT_ASSERT( rval ); CPPUNIT_ASSERT_DOUBLES_EQUAL( faux_two.value * e_weight.value, value, DBL_EPSILON ); }
void TMPQualityMetricTest< QMType >::test_evaluate_fixed_indices | ( | ) | [inline] |
Definition at line 555 of file TMPQualityMetricTest.hpp.
{ tester.test_get_indices_fixed( &zero_qm ); }
void TMPQualityMetricTest< QMType >::test_evaluate_surface | ( | ) | [inline] |
Definition at line 735 of file TMPQualityMetricTest.hpp.
References col_dot_prod(), CPPUNIT_ASSERT, CPPUNIT_ASSERT_DOUBLES_EQUAL, CPPUNIT_ASSERT_EQUAL, MSQ_CHKERR, MBMesquite::PatchData::num_nodes(), MBMesquite::QUADRILATERAL, MBMesquite::PatchData::set_vertex_coordinates(), MBMesquite::TRIANGLE, value(), and MBMesquite::PatchData::vertex_by_index().
{ MsqPrintError err( cout ); PatchData pd; bool rval; double value; QMType m( &surf_target, &faux_pi ); // test with aligned elements faux_pi.count = 0; tester.get_ideal_element( QUADRILATERAL, true, pd ); rval = m.evaluate( pd, 0, value, err ); CPPUNIT_ASSERT( !MSQ_CHKERR( err ) ); CPPUNIT_ASSERT( rval ); CPPUNIT_ASSERT_DOUBLES_EQUAL( faux_pi.value, value, DBL_EPSILON ); CPPUNIT_ASSERT_EQUAL( 1, faux_pi.count ); // test that columns are orthogonal for ideal quad element CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0, col_dot_prod( faux_pi.last_A_2D ), 1e-6 ); // test with an element rotated about X-axis faux_pi.count = 0; tester.get_ideal_element( QUADRILATERAL, true, pd ); // rotate by 90 degrees about X axis for( size_t i = 0; i < pd.num_nodes(); ++i ) { Vector3D orig = pd.vertex_by_index( i ); Vector3D newp( orig[0], -orig[2], orig[1] ); pd.set_vertex_coordinates( newp, i, err ); } rval = m.evaluate( pd, 0, value, err ); CPPUNIT_ASSERT( !MSQ_CHKERR( err ) ); CPPUNIT_ASSERT( rval ); CPPUNIT_ASSERT_DOUBLES_EQUAL( faux_pi.value, value, DBL_EPSILON ); CPPUNIT_ASSERT_EQUAL( 1, faux_pi.count ); // test with an element rotated about Y-axis faux_pi.count = 0; tester.get_ideal_element( TRIANGLE, true, pd ); // rotate by -90 degrees about Y axis for( size_t i = 0; i < pd.num_nodes(); ++i ) { Vector3D orig = pd.vertex_by_index( i ); Vector3D newp( orig[2], orig[1], -orig[0] ); pd.set_vertex_coordinates( newp, i, err ); } rval = m.evaluate( pd, 0, value, err ); CPPUNIT_ASSERT( !MSQ_CHKERR( err ) ); CPPUNIT_ASSERT( rval ); CPPUNIT_ASSERT_DOUBLES_EQUAL( faux_pi.value, value, DBL_EPSILON ); CPPUNIT_ASSERT_EQUAL( 1, faux_pi.count ); }
void TMPQualityMetricTest< QMType >::test_evaluate_surface_weight | ( | ) | [inline] |
Definition at line 445 of file TMPQualityMetricTest.hpp.
{ MsqPrintError err( cout ); PatchData pd; bool rval; double value; QMType m( &surf_target, &e_weight, &faux_pi ); tester.get_ideal_element( TRIANGLE, true, pd ); rval = m.evaluate( pd, 0, value, err ); CPPUNIT_ASSERT( !MSQ_CHKERR( err ) ); CPPUNIT_ASSERT( rval ); CPPUNIT_ASSERT_DOUBLES_EQUAL( faux_pi.value * e_weight.value, value, DBL_EPSILON ); }
void TMPQualityMetricTest< QMType >::test_evaluate_with_indices | ( | ) | [inline] |
Definition at line 551 of file TMPQualityMetricTest.hpp.
void TMPQualityMetricTest< QMType >::test_get_element_evaluations | ( | ) | [inline] |
Definition at line 419 of file TMPQualityMetricTest.hpp.
{ QMType edge_metric( &ideal, &faux_zero ); tester.test_get_in_element_evaluations( &zero_qm ); tester.test_get_in_element_evaluations( &edge_metric ); }
void TMPQualityMetricTest< QMType >::test_get_evaluations | ( | ) | [inline] |
Definition at line 413 of file TMPQualityMetricTest.hpp.
{ QMType edge_metric( &ideal, &faux_zero ); tester.test_get_sample_evaluations( &zero_qm ); tester.test_get_sample_evaluations( &edge_metric ); }
void TMPQualityMetricTest< QMType >::test_gradient_2D | ( | ) | [inline] |
Definition at line 537 of file TMPQualityMetricTest.hpp.
{ test_gradient_common( &ideal ); }
void TMPQualityMetricTest< QMType >::test_gradient_3D | ( | ) | [inline] |
Definition at line 894 of file TMPQualityMetricTest.hpp.
References ASSERT_NO_ERROR, MBMesquite::PatchData::attach_settings(), conn, CPPUNIT_ASSERT_DOUBLES_EQUAL, CPPUNIT_ASSERT_VECTORS_EQUAL, MBMesquite::PatchData::fill(), MBMesquite::ElemSampleQM::handle(), MBMesquite::HEXAHEDRON, MBMesquite::MsqMatrix< R, C >::row(), settings, MBMesquite::sqr_Frobenius(), MBMesquite::transpose(), and z.
{ MsqPrintError err( std::cout ); // check for expected value at center of flattened hex // construct flattened hex const double z = 0.5; const double vertices[] = { 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, z, 1.0, 0.0, z, 1.0, 1.0, z, 0.0, 1.0, z }; size_t conn[8] = { 0, 1, 2, 3, 4, 5, 6, 7 }; PatchData pd; pd.fill( 8, vertices, 1, HEXAHEDRON, conn, 0, err ); ASSERT_NO_ERROR( err ); // calculate Jacobian matrix at element center // derivatives of trilinear map at hex center const double deriv_vals[8][3] = { { -0.25, -0.25, -0.25 }, { 0.25, -0.25, -0.25 }, { 0.25, 0.25, -0.25 }, { -0.25, 0.25, -0.25 }, { -0.25, -0.25, 0.25 }, { 0.25, -0.25, 0.25 }, { 0.25, 0.25, 0.25 }, { -0.25, 0.25, 0.25 } }; MsqMatrix< 8, 3 > coeff_derivs( deriv_vals ); MsqMatrix< 8, 3 > coords( vertices ); MsqMatrix< 3, 3 > J = transpose( coords ) * coeff_derivs; // calculate expected metric value const double expt_val = sqr_Frobenius( J ); // calculate derivative for each element vertex MsqVector< 3 > expt_grad[8]; for( int v = 0; v < 8; ++v ) expt_grad[v] = 2 * J * transpose( coeff_derivs.row( v ) ); // construct metric pd.attach_settings( &settings ); TestGradTargetMetric< typename TMPTypes< QMType >::MetricType > tm; IdealShapeTarget tc; QMType m( &tc, 0, &tm ); // evaluate metric double act_val; std::vector< size_t > indices; std::vector< Vector3D > act_grad; size_t h = ElemSampleQM::handle( Sample( 3, 0 ), 0 ); m.evaluate_with_gradient( pd, h, act_val, indices, act_grad, err ); ASSERT_NO_ERROR( err ); // compare values CPPUNIT_ASSERT_DOUBLES_EQUAL( expt_val, act_val, 1e-10 ); CPPUNIT_ASSERT_VECTORS_EQUAL( Vector3D( expt_grad[indices[0]].data() ), act_grad[0], 1e-10 ); CPPUNIT_ASSERT_VECTORS_EQUAL( Vector3D( expt_grad[indices[1]].data() ), act_grad[1], 1e-10 ); CPPUNIT_ASSERT_VECTORS_EQUAL( Vector3D( expt_grad[indices[2]].data() ), act_grad[2], 1e-10 ); CPPUNIT_ASSERT_VECTORS_EQUAL( Vector3D( expt_grad[indices[3]].data() ), act_grad[3], 1e-10 ); CPPUNIT_ASSERT_VECTORS_EQUAL( Vector3D( expt_grad[indices[4]].data() ), act_grad[4], 1e-10 ); CPPUNIT_ASSERT_VECTORS_EQUAL( Vector3D( expt_grad[indices[5]].data() ), act_grad[5], 1e-10 ); CPPUNIT_ASSERT_VECTORS_EQUAL( Vector3D( expt_grad[indices[6]].data() ), act_grad[6], 1e-10 ); CPPUNIT_ASSERT_VECTORS_EQUAL( Vector3D( expt_grad[indices[7]].data() ), act_grad[7], 1e-10 ); // check numerical approx of gradient m.QualityMetric::evaluate_with_gradient( pd, h, act_val, indices, act_grad, err ); ASSERT_NO_ERROR( err ); CPPUNIT_ASSERT_DOUBLES_EQUAL( expt_val, act_val, 1e-10 ); CPPUNIT_ASSERT_VECTORS_EQUAL( Vector3D( expt_grad[indices[0]].data() ), act_grad[0], 1e-5 ); CPPUNIT_ASSERT_VECTORS_EQUAL( Vector3D( expt_grad[indices[1]].data() ), act_grad[1], 1e-5 ); CPPUNIT_ASSERT_VECTORS_EQUAL( Vector3D( expt_grad[indices[2]].data() ), act_grad[2], 1e-5 ); CPPUNIT_ASSERT_VECTORS_EQUAL( Vector3D( expt_grad[indices[3]].data() ), act_grad[3], 1e-5 ); CPPUNIT_ASSERT_VECTORS_EQUAL( Vector3D( expt_grad[indices[4]].data() ), act_grad[4], 1e-5 ); CPPUNIT_ASSERT_VECTORS_EQUAL( Vector3D( expt_grad[indices[5]].data() ), act_grad[5], 1e-5 ); CPPUNIT_ASSERT_VECTORS_EQUAL( Vector3D( expt_grad[indices[6]].data() ), act_grad[6], 1e-5 ); CPPUNIT_ASSERT_VECTORS_EQUAL( Vector3D( expt_grad[indices[7]].data() ), act_grad[7], 1e-5 ); }
void TMPQualityMetricTest< QMType >::test_gradient_common | ( | TargetCalculator * | tc | ) | [inline] |
Definition at line 832 of file TMPQualityMetricTest.hpp.
References ASSERT_NO_ERROR, MBMesquite::PatchData::attach_settings(), conn, CPPUNIT_ASSERT_DOUBLES_EQUAL, CPPUNIT_ASSERT_VECTORS_EQUAL, MBMesquite::PatchData::fill(), MBMesquite::ElemSampleQM::handle(), MBMesquite::QUADRILATERAL, MBMesquite::MsqMatrix< R, C >::row(), MBMesquite::PatchData::set_domain(), settings, MBMesquite::sqr_Frobenius(), MBMesquite::transpose(), and MBMesquite::PlanarDomain::XY.
{ MsqPrintError err( std::cout ); // check for expected value at center of flattened hex // construct flattened hex const double y = 0.5; const double vertices[] = { 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, y, 0.0, 0.0, y, 0.0 }; size_t conn[8] = { 0, 1, 2, 3 }; PatchData pd; pd.fill( 4, vertices, 1, QUADRILATERAL, conn, 0, err ); ASSERT_NO_ERROR( err ); // calculate Jacobian matrix at element center // derivatives of bilinear map at quad center const double deriv_vals[] = { -0.5, -0.5, 0.5, -0.5, 0.5, 0.5, -0.5, 0.5 }; MsqMatrix< 4, 2 > coeff_derivs( deriv_vals ); MsqMatrix< 4, 3 > coords( vertices ); MsqMatrix< 3, 2 > J = transpose( coords ) * coeff_derivs; // calculate expected metric value const double expt_val = sqr_Frobenius( J ); // calculate derivative for each element vertex MsqVector< 3 > expt_grad[4]; for( int v = 0; v < 4; ++v ) expt_grad[v] = 2 * J * transpose( coeff_derivs.row( v ) ); // construct metric pd.attach_settings( &settings ); TestGradTargetMetric< typename TMPTypes< QMType >::MetricType > tm; // IdealShapeTarget tc; QMType m( tc, &tm ); PlanarDomain plane( PlanarDomain::XY ); pd.set_domain( &plane ); // evaluate metric double act_val; std::vector< size_t > indices; std::vector< Vector3D > act_grad; size_t h = ElemSampleQM::handle( Sample( 2, 0 ), 0 ); m.evaluate_with_gradient( pd, h, act_val, indices, act_grad, err ); ASSERT_NO_ERROR( err ); // compare values CPPUNIT_ASSERT_DOUBLES_EQUAL( expt_val, act_val, 1e-10 ); CPPUNIT_ASSERT_VECTORS_EQUAL( Vector3D( expt_grad[indices[0]].data() ), act_grad[0], 1e-10 ); CPPUNIT_ASSERT_VECTORS_EQUAL( Vector3D( expt_grad[indices[1]].data() ), act_grad[1], 1e-10 ); CPPUNIT_ASSERT_VECTORS_EQUAL( Vector3D( expt_grad[indices[2]].data() ), act_grad[2], 1e-10 ); CPPUNIT_ASSERT_VECTORS_EQUAL( Vector3D( expt_grad[indices[3]].data() ), act_grad[3], 1e-10 ); // check numerical approx of gradient m.QualityMetric::evaluate_with_gradient( pd, h, act_val, indices, act_grad, err ); ASSERT_NO_ERROR( err ); CPPUNIT_ASSERT_DOUBLES_EQUAL( expt_val, act_val, 1e-10 ); CPPUNIT_ASSERT_VECTORS_EQUAL( Vector3D( expt_grad[indices[0]].data() ), act_grad[0], 1e-5 ); CPPUNIT_ASSERT_VECTORS_EQUAL( Vector3D( expt_grad[indices[1]].data() ), act_grad[1], 1e-5 ); CPPUNIT_ASSERT_VECTORS_EQUAL( Vector3D( expt_grad[indices[2]].data() ), act_grad[2], 1e-5 ); CPPUNIT_ASSERT_VECTORS_EQUAL( Vector3D( expt_grad[indices[3]].data() ), act_grad[3], 1e-5 ); }
void TMPQualityMetricTest< QMType >::test_gradient_surface | ( | ) | [inline] |
Definition at line 541 of file TMPQualityMetricTest.hpp.
{ test_gradient_common( &surf_target ); }
void TMPQualityMetricTest< QMType >::test_gradient_with_fixed_vertices | ( | ) | [inline] |
Definition at line 579 of file TMPQualityMetricTest.hpp.
{ tester.test_gradient_with_fixed_vertex( ¢er_qm, ¢erOnly ); }
void TMPQualityMetricTest< QMType >::test_hessian_with_fixed_vertices | ( | ) | [inline] |
Definition at line 608 of file TMPQualityMetricTest.hpp.
{ tester.test_hessian_with_fixed_vertex( ¢er_qm, ¢erOnly ); }
void TMPQualityMetricTest< QMType >::test_ideal_element_gradient | ( | ) | [inline] |
Definition at line 565 of file TMPQualityMetricTest.hpp.
{ tester.test_ideal_element_zero_gradient( &test_qm, false ); tester.test_ideal_element_zero_gradient( &test_qm_surf, false ); }
void TMPQualityMetricTest< QMType >::test_negate_flag | ( | ) | [inline] |
Definition at line 405 of file TMPQualityMetricTest.hpp.
{ CPPUNIT_ASSERT_EQUAL( 1, zero_qm.get_negate_flag() ); }
void TMPQualityMetricTest< QMType >::test_sample_indices | ( | ) | [inline] |
Definition at line 547 of file TMPQualityMetricTest.hpp.
{ tester.test_get_sample_indices( &zero_qm ); }
void TMPQualityMetricTest< QMType >::test_supported_types | ( | ) | [inline] |
Definition at line 409 of file TMPQualityMetricTest.hpp.
{ tester.test_supported_element_types( &zero_qm ); }
void TMPQualityMetricTest< QMType >::test_surf_eval_ortho_quad | ( | ) | [inline] |
Definition at line 495 of file TMPQualityMetricTest.hpp.
{ MsqPrintError err( cout ); PatchData pd; bool rval; double value; QMType m( &surf_target, &faux_zero ); faux_zero.count = 0; tester.get_ideal_element( QUADRILATERAL, true, pd ); rval = m.evaluate( pd, 0, value, err ); CPPUNIT_ASSERT( !MSQ_CHKERR( err ) ); CPPUNIT_ASSERT( rval ); CPPUNIT_ASSERT_EQUAL( 1, faux_zero.count ); CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0, col_dot_prod( faux_zero.last_A_2D ), DBL_EPSILON ); }
void TMPQualityMetricTest< QMType >::test_symmetric_hessian_diagonal | ( | ) | [inline] |
Definition at line 599 of file TMPQualityMetricTest.hpp.
void TMPQualityMetricTest< QMType >::test_weighted_diagonals | ( | ) | [inline] |
Definition at line 628 of file TMPQualityMetricTest.hpp.
void TMPQualityMetricTest< QMType >::test_weighted_gradients | ( | ) | [inline] |
Definition at line 575 of file TMPQualityMetricTest.hpp.
void TMPQualityMetricTest< QMType >::test_weighted_hessians | ( | ) | [inline] |
Definition at line 604 of file TMPQualityMetricTest.hpp.
QMType TMPQualityMetricTest< QMType >::center_qm [protected] |
Definition at line 378 of file TMPQualityMetricTest.hpp.
Settings TMPQualityMetricTest< QMType >::centerOnly [protected] |
Definition at line 379 of file TMPQualityMetricTest.hpp.
ScaleWeight TMPQualityMetricTest< QMType >::e_weight [protected] |
Definition at line 373 of file TMPQualityMetricTest.hpp.
FauxMetric< typename TMPTypes< QMType >::MetricType > TMPQualityMetricTest< QMType >::faux_pi [protected] |
Definition at line 375 of file TMPQualityMetricTest.hpp.
FauxMetric< typename TMPTypes< QMType >::MetricType > TMPQualityMetricTest< QMType >::faux_two [protected] |
Definition at line 375 of file TMPQualityMetricTest.hpp.
FauxMetric< typename TMPTypes< QMType >::MetricType > TMPQualityMetricTest< QMType >::faux_zero [protected] |
Definition at line 375 of file TMPQualityMetricTest.hpp.
CenterMF3D TMPQualityMetricTest< QMType >::hexCenter [protected] |
Definition at line 381 of file TMPQualityMetricTest.hpp.
IdealShapeTarget TMPQualityMetricTest< QMType >::ideal [protected] |
Definition at line 371 of file TMPQualityMetricTest.hpp.
NumericalMetric< typename QMType::MetricType > TMPQualityMetricTest< QMType >::num_metric [protected] |
Definition at line 377 of file TMPQualityMetricTest.hpp.
CenterMF3D TMPQualityMetricTest< QMType >::priCenter [protected] |
Definition at line 381 of file TMPQualityMetricTest.hpp.
CenterMF3D TMPQualityMetricTest< QMType >::pyrCenter [protected] |
Definition at line 381 of file TMPQualityMetricTest.hpp.
CenterMF2D TMPQualityMetricTest< QMType >::quadCenter [protected] |
Definition at line 380 of file TMPQualityMetricTest.hpp.
Settings TMPQualityMetricTest< QMType >::settings [protected] |
Definition at line 370 of file TMPQualityMetricTest.hpp.
IdealShapeXY TMPQualityMetricTest< QMType >::surf_target [protected] |
Definition at line 372 of file TMPQualityMetricTest.hpp.
TMPTypes< QMType >::TestType TMPQualityMetricTest< QMType >::test_metric [protected] |
Definition at line 376 of file TMPQualityMetricTest.hpp.
QMType TMPQualityMetricTest< QMType >::test_qm [protected] |
Definition at line 378 of file TMPQualityMetricTest.hpp.
QMType TMPQualityMetricTest< QMType >::test_qm_surf [protected] |
Definition at line 378 of file TMPQualityMetricTest.hpp.
QualityMetricTester TMPQualityMetricTest< QMType >::tester [protected] |
Definition at line 368 of file TMPQualityMetricTest.hpp.
CenterMF3D TMPQualityMetricTest< QMType >::tetCenter [protected] |
Definition at line 381 of file TMPQualityMetricTest.hpp.
CenterMF2D TMPQualityMetricTest< QMType >::triCenter [protected] |
Definition at line 380 of file TMPQualityMetricTest.hpp.
QMType TMPQualityMetricTest< QMType >::weight_qm [protected] |
Definition at line 378 of file TMPQualityMetricTest.hpp.
QMType TMPQualityMetricTest< QMType >::zero_qm [protected] |
Definition at line 378 of file TMPQualityMetricTest.hpp.