MOAB: Mesh Oriented datABase  (version 5.4.1)
h5portable.cpp
Go to the documentation of this file.
00001 /** \file   h5portable.cpp
00002  *  \author Jason Kraftcheck
00003  *  \date   2010-09-23
00004  *
00005  * Tests for HDF5 portability because we call H5Tconvert ourselves
00006  * to work around parallel performance issues in the HDF5 library.
00007  */
00008 
00009 #include "moab/Core.hpp"
00010 #include "moab/Range.hpp"
00011 #include "TestRunner.hpp"
00012 #include "ReadHDF5.hpp"
00013 #include "MBTagConventions.hpp"
00014 #include "moab/FileOptions.hpp"
00015 #include <vector>
00016 #include <cstdlib>
00017 #include <iostream>
00018 #include <algorithm>
00019 #include <limits>
00020 
00021 using namespace moab;
00022 
00023 #define FILE_NAME_BASE "portable"
00024 #define BASE_NAME      STRINGIFY( MESHDIR ) "/h5file/" FILE_NAME_BASE
00025 #define NATIVE_NAME    FILE_NAME_BASE ".h5m"
00026 #define READ_OPTS      "BUFFER_SIZE=256"
00027 
00028 const int default_int_tag[]     = { -100, -99 };
00029 const int mesh_int_tag[]        = { 1134, -1134 };
00030 const double default_real_tag[] = { -1, -2, -3, -4, -5, -6, -7, -8 };
00031 const double mesh_real_tag[]    = { 8, 7, 6, 5, 4, 3, 2, 1 };
00032 
00033 const size_t INTERVALS = 8;
00034 const size_t NUM_VERT  = ( INTERVALS + 1 ) * ( INTERVALS + 1 );
00035 const size_t NUM_QUAD  = INTERVALS * INTERVALS;
00036 const double Z         = 0.0;
00037 const double EPS       = std::numeric_limits< double >::epsilon();
00038 
00039 // This function is not actually called from any test.
00040 // It is the utility code used to generate the initial
00041 // input file.
00042 //
00043 // Create a mesh with the following properties:
00044 //   A 8x8 grid of quadrilateral elements in the Z plane
00045 //   Lower left vertex is at origin
00046 //   Vertex coordinates are incremented by 1 in increasing X and Y directions
00047 //   Each element's connectivity is ordered starting with the lower-left vertex
00048 //      counter-clockwise about the positive Z axis.
00049 //   Each element is tagged with the integer value of it's lower-left vertex
00050 //      coordinates ("int_tag", default = [-100,-99], mesh = [1134,-1134])
00051 //   Each element is tagged with the array of its vertex coordinates (interleaved)
00052 //      ("real_tag", default = [-1, -2, -3, -4, -5, -6, -7, -8], mesh = [8, 7, 5, 5, 4, 3, 2, 1])
00053 //   Each vertex is tagged with the handle of the element for which it is the
00054 //      lower left vertex ("handle_tag")
00055 //   A set containing each row of quads that is a child of the row below it
00056 //   Each set tagged with a bit tag indicating whether it is an even or odd row,
00057 //     with the first row even. ("bit_tag");
00058 //   Each set will also be tagged with an integer tag named 'rowset' containing
00059 //     the same value as the "bit_tag" for use in testing partial reads.
00060 //
00061 //  |      |      |      |      |      |      |      |      |
00062 //  |  17  |  18  |  19  |  20  |  21  |  22  |  23  |  24  |
00063 //  |      |      |      |      |      |      |      |      |
00064 // 19-----20-----21-----22-----23-----24-----25-----26-----27
00065 //  |      |      |      |      |      |      |      |      |
00066 //  |   9  |  10  |  11  |  12  |  13  |  14  |  15  |  16  |
00067 //  |      |      |      |      |      |      |      |      |
00068 // 10-----11-----12-----13-----14-----15-----16-----17-----18
00069 //  |      |      |      |      |      |      |      |      |
00070 //  |   1  |   2  |   3  |   4  |   5  |   6  |   7  |   8  |
00071 //  |      |      |      |      |      |      |      |      |
00072 //  1------2------3------4------5------6------7------8------9
00073 void create_mesh( const char* filename )
00074 {
00075     EntityHandle verts[NUM_VERT];
00076     EntityHandle quads[NUM_QUAD];
00077 
00078     ErrorCode rval;
00079     Core core;
00080     Interface& mb           = core;
00081     const EntityHandle root = 0;
00082 
00083     Tag int_tag, real_tag, handle_tag, bit_tag, row_tag;
00084 
00085     rval = mb.tag_get_handle( "int_tag", 2, MB_TYPE_INTEGER, int_tag, MB_TAG_DENSE | MB_TAG_EXCL, default_int_tag );CHECK_ERR( rval );
00086     rval = mb.tag_set_data( int_tag, &root, 1, mesh_int_tag );CHECK_ERR( rval );
00087 
00088     rval = mb.tag_get_handle( "real_tag", 8, MB_TYPE_DOUBLE, real_tag, MB_TAG_DENSE | MB_TAG_EXCL, default_real_tag );CHECK_ERR( rval );
00089     rval = mb.tag_set_data( real_tag, &root, 1, mesh_real_tag );CHECK_ERR( rval );
00090 
00091     rval = mb.tag_get_handle( "handle_tag", 1, MB_TYPE_HANDLE, handle_tag, MB_TAG_SPARSE | MB_TAG_EXCL );CHECK_ERR( rval );
00092 
00093     rval = mb.tag_get_handle( "bit_tag", 1, MB_TYPE_BIT, bit_tag, MB_TAG_EXCL );CHECK_ERR( rval );
00094 
00095     rval = mb.tag_get_handle( "rowset", 1, MB_TYPE_INTEGER, row_tag, MB_TAG_SPARSE | MB_TAG_EXCL );CHECK_ERR( rval );
00096 
00097     for( size_t i = 0; i < NUM_VERT; ++i )
00098     {
00099         double coords[] = { static_cast< double >( i % 9 ), static_cast< double >( i / 9 ),
00100                             static_cast< double >( Z ) };
00101         rval            = mb.create_vertex( coords, verts[i] );CHECK_ERR( rval );
00102     }
00103 
00104     for( size_t i = 0; i < NUM_QUAD; ++i )
00105     {
00106         size_t j            = ( i / 8 ) * 9 + i % 8;
00107         EntityHandle conn[] = { verts[j], verts[j + 1], verts[j + 10], verts[j + 9] };
00108         rval                = mb.create_element( MBQUAD, conn, 4, quads[i] );CHECK_ERR( rval );
00109 
00110         double coords[4 * 3];
00111         rval = mb.get_coords( conn, 4, coords );CHECK_ERR( rval );
00112 
00113         int int_val[] = { (int)coords[0], (int)coords[1] };
00114         rval          = mb.tag_set_data( int_tag, quads + i, 1, int_val );CHECK_ERR( rval );
00115 
00116         double real_val[] = { coords[0], coords[1], coords[3], coords[4], coords[6], coords[7], coords[9], coords[10] };
00117         rval              = mb.tag_set_data( real_tag, quads + i, 1, real_val );CHECK_ERR( rval );
00118 
00119         rval = mb.tag_set_data( handle_tag, conn, 1, quads + i );CHECK_ERR( rval );
00120     }
00121 
00122     EntityHandle prev = 0;
00123     for( size_t i = 0; i < INTERVALS; ++i )
00124     {
00125         EntityHandle set;
00126         int flag = i < 4 ? MESHSET_SET : MESHSET_ORDERED;
00127         rval     = mb.create_meshset( flag, set );CHECK_ERR( rval );
00128 
00129         rval = mb.add_entities( set, quads + i * INTERVALS, INTERVALS );CHECK_ERR( rval );
00130 
00131         char bit = i % 2;
00132         rval     = mb.tag_set_data( bit_tag, &set, 1, &bit );CHECK_ERR( rval );
00133 
00134         int ival = bit;
00135         rval     = mb.tag_set_data( row_tag, &set, 1, &ival );CHECK_ERR( rval );
00136 
00137         if( prev != 0 )
00138         {
00139             rval = mb.add_parent_child( prev, set );CHECK_ERR( rval );
00140         }
00141         prev = set;
00142     }
00143 
00144     rval = mb.write_file( filename, "MOAB" );CHECK_ERR( rval );
00145 }
00146 
00147 void test_load_file( const char* filename )
00148 {
00149     Core core;
00150     Interface& mb  = core;
00151     ErrorCode rval = mb.load_file( filename, 0, READ_OPTS );CHECK_ERR( rval );
00152 }
00153 
00154 void test_read_vertices( const char* filename )
00155 {
00156     // load the file
00157     Core core;
00158     Interface& mb  = core;
00159     ErrorCode rval = mb.load_file( filename, 0, READ_OPTS );CHECK_ERR( rval );
00160     // get the vertices
00161     Range verts;
00162     rval = mb.get_entities_by_type( 0, MBVERTEX, verts );CHECK_ERR( rval );
00163     CHECK_EQUAL( NUM_VERT, verts.size() );
00164     // check vertex coordinates
00165     bool seen[INTERVALS + 1][INTERVALS + 1];
00166     for( size_t i = 0; i <= INTERVALS; ++i )
00167         for( size_t j = 0; j <= INTERVALS; ++j )
00168             seen[i][j] = false;
00169     for( Range::iterator i = verts.begin(); i != verts.end(); ++i )
00170     {
00171         double coords[3];
00172         rval = mb.get_coords( &*i, 1, coords );CHECK_ERR( rval );
00173         CHECK_REAL_EQUAL( Z, coords[2], EPS );
00174         size_t x = (size_t)coords[0];
00175         size_t y = (size_t)coords[1];
00176         CHECK_REAL_EQUAL( (double)x, coords[0], EPS );
00177         CHECK_REAL_EQUAL( (double)y, coords[1], EPS );
00178         CHECK( x <= INTERVALS );
00179         CHECK( y <= INTERVALS );
00180         CHECK( !seen[x][y] );
00181         seen[x][y] = true;
00182     }
00183 }
00184 
00185 void test_elements( Interface& mb, bool odd_only )
00186 {
00187     // get the elements
00188     Range quads;
00189     ErrorCode rval = mb.get_entities_by_type( 0, MBQUAD, quads );CHECK_ERR( rval );
00190     CHECK_EQUAL( NUM_QUAD / ( 1 + odd_only ), quads.size() );
00191     // check quad connectivity
00192     bool seen[INTERVALS][INTERVALS];
00193     for( size_t i = 0; i < INTERVALS; ++i )
00194         for( size_t j = 0; j < INTERVALS; ++j )
00195             seen[i][j] = false;
00196     for( Range::iterator i = quads.begin(); i != quads.end(); ++i )
00197     {
00198         const EntityHandle* conn = 0;
00199         int len                  = 0;
00200         rval                     = mb.get_connectivity( *i, conn, len );CHECK_ERR( rval );
00201         CHECK_EQUAL( 4, len );
00202         double coords[4 * 3];
00203         rval = mb.get_coords( conn, len, coords );CHECK_ERR( rval );
00204 
00205         size_t x = (size_t)coords[0];
00206         size_t y = (size_t)coords[1];
00207         CHECK_REAL_EQUAL( (double)x, coords[0], EPS );
00208         CHECK_REAL_EQUAL( (double)y, coords[1], EPS );
00209         CHECK( x < INTERVALS );
00210         CHECK( y < INTERVALS );
00211 
00212         CHECK_REAL_EQUAL( Z, coords[2], EPS );
00213         CHECK_REAL_EQUAL( 1.0 + x, coords[3], EPS );
00214         CHECK_REAL_EQUAL( 0.0 + y, coords[4], EPS );
00215         CHECK_REAL_EQUAL( Z, coords[5], EPS );
00216         CHECK_REAL_EQUAL( 1.0 + x, coords[6], EPS );
00217         CHECK_REAL_EQUAL( 1.0 + y, coords[7], EPS );
00218         CHECK_REAL_EQUAL( Z, coords[8], EPS );
00219         CHECK_REAL_EQUAL( 0.0 + x, coords[9], EPS );
00220         CHECK_REAL_EQUAL( 1.0 + y, coords[10], EPS );
00221         CHECK_REAL_EQUAL( Z, coords[11], EPS );
00222     }
00223 
00224     if( odd_only )
00225     {
00226         for( size_t i = 0; i < INTERVALS; i += 2 )
00227             for( size_t j = 0; j < INTERVALS; ++j )
00228                 CHECK( !seen[i][j] );
00229     }
00230 }
00231 
00232 void test_read_elements( const char* filename )
00233 {
00234     // load the file
00235     Core core;
00236     Interface& mb  = core;
00237     ErrorCode rval = mb.load_file( filename, 0, READ_OPTS );CHECK_ERR( rval );
00238     // check the elements
00239     test_elements( mb, false );
00240 }
00241 
00242 void read_sets( Interface& mb, EntityHandle rows[INTERVALS] )
00243 {
00244     // get the sets
00245     Range sets;
00246     ErrorCode rval = mb.get_entities_by_type( 0, MBENTITYSET, sets );CHECK_ERR( rval );
00247     CHECK_EQUAL( INTERVALS, sets.size() );
00248     // check set contents
00249     for( Range::iterator i = sets.begin(); i != sets.end(); ++i )
00250     {
00251         Range contents;
00252         rval = mb.get_entities_by_handle( *i, contents );CHECK_ERR( rval );
00253         CHECK_EQUAL( INTERVALS, contents.size() );
00254         CHECK( contents.all_of_type( MBQUAD ) );
00255 
00256         const EntityHandle* conn = 0;
00257         int len                  = 0;
00258         rval                     = mb.get_connectivity( contents.front(), conn, len );CHECK_ERR( rval );
00259         double coords[3];
00260         rval = mb.get_coords( conn, 1, coords );CHECK_ERR( rval );
00261 
00262         size_t y = (size_t)coords[1];
00263         CHECK( y < INTERVALS );
00264         rows[y] = *i;
00265     }
00266 }
00267 
00268 void test_read_set_contents( const char* filename )
00269 {
00270     // load the file
00271     Core core;
00272     Interface& mb  = core;
00273     ErrorCode rval = mb.load_file( filename, 0, READ_OPTS );CHECK_ERR( rval );
00274     // get the sets
00275     EntityHandle rows[INTERVALS];
00276     read_sets( mb, rows );
00277     // check set contents
00278     for( size_t i = 0; i < INTERVALS; ++i )
00279     {
00280         Range contents;
00281         rval = mb.get_entities_by_handle( rows[i], contents );CHECK_ERR( rval );
00282         CHECK_EQUAL( INTERVALS, contents.size() );
00283         CHECK( contents.all_of_type( MBQUAD ) );
00284 
00285         for( Range::iterator j = contents.begin(); j != contents.end(); ++j )
00286         {
00287             const EntityHandle* conn = 0;
00288             int len                  = 0;
00289             rval                     = mb.get_connectivity( *j, conn, len );CHECK_ERR( rval );
00290             double coords[3];
00291             rval = mb.get_coords( conn, 1, coords );CHECK_ERR( rval );
00292 
00293             size_t y = (size_t)coords[1];
00294             CHECK_EQUAL( i, y );
00295         }
00296     }
00297 }
00298 
00299 void test_read_set_parent_child( const char* filename )
00300 {
00301     // load the file
00302     Core core;
00303     Interface& mb  = core;
00304     ErrorCode rval = mb.load_file( filename, 0, READ_OPTS );CHECK_ERR( rval );
00305     // get the sets
00306     EntityHandle rows[INTERVALS];
00307     read_sets( mb, rows );
00308     // check set children
00309     std::vector< EntityHandle > list;
00310     for( size_t i = 0; i < INTERVALS - 1; ++i )
00311     {
00312         list.clear();
00313         rval = mb.get_child_meshsets( rows[i], list );CHECK_ERR( rval );
00314         CHECK_EQUAL( (size_t)1, list.size() );
00315         CHECK_EQUAL( rows[i + 1], list.front() );
00316     }
00317     list.clear();
00318     rval = mb.get_child_meshsets( rows[INTERVALS - 1], list );CHECK_ERR( rval );
00319     CHECK( list.empty() );
00320     // check set parents
00321     list.clear();
00322     rval = mb.get_parent_meshsets( rows[0], list );CHECK_ERR( rval );
00323     CHECK( list.empty() );
00324     for( size_t i = 1; i < INTERVALS; ++i )
00325     {
00326         list.clear();
00327         rval = mb.get_parent_meshsets( rows[i], list );CHECK_ERR( rval );
00328         CHECK_EQUAL( (size_t)1, list.size() );
00329         CHECK_EQUAL( rows[i - 1], list.front() );
00330     }
00331 }
00332 
00333 void test_read_int_tag( const char* filename )
00334 {
00335     // load the file
00336     Core core;
00337     Interface& mb  = core;
00338     ErrorCode rval = mb.load_file( filename, 0, READ_OPTS );CHECK_ERR( rval );
00339 
00340     // get the tag
00341     Tag tag;
00342     rval = mb.tag_get_handle( "int_tag", 2, MB_TYPE_INTEGER, tag );CHECK_ERR( rval );
00343 
00344     // check tag properties
00345     int size;
00346     rval = mb.tag_get_length( tag, size );CHECK_ERR( rval );
00347     CHECK_EQUAL( 2, size );
00348     TagType storage;
00349     rval = mb.tag_get_type( tag, storage );CHECK_ERR( rval );
00350     CHECK_EQUAL( MB_TAG_DENSE, storage );
00351     DataType type;
00352     rval = mb.tag_get_data_type( tag, type );CHECK_ERR( rval );
00353     CHECK_EQUAL( MB_TYPE_INTEGER, type );
00354 
00355     // check default value
00356     int value[2];
00357     rval = mb.tag_get_default_value( tag, value );CHECK_ERR( rval );
00358     CHECK_ARRAYS_EQUAL( default_int_tag, 2, value, 2 );
00359 
00360     // check mesh value
00361     const EntityHandle root = 0;
00362     rval                    = mb.tag_get_data( tag, &root, 1, value );CHECK_ERR( rval );
00363     CHECK_ARRAYS_EQUAL( mesh_int_tag, 2, value, 2 );
00364 
00365     // check entity values
00366     Range quads;
00367     rval = mb.get_entities_by_type( 0, MBQUAD, quads );CHECK_ERR( rval );
00368     for( Range::iterator i = quads.begin(); i != quads.end(); ++i )
00369     {
00370         const EntityHandle* conn = 0;
00371         int len                  = 0;
00372         rval                     = mb.get_connectivity( *i, conn, len );CHECK_ERR( rval );
00373         double coords[3];
00374         rval = mb.get_coords( conn, 1, coords );CHECK_ERR( rval );
00375         int exp[] = { (int)coords[0], (int)coords[1] };
00376 
00377         rval = mb.tag_get_data( tag, &*i, 1, value );CHECK_ERR( rval );
00378         CHECK_ARRAYS_EQUAL( exp, 2, value, 2 );
00379     }
00380 }
00381 
00382 void test_read_real_tag( const char* filename )
00383 {
00384     // load the file
00385     Core core;
00386     Interface& mb  = core;
00387     ErrorCode rval = mb.load_file( filename, 0, READ_OPTS );CHECK_ERR( rval );
00388 
00389     // get the tag
00390     Tag tag;
00391     rval = mb.tag_get_handle( "real_tag", 8, MB_TYPE_DOUBLE, tag );CHECK_ERR( rval );
00392 
00393     // check tag properties
00394     int size;
00395     rval = mb.tag_get_length( tag, size );CHECK_ERR( rval );
00396     CHECK_EQUAL( 8, size );
00397     TagType storage;
00398     rval = mb.tag_get_type( tag, storage );CHECK_ERR( rval );
00399     CHECK_EQUAL( MB_TAG_DENSE, storage );
00400     DataType type;
00401     rval = mb.tag_get_data_type( tag, type );CHECK_ERR( rval );
00402     CHECK_EQUAL( MB_TYPE_DOUBLE, type );
00403 
00404     // check default value
00405     double value[8];
00406     rval = mb.tag_get_default_value( tag, value );CHECK_ERR( rval );
00407     CHECK_ARRAYS_EQUAL( default_real_tag, 8, value, 8 );
00408 
00409     // check mesh value
00410     const EntityHandle root = 0;
00411     rval                    = mb.tag_get_data( tag, &root, 1, value );CHECK_ERR( rval );
00412     CHECK_ARRAYS_EQUAL( mesh_real_tag, 8, value, 8 );
00413 
00414     // check entity values
00415     Range quads;
00416     rval = mb.get_entities_by_type( 0, MBQUAD, quads );CHECK_ERR( rval );
00417     for( Range::iterator i = quads.begin(); i != quads.end(); ++i )
00418     {
00419         const EntityHandle* conn = 0;
00420         int len                  = 0;
00421         rval                     = mb.get_connectivity( *i, conn, len );CHECK_ERR( rval );
00422         CHECK_EQUAL( 4, len );
00423         double coords[3 * 4];
00424         rval = mb.get_coords( conn, len, coords );CHECK_ERR( rval );
00425         double exp[] = { coords[0], coords[1], coords[3], coords[4], coords[6], coords[7], coords[9], coords[10] };
00426 
00427         rval = mb.tag_get_data( tag, &*i, 1, value );CHECK_ERR( rval );
00428         CHECK_ARRAYS_EQUAL( exp, 8, value, 8 );
00429     }
00430 }
00431 
00432 void test_read_handle_tag( const char* filename )
00433 {
00434     // load the file
00435     Core core;
00436     Interface& mb  = core;
00437     ErrorCode rval = mb.load_file( filename, 0, READ_OPTS );CHECK_ERR( rval );
00438 
00439     // get the tag
00440     Tag tag;
00441     rval = mb.tag_get_handle( "handle_tag", 1, MB_TYPE_HANDLE, tag );CHECK_ERR( rval );
00442 
00443     // check tag properties
00444     int size;
00445     rval = mb.tag_get_length( tag, size );CHECK_ERR( rval );
00446     CHECK_EQUAL( 1, size );
00447     TagType storage;
00448     rval = mb.tag_get_type( tag, storage );CHECK_ERR( rval );
00449     CHECK_EQUAL( MB_TAG_SPARSE, storage );
00450     DataType type;
00451     rval = mb.tag_get_data_type( tag, type );CHECK_ERR( rval );
00452     CHECK_EQUAL( MB_TYPE_HANDLE, type );
00453 
00454     // check entity values
00455     Range quads;
00456     rval = mb.get_entities_by_type( 0, MBQUAD, quads );CHECK_ERR( rval );
00457     for( Range::iterator i = quads.begin(); i != quads.end(); ++i )
00458     {
00459         const EntityHandle* conn = 0;
00460         int len                  = 0;
00461         rval                     = mb.get_connectivity( *i, conn, len );CHECK_ERR( rval );
00462 
00463         EntityHandle value;
00464         rval = mb.tag_get_data( tag, conn, 1, &value );CHECK_ERR( rval );
00465         CHECK_EQUAL( *i, value );
00466     }
00467 }
00468 
00469 void test_read_bit_tag( const char* filename )
00470 {
00471     // load the file
00472     Core core;
00473     Interface& mb  = core;
00474     ErrorCode rval = mb.load_file( filename, 0, READ_OPTS );CHECK_ERR( rval );
00475 
00476     // get the tag
00477     Tag tag;
00478     rval = mb.tag_get_handle( "bit_tag", 1, MB_TYPE_BIT, tag );CHECK_ERR( rval );
00479 
00480     // check tag properties
00481     int size;
00482     rval = mb.tag_get_length( tag, size );CHECK_ERR( rval );
00483     CHECK_EQUAL( 1, size );
00484     TagType storage;
00485     rval = mb.tag_get_type( tag, storage );CHECK_ERR( rval );
00486     CHECK_EQUAL( MB_TAG_BIT, storage );
00487     DataType type;
00488     rval = mb.tag_get_data_type( tag, type );CHECK_ERR( rval );
00489     CHECK_EQUAL( MB_TYPE_BIT, type );
00490 
00491     // check entity values
00492     EntityHandle sets[INTERVALS];
00493     read_sets( mb, sets );
00494     char values[INTERVALS], expected[INTERVALS];
00495     rval = mb.tag_get_data( tag, sets, INTERVALS, values );CHECK_ERR( rval );
00496     for( size_t i = 0; i < INTERVALS; ++i )
00497         expected[i] = (char)( i % 2 );
00498     CHECK_ARRAYS_EQUAL( expected, INTERVALS, values, INTERVALS );
00499 }
00500 
00501 void test_read_partial( const char* filename )
00502 {
00503     // load the file
00504     Core core;
00505     Interface& mb  = core;
00506     const int odd  = 1;
00507     ErrorCode rval = mb.load_file( filename, 0, "CHILDREN=NONE;SETS=NONE;" READ_OPTS, "rowset", &odd, 1 );CHECK_ERR( rval );
00508     // check the elements
00509     test_elements( mb, true );
00510 }
00511 
00512 // Make sure everything works without data conversion just to verify
00513 // that the tests themselves are valid
00514 void test_native_read()
00515 {
00516     const char* filename = NATIVE_NAME;
00517     create_mesh( filename );
00518     test_read_vertices( filename );
00519     test_read_elements( filename );
00520     test_read_set_contents( filename );
00521     test_read_set_parent_child( filename );
00522     test_read_int_tag( filename );
00523     test_read_real_tag( filename );
00524     test_read_handle_tag( filename );
00525     test_read_bit_tag( filename );
00526     test_read_partial( filename );
00527     if( !getenv( "KEEP_FILE" ) ) remove( filename );
00528 }
00529 
00530 #define DEFINE_TEST_SET( NAME )                                   \
00531     void test_load_file_##NAME()                                  \
00532     {                                                             \
00533         test_load_file( BASE_NAME "_" #NAME ".h5m" );             \
00534     }                                                             \
00535     void test_read_vertices_##NAME()                              \
00536     {                                                             \
00537         test_read_vertices( BASE_NAME "_" #NAME ".h5m" );         \
00538     }                                                             \
00539     void test_read_elements_##NAME()                              \
00540     {                                                             \
00541         test_read_elements( BASE_NAME "_" #NAME ".h5m" );         \
00542     }                                                             \
00543     void test_read_set_contents_##NAME()                          \
00544     {                                                             \
00545         test_read_set_contents( BASE_NAME "_" #NAME ".h5m" );     \
00546     }                                                             \
00547     void test_read_set_parent_child_##NAME()                      \
00548     {                                                             \
00549         test_read_set_parent_child( BASE_NAME "_" #NAME ".h5m" ); \
00550     }                                                             \
00551     void test_read_int_tag_##NAME()                               \
00552     {                                                             \
00553         test_read_int_tag( BASE_NAME "_" #NAME ".h5m" );          \
00554     }                                                             \
00555     void test_read_real_tag_##NAME()                              \
00556     {                                                             \
00557         test_read_real_tag( BASE_NAME "_" #NAME ".h5m" );         \
00558     }                                                             \
00559     void test_read_handle_tag_##NAME()                            \
00560     {                                                             \
00561         test_read_handle_tag( BASE_NAME "_" #NAME ".h5m" );       \
00562     }                                                             \
00563     void test_read_bit_tag_##NAME()                               \
00564     {                                                             \
00565         test_read_bit_tag( BASE_NAME "_" #NAME ".h5m" );          \
00566     }                                                             \
00567     void test_read_partial_##NAME()                               \
00568     {                                                             \
00569         test_read_partial( BASE_NAME "_" #NAME ".h5m" );          \
00570     }
00571 
00572 #define REGISTER_TEST_SET( NAME )                                                          \
00573     REGISTER_DEP_TEST( test_load_file_##NAME, test_native_read );                          \
00574     REGISTER_DEP_TEST( test_read_vertices_##NAME, test_load_file_##NAME );                 \
00575     REGISTER_DEP_TEST( test_read_elements_##NAME, test_read_vertices_##NAME );             \
00576     REGISTER_DEP_TEST( test_read_set_contents_##NAME, test_read_elements_##NAME );         \
00577     REGISTER_DEP_TEST( test_read_set_parent_child_##NAME, test_read_set_contents_##NAME ); \
00578     REGISTER_DEP_TEST( test_read_int_tag_##NAME, test_read_elements_##NAME );              \
00579     REGISTER_DEP_TEST( test_read_real_tag_##NAME, test_read_elements_##NAME );             \
00580     REGISTER_DEP_TEST( test_read_handle_tag_##NAME, test_read_elements_##NAME );           \
00581     REGISTER_DEP_TEST( test_read_bit_tag_##NAME, test_read_set_contents_##NAME );          \
00582     REGISTER_DEP_TEST( test_read_partial_##NAME, test_read_elements_##NAME );
00583 
00584 DEFINE_TEST_SET( x86_64 )
00585 DEFINE_TEST_SET( x86_32 )
00586 DEFINE_TEST_SET( power_32 )
00587 
00588 int main( int argc, char* argv[] )
00589 {
00590 #ifdef MOAB_HAVE_MPI
00591     int fail = MPI_Init( &argc, &argv );
00592     if( fail ) return fail;
00593 #endif
00594     REGISTER_TEST( test_native_read );
00595     REGISTER_TEST_SET( x86_64 );
00596     REGISTER_TEST_SET( x86_32 );
00597     REGISTER_TEST_SET( power_32 );
00598     int result = RUN_TESTS( argc, argv );
00599 #ifdef MOAB_HAVE_MPI
00600     fail = MPI_Finalize();
00601     if( fail ) return fail;
00602 #endif
00603     return result;
00604 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines