MOAB: Mesh Oriented datABase  (version 5.2.1)
DomainClassifierTest.cpp
Go to the documentation of this file.
00001 /* *****************************************************************
00002     MESQUITE -- The Mesh Quality Improvement Toolkit
00003 
00004     Copyright 2008 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     retain 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     (2008) kraftche@cae.wisc.edu
00024 
00025   ***************************************************************** */
00026 
00027 /** \file DomainClassifierTest.cpp
00028  *  \brief
00029  *  \author Jason Kraftcheck
00030  */
00031 
00032 #include "Mesquite.hpp"
00033 #include "UnitUtil.hpp"
00034 #include "DomainClassifier.hpp"
00035 #include "MeshDomain1D.hpp"
00036 #include "MsqError.hpp"
00037 #include "MeshImpl.hpp"
00038 #include "MsqVertex.hpp"
00039 #include "PlanarDomain.hpp"
00040 
00041 #include <stdio.h>
00042 #include <iostream>
00043 #include <algorithm>
00044 
00045 using namespace MBMesquite;
00046 using namespace std;
00047 
00048 class DomainClassifierTest : public CppUnit::TestFixture
00049 {
00050   private:
00051     CPPUNIT_TEST_SUITE( DomainClassifierTest );
00052     CPPUNIT_TEST( test_classify_by_handle );
00053     CPPUNIT_TEST( test_valid_classification );
00054     CPPUNIT_TEST( test_classify_by_tag );
00055     CPPUNIT_TEST( test_classify_skin );
00056     CPPUNIT_TEST( test_classify_by_geometry );
00057     CPPUNIT_TEST_SUITE_END();
00058 
00059   public:
00060     typedef DomainClassifier::DomainSet DomSet;
00061     typedef std::vector< DomSet > DomSetList;
00062     MeshImpl myMesh;
00063     DomSetList myDomains;
00064     std::vector< int > domainDims;
00065 
00066     void setUp();
00067     void tearDown();
00068 
00069     void test_classify_by_handle();
00070     void test_valid_classification();
00071     void test_classify_by_tag();
00072     void test_classify_skin();
00073     void test_classify_by_geometry();
00074 
00075     void check_domain( DomainClassifier& dom );
00076 };
00077 
00078 CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( DomainClassifierTest, "Unit" );
00079 CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( DomainClassifierTest, "DomainClassifierTest" );
00080 
00081 static void print_domain( int i, DomainClassifier::DomainSet& set )
00082 {
00083     if( PointDomain* pd = dynamic_cast< PointDomain* >( set.domain ) )
00084         printf( "%d: PointDomain( %f %f %f ) @ %p\n", i, pd->geom()[0], pd->geom()[1], pd->geom()[2], pd );
00085     else if( LineDomain* ld = dynamic_cast< LineDomain* >( set.domain ) )
00086     {
00087         if( fabs( ld->geom().direction()[0] ) < 1e-6 && fabs( ld->geom().direction()[1] ) < 1e-6 )
00088             printf( "%d: LineDomain( x = %f, y = %f ) @ %p\n", i, ld->geom().point()[0], ld->geom().point()[1], ld );
00089         else if( fabs( ld->geom().direction()[1] ) < 1e-6 && fabs( ld->geom().direction()[2] ) < 1e-6 )
00090             printf( "%d: LineDomain( y = %f, z = %f ) @ %p\n", i, ld->geom().point()[1], ld->geom().point()[2], ld );
00091         else if( fabs( ld->geom().direction()[0] ) < 1e-6 && fabs( ld->geom().direction()[2] ) < 1e-6 )
00092             printf( "%d: LineDomain( x = %f, z = %f ) @ %p\n", i, ld->geom().point()[0], ld->geom().point()[2], ld );
00093         else
00094             printf( "%d: LineDomain( ? ) @ %p\n", i, ld );
00095     }
00096     else if( PlanarDomain* pd = dynamic_cast< PlanarDomain* >( set.domain ) )
00097     {
00098         if( fabs( pd->get_normal()[0] ) < 1e-6 && fabs( pd->get_normal()[1] ) < 1e-6 )
00099             printf( "%d: PlanarDomain( z = %f ) @ %p\n", i, pd->get_origin()[2], pd );
00100         else if( fabs( pd->get_normal()[1] ) < 1e-6 && fabs( pd->get_normal()[2] ) < 1e-6 )
00101             printf( "%d: PlanarDomain( x = %f ) @ %p\n", i, pd->get_origin()[1], pd );
00102         else if( fabs( pd->get_normal()[0] ) < 1e-6 && fabs( pd->get_normal()[2] ) < 1e-6 )
00103             printf( "%d: PlanarDomain( y = %f ) @ %p\n", i, pd->get_origin()[0], pd );
00104         else
00105             printf( "%d: PlanarDomain( ? ) @ %p\n", i, pd );
00106     }
00107     else
00108     {
00109         printf( "%d: unknown domain type @ %p\n", i, set.domain );
00110     }
00111 
00112     if( !set.vertices.empty() )
00113     {
00114         printf( "  vertices: " );
00115         std::vector< Mesh::VertexHandle >::iterator vi = set.vertices.begin();
00116         for( ; vi != set.vertices.end(); ++vi )
00117             printf( "%lu, ", (unsigned long)*vi );
00118         printf( "\n" );
00119     }
00120     if( !set.elements.empty() )
00121     {
00122         printf( "  elements: " );
00123         std::vector< Mesh::ElementHandle >::iterator ei = set.elements.begin();
00124         for( ; ei != set.elements.end(); ++ei )
00125             printf( "%lu, ", (unsigned long)*ei );
00126         printf( "\n" );
00127     }
00128 }
00129 
00130 void DomainClassifierTest::setUp()
00131 {
00132     myMesh.clear();
00133     myDomains.clear();
00134     domainDims.clear();
00135     // vertex coodinates
00136     const char vertex_data[] = "POINTS 64 float\n"
00137                                "0 0 0  1 0 0  2 0 0  3 0 0\n"
00138                                "0 1 0  1 1 0  2 1 0  3 1 0\n"
00139                                "0 2 0  1 2 0  2 2 0  3 2 0\n"
00140                                "0 3 0  1 3 0  2 3 0  3 3 0\n"
00141                                "\n"
00142                                "0 0 1  1 0 1  2 0 1  3 0 1\n"
00143                                "0 1 1  1 1 1  2 1 1  3 1 1\n"
00144                                "0 2 1  1 2 1  2 2 1  3 2 1\n"
00145                                "0 3 1  1 3 1  2 3 1  3 3 1\n"
00146                                "\n"
00147                                "0 0 2  1 0 2  2 0 2  3 0 2\n"
00148                                "0 1 2  1 1 2  2 1 2  3 1 2\n"
00149                                "0 2 2  1 2 2  2 2 2  3 2 2\n"
00150                                "0 3 2  1 3 2  2 3 2  3 3 2\n"
00151                                "\n"
00152                                "0 0 3  1 0 3  2 0 3  3 0 3\n"
00153                                "0 1 3  1 1 3  2 1 3  3 1 3\n"
00154                                "0 2 3  1 2 3  2 2 3  3 2 3\n"
00155                                "0 3 3  1 3 3  2 3 3  3 3 3\n"
00156                                "\n";
00157     // quad connectivity for quads on mesh skin
00158     const int num_quads    = 9 * 6;             // nine per side
00159     const char quad_data[] = "4  1  0  4  5\n"  // -z face (z == 0)
00160                              "4  2  1  5  6\n"
00161                              "4  3  2  6  7\n"
00162                              "4  5  4  8  9\n"
00163                              "4  6  5  9 10\n"
00164                              "4  7  6 10 11\n"
00165                              "4  9  8 12 13\n"
00166                              "4 10  9 13 14\n"
00167                              "4 11 10 14 15\n"
00168                              "\n"
00169                              "4 48 49 53 52\n"  // +z face (z == 3)
00170                              "4 49 50 54 53\n"
00171                              "4 50 51 55 54\n"
00172                              "4 52 53 57 56\n"
00173                              "4 53 54 58 57\n"
00174                              "4 54 55 59 58\n"
00175                              "4 56 57 61 60\n"
00176                              "4 57 58 62 61\n"
00177                              "4 58 59 63 62\n"
00178                              "\n"
00179                              "4  0  1 17 16\n"  // -y face (y == 0)
00180                              "4  1  2 18 17\n"
00181                              "4  2  3 19 18\n"
00182                              "4 16 17 33 32\n"
00183                              "4 17 18 34 33\n"
00184                              "4 18 19 35 34\n"
00185                              "4 32 33 49 48\n"
00186                              "4 33 34 50 49\n"
00187                              "4 34 35 51 50\n"
00188                              "\n"
00189                              "4 13 12 28 29\n"  // +y face (y == 3)
00190                              "4 14 13 29 30\n"
00191                              "4 15 14 30 31\n"
00192                              "4 29 28 44 45\n"
00193                              "4 30 29 45 46\n"
00194                              "4 31 30 46 47\n"
00195                              "4 45 44 60 61\n"
00196                              "4 46 45 61 62\n"
00197                              "4 47 46 62 63\n"
00198                              "\n"
00199                              "4  4  0 16 20\n"  // -x face (x == 0)
00200                              "4  8  4 20 24\n"
00201                              "4 12  8 24 28\n"
00202                              "4 20 16 32 36\n"
00203                              "4 24 20 36 40\n"
00204                              "4 28 24 40 44\n"
00205                              "4 36 32 48 52\n"
00206                              "4 40 36 52 56\n"
00207                              "4 44 40 56 60\n"
00208                              "\n"
00209                              "4  3  7 23 19\n"  // +x face (x == 3)
00210                              "4  7 11 27 23\n"
00211                              "4 11 15 31 27\n"
00212                              "4 19 23 39 35\n"
00213                              "4 23 27 43 39\n"
00214                              "4 27 31 47 43\n"
00215                              "4 35 39 55 51\n"
00216                              "4 39 43 59 55\n"
00217                              "4 43 47 63 59\n"
00218                              "\n";
00219     // hexahedron connectivity
00220     const int num_hexes   = 3 * 3 * 3;
00221     const char hex_data[] = "8  0  1  5  4 16 17 21 20\n"
00222                             "8  1  2  6  5 17 18 22 21\n"
00223                             "8  2  3  7  6 18 19 23 22\n"
00224                             "8  4  5  9  8 20 21 25 24\n"
00225                             "8  5  6 10  9 21 22 26 25\n"
00226                             "8  6  7 11 10 22 23 27 26\n"
00227                             "8  8  9 13 12 24 25 29 28\n"
00228                             "8  9 10 14 13 25 26 30 29\n"
00229                             "8 10 11 15 14 26 27 31 30\n"
00230                             "\n"
00231                             "8 16 17 21 20 32 33 37 36\n"
00232                             "8 17 18 22 21 33 34 38 37\n"
00233                             "8 18 19 23 22 34 35 39 38\n"
00234                             "8 20 21 25 24 36 37 41 40\n"
00235                             "8 21 22 26 25 37 38 42 41\n"
00236                             "8 22 23 27 26 38 39 43 42\n"
00237                             "8 24 25 29 28 40 41 45 44\n"
00238                             "8 25 26 30 29 41 42 46 45\n"
00239                             "8 26 27 31 30 42 43 47 46\n"
00240                             "\n"
00241                             "8 32 33 37 36 48 49 53 52\n"
00242                             "8 33 34 38 37 49 50 54 53\n"
00243                             "8 34 35 39 38 50 51 55 54\n"
00244                             "8 36 37 41 40 52 53 57 56\n"
00245                             "8 37 38 42 41 53 54 58 57\n"
00246                             "8 38 39 43 42 54 55 59 58\n"
00247                             "8 40 41 45 44 56 57 61 60\n"
00248                             "8 41 42 46 45 57 58 62 61\n"
00249                             "8 42 43 47 46 58 59 63 62\n"
00250                             "\n";
00251     // a few interior quads
00252     const int num_interior_quads    = 3;
00253     const char interior_quad_data[] = "4  1  5 25 17\n"
00254                                       "4  4  5 25 24\n"
00255                                       "4 16 17 25 24\n"
00256                                       "\n";
00257 
00258     const char filename[] = "dctest.vtk";
00259     FILE* file            = fopen( filename, "w" );
00260     fputs( "# vtk DataFile Version 2.0\n", file );
00261     fputs( "Mesquite Mesh\n", file );
00262     fputs( "ASCII\n", file );
00263     fputs( "DATASET UNSTRUCTURED_GRID\n", file );
00264     fputs( vertex_data, file );
00265 
00266     int num_elem      = num_quads + num_hexes + num_interior_quads;
00267     int num_elem_data = 5 * num_quads + 9 * num_hexes * 5 * num_interior_quads;
00268     fprintf( file, "CELLS %d %d\n", num_elem, num_elem_data );
00269     fputs( quad_data, file );
00270     fputs( hex_data, file );
00271     fputs( interior_quad_data, file );
00272     fprintf( file, "CELL_TYPES %d\n", num_elem );
00273     for( int i = 0; i < num_quads; ++i )
00274         fputs( "9\n", file );
00275     for( int i = 0; i < num_hexes; ++i )
00276         fputs( "12\n", file );
00277     for( int i = 0; i < num_interior_quads; ++i )
00278         fputs( "9\n", file );
00279 
00280     fclose( file );
00281     MsqPrintError err( std::cerr );
00282     myMesh.read_vtk( filename, err );
00283     remove( filename );
00284     CPPUNIT_ASSERT( !err );
00285 
00286     std::vector< Mesh::VertexHandle > verts;
00287     std::vector< Mesh::ElementHandle > elems;
00288     myMesh.get_all_vertices( verts, err );
00289     CPPUNIT_ASSERT( !err );
00290     CPPUNIT_ASSERT_EQUAL( (size_t)64, verts.size() );
00291     myMesh.get_all_elements( elems, err );
00292     CPPUNIT_ASSERT( !err );
00293     CPPUNIT_ASSERT_EQUAL( (size_t)num_elem, elems.size() );
00294 
00295     // define point domains
00296     PointDomain* pdom[8];
00297     pdom[0]         = new PointDomain( Vector3D( 0, 0, 0 ) );
00298     pdom[1]         = new PointDomain( Vector3D( 3, 0, 0 ) );
00299     pdom[2]         = new PointDomain( Vector3D( 0, 3, 0 ) );
00300     pdom[3]         = new PointDomain( Vector3D( 3, 3, 0 ) );
00301     pdom[4]         = new PointDomain( Vector3D( 0, 0, 3 ) );
00302     pdom[5]         = new PointDomain( Vector3D( 3, 0, 3 ) );
00303     pdom[6]         = new PointDomain( Vector3D( 0, 3, 3 ) );
00304     pdom[7]         = new PointDomain( Vector3D( 3, 3, 3 ) );
00305     size_t pdidx[8] = { 0, 3, 12, 15, 48, 51, 60, 63 };
00306     for( unsigned i = 0; i < 8; ++i )
00307     {
00308         MsqVertex coords;
00309         Mesh::VertexHandle h = verts[pdidx[i]];
00310         myMesh.vertices_get_coordinates( &h, &coords, 1, err );
00311         CPPUNIT_ASSERT( !err );
00312         CPPUNIT_ASSERT_VECTORS_EQUAL( pdom[i]->geom(), coords, 1e-6 );
00313         DomSet set;
00314         set.domain = pdom[i];
00315         set.vertices.push_back( h );
00316         myDomains.push_back( set );
00317         domainDims.push_back( 0 );
00318     }
00319 
00320     // define line domains
00321     LineDomain* ldom[12];
00322     ldom[0]             = new LineDomain( Vector3D( 0, 0, 0 ), Vector3D( 1, 0, 0 ) );  // y=0,z=0
00323     ldom[1]             = new LineDomain( Vector3D( 0, 3, 0 ), Vector3D( 1, 0, 0 ) );  // y=3,z=0
00324     ldom[2]             = new LineDomain( Vector3D( 0, 0, 3 ), Vector3D( 1, 0, 0 ) );  // y=0,z=3
00325     ldom[3]             = new LineDomain( Vector3D( 0, 3, 3 ), Vector3D( 1, 0, 0 ) );  // y=3,z=3
00326     ldom[4]             = new LineDomain( Vector3D( 0, 0, 0 ), Vector3D( 0, 1, 0 ) );  // x=0,z=0
00327     ldom[5]             = new LineDomain( Vector3D( 3, 0, 0 ), Vector3D( 0, 1, 0 ) );  // x=3,z=0
00328     ldom[6]             = new LineDomain( Vector3D( 0, 0, 3 ), Vector3D( 0, 1, 0 ) );  // x=0,z=3
00329     ldom[7]             = new LineDomain( Vector3D( 3, 0, 3 ), Vector3D( 0, 1, 0 ) );  // x=3,z=3
00330     ldom[8]             = new LineDomain( Vector3D( 0, 0, 0 ), Vector3D( 0, 0, 1 ) );  // x=0,y=0
00331     ldom[9]             = new LineDomain( Vector3D( 3, 0, 0 ), Vector3D( 0, 0, 1 ) );  // x=3,y=0
00332     ldom[10]            = new LineDomain( Vector3D( 0, 3, 0 ), Vector3D( 0, 0, 1 ) );  // x=0,y=3
00333     ldom[11]            = new LineDomain( Vector3D( 3, 3, 0 ), Vector3D( 0, 0, 1 ) );  // x=3,y=3
00334     size_t ldidx[12][2] = { { 1, 2 },   { 13, 14 }, { 49, 50 }, { 61, 62 }, { 4, 8 },   { 7, 11 },
00335                             { 52, 56 }, { 55, 59 }, { 16, 32 }, { 19, 35 }, { 28, 44 }, { 31, 47 } };
00336     for( unsigned i = 0; i < 12; ++i )
00337     {
00338         Mesh::VertexHandle v[2];
00339         v[0] = verts[ldidx[i][0]];
00340         v[1] = verts[ldidx[i][1]];
00341         MsqVertex coords[2];
00342         myMesh.vertices_get_coordinates( v, coords, 2, err );
00343         CPPUNIT_ASSERT( !err );
00344         CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0, ldom[i]->geom().distance( coords[0] ), 1e-6 );
00345         CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0, ldom[i]->geom().distance( coords[1] ), 1e-6 );
00346         DomSet set;
00347         set.domain = ldom[i];
00348         set.vertices.push_back( v[0] );
00349         set.vertices.push_back( v[1] );
00350         myDomains.push_back( set );
00351         domainDims.push_back( 1 );
00352     }
00353 
00354     // define planar domains
00355     PlanarDomain* sdom[6];
00356     sdom[0]            = new PlanarDomain( Vector3D( 0, 0, -1 ), Vector3D( 0, 0, 0 ) );
00357     sdom[1]            = new PlanarDomain( Vector3D( 0, 0, 1 ), Vector3D( 0, 0, 3 ) );
00358     sdom[2]            = new PlanarDomain( Vector3D( 0, -1, 0 ), Vector3D( 0, 0, 0 ) );
00359     sdom[3]            = new PlanarDomain( Vector3D( 0, 1, 0 ), Vector3D( 0, 3, 0 ) );
00360     sdom[4]            = new PlanarDomain( Vector3D( -1, 0, 0 ), Vector3D( 0, 0, 0 ) );
00361     sdom[5]            = new PlanarDomain( Vector3D( 1, 0, 0 ), Vector3D( 3, 0, 0 ) );
00362     size_t sdidx[6][4] = { { 5, 6, 9, 10 },    { 53, 54, 57, 58 }, { 17, 18, 33, 34 },
00363                            { 29, 30, 45, 46 }, { 20, 24, 36, 40 }, { 23, 27, 39, 43 } };
00364     for( unsigned i = 0; i < 6; ++i )
00365     {
00366         DomSet set;
00367         set.domain = sdom[i];
00368         for( unsigned j = 0; j < 4; ++j )
00369             set.vertices.push_back( verts[sdidx[i][j]] );
00370         for( unsigned j = 0; j < 9; ++j )
00371             set.elements.push_back( elems[9 * i + j] );
00372         myDomains.push_back( set );
00373         domainDims.push_back( 2 );
00374     }
00375 
00376     //  for (unsigned i = 0; i < myDomains.size(); ++i)
00377     //    print_domain( i, myDomains[i] );
00378 }
00379 
00380 void DomainClassifierTest::tearDown()
00381 {
00382     myMesh.clear();
00383     while( !myDomains.empty() )
00384     {
00385         delete myDomains.back().domain;
00386         myDomains.pop_back();
00387     }
00388     domainDims.clear();
00389 }
00390 
00391 void DomainClassifierTest::check_domain( DomainClassifier& domain )
00392 {
00393     std::vector< Mesh::VertexHandle > vertices, cverts;
00394     std::vector< Mesh::ElementHandle > elements, celems;
00395 
00396     // Check that, for each entity with a domain, the
00397     // DomainClassifier instance returns that domain.
00398     // Also, put all entities with domains into cverts and
00399     // celems for later.
00400     for( unsigned i = 0; i < myDomains.size(); ++i )
00401     {
00402         for( unsigned j = 0; j < myDomains[i].vertices.size(); ++j )
00403         {
00404             Mesh::VertexHandle v  = myDomains[i].vertices[j];
00405             const MeshDomain* ptr = domain.find_vertex_domain( v );
00406             CPPUNIT_ASSERT( myDomains[i].domain == ptr );
00407             cverts.push_back( v );
00408         }
00409         for( unsigned k = 0; k < myDomains[i].elements.size(); ++k )
00410         {
00411             Mesh::ElementHandle e = myDomains[i].elements[k];
00412             const MeshDomain* ptr = domain.find_element_domain( e );
00413             CPPUNIT_ASSERT( myDomains[i].domain == ptr );
00414             celems.push_back( e );
00415         }
00416     }
00417 
00418     // sort cverts and celems so we can do binary_search later
00419     std::sort( cverts.begin(), cverts.end() );
00420     std::sort( celems.begin(), celems.end() );
00421     // get all vertices and elements in mesh
00422     MsqPrintError err( std::cerr );
00423     myMesh.get_all_vertices( vertices, err );
00424     CPPUNIT_ASSERT( !err );
00425     myMesh.get_all_elements( elements, err );
00426     CPPUNIT_ASSERT( !err );
00427 
00428     // For each vertex not in a domain (not in cverts), make sure
00429     // that the domain is NULL.
00430     for( size_t i = 0; i < vertices.size(); ++i )
00431     {
00432         if( std::binary_search( cverts.begin(), cverts.end(), vertices[i] ) ) continue;
00433 
00434         const MeshDomain* ptr = domain.find_vertex_domain( vertices[i] );
00435         CPPUNIT_ASSERT( NULL == ptr );
00436     }
00437     // For each element not in a domain (not in celems), make sure
00438     // that the domain is NULL.
00439     for( size_t i = 0; i < elements.size(); ++i )
00440     {
00441         if( std::binary_search( celems.begin(), celems.end(), elements[i] ) ) continue;
00442 
00443         const MeshDomain* ptr = domain.find_element_domain( elements[i] );
00444         CPPUNIT_ASSERT( NULL == ptr );
00445     }
00446 }
00447 
00448 void DomainClassifierTest::test_classify_by_handle()
00449 {
00450     MsqPrintError err( std::cerr );
00451     DomainClassifier domain;
00452     DomainClassifier::classify_by_handle( domain, &myMesh, arrptr( myDomains ), myDomains.size(), err );
00453     CPPUNIT_ASSERT( !err );
00454 
00455     check_domain( domain );
00456 }
00457 
00458 void DomainClassifierTest::test_valid_classification()
00459 {
00460     MsqPrintError err( std::cerr );
00461     DomainClassifier domain;
00462     DomainClassifier::classify_by_handle( domain, &myMesh, arrptr( myDomains ), myDomains.size(), err );
00463     CPPUNIT_ASSERT( !err );
00464 
00465     domain.test_valid_classification( &myMesh, err );
00466     CPPUNIT_ASSERT( !err );
00467 }
00468 
00469 void DomainClassifierTest::test_classify_by_tag()
00470 {
00471     CPPUNIT_ASSERT( !myDomains.empty() );
00472 
00473     MsqPrintError err( std::cerr );
00474     int def       = myDomains.size();
00475     TagHandle tag = myMesh.tag_create( "domain", Mesh::INT, 1, &def, err );
00476     CPPUNIT_ASSERT( !err );
00477 
00478     std::vector< MeshDomain* > dom_list;
00479     std::vector< int > id_list;
00480     for( unsigned i = 0; i < myDomains.size(); ++i )
00481     {
00482         std::vector< int > vtx_data( myDomains[i].vertices.size(), i );
00483         std::vector< int > elm_data( myDomains[i].elements.size(), i );
00484         if( !vtx_data.empty() )
00485         {
00486             myMesh.tag_set_vertex_data( tag, vtx_data.size(), &( myDomains[i].vertices[0] ), arrptr( vtx_data ), err );
00487             CPPUNIT_ASSERT( !err );
00488         }
00489         if( !elm_data.empty() )
00490         {
00491             myMesh.tag_set_element_data( tag, elm_data.size(), &( myDomains[i].elements[0] ), arrptr( elm_data ), err );
00492             CPPUNIT_ASSERT( !err );
00493         }
00494 
00495         dom_list.push_back( myDomains[i].domain );
00496         id_list.push_back( i );
00497     }
00498 
00499     DomainClassifier domain;
00500     DomainClassifier::classify_by_tag( domain, &myMesh, "domain", arrptr( dom_list ), arrptr( id_list ),
00501                                        myDomains.size(), err );
00502     CPPUNIT_ASSERT( !err );
00503 
00504     check_domain( domain );
00505 }
00506 
00507 void DomainClassifierTest::test_classify_skin()
00508 {
00509     CPPUNIT_ASSERT( !myDomains.empty() );
00510 
00511     MsqPrintError err( std::cerr );
00512     std::vector< MeshDomain* > arr( myDomains.size() );
00513     for( size_t i = 0; i < myDomains.size(); ++i )
00514         arr[i] = myDomains[i].domain;
00515 
00516     DomainClassifier domain;
00517     DomainClassifier::classify_skin_geometrically( domain, &myMesh, 1e-6, arrptr( arr ), arrptr( domainDims ),
00518                                                    arr.size(), err );
00519     CPPUNIT_ASSERT( !err );
00520 
00521     check_domain( domain );
00522 }
00523 
00524 void DomainClassifierTest::test_classify_by_geometry()
00525 {
00526     CPPUNIT_ASSERT( !myDomains.empty() );
00527 
00528     MsqPrintError err( std::cerr );
00529     std::vector< MeshDomain* > arr( myDomains.size() );
00530     for( size_t i = 0; i < myDomains.size(); ++i )
00531         arr[i] = myDomains[i].domain;
00532 
00533     DomainClassifier domain;
00534     DomainClassifier::classify_geometrically( domain, &myMesh, 1e-6, arrptr( arr ), arrptr( domainDims ), arr.size(),
00535                                               err );
00536     CPPUNIT_ASSERT( !err );
00537 
00538     check_domain( domain );
00539 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines