MOAB: Mesh Oriented datABase
(version 5.4.1)
|
00001 /* ***************************************************************** 00002 MESQUITE -- The Mesh Quality Improvement Toolkit 00003 00004 Copyright 2004 Sandia Corporation and Argonne National 00005 Laboratory. Under the terms of Contract DE-AC04-94AL85000 00006 with Sandia Corporation, the U.S. Government retains certain 00007 rights in 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 diachin2@llnl.gov, djmelan@sandia.gov, mbrewer@sandia.gov, 00024 pknupp@sandia.gov, tleurent@mcs.anl.gov, tmunson@mcs.anl.gov 00025 00026 ***************************************************************** */ 00027 // -*- Mode : c++; tab-width: 3; c-tab-always-indent: t; indent-tabs-mode: nil; c-basic-offset: 3 00028 // -*- 00029 // 00030 // SUMMARY: 00031 // USAGE: 00032 // 00033 // AUTHOR: Thomas Leurent <tleurent@mcs.anl.gov> 00034 // ORG: Argonne National Laboratory 00035 // E-MAIL: tleurent@mcs.anl.gov 00036 // 00037 // ORIG-DATE: 12-Nov-02 at 18:05:56 00038 // LAST-MOD: 9-Apr-03 at 10:05:06 by Thomas Leurent 00039 // 00040 // DESCRIPTION: 00041 // ============ 00042 /*! \file MsqVertexTest.cpp 00043 00044 Unit testing of various functions in the MsqVertex class. 00045 00046 */ 00047 // DESCRIP-END. 00048 // 00049 00050 #include "MsqVertex.hpp" 00051 #include "PatchData.hpp" 00052 #include "PatchDataInstances.hpp" 00053 00054 #include <cmath> 00055 #include <iostream> 00056 00057 #include "cppunit/extensions/HelperMacros.h" 00058 00059 using namespace MBMesquite; 00060 using std::cerr; 00061 using std::cout; 00062 using std::endl; 00063 00064 class MsqVertexTest : public CppUnit::TestFixture 00065 { 00066 00067 private: 00068 CPPUNIT_TEST_SUITE( MsqVertexTest ); 00069 CPPUNIT_TEST( test_flags ); 00070 CPPUNIT_TEST_SUITE_END(); 00071 00072 private: 00073 PatchData one_hex_patch; 00074 PatchData one_tet_patch; 00075 PatchData one_qua_patch; 00076 PatchData one_tri_patch; 00077 Vector3D e1, e2, e3; 00078 double tolEps; 00079 00080 public: 00081 void setUp() 00082 { 00083 tolEps = 1.e-12; 00084 // set up the unit vectors 00085 e1.set( 1, 0, 0 ); 00086 e2.set( 0, 1, 0 ); 00087 e3.set( 0, 0, 1 ); 00088 00089 MsqPrintError err( cout ); 00090 00091 double hcoords[] = { 1.0, 1.0, 1.0, 2.0, 1.0, 1.0, 2.0, 2.0, 1.0, 1.0, 2.0, 1.0, 00092 1.0, 1.0, 2.0, 2.0, 1.0, 2.0, 2.0, 2.0, 2.0, 1.0, 2.0, 2.0 }; 00093 size_t hconn[] = { 0, 1, 2, 3, 4, 5, 6, 7 }; 00094 one_hex_patch.fill( 8, hcoords, 1, HEXAHEDRON, hconn, 0, err ); 00095 00096 double tcoords[] = { 1.0, 00097 1.0, 00098 1.0, 00099 2.0, 00100 1.0, 00101 1.0, 00102 1.5, 00103 1 + sqrt( 3.0 ) / 2.0, 00104 1.0, 00105 1.5, 00106 1 + sqrt( 3.0 ) / 6.0, 00107 1 + sqrt( 2.0 ) / sqrt( 3.0 ) }; 00108 size_t tconn[] = { 0, 1, 2, 3 }; 00109 one_tet_patch.fill( 4, tcoords, 1, TETRAHEDRON, tconn, 0, err ); 00110 00111 double qcoords[] = { 1.0, 1.0, 1.0, 2.0, 1.0, 1.0, 2.0, 2.0, 1.0, 1.0, 2.0, 1.0 }; 00112 size_t qconn[] = { 0, 1, 2, 3 }; 00113 one_qua_patch.fill( 4, qcoords, 1, QUADRILATERAL, qconn, 0, err ); 00114 00115 double rcoords[] = { 1.0, 1.0, 1.0, 2.0, 1.0, 1.0, 1.5, 1 + sqrt( 3.0 ) / 2.0, 1.0 }; 00116 size_t rconn[] = { 0, 1, 2 }; 00117 one_tri_patch.fill( 3, rcoords, 1, TRIANGLE, rconn, 0, err ); 00118 } 00119 00120 void tearDown() {} 00121 00122 public: 00123 MsqVertexTest() {} 00124 00125 void test_hex_vertices() 00126 { 00127 MsqPrintError err( cout ); 00128 // prints out the vertices. 00129 const MsqVertex* ideal_vertices = one_hex_patch.get_vertex_array( err ); 00130 CPPUNIT_ASSERT( !err ); 00131 int num_vtx = one_hex_patch.num_nodes(); 00132 CPPUNIT_ASSERT_EQUAL( 8, num_vtx ); 00133 00134 MsqVertex vtx; 00135 00136 vtx.set( 1, 1, 1 ); 00137 CPPUNIT_ASSERT_EQUAL( vtx, ideal_vertices[0] ); 00138 00139 vtx.set( 2, 2, 2 ); 00140 CPPUNIT_ASSERT_EQUAL( vtx, ideal_vertices[6] ); 00141 00142 vtx.set( 1, 2, 2 ); 00143 CPPUNIT_ASSERT_EQUAL( vtx, ideal_vertices[7] ); 00144 } 00145 00146 void test_flags() 00147 { 00148 MsqVertex vtx( 1, 2, 3 ); 00149 CPPUNIT_ASSERT( vtx.is_flag_set( MsqVertex::MSQ_HARD_FIXED ) == false ); 00150 vtx.set_hard_fixed_flag(); 00151 CPPUNIT_ASSERT( vtx.is_flag_set( MsqVertex::MSQ_CULLED ) == false ); 00152 CPPUNIT_ASSERT( vtx.is_flag_set( MsqVertex::MSQ_HARD_FIXED ) == true ); 00153 CPPUNIT_ASSERT( ( vtx.is_flag_set( MsqVertex::MSQ_CULLED ) || vtx.is_flag_set( MsqVertex::MSQ_HARD_FIXED ) ) == 00154 true ); 00155 CPPUNIT_ASSERT( ( vtx.is_flag_set( MsqVertex::MSQ_CULLED ) && vtx.is_flag_set( MsqVertex::MSQ_HARD_FIXED ) ) == 00156 false ); 00157 } 00158 }; 00159 00160 CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( MsqVertexTest, "MsqVertexTest" ); 00161 CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( MsqVertexTest, "Unit" );