MOAB: Mesh Oriented datABase  (version 5.2.1)
read_gcrm_nc.cpp
Go to the documentation of this file.
00001 #include "TestUtil.hpp"
00002 #include "moab/Core.hpp"
00003 #include "moab/ReadUtilIface.hpp"
00004 #include "MBTagConventions.hpp"
00005 
00006 using namespace moab;
00007 
00008 std::string example = TestDir + "/io/gcrm_r3.nc";
00009 
00010 #ifdef MOAB_HAVE_MPI
00011 #include "moab_mpi.h"
00012 #include "moab/ParallelComm.hpp"
00013 #endif
00014 
00015 void test_read_all();
00016 void test_read_onevar();
00017 void test_read_onetimestep();
00018 void test_read_nomesh();
00019 void test_read_novars();
00020 void test_read_no_edges();  // Test read option NO_EDGES
00021 void test_gather_onevar();  // Test gather set with one variable
00022 
00023 void get_options( std::string& opts );
00024 
00025 const double eps     = 1e-6;
00026 const int layers     = 3;
00027 const int interfaces = 3;
00028 
00029 int main( int argc, char* argv[] )
00030 {
00031     int result = 0;
00032 
00033 #ifdef MOAB_HAVE_MPI
00034     int fail = MPI_Init( &argc, &argv );
00035     if( fail ) return 1;
00036 #else
00037     argv[0]   = argv[argc - argc];  // To remove the warnings in serial mode about unused variables
00038 #endif
00039 
00040     result += RUN_TEST( test_read_all );
00041     result += RUN_TEST( test_read_onevar );
00042     result += RUN_TEST( test_read_onetimestep );
00043     result += RUN_TEST( test_read_nomesh );
00044     result += RUN_TEST( test_read_novars );
00045     result += RUN_TEST( test_read_no_edges );
00046     result += RUN_TEST( test_gather_onevar );
00047 
00048 #ifdef MOAB_HAVE_MPI
00049     fail = MPI_Finalize();
00050     if( fail ) return 1;
00051 #endif
00052 
00053     return result;
00054 }
00055 
00056 void test_read_all()
00057 {
00058     Core moab;
00059     Interface& mb = moab;
00060 
00061     std::string opts;
00062     get_options( opts );
00063 
00064     // Read mesh and read all variables at all timesteps
00065     ErrorCode rval = mb.load_file( example.c_str(), 0, opts.c_str() );CHECK_ERR( rval );
00066 
00067 #ifdef MOAB_HAVE_MPI
00068     ParallelComm* pcomm = ParallelComm::get_pcomm( &mb, 0 );
00069     int procs           = pcomm->proc_config().proc_size();
00070 #else
00071     int procs = 1;
00072 #endif
00073 
00074     // Make check runs this test on one processor
00075     if( 1 == procs )
00076     {
00077         // For u, wind and vorticity, check tag values on two entities
00078         double val[2 * layers];
00079 
00080         // Check tags for vertex variable u
00081         Tag u_tag0, u_tag1;
00082         rval = mb.tag_get_handle( "u0", layers, MB_TYPE_DOUBLE, u_tag0 );CHECK_ERR( rval );
00083         rval = mb.tag_get_handle( "u1", layers, MB_TYPE_DOUBLE, u_tag1 );CHECK_ERR( rval );
00084 
00085         // Get vertices (1280 vertices)
00086         Range verts;
00087         rval = mb.get_entities_by_type( 0, MBVERTEX, verts );CHECK_ERR( rval );
00088         CHECK_EQUAL( (size_t)1280, verts.size() );
00089         CHECK_EQUAL( (size_t)1, verts.psize() );
00090 
00091         // Check u tag values on first and last vertices
00092         EntityHandle vert_ents[] = { verts[0], verts[1279] };
00093 
00094         // Only check first two layers
00095         // Timestep 0
00096         rval = mb.tag_get_data( u_tag0, vert_ents, 2, val );CHECK_ERR( rval );
00097         // Layer 0
00098         CHECK_REAL_EQUAL( -4.839992, val[0 * layers], eps );
00099         CHECK_REAL_EQUAL( -3.699257, val[1 * layers], eps );
00100         // Layer 1
00101         CHECK_REAL_EQUAL( -4.839925, val[0 * layers + 1], eps );
00102         CHECK_REAL_EQUAL( -3.699206, val[1 * layers + 1], eps );
00103 
00104         // Timestep 1
00105         rval = mb.tag_get_data( u_tag1, vert_ents, 2, val );CHECK_ERR( rval );
00106         // Layer 0
00107         CHECK_REAL_EQUAL( -4.712473, val[0 * layers], eps );
00108         CHECK_REAL_EQUAL( -3.601793, val[1 * layers], eps );
00109         // Layer 1
00110         CHECK_REAL_EQUAL( -4.712409, val[0 * layers + 1], eps );
00111         CHECK_REAL_EQUAL( -3.601743, val[1 * layers + 1], eps );
00112 
00113         // Check tags for edge variable wind
00114         Tag wind_tag0, wind_tag1;
00115         rval = mb.tag_get_handle( "wind0", layers, MB_TYPE_DOUBLE, wind_tag0 );CHECK_ERR( rval );
00116         rval = mb.tag_get_handle( "wind1", layers, MB_TYPE_DOUBLE, wind_tag1 );CHECK_ERR( rval );
00117 
00118         // Get edges (1920 edges)
00119         Range edges;
00120         rval = mb.get_entities_by_type( 0, MBEDGE, edges );CHECK_ERR( rval );
00121         CHECK_EQUAL( (size_t)1920, edges.size() );
00122         CHECK_EQUAL( (size_t)1, edges.psize() );
00123 
00124         // Check wind tag values on first and last edges
00125         EntityHandle edge_ents[] = { edges[0], edges[1919] };
00126 
00127         // Only check first two layers
00128         // Timestep 0
00129         rval = mb.tag_get_data( wind_tag0, edge_ents, 2, val );CHECK_ERR( rval );
00130         // Layer 0
00131         CHECK_REAL_EQUAL( -5.081991, val[0 * layers], eps );
00132         CHECK_REAL_EQUAL( -6.420274, val[1 * layers], eps );
00133         // Layer 1
00134         CHECK_REAL_EQUAL( -5.081781, val[0 * layers + 1], eps );
00135         CHECK_REAL_EQUAL( -6.419831, val[1 * layers + 1], eps );
00136 
00137         // Timestep 1
00138         rval = mb.tag_get_data( wind_tag1, edge_ents, 2, val );CHECK_ERR( rval );
00139         // Layer 0
00140         CHECK_REAL_EQUAL( -4.948097, val[0 * layers], eps );
00141         CHECK_REAL_EQUAL( -6.251121, val[1 * layers], eps );
00142         // Layer 1
00143         CHECK_REAL_EQUAL( -4.947892, val[0 * layers + 1], eps );
00144         CHECK_REAL_EQUAL( -6.250690, val[1 * layers + 1], eps );
00145 
00146         // Check tags for cell variable vorticity
00147         Tag vorticity_tag0, vorticity_tag1;
00148         rval = mb.tag_get_handle( "vorticity0", layers, MB_TYPE_DOUBLE, vorticity_tag0 );CHECK_ERR( rval );
00149         rval = mb.tag_get_handle( "vorticity1", layers, MB_TYPE_DOUBLE, vorticity_tag1 );CHECK_ERR( rval );
00150 
00151         // Get cells (12 pentagons and 630 hexagons)
00152         Range cells;
00153         rval = mb.get_entities_by_type( 0, MBPOLYGON, cells );CHECK_ERR( rval );
00154         CHECK_EQUAL( (size_t)642, cells.size() );
00155 
00156         // GCRM pentagons are always padded to hexagons
00157         CHECK_EQUAL( (size_t)1, cells.psize() );
00158 
00159         // Check vorticity tag values on first and last cells
00160         EntityHandle cell_ents[] = { cells[0], cells[641] };
00161 
00162         // Only check first two layers
00163         // Timestep 0
00164         rval = mb.tag_get_data( vorticity_tag0, cell_ents, 2, val );CHECK_ERR( rval );
00165         // Layer 0
00166         CHECK_REAL_EQUAL( 3.629994, val[0 * layers], eps );
00167         CHECK_REAL_EQUAL( -0.554888, val[1 * layers], eps );
00168         // Layer 1
00169         CHECK_REAL_EQUAL( 3.629944, val[0 * layers + 1], eps );
00170         CHECK_REAL_EQUAL( -0.554881, val[1 * layers + 1], eps );
00171 
00172         // Timestep 1
00173         rval = mb.tag_get_data( vorticity_tag1, cell_ents, 2, val );CHECK_ERR( rval );
00174         // Layer 0
00175         CHECK_REAL_EQUAL( 3.534355, val[0 * layers], eps );
00176         CHECK_REAL_EQUAL( -0.540269, val[1 * layers], eps );
00177         // Layer 1
00178         CHECK_REAL_EQUAL( 3.534306, val[0 * layers + 1], eps );
00179         CHECK_REAL_EQUAL( -0.540262, val[1 * layers + 1], eps );
00180 
00181         // Check tags for cell variable pressure
00182         Tag pressure_tag0, pressure_tag1;
00183         rval = mb.tag_get_handle( "pressure0", interfaces, MB_TYPE_DOUBLE, pressure_tag0 );CHECK_ERR( rval );
00184         rval = mb.tag_get_handle( "pressure1", interfaces, MB_TYPE_DOUBLE, pressure_tag1 );CHECK_ERR( rval );
00185 
00186         // For pressure, check tag values on two cells
00187         double pressure_val[2 * interfaces];
00188 
00189         // Check pressure tag values on first and last cells
00190         // Only check first two interfaces
00191         // Timestep 0
00192         rval = mb.tag_get_data( pressure_tag0, cell_ents, 2, pressure_val );CHECK_ERR( rval );
00193         // Interface 0
00194         CHECK_REAL_EQUAL( 4.44234e-06, pressure_val[0 * interfaces], 1e-11 );
00195         CHECK_REAL_EQUAL( 0.2486804, pressure_val[1 * interfaces], 1e-7 );
00196         // Interface 1
00197         CHECK_REAL_EQUAL( 4.44234e-06, pressure_val[0 * interfaces + 1], 1e-11 );
00198         CHECK_REAL_EQUAL( 0.2486804, pressure_val[1 * interfaces + 1], 1e-7 );
00199 
00200         // Timestep 1
00201         rval = mb.tag_get_data( pressure_tag1, cell_ents, 2, pressure_val );CHECK_ERR( rval );
00202         // Interface 0
00203         CHECK_REAL_EQUAL( 2.365176e-07, pressure_val[0 * interfaces], 1e-13 );
00204         CHECK_REAL_EQUAL( 0.02234409, pressure_val[1 * interfaces], 1e-8 );
00205         // Interface 1
00206         CHECK_REAL_EQUAL( 2.365176e-07, pressure_val[0 * interfaces + 1], 1e-13 );
00207         CHECK_REAL_EQUAL( 0.02234409, pressure_val[1 * interfaces + 1], 1e-8 );
00208     }
00209 }
00210 
00211 void test_read_onevar()
00212 {
00213     Core moab;
00214     Interface& mb = moab;
00215 
00216     std::string opts;
00217     get_options( opts );
00218 
00219     // Read mesh and read cell variable vorticity at all timesteps
00220     opts += ";VARIABLE=vorticity";
00221     ErrorCode rval = mb.load_file( example.c_str(), NULL, opts.c_str() );CHECK_ERR( rval );
00222 
00223 #ifdef MOAB_HAVE_MPI
00224     ParallelComm* pcomm = ParallelComm::get_pcomm( &mb, 0 );
00225     int procs           = pcomm->proc_config().proc_size();
00226 #else
00227     int procs = 1;
00228 #endif
00229 
00230     // Make check runs this test on one processor
00231     if( 1 == procs )
00232     {
00233         // Check vorticity tags
00234         Tag vorticity_tag0, vorticity_tag1;
00235         rval = mb.tag_get_handle( "vorticity0", layers, MB_TYPE_DOUBLE, vorticity_tag0 );CHECK_ERR( rval );
00236         rval = mb.tag_get_handle( "vorticity1", layers, MB_TYPE_DOUBLE, vorticity_tag1 );CHECK_ERR( rval );
00237 
00238         // Get cells (12 pentagons and 630 hexagons)
00239         Range cells;
00240         rval = mb.get_entities_by_type( 0, MBPOLYGON, cells );CHECK_ERR( rval );
00241         CHECK_EQUAL( (size_t)642, cells.size() );
00242 
00243         // GCRM pentagons are always padded to hexagons
00244         CHECK_EQUAL( (size_t)1, cells.psize() );
00245 
00246         // Check vorticity tag values on 4 cells: first cell, two median cells, and last cell
00247         EntityHandle cell_ents[] = { cells[0], cells[320], cells[321], cells[641] };
00248         double vorticity_val[4 * layers];
00249 
00250         // Only check first two layers
00251         // Timestep 0
00252         rval = mb.tag_get_data( vorticity_tag0, cell_ents, 4, vorticity_val );CHECK_ERR( rval );
00253         // Layer 0
00254         CHECK_REAL_EQUAL( 3.629994, vorticity_val[0 * layers], eps );
00255         CHECK_REAL_EQUAL( 0.131688, vorticity_val[1 * layers], eps );
00256         CHECK_REAL_EQUAL( -0.554888, vorticity_val[2 * layers], eps );
00257         CHECK_REAL_EQUAL( -0.554888, vorticity_val[3 * layers], eps );
00258         // Layer 1
00259         CHECK_REAL_EQUAL( 3.629944, vorticity_val[0 * layers + 1], eps );
00260         CHECK_REAL_EQUAL( 0.131686, vorticity_val[1 * layers + 1], eps );
00261         CHECK_REAL_EQUAL( -0.554881, vorticity_val[2 * layers + 1], eps );
00262         CHECK_REAL_EQUAL( -0.554881, vorticity_val[3 * layers + 1], eps );
00263 
00264         // Timestep 1
00265         rval = mb.tag_get_data( vorticity_tag1, cell_ents, 4, vorticity_val );CHECK_ERR( rval );
00266         // Layer 0
00267         CHECK_REAL_EQUAL( 3.534355, vorticity_val[0 * layers], eps );
00268         CHECK_REAL_EQUAL( 0.128218, vorticity_val[1 * layers], eps );
00269         CHECK_REAL_EQUAL( -0.540269, vorticity_val[2 * layers], eps );
00270         CHECK_REAL_EQUAL( -0.540269, vorticity_val[3 * layers], eps );
00271         // Layer 1
00272         CHECK_REAL_EQUAL( 3.534306, vorticity_val[0 * layers + 1], eps );
00273         CHECK_REAL_EQUAL( 0.128216, vorticity_val[1 * layers + 1], eps );
00274         CHECK_REAL_EQUAL( -0.540262, vorticity_val[2 * layers + 1], eps );
00275         CHECK_REAL_EQUAL( -0.540262, vorticity_val[3 * layers + 1], eps );
00276     }
00277 }
00278 
00279 void test_read_onetimestep()
00280 {
00281     Core moab;
00282     Interface& mb = moab;
00283 
00284     std::string opts;
00285     get_options( opts );
00286 
00287     // Read mesh and read all variables at 2nd timestep
00288     opts += ";TIMESTEP=1";
00289     ErrorCode rval = mb.load_file( example.c_str(), NULL, opts.c_str() );CHECK_ERR( rval );
00290 
00291     // Check vorticity tags
00292     Tag vorticity_tag0, vorticity_tag1;
00293     rval = mb.tag_get_handle( "vorticity0", layers, MB_TYPE_DOUBLE, vorticity_tag0 );
00294     // Tag vorticity0 should not exist
00295     CHECK_EQUAL( rval, MB_TAG_NOT_FOUND );
00296     rval = mb.tag_get_handle( "vorticity1", layers, MB_TYPE_DOUBLE, vorticity_tag1 );CHECK_ERR( rval );
00297 }
00298 
00299 void test_read_nomesh()
00300 {
00301     Core moab;
00302     Interface& mb = moab;
00303 
00304     // Need a file set for nomesh to work right
00305     EntityHandle file_set;
00306     ErrorCode rval = mb.create_meshset( MESHSET_SET, file_set );CHECK_ERR( rval );
00307 
00308     std::string orig, opts;
00309     get_options( orig );
00310 
00311     // Read mesh and read all variables at 1st timestep
00312     opts = orig + ";TIMESTEP=0";
00313     rval = mb.load_file( example.c_str(), &file_set, opts.c_str() );CHECK_ERR( rval );
00314 
00315     // Check u tags
00316     Tag u_tag0, u_tag1;
00317     rval = mb.tag_get_handle( "u0", layers, MB_TYPE_DOUBLE, u_tag0 );CHECK_ERR( rval );
00318     // Tag u1 should not exist
00319     rval = mb.tag_get_handle( "u1", layers, MB_TYPE_DOUBLE, u_tag1 );
00320     CHECK_EQUAL( rval, MB_TAG_NOT_FOUND );
00321 
00322     // Read all variables at 2nd timestep 0, no need to read mesh
00323     opts = orig + ";TIMESTEP=1;NOMESH";
00324     rval = mb.load_file( example.c_str(), &file_set, opts.c_str() );CHECK_ERR( rval );
00325 
00326     // Check tag u1 again
00327     rval = mb.tag_get_handle( "u1", layers, MB_TYPE_DOUBLE, u_tag1 );
00328     // Tag u1 should exist at this time
00329     CHECK_ERR( rval );
00330 }
00331 
00332 void test_read_novars()
00333 {
00334     Core moab;
00335     Interface& mb = moab;
00336 
00337     // Need a file set for nomesh to work right
00338     EntityHandle file_set;
00339     ErrorCode rval = mb.create_meshset( MESHSET_SET, file_set );CHECK_ERR( rval );
00340 
00341     std::string orig, opts;
00342     get_options( orig );CHECK_ERR( rval );
00343 
00344     // Read header info only, no mesh, no variables
00345     opts = orig + ";NOMESH;VARIABLE=";
00346     rval = mb.load_file( example.c_str(), &file_set, opts.c_str() );CHECK_ERR( rval );
00347 
00348     // Read mesh, but still no variables
00349     opts = orig + ";VARIABLE=";
00350     rval = mb.load_file( example.c_str(), &file_set, opts.c_str() );CHECK_ERR( rval );
00351 
00352     // Check vorticity tags
00353     Tag vorticity_tag0, vorticity_tag1;
00354     rval = mb.tag_get_handle( "vorticity0", layers, MB_TYPE_DOUBLE, vorticity_tag0 );
00355     // Tag vorticity0 should not exist
00356     CHECK_EQUAL( rval, MB_TAG_NOT_FOUND );
00357     rval = mb.tag_get_handle( "vorticity1", layers, MB_TYPE_DOUBLE, vorticity_tag1 );
00358     // Tag vorticity1 should not exist
00359     CHECK_EQUAL( rval, MB_TAG_NOT_FOUND );
00360 
00361     // Read vorticity at 1st timestep, no need to read mesh
00362     opts = orig + ";VARIABLE=vorticity;TIMESTEP=0;NOMESH";
00363     rval = mb.load_file( example.c_str(), &file_set, opts.c_str() );CHECK_ERR( rval );
00364 
00365     // Check vorticity tags again
00366     rval = mb.tag_get_handle( "vorticity0", layers, MB_TYPE_DOUBLE, vorticity_tag0 );
00367     // Tag vorticity0 should exist at this time
00368     CHECK_ERR( rval );
00369     // Tag vorticity1 should still not exist
00370     rval = mb.tag_get_handle( "vorticity1", layers, MB_TYPE_DOUBLE, vorticity_tag1 );
00371     CHECK_EQUAL( rval, MB_TAG_NOT_FOUND );
00372 
00373     // Read vorticity at 2nd timestep, no need to read mesh
00374     opts = orig + ";VARIABLE=vorticity;TIMESTEP=1;NOMESH";
00375     rval = mb.load_file( example.c_str(), &file_set, opts.c_str() );CHECK_ERR( rval );
00376 
00377     // Check tag vorticity1 again
00378     rval = mb.tag_get_handle( "vorticity1", layers, MB_TYPE_DOUBLE, vorticity_tag1 );
00379     // Tag vorticity1 should exist at this time
00380     CHECK_ERR( rval );
00381 
00382 #ifdef MOAB_HAVE_MPI
00383     ParallelComm* pcomm = ParallelComm::get_pcomm( &mb, 0 );
00384     int procs           = pcomm->proc_config().proc_size();
00385 #else
00386     int procs = 1;
00387 #endif
00388 
00389     // Make check runs this test on one processor
00390     if( 1 == procs )
00391     {
00392         // Get cells (12 pentagons and 630 hexagons)
00393         Range cells;
00394         rval = mb.get_entities_by_type( file_set, MBPOLYGON, cells );CHECK_ERR( rval );
00395         CHECK_EQUAL( (size_t)642, cells.size() );
00396 
00397         // GCRM pentagons are always padded to hexagons
00398         CHECK_EQUAL( (size_t)1, cells.psize() );
00399 
00400         // Check vorticity tag values on 4 cells: first cell, two median cells, and last cell
00401         EntityHandle cell_ents[] = { cells[0], cells[320], cells[321], cells[641] };
00402         double vorticity_val[4 * layers];
00403 
00404         // Only check first two layers
00405         // Timestep 0
00406         rval = mb.tag_get_data( vorticity_tag0, cell_ents, 4, vorticity_val );CHECK_ERR( rval );
00407         // Layer 0
00408         CHECK_REAL_EQUAL( 3.629994, vorticity_val[0 * layers], eps );
00409         CHECK_REAL_EQUAL( 0.131688, vorticity_val[1 * layers], eps );
00410         CHECK_REAL_EQUAL( -0.554888, vorticity_val[2 * layers], eps );
00411         CHECK_REAL_EQUAL( -0.554888, vorticity_val[3 * layers], eps );
00412         // Layer 1
00413         CHECK_REAL_EQUAL( 3.629944, vorticity_val[0 * layers + 1], eps );
00414         CHECK_REAL_EQUAL( 0.131686, vorticity_val[1 * layers + 1], eps );
00415         CHECK_REAL_EQUAL( -0.554881, vorticity_val[2 * layers + 1], eps );
00416         CHECK_REAL_EQUAL( -0.554881, vorticity_val[3 * layers + 1], eps );
00417 
00418         // Timestep 1
00419         rval = mb.tag_get_data( vorticity_tag1, cell_ents, 4, vorticity_val );CHECK_ERR( rval );
00420         // Layer 0
00421         CHECK_REAL_EQUAL( 3.534355, vorticity_val[0 * layers], eps );
00422         CHECK_REAL_EQUAL( 0.128218, vorticity_val[1 * layers], eps );
00423         CHECK_REAL_EQUAL( -0.540269, vorticity_val[2 * layers], eps );
00424         CHECK_REAL_EQUAL( -0.540269, vorticity_val[3 * layers], eps );
00425         // Layer 1
00426         CHECK_REAL_EQUAL( 3.534306, vorticity_val[0 * layers + 1], eps );
00427         CHECK_REAL_EQUAL( 0.128216, vorticity_val[1 * layers + 1], eps );
00428         CHECK_REAL_EQUAL( -0.540262, vorticity_val[2 * layers + 1], eps );
00429         CHECK_REAL_EQUAL( -0.540262, vorticity_val[3 * layers + 1], eps );
00430     }
00431 }
00432 
00433 void test_read_no_edges()
00434 {
00435     Core moab;
00436     Interface& mb = moab;
00437 
00438     std::string opts;
00439     get_options( opts );
00440 
00441     opts += ";NO_EDGES;VARIABLE=";
00442     ErrorCode rval = mb.load_file( example.c_str(), NULL, opts.c_str() );CHECK_ERR( rval );
00443 
00444     // Get edges
00445     Range edges;
00446     rval = mb.get_entities_by_type( 0, MBEDGE, edges );CHECK_ERR( rval );
00447     CHECK_EQUAL( (size_t)0, edges.size() );
00448 }
00449 
00450 void test_gather_onevar()
00451 {
00452     Core moab;
00453     Interface& mb = moab;
00454 
00455     EntityHandle file_set;
00456     ErrorCode rval = mb.create_meshset( MESHSET_SET, file_set );CHECK_ERR( rval );
00457 
00458     std::string opts;
00459     get_options( opts );
00460 
00461     // Read cell variable vorticity and create gather set on processor 0
00462     opts += ";VARIABLE=vorticity;GATHER_SET=0";
00463     rval = mb.load_file( example.c_str(), &file_set, opts.c_str() );CHECK_ERR( rval );
00464 
00465 #ifdef MOAB_HAVE_MPI
00466     ParallelComm* pcomm = ParallelComm::get_pcomm( &mb, 0 );
00467     int rank            = pcomm->proc_config().proc_rank();
00468 
00469     Range cells, cells_owned;
00470     rval = mb.get_entities_by_type( file_set, MBPOLYGON, cells );CHECK_ERR( rval );
00471 
00472     // Get local owned cells
00473     rval = pcomm->filter_pstatus( cells, PSTATUS_NOT_OWNED, PSTATUS_NOT, -1, &cells_owned );CHECK_ERR( rval );
00474 
00475     EntityHandle gather_set = 0;
00476     if( 0 == rank )
00477     {
00478         // Get gather set
00479         ReadUtilIface* readUtilIface;
00480         mb.query_interface( readUtilIface );
00481         rval = readUtilIface->get_gather_set( gather_set );CHECK_ERR( rval );
00482         assert( gather_set != 0 );
00483     }
00484 
00485     Tag vorticity_tag0, gid_tag;
00486     rval = mb.tag_get_handle( "vorticity0", layers, MB_TYPE_DOUBLE, vorticity_tag0, MB_TAG_DENSE );CHECK_ERR( rval );
00487 
00488     gid_tag = mb.globalId_tag();
00489 
00490     pcomm->gather_data( cells_owned, vorticity_tag0, gid_tag, gather_set, 0 );
00491 
00492     if( 0 == rank )
00493     {
00494         // Get gather set cells
00495         Range gather_set_cells;
00496         rval = mb.get_entities_by_type( gather_set, MBPOLYGON, gather_set_cells );CHECK_ERR( rval );
00497         CHECK_EQUAL( (size_t)642, gather_set_cells.size() );
00498         CHECK_EQUAL( (size_t)1, gather_set_cells.psize() );
00499 
00500         // Check vorticity0 tag values on 4 gather set cells: first cell, two median cells, and last
00501         // cell
00502         EntityHandle cell_ents[] = { gather_set_cells[0], gather_set_cells[320], gather_set_cells[321],
00503                                      gather_set_cells[641] };
00504         double vorticity0_val[4 * layers];
00505         rval = mb.tag_get_data( vorticity_tag0, cell_ents, 4, vorticity0_val );CHECK_ERR( rval );
00506 
00507         // Only check first two layers
00508         // Layer 0
00509         CHECK_REAL_EQUAL( 3.629994, vorticity0_val[0 * layers], eps );
00510         CHECK_REAL_EQUAL( 0.131688, vorticity0_val[1 * layers], eps );
00511         CHECK_REAL_EQUAL( -0.554888, vorticity0_val[2 * layers], eps );
00512         CHECK_REAL_EQUAL( -0.554888, vorticity0_val[3 * layers], eps );
00513         // Layer 1
00514         CHECK_REAL_EQUAL( 3.629944, vorticity0_val[0 * layers + 1], eps );
00515         CHECK_REAL_EQUAL( 0.131686, vorticity0_val[1 * layers + 1], eps );
00516         CHECK_REAL_EQUAL( -0.554881, vorticity0_val[2 * layers + 1], eps );
00517         CHECK_REAL_EQUAL( -0.554881, vorticity0_val[3 * layers + 1], eps );
00518     }
00519 #endif
00520 }
00521 
00522 void get_options( std::string& opts )
00523 {
00524 #ifdef MOAB_HAVE_MPI
00525     // Use parallel options
00526     opts = std::string( ";;PARALLEL=READ_PART;PARTITION_METHOD=TRIVIAL" );
00527 #else
00528     opts      = std::string( ";;" );
00529 #endif
00530 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines