MOAB: Mesh Oriented datABase  (version 5.2.1)
IdealWeightInverseMeanRatioTest.cpp
Go to the documentation of this file.
00001 /* *****************************************************************
00002     MESQUITE -- The Mesh Quality Improvement Toolkit
00003 
00004     Copyright 2006 Sandia National Laboratories.  Developed at the
00005     University of Wisconsin--Madison under SNL contract number
00006     624796.  The U.S. Government and the University of Wisconsin
00007     retian certain rights to this software.
00008 
00009     This library is free software; you can redistribute it and/or
00010     modify it under the terms of the GNU Lesser General Public
00011     License as published by the Free Software Foundation; either
00012     version 2.1 of the License, or (at your option) any later version.
00013 
00014     This library is distributed in the hope that it will be useful,
00015     but WITHOUT ANY WARRANTY; without even the implied warranty of
00016     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00017     Lesser General Public License for more details.
00018 
00019     You should have received a copy of the GNU Lesser General Public License
00020     (lgpl.txt) along with this library; if not, write to the Free Software
00021     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00022 
00023     (2006) kraftche@cae.wisc.edu
00024 
00025   ***************************************************************** */
00026 
00027 /** \file IdealWeightInverseMeanRatioTest.cpp
00028  *  \brief unit tests for IdealWeightInverseMeanRatio quality metric
00029  *  \author Jason Kraftcheck
00030  */
00031 
00032 #include "Mesquite.hpp"
00033 #include "IdealWeightInverseMeanRatio.hpp"
00034 #include "cppunit/extensions/HelperMacros.h"
00035 #include "QualityMetricTester.hpp"
00036 
00037 using namespace MBMesquite;
00038 
00039 class IdealWeightInverseMeanRatioTest : public CppUnit::TestFixture
00040 {
00041   private:
00042     CPPUNIT_TEST_SUITE( IdealWeightInverseMeanRatioTest );
00043 
00044     CPPUNIT_TEST( test_supported_types );
00045     CPPUNIT_TEST( test_ideal_element_eval );
00046     CPPUNIT_TEST( test_ideal_element_grad );
00047     CPPUNIT_TEST( test_ideal_element_hess );
00048     CPPUNIT_TEST( test_valid_hessian );
00049     CPPUNIT_TEST( test_measures_quality );
00050     CPPUNIT_TEST( test_gradient_reflects_quality );
00051     CPPUNIT_TEST( test_domain_deviation );
00052     CPPUNIT_TEST( test_inverted_elements );
00053     CPPUNIT_TEST( test_degenerate_elements );
00054     CPPUNIT_TEST( test_get_evaluations );
00055     CPPUNIT_TEST( test_get_element_indices );
00056     CPPUNIT_TEST( test_get_fixed_indices );
00057     CPPUNIT_TEST( test_eval_with_indices );
00058     CPPUNIT_TEST( test_eval_with_gradient );
00059     CPPUNIT_TEST( test_eval_with_hessian );
00060     CPPUNIT_TEST( test_eval_with_hessian_diagonal );
00061     CPPUNIT_TEST( test_location_invariant );
00062     CPPUNIT_TEST( test_scale_invariant );
00063     CPPUNIT_TEST( test_orient_invariant );
00064 
00065     CPPUNIT_TEST_SUITE_END();
00066 
00067     IdealWeightInverseMeanRatio mMetric;
00068     QualityMetricTester tester;
00069 
00070   public:
00071     IdealWeightInverseMeanRatioTest() : tester( QualityMetricTester::ALL_FE_EXCEPT_SEPTAHEDRON )
00072     {
00073         tester.ideal_pyramid_base_equals_height( true );
00074     }
00075 
00076     void test_supported_types()
00077     {
00078         tester.test_supported_element_types( &mMetric );
00079     }
00080 
00081     void test_ideal_element_eval()
00082     {
00083         tester.test_evaluate_unit_edge_element( &mMetric, TRIANGLE, 1.0 );
00084         tester.test_evaluate_unit_edge_element( &mMetric, QUADRILATERAL, 1.0 );
00085         tester.test_evaluate_unit_edge_element( &mMetric, TETRAHEDRON, 1.0 );
00086         tester.test_evaluate_unit_edge_element( &mMetric, HEXAHEDRON, 1.0 );
00087         tester.test_evaluate_unit_edge_element( &mMetric, PRISM, 1.0 );
00088         tester.test_evaluate_unit_edge_element( &mMetric, PYRAMID, 1.0 );
00089     }
00090 
00091     void test_ideal_element_grad()
00092     {
00093         tester.test_ideal_element_zero_gradient( &mMetric, false );
00094     }
00095 
00096     void test_ideal_element_hess()
00097     {
00098         tester.test_ideal_element_positive_definite_Hessian( &mMetric, false );
00099     }
00100 
00101     void test_valid_hessian()
00102     {
00103         tester.test_symmetric_Hessian_diagonal_blocks( &mMetric );
00104     }
00105 
00106     void test_measures_quality()
00107     {
00108         tester.test_measures_quality( &mMetric );
00109     }
00110 
00111     void test_gradient_reflects_quality()
00112     {
00113         tester.test_gradient_reflects_quality( &mMetric );
00114     }
00115 
00116     void test_domain_deviation()
00117     {
00118         tester.test_domain_deviation_quality( &mMetric );
00119         tester.test_domain_deviation_gradient( &mMetric );
00120     }
00121 
00122     void test_inverted_elements()
00123     {
00124         tester.test_evaluate_inverted_element( &mMetric, false );
00125     }
00126 
00127     void test_degenerate_elements()
00128     {
00129         tester.test_evaluate_degenerate_element( &mMetric, false );
00130     }
00131 
00132     void test_get_evaluations()
00133     {
00134         tester.test_get_element_evaluations( &mMetric );
00135     }
00136 
00137     void test_get_element_indices()
00138     {
00139         tester.test_get_element_indices( &mMetric );
00140     }
00141 
00142     void test_get_fixed_indices()
00143     {
00144         tester.test_get_indices_fixed( &mMetric );
00145     }
00146 
00147     void test_eval_with_indices()
00148     {
00149         tester.compare_eval_and_eval_with_indices( &mMetric );
00150     }
00151 
00152     void test_eval_with_gradient()
00153     {
00154         tester.compare_eval_with_indices_and_eval_with_gradient( &mMetric );
00155         tester.compare_analytical_and_numerical_gradients( &mMetric );
00156     }
00157 
00158     void test_eval_with_hessian()
00159     {
00160         tester.compare_eval_with_indices_and_eval_with_hessian( &mMetric );
00161         tester.compare_eval_with_grad_and_eval_with_hessian( &mMetric );
00162         tester.compare_analytical_and_numerical_hessians( &mMetric );
00163     }
00164 
00165     void test_eval_with_hessian_diagonal()
00166     {
00167         tester.compare_eval_with_diag_and_eval_with_hessian( &mMetric );
00168     }
00169 
00170     void test_location_invariant()
00171     {
00172         tester.test_location_invariant( &mMetric );
00173         tester.test_grad_location_invariant( &mMetric );
00174         tester.test_hessian_location_invariant( &mMetric );
00175     }
00176 
00177     void test_scale_invariant()
00178     {
00179         tester.test_scale_invariant( &mMetric );
00180     }
00181 
00182     void test_orient_invariant()
00183     {
00184         tester.test_orient_invariant( &mMetric );
00185         tester.test_grad_orient_invariant( &mMetric );
00186     }
00187 };
00188 
00189 CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( IdealWeightInverseMeanRatioTest, "IdealWeightInverseMeanRatioTest" );
00190 CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( IdealWeightInverseMeanRatioTest, "Unit" );
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines