MOAB: Mesh Oriented datABase  (version 5.4.1)
UntangleBetaTest.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) [email protected]
00024 
00025   ***************************************************************** */
00026 
00027 /** \file UntangleBetaTest.cpp
00028  *  \brief unit tests for UntangleBetaQualityMetric
00029  *  \author Jason Kraftcheck
00030  */
00031 
00032 #include "Mesquite.hpp"
00033 #include "UntangleBetaQualityMetric.hpp"
00034 #include "cppunit/extensions/HelperMacros.h"
00035 #include "QualityMetricTester.hpp"
00036 #include "PatchData.hpp"
00037 #include "UnitUtil.hpp"
00038 
00039 using namespace MBMesquite;
00040 
00041 class UntangleBetaTest : public CppUnit::TestFixture
00042 {
00043   private:
00044     CPPUNIT_TEST_SUITE( UntangleBetaTest );
00045 
00046     CPPUNIT_TEST( test_supported_types );
00047     CPPUNIT_TEST( test_ideal_element_eval );
00048     CPPUNIT_TEST( test_inverted_elements );
00049     CPPUNIT_TEST( test_degenerate_elements );
00050     CPPUNIT_TEST( test_get_evaluations );
00051     CPPUNIT_TEST( test_get_element_indices );
00052     CPPUNIT_TEST( test_get_fixed_indices );
00053     CPPUNIT_TEST( test_eval_with_indices );
00054     CPPUNIT_TEST( test_location_invariant );
00055     CPPUNIT_TEST( test_orient_invariant );
00056 
00057     CPPUNIT_TEST_SUITE_END();
00058 
00059     UntangleBetaQualityMetric mMetric;
00060     QualityMetricTester tester;
00061 
00062   public:
00063     UntangleBetaTest() : tester( QualityMetricTester::ALL_FE_EXCEPT_SEPTAHEDRON )
00064     {
00065         tester.ideal_pyramid_base_equals_height( true );
00066     }
00067 
00068     void test_supported_types()
00069     {
00070         tester.test_supported_element_types( &mMetric );
00071     }
00072 
00073     void test_ideal_element_eval()
00074     {
00075         tester.test_evaluate_unit_edge_element( &mMetric, TRIANGLE, 0.0 );
00076         tester.test_evaluate_unit_edge_element( &mMetric, QUADRILATERAL, 0.0 );
00077         tester.test_evaluate_unit_edge_element( &mMetric, TETRAHEDRON, 0.0 );
00078         tester.test_evaluate_unit_edge_element( &mMetric, HEXAHEDRON, 0.0 );
00079         tester.test_evaluate_unit_edge_element( &mMetric, PRISM, 0.0 );
00080         tester.test_evaluate_unit_edge_element( &mMetric, PYRAMID, 0.0 );
00081     }
00082 
00083     void test_inverted_elements()
00084     {
00085         MsqPrintError err( std::cout );
00086         double value;
00087         PatchData pd;
00088         char val_str[128];
00089 
00090         tester.get_inverted_element( TRIANGLE, pd );
00091         mMetric.evaluate( pd, 0, value, err );
00092         ASSERT_NO_ERROR( err );
00093         sprintf( val_str, "value: %f", value );
00094         CPPUNIT_ASSERT_MESSAGE( val_str, value > 1e-6 );
00095 
00096         tester.get_inverted_element( QUADRILATERAL, pd );
00097         mMetric.evaluate( pd, 0, value, err );
00098         ASSERT_NO_ERROR( err );
00099         sprintf( val_str, "value: %f", value );
00100         CPPUNIT_ASSERT_MESSAGE( val_str, value > 1e-6 );
00101 
00102         tester.get_inverted_element( TETRAHEDRON, pd );
00103         mMetric.evaluate( pd, 0, value, err );
00104         ASSERT_NO_ERROR( err );
00105         sprintf( val_str, "value: %f", value );
00106         CPPUNIT_ASSERT_MESSAGE( val_str, value > 1e-6 );
00107 
00108         tester.get_inverted_element( HEXAHEDRON, pd );
00109         mMetric.evaluate( pd, 0, value, err );
00110         ASSERT_NO_ERROR( err );
00111         sprintf( val_str, "value: %f", value );
00112         CPPUNIT_ASSERT_MESSAGE( val_str, value > 1e-6 );
00113 
00114         tester.get_inverted_element( PRISM, pd );
00115         mMetric.evaluate( pd, 0, value, err );
00116         ASSERT_NO_ERROR( err );
00117         sprintf( val_str, "value: %f", value );
00118         CPPUNIT_ASSERT_MESSAGE( val_str, value > 1e-6 );
00119 
00120         tester.get_inverted_element( PYRAMID, pd );
00121         mMetric.evaluate( pd, 0, value, err );
00122         ASSERT_NO_ERROR( err );
00123         sprintf( val_str, "value: %f", value );
00124         CPPUNIT_ASSERT_MESSAGE( val_str, value > 1e-6 );
00125     }
00126 
00127     void test_degenerate_elements()
00128     {
00129         MsqPrintError err( std::cout );
00130         double value;
00131         PatchData pd;
00132         char val_str[128];
00133 
00134         tester.get_zero_element( TRIANGLE, pd );
00135         mMetric.evaluate( pd, 0, value, err );
00136         ASSERT_NO_ERROR( err );
00137         sprintf( val_str, "value: %f", value );
00138         CPPUNIT_ASSERT_MESSAGE( val_str, value > 1e-6 );
00139 
00140         tester.get_zero_element( QUADRILATERAL, pd );
00141         mMetric.evaluate( pd, 0, value, err );
00142         ASSERT_NO_ERROR( err );
00143         sprintf( val_str, "value: %f", value );
00144         CPPUNIT_ASSERT_MESSAGE( val_str, value > 1e-6 );
00145 
00146         tester.get_zero_element( TETRAHEDRON, pd );
00147         mMetric.evaluate( pd, 0, value, err );
00148         ASSERT_NO_ERROR( err );
00149         sprintf( val_str, "value: %f", value );
00150         CPPUNIT_ASSERT_MESSAGE( val_str, value > 1e-6 );
00151 
00152         tester.get_zero_element( HEXAHEDRON, pd );
00153         mMetric.evaluate( pd, 0, value, err );
00154         ASSERT_NO_ERROR( err );
00155         sprintf( val_str, "value: %f", value );
00156         CPPUNIT_ASSERT_MESSAGE( val_str, value > 1e-6 );
00157 
00158         tester.get_zero_element( PRISM, pd );
00159         mMetric.evaluate( pd, 0, value, err );
00160         ASSERT_NO_ERROR( err );
00161         sprintf( val_str, "value: %f", value );
00162         CPPUNIT_ASSERT_MESSAGE( val_str, value > 1e-6 );
00163 
00164         tester.get_zero_element( PYRAMID, pd );
00165         mMetric.evaluate( pd, 0, value, err );
00166         ASSERT_NO_ERROR( err );
00167         sprintf( val_str, "value: %f", value );
00168         CPPUNIT_ASSERT_MESSAGE( val_str, value > 1e-6 );
00169     }
00170 
00171     void test_get_evaluations()
00172     {
00173         tester.test_get_element_evaluations( &mMetric );
00174     }
00175 
00176     void test_get_element_indices()
00177     {
00178         tester.test_get_element_indices( &mMetric );
00179     }
00180 
00181     void test_get_fixed_indices()
00182     {
00183         tester.test_get_indices_fixed( &mMetric );
00184     }
00185 
00186     void test_eval_with_indices()
00187     {
00188         tester.compare_eval_and_eval_with_indices( &mMetric );
00189     }
00190 
00191     void test_location_invariant()
00192     {
00193         tester.test_location_invariant( &mMetric, true );
00194         tester.test_grad_location_invariant( &mMetric, true );
00195         tester.test_hessian_location_invariant( &mMetric, true );
00196     }
00197 
00198     void test_orient_invariant()
00199     {
00200         tester.test_orient_invariant( &mMetric, true );
00201         tester.test_grad_orient_invariant( &mMetric, true );
00202     }
00203 };
00204 
00205 CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( UntangleBetaTest, "UntangleBetaTest" );
00206 CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( UntangleBetaTest, "Unit" );
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines