MOAB: Mesh Oriented datABase  (version 5.5.0)
h5portable.cpp File Reference
#include "moab/Core.hpp"
#include "moab/Range.hpp"
#include "TestRunner.hpp"
#include "ReadHDF5.hpp"
#include "MBTagConventions.hpp"
#include "moab/FileOptions.hpp"
#include <vector>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <limits>
+ Include dependency graph for h5portable.cpp:

Go to the source code of this file.

Macros

#define FILE_NAME_BASE   "portable"
 
#define BASE_NAME   STRINGIFY( MESHDIR ) "/h5file/" FILE_NAME_BASE
 
#define NATIVE_NAME   FILE_NAME_BASE ".h5m"
 
#define READ_OPTS   "BUFFER_SIZE=256"
 
#define DEFINE_TEST_SET(NAME)
 
#define REGISTER_TEST_SET(NAME)
 

Functions

void create_mesh (const char *filename)
 
void test_load_file (const char *filename)
 
void test_read_vertices (const char *filename)
 
void test_elements (Interface &mb, bool odd_only)
 
void test_read_elements (const char *filename)
 
void read_sets (Interface &mb, EntityHandle rows[INTERVALS])
 
void test_read_set_contents (const char *filename)
 
void test_read_set_parent_child (const char *filename)
 
void test_read_int_tag (const char *filename)
 
void test_read_real_tag (const char *filename)
 
void test_read_handle_tag (const char *filename)
 
void test_read_bit_tag (const char *filename)
 
void test_read_partial (const char *filename)
 
void test_native_read ()
 
int main (int argc, char *argv[])
 

Variables

const int default_int_tag [] = { -100, -99 }
 
const int mesh_int_tag [] = { 1134, -1134 }
 
const double default_real_tag [] = { -1, -2, -3, -4, -5, -6, -7, -8 }
 
const double mesh_real_tag [] = { 8, 7, 6, 5, 4, 3, 2, 1 }
 
const size_t INTERVALS = 8
 
const size_t NUM_VERT = ( INTERVALS + 1 ) * ( INTERVALS + 1 )
 
const size_t NUM_QUAD = INTERVALS * INTERVALS
 
const double Z = 0.0
 
const double EPS = std::numeric_limits< double >::epsilon()
 

Detailed Description

Author
Jason Kraftcheck
Date
2010-09-23

Tests for HDF5 portability because we call H5Tconvert ourselves to work around parallel performance issues in the HDF5 library.

Definition in file h5portable.cpp.

Macro Definition Documentation

◆ BASE_NAME

#define BASE_NAME   STRINGIFY( MESHDIR ) "/h5file/" FILE_NAME_BASE

Definition at line 24 of file h5portable.cpp.

◆ DEFINE_TEST_SET

#define DEFINE_TEST_SET (   NAME)

Definition at line 530 of file h5portable.cpp.

◆ FILE_NAME_BASE

#define FILE_NAME_BASE   "portable"

Definition at line 23 of file h5portable.cpp.

◆ NATIVE_NAME

#define NATIVE_NAME   FILE_NAME_BASE ".h5m"

Definition at line 25 of file h5portable.cpp.

◆ READ_OPTS

#define READ_OPTS   "BUFFER_SIZE=256"

Definition at line 26 of file h5portable.cpp.

◆ REGISTER_TEST_SET

#define REGISTER_TEST_SET (   NAME)
Value:
REGISTER_DEP_TEST( test_load_file_##NAME, test_native_read ); \
REGISTER_DEP_TEST( test_read_vertices_##NAME, test_load_file_##NAME ); \
REGISTER_DEP_TEST( test_read_elements_##NAME, test_read_vertices_##NAME ); \
REGISTER_DEP_TEST( test_read_set_contents_##NAME, test_read_elements_##NAME ); \
REGISTER_DEP_TEST( test_read_set_parent_child_##NAME, test_read_set_contents_##NAME ); \
REGISTER_DEP_TEST( test_read_int_tag_##NAME, test_read_elements_##NAME ); \
REGISTER_DEP_TEST( test_read_real_tag_##NAME, test_read_elements_##NAME ); \
REGISTER_DEP_TEST( test_read_handle_tag_##NAME, test_read_elements_##NAME ); \
REGISTER_DEP_TEST( test_read_bit_tag_##NAME, test_read_set_contents_##NAME ); \
REGISTER_DEP_TEST( test_read_partial_##NAME, test_read_elements_##NAME );

Definition at line 572 of file h5portable.cpp.

Function Documentation

◆ create_mesh()

void create_mesh ( const char *  filename)

Definition at line 73 of file h5portable.cpp.

74 {
75  EntityHandle verts[NUM_VERT];
76  EntityHandle quads[NUM_QUAD];
77 
78  ErrorCode rval;
79  Core core;
80  Interface& mb = core;
81  const EntityHandle root = 0;
82 
83  Tag int_tag, real_tag, handle_tag, bit_tag, row_tag;
84 
85  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 );
86  rval = mb.tag_set_data( int_tag, &root, 1, mesh_int_tag );CHECK_ERR( rval );
87 
88  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 );
89  rval = mb.tag_set_data( real_tag, &root, 1, mesh_real_tag );CHECK_ERR( rval );
90 
91  rval = mb.tag_get_handle( "handle_tag", 1, MB_TYPE_HANDLE, handle_tag, MB_TAG_SPARSE | MB_TAG_EXCL );CHECK_ERR( rval );
92 
93  rval = mb.tag_get_handle( "bit_tag", 1, MB_TYPE_BIT, bit_tag, MB_TAG_EXCL );CHECK_ERR( rval );
94 
95  rval = mb.tag_get_handle( "rowset", 1, MB_TYPE_INTEGER, row_tag, MB_TAG_SPARSE | MB_TAG_EXCL );CHECK_ERR( rval );
96 
97  for( size_t i = 0; i < NUM_VERT; ++i )
98  {
99  double coords[] = { static_cast< double >( i % 9 ), static_cast< double >( i / 9 ),
100  static_cast< double >( Z ) };
101  rval = mb.create_vertex( coords, verts[i] );CHECK_ERR( rval );
102  }
103 
104  for( size_t i = 0; i < NUM_QUAD; ++i )
105  {
106  size_t j = ( i / 8 ) * 9 + i % 8;
107  EntityHandle conn[] = { verts[j], verts[j + 1], verts[j + 10], verts[j + 9] };
108  rval = mb.create_element( MBQUAD, conn, 4, quads[i] );CHECK_ERR( rval );
109 
110  double coords[4 * 3];
111  rval = mb.get_coords( conn, 4, coords );CHECK_ERR( rval );
112 
113  int int_val[] = { (int)coords[0], (int)coords[1] };
114  rval = mb.tag_set_data( int_tag, quads + i, 1, int_val );CHECK_ERR( rval );
115 
116  double real_val[] = { coords[0], coords[1], coords[3], coords[4], coords[6], coords[7], coords[9], coords[10] };
117  rval = mb.tag_set_data( real_tag, quads + i, 1, real_val );CHECK_ERR( rval );
118 
119  rval = mb.tag_set_data( handle_tag, conn, 1, quads + i );CHECK_ERR( rval );
120  }
121 
122  EntityHandle prev = 0;
123  for( size_t i = 0; i < INTERVALS; ++i )
124  {
125  EntityHandle set;
126  int flag = i < 4 ? MESHSET_SET : MESHSET_ORDERED;
127  rval = mb.create_meshset( flag, set );CHECK_ERR( rval );
128 
129  rval = mb.add_entities( set, quads + i * INTERVALS, INTERVALS );CHECK_ERR( rval );
130 
131  char bit = i % 2;
132  rval = mb.tag_set_data( bit_tag, &set, 1, &bit );CHECK_ERR( rval );
133 
134  int ival = bit;
135  rval = mb.tag_set_data( row_tag, &set, 1, &ival );CHECK_ERR( rval );
136 
137  if( prev != 0 )
138  {
139  rval = mb.add_parent_child( prev, set );CHECK_ERR( rval );
140  }
141  prev = set;
142  }
143 
144  rval = mb.write_file( filename, "MOAB" );CHECK_ERR( rval );
145 }

References moab::Core::add_entities(), moab::Core::add_parent_child(), CHECK_ERR, moab::Core::create_element(), moab::Core::create_meshset(), moab::Core::create_vertex(), default_int_tag, default_real_tag, ErrorCode, filename, moab::Core::get_coords(), INTERVALS, mb, MB_TAG_DENSE, MB_TAG_EXCL, MB_TAG_SPARSE, MB_TYPE_BIT, MB_TYPE_DOUBLE, MB_TYPE_HANDLE, MB_TYPE_INTEGER, MBQUAD, mesh_int_tag, mesh_real_tag, MESHSET_SET, NUM_QUAD, NUM_VERT, moab::Core::tag_get_handle(), moab::Core::tag_set_data(), moab::Core::write_file(), and Z.

Referenced by test_native_read().

◆ main()

int main ( int  argc,
char *  argv[] 
)

Definition at line 588 of file h5portable.cpp.

589 {
590 #ifdef MOAB_HAVE_MPI
591  int fail = MPI_Init( &argc, &argv );
592  if( fail ) return fail;
593 #endif
595  REGISTER_TEST_SET( x86_64 );
596  REGISTER_TEST_SET( x86_32 );
597  REGISTER_TEST_SET( power_32 );
598  int result = RUN_TESTS( argc, argv );
599 #ifdef MOAB_HAVE_MPI
600  fail = MPI_Finalize();
601  if( fail ) return fail;
602 #endif
603  return result;
604 }

References moab::fail(), REGISTER_TEST, REGISTER_TEST_SET, RUN_TESTS, and test_native_read().

◆ read_sets()

void read_sets ( Interface mb,
EntityHandle  rows[INTERVALS] 
)

Definition at line 242 of file h5portable.cpp.

243 {
244  // get the sets
245  Range sets;
246  ErrorCode rval = mb.get_entities_by_type( 0, MBENTITYSET, sets );CHECK_ERR( rval );
247  CHECK_EQUAL( INTERVALS, sets.size() );
248  // check set contents
249  for( Range::iterator i = sets.begin(); i != sets.end(); ++i )
250  {
251  Range contents;
252  rval = mb.get_entities_by_handle( *i, contents );CHECK_ERR( rval );
253  CHECK_EQUAL( INTERVALS, contents.size() );
254  CHECK( contents.all_of_type( MBQUAD ) );
255 
256  const EntityHandle* conn = 0;
257  int len = 0;
258  rval = mb.get_connectivity( contents.front(), conn, len );CHECK_ERR( rval );
259  double coords[3];
260  rval = mb.get_coords( conn, 1, coords );CHECK_ERR( rval );
261 
262  size_t y = (size_t)coords[1];
263  CHECK( y < INTERVALS );
264  rows[y] = *i;
265  }
266 }

References moab::Range::all_of_type(), moab::Range::begin(), CHECK, CHECK_EQUAL, CHECK_ERR, moab::Range::end(), ErrorCode, moab::Range::front(), moab::Core::get_connectivity(), moab::Core::get_coords(), moab::Core::get_entities_by_handle(), moab::Core::get_entities_by_type(), INTERVALS, mb, MBENTITYSET, MBQUAD, and moab::Range::size().

Referenced by test_gather_sets_ranged(), test_read_bit_tag(), test_read_set_contents(), and test_read_set_parent_child().

◆ test_elements()

void test_elements ( Interface mb,
bool  odd_only 
)

Definition at line 185 of file h5portable.cpp.

186 {
187  // get the elements
188  Range quads;
189  ErrorCode rval = mb.get_entities_by_type( 0, MBQUAD, quads );CHECK_ERR( rval );
190  CHECK_EQUAL( NUM_QUAD / ( 1 + odd_only ), quads.size() );
191  // check quad connectivity
192  bool seen[INTERVALS][INTERVALS];
193  for( size_t i = 0; i < INTERVALS; ++i )
194  for( size_t j = 0; j < INTERVALS; ++j )
195  seen[i][j] = false;
196  for( Range::iterator i = quads.begin(); i != quads.end(); ++i )
197  {
198  const EntityHandle* conn = 0;
199  int len = 0;
200  rval = mb.get_connectivity( *i, conn, len );CHECK_ERR( rval );
201  CHECK_EQUAL( 4, len );
202  double coords[4 * 3];
203  rval = mb.get_coords( conn, len, coords );CHECK_ERR( rval );
204 
205  size_t x = (size_t)coords[0];
206  size_t y = (size_t)coords[1];
207  CHECK_REAL_EQUAL( (double)x, coords[0], EPS );
208  CHECK_REAL_EQUAL( (double)y, coords[1], EPS );
209  CHECK( x < INTERVALS );
210  CHECK( y < INTERVALS );
211 
212  CHECK_REAL_EQUAL( Z, coords[2], EPS );
213  CHECK_REAL_EQUAL( 1.0 + x, coords[3], EPS );
214  CHECK_REAL_EQUAL( 0.0 + y, coords[4], EPS );
215  CHECK_REAL_EQUAL( Z, coords[5], EPS );
216  CHECK_REAL_EQUAL( 1.0 + x, coords[6], EPS );
217  CHECK_REAL_EQUAL( 1.0 + y, coords[7], EPS );
218  CHECK_REAL_EQUAL( Z, coords[8], EPS );
219  CHECK_REAL_EQUAL( 0.0 + x, coords[9], EPS );
220  CHECK_REAL_EQUAL( 1.0 + y, coords[10], EPS );
221  CHECK_REAL_EQUAL( Z, coords[11], EPS );
222  }
223 
224  if( odd_only )
225  {
226  for( size_t i = 0; i < INTERVALS; i += 2 )
227  for( size_t j = 0; j < INTERVALS; ++j )
228  CHECK( !seen[i][j] );
229  }
230 }

References moab::Range::begin(), CHECK, CHECK_EQUAL, CHECK_ERR, CHECK_REAL_EQUAL, moab::Range::end(), EPS, ErrorCode, moab::Core::get_connectivity(), moab::Core::get_coords(), moab::Core::get_entities_by_type(), INTERVALS, mb, MBQUAD, NUM_QUAD, moab::Range::size(), and Z.

Referenced by test_read_elements(), and test_read_partial().

◆ test_load_file()

void test_load_file ( const char *  filename)

Definition at line 147 of file h5portable.cpp.

148 {
149  Core core;
150  Interface& mb = core;
151  ErrorCode rval = mb.load_file( filename, 0, READ_OPTS );CHECK_ERR( rval );
152 }

References CHECK_ERR, ErrorCode, filename, moab::Core::load_file(), mb, and READ_OPTS.

◆ test_native_read()

◆ test_read_bit_tag()

void test_read_bit_tag ( const char *  filename)

Definition at line 469 of file h5portable.cpp.

470 {
471  // load the file
472  Core core;
473  Interface& mb = core;
474  ErrorCode rval = mb.load_file( filename, 0, READ_OPTS );CHECK_ERR( rval );
475 
476  // get the tag
477  Tag tag;
478  rval = mb.tag_get_handle( "bit_tag", 1, MB_TYPE_BIT, tag );CHECK_ERR( rval );
479 
480  // check tag properties
481  int size;
482  rval = mb.tag_get_length( tag, size );CHECK_ERR( rval );
483  CHECK_EQUAL( 1, size );
484  TagType storage;
485  rval = mb.tag_get_type( tag, storage );CHECK_ERR( rval );
486  CHECK_EQUAL( MB_TAG_BIT, storage );
487  DataType type;
488  rval = mb.tag_get_data_type( tag, type );CHECK_ERR( rval );
489  CHECK_EQUAL( MB_TYPE_BIT, type );
490 
491  // check entity values
492  EntityHandle sets[INTERVALS];
493  read_sets( mb, sets );
494  char values[INTERVALS], expected[INTERVALS];
495  rval = mb.tag_get_data( tag, sets, INTERVALS, values );CHECK_ERR( rval );
496  for( size_t i = 0; i < INTERVALS; ++i )
497  expected[i] = (char)( i % 2 );
498  CHECK_ARRAYS_EQUAL( expected, INTERVALS, values, INTERVALS );
499 }

References CHECK_ARRAYS_EQUAL, CHECK_EQUAL, CHECK_ERR, ErrorCode, filename, INTERVALS, moab::Core::load_file(), mb, MB_TAG_BIT, MB_TYPE_BIT, READ_OPTS, read_sets(), size, moab::Core::tag_get_data(), moab::Core::tag_get_data_type(), moab::Core::tag_get_handle(), moab::Core::tag_get_length(), moab::Core::tag_get_type(), and TagType.

Referenced by test_native_read().

◆ test_read_elements()

void test_read_elements ( const char *  filename)

Definition at line 232 of file h5portable.cpp.

233 {
234  // load the file
235  Core core;
236  Interface& mb = core;
237  ErrorCode rval = mb.load_file( filename, 0, READ_OPTS );CHECK_ERR( rval );
238  // check the elements
239  test_elements( mb, false );
240 }

References CHECK_ERR, ErrorCode, filename, moab::Core::load_file(), mb, READ_OPTS, and test_elements().

Referenced by test_native_read().

◆ test_read_handle_tag()

void test_read_handle_tag ( const char *  filename)

Definition at line 432 of file h5portable.cpp.

433 {
434  // load the file
435  Core core;
436  Interface& mb = core;
437  ErrorCode rval = mb.load_file( filename, 0, READ_OPTS );CHECK_ERR( rval );
438 
439  // get the tag
440  Tag tag;
441  rval = mb.tag_get_handle( "handle_tag", 1, MB_TYPE_HANDLE, tag );CHECK_ERR( rval );
442 
443  // check tag properties
444  int size;
445  rval = mb.tag_get_length( tag, size );CHECK_ERR( rval );
446  CHECK_EQUAL( 1, size );
447  TagType storage;
448  rval = mb.tag_get_type( tag, storage );CHECK_ERR( rval );
449  CHECK_EQUAL( MB_TAG_SPARSE, storage );
450  DataType type;
451  rval = mb.tag_get_data_type( tag, type );CHECK_ERR( rval );
452  CHECK_EQUAL( MB_TYPE_HANDLE, type );
453 
454  // check entity values
455  Range quads;
456  rval = mb.get_entities_by_type( 0, MBQUAD, quads );CHECK_ERR( rval );
457  for( Range::iterator i = quads.begin(); i != quads.end(); ++i )
458  {
459  const EntityHandle* conn = 0;
460  int len = 0;
461  rval = mb.get_connectivity( *i, conn, len );CHECK_ERR( rval );
462 
463  EntityHandle value;
464  rval = mb.tag_get_data( tag, conn, 1, &value );CHECK_ERR( rval );
465  CHECK_EQUAL( *i, value );
466  }
467 }

References moab::Range::begin(), CHECK_EQUAL, CHECK_ERR, moab::Range::end(), ErrorCode, filename, moab::Core::get_connectivity(), moab::Core::get_entities_by_type(), moab::Core::load_file(), mb, MB_TAG_SPARSE, MB_TYPE_HANDLE, MBQUAD, READ_OPTS, size, moab::Core::tag_get_data(), moab::Core::tag_get_data_type(), moab::Core::tag_get_handle(), moab::Core::tag_get_length(), moab::Core::tag_get_type(), and TagType.

Referenced by test_native_read().

◆ test_read_int_tag()

void test_read_int_tag ( const char *  filename)

Definition at line 333 of file h5portable.cpp.

334 {
335  // load the file
336  Core core;
337  Interface& mb = core;
338  ErrorCode rval = mb.load_file( filename, 0, READ_OPTS );CHECK_ERR( rval );
339 
340  // get the tag
341  Tag tag;
342  rval = mb.tag_get_handle( "int_tag", 2, MB_TYPE_INTEGER, tag );CHECK_ERR( rval );
343 
344  // check tag properties
345  int size;
346  rval = mb.tag_get_length( tag, size );CHECK_ERR( rval );
347  CHECK_EQUAL( 2, size );
348  TagType storage;
349  rval = mb.tag_get_type( tag, storage );CHECK_ERR( rval );
350  CHECK_EQUAL( MB_TAG_DENSE, storage );
351  DataType type;
352  rval = mb.tag_get_data_type( tag, type );CHECK_ERR( rval );
353  CHECK_EQUAL( MB_TYPE_INTEGER, type );
354 
355  // check default value
356  int value[2];
357  rval = mb.tag_get_default_value( tag, value );CHECK_ERR( rval );
358  CHECK_ARRAYS_EQUAL( default_int_tag, 2, value, 2 );
359 
360  // check mesh value
361  const EntityHandle root = 0;
362  rval = mb.tag_get_data( tag, &root, 1, value );CHECK_ERR( rval );
363  CHECK_ARRAYS_EQUAL( mesh_int_tag, 2, value, 2 );
364 
365  // check entity values
366  Range quads;
367  rval = mb.get_entities_by_type( 0, MBQUAD, quads );CHECK_ERR( rval );
368  for( Range::iterator i = quads.begin(); i != quads.end(); ++i )
369  {
370  const EntityHandle* conn = 0;
371  int len = 0;
372  rval = mb.get_connectivity( *i, conn, len );CHECK_ERR( rval );
373  double coords[3];
374  rval = mb.get_coords( conn, 1, coords );CHECK_ERR( rval );
375  int exp[] = { (int)coords[0], (int)coords[1] };
376 
377  rval = mb.tag_get_data( tag, &*i, 1, value );CHECK_ERR( rval );
378  CHECK_ARRAYS_EQUAL( exp, 2, value, 2 );
379  }
380 }

References moab::Range::begin(), CHECK_ARRAYS_EQUAL, CHECK_EQUAL, CHECK_ERR, default_int_tag, moab::Range::end(), ErrorCode, filename, moab::Core::get_connectivity(), moab::Core::get_coords(), moab::Core::get_entities_by_type(), moab::Core::load_file(), mb, MB_TAG_DENSE, MB_TYPE_INTEGER, MBQUAD, mesh_int_tag, READ_OPTS, size, moab::Core::tag_get_data(), moab::Core::tag_get_data_type(), moab::Core::tag_get_default_value(), moab::Core::tag_get_handle(), moab::Core::tag_get_length(), moab::Core::tag_get_type(), and TagType.

Referenced by test_native_read().

◆ test_read_partial()

void test_read_partial ( const char *  filename)

Definition at line 501 of file h5portable.cpp.

502 {
503  // load the file
504  Core core;
505  Interface& mb = core;
506  const int odd = 1;
507  ErrorCode rval = mb.load_file( filename, 0, "CHILDREN=NONE;SETS=NONE;" READ_OPTS, "rowset", &odd, 1 );CHECK_ERR( rval );
508  // check the elements
509  test_elements( mb, true );
510 }

References CHECK_ERR, ErrorCode, filename, moab::Core::load_file(), mb, READ_OPTS, and test_elements().

Referenced by test_native_read().

◆ test_read_real_tag()

void test_read_real_tag ( const char *  filename)

Definition at line 382 of file h5portable.cpp.

383 {
384  // load the file
385  Core core;
386  Interface& mb = core;
387  ErrorCode rval = mb.load_file( filename, 0, READ_OPTS );CHECK_ERR( rval );
388 
389  // get the tag
390  Tag tag;
391  rval = mb.tag_get_handle( "real_tag", 8, MB_TYPE_DOUBLE, tag );CHECK_ERR( rval );
392 
393  // check tag properties
394  int size;
395  rval = mb.tag_get_length( tag, size );CHECK_ERR( rval );
396  CHECK_EQUAL( 8, size );
397  TagType storage;
398  rval = mb.tag_get_type( tag, storage );CHECK_ERR( rval );
399  CHECK_EQUAL( MB_TAG_DENSE, storage );
400  DataType type;
401  rval = mb.tag_get_data_type( tag, type );CHECK_ERR( rval );
402  CHECK_EQUAL( MB_TYPE_DOUBLE, type );
403 
404  // check default value
405  double value[8];
406  rval = mb.tag_get_default_value( tag, value );CHECK_ERR( rval );
407  CHECK_ARRAYS_EQUAL( default_real_tag, 8, value, 8 );
408 
409  // check mesh value
410  const EntityHandle root = 0;
411  rval = mb.tag_get_data( tag, &root, 1, value );CHECK_ERR( rval );
412  CHECK_ARRAYS_EQUAL( mesh_real_tag, 8, value, 8 );
413 
414  // check entity values
415  Range quads;
416  rval = mb.get_entities_by_type( 0, MBQUAD, quads );CHECK_ERR( rval );
417  for( Range::iterator i = quads.begin(); i != quads.end(); ++i )
418  {
419  const EntityHandle* conn = 0;
420  int len = 0;
421  rval = mb.get_connectivity( *i, conn, len );CHECK_ERR( rval );
422  CHECK_EQUAL( 4, len );
423  double coords[3 * 4];
424  rval = mb.get_coords( conn, len, coords );CHECK_ERR( rval );
425  double exp[] = { coords[0], coords[1], coords[3], coords[4], coords[6], coords[7], coords[9], coords[10] };
426 
427  rval = mb.tag_get_data( tag, &*i, 1, value );CHECK_ERR( rval );
428  CHECK_ARRAYS_EQUAL( exp, 8, value, 8 );
429  }
430 }

References moab::Range::begin(), CHECK_ARRAYS_EQUAL, CHECK_EQUAL, CHECK_ERR, default_real_tag, moab::Range::end(), ErrorCode, filename, moab::Core::get_connectivity(), moab::Core::get_coords(), moab::Core::get_entities_by_type(), moab::Core::load_file(), mb, MB_TAG_DENSE, MB_TYPE_DOUBLE, MBQUAD, mesh_real_tag, READ_OPTS, size, moab::Core::tag_get_data(), moab::Core::tag_get_data_type(), moab::Core::tag_get_default_value(), moab::Core::tag_get_handle(), moab::Core::tag_get_length(), moab::Core::tag_get_type(), and TagType.

Referenced by test_native_read().

◆ test_read_set_contents()

void test_read_set_contents ( const char *  filename)

Definition at line 268 of file h5portable.cpp.

269 {
270  // load the file
271  Core core;
272  Interface& mb = core;
273  ErrorCode rval = mb.load_file( filename, 0, READ_OPTS );CHECK_ERR( rval );
274  // get the sets
275  EntityHandle rows[INTERVALS];
276  read_sets( mb, rows );
277  // check set contents
278  for( size_t i = 0; i < INTERVALS; ++i )
279  {
280  Range contents;
281  rval = mb.get_entities_by_handle( rows[i], contents );CHECK_ERR( rval );
282  CHECK_EQUAL( INTERVALS, contents.size() );
283  CHECK( contents.all_of_type( MBQUAD ) );
284 
285  for( Range::iterator j = contents.begin(); j != contents.end(); ++j )
286  {
287  const EntityHandle* conn = 0;
288  int len = 0;
289  rval = mb.get_connectivity( *j, conn, len );CHECK_ERR( rval );
290  double coords[3];
291  rval = mb.get_coords( conn, 1, coords );CHECK_ERR( rval );
292 
293  size_t y = (size_t)coords[1];
294  CHECK_EQUAL( i, y );
295  }
296  }
297 }

References moab::Range::all_of_type(), moab::Range::begin(), CHECK, CHECK_EQUAL, CHECK_ERR, moab::Range::end(), ErrorCode, filename, moab::Core::get_connectivity(), moab::Core::get_coords(), moab::Core::get_entities_by_handle(), INTERVALS, moab::Core::load_file(), mb, MBQUAD, READ_OPTS, read_sets(), and moab::Range::size().

Referenced by test_native_read().

◆ test_read_set_parent_child()

void test_read_set_parent_child ( const char *  filename)

Definition at line 299 of file h5portable.cpp.

300 {
301  // load the file
302  Core core;
303  Interface& mb = core;
304  ErrorCode rval = mb.load_file( filename, 0, READ_OPTS );CHECK_ERR( rval );
305  // get the sets
306  EntityHandle rows[INTERVALS];
307  read_sets( mb, rows );
308  // check set children
309  std::vector< EntityHandle > list;
310  for( size_t i = 0; i < INTERVALS - 1; ++i )
311  {
312  list.clear();
313  rval = mb.get_child_meshsets( rows[i], list );CHECK_ERR( rval );
314  CHECK_EQUAL( (size_t)1, list.size() );
315  CHECK_EQUAL( rows[i + 1], list.front() );
316  }
317  list.clear();
318  rval = mb.get_child_meshsets( rows[INTERVALS - 1], list );CHECK_ERR( rval );
319  CHECK( list.empty() );
320  // check set parents
321  list.clear();
322  rval = mb.get_parent_meshsets( rows[0], list );CHECK_ERR( rval );
323  CHECK( list.empty() );
324  for( size_t i = 1; i < INTERVALS; ++i )
325  {
326  list.clear();
327  rval = mb.get_parent_meshsets( rows[i], list );CHECK_ERR( rval );
328  CHECK_EQUAL( (size_t)1, list.size() );
329  CHECK_EQUAL( rows[i - 1], list.front() );
330  }
331 }

References CHECK, CHECK_EQUAL, CHECK_ERR, ErrorCode, filename, moab::Core::get_child_meshsets(), moab::Core::get_parent_meshsets(), INTERVALS, moab::Core::load_file(), mb, READ_OPTS, and read_sets().

Referenced by test_native_read().

◆ test_read_vertices()

void test_read_vertices ( const char *  filename)

Definition at line 154 of file h5portable.cpp.

155 {
156  // load the file
157  Core core;
158  Interface& mb = core;
159  ErrorCode rval = mb.load_file( filename, 0, READ_OPTS );CHECK_ERR( rval );
160  // get the vertices
161  Range verts;
162  rval = mb.get_entities_by_type( 0, MBVERTEX, verts );CHECK_ERR( rval );
163  CHECK_EQUAL( NUM_VERT, verts.size() );
164  // check vertex coordinates
165  bool seen[INTERVALS + 1][INTERVALS + 1];
166  for( size_t i = 0; i <= INTERVALS; ++i )
167  for( size_t j = 0; j <= INTERVALS; ++j )
168  seen[i][j] = false;
169  for( Range::iterator i = verts.begin(); i != verts.end(); ++i )
170  {
171  double coords[3];
172  rval = mb.get_coords( &*i, 1, coords );CHECK_ERR( rval );
173  CHECK_REAL_EQUAL( Z, coords[2], EPS );
174  size_t x = (size_t)coords[0];
175  size_t y = (size_t)coords[1];
176  CHECK_REAL_EQUAL( (double)x, coords[0], EPS );
177  CHECK_REAL_EQUAL( (double)y, coords[1], EPS );
178  CHECK( x <= INTERVALS );
179  CHECK( y <= INTERVALS );
180  CHECK( !seen[x][y] );
181  seen[x][y] = true;
182  }
183 }

References moab::Range::begin(), CHECK, CHECK_EQUAL, CHECK_ERR, CHECK_REAL_EQUAL, moab::Range::end(), EPS, ErrorCode, filename, moab::Core::get_coords(), moab::Core::get_entities_by_type(), INTERVALS, moab::Core::load_file(), mb, MBVERTEX, NUM_VERT, READ_OPTS, moab::Range::size(), and Z.

Referenced by test_native_read().

Variable Documentation

◆ default_int_tag

const int default_int_tag[] = { -100, -99 }

Definition at line 28 of file h5portable.cpp.

Referenced by create_mesh(), and test_read_int_tag().

◆ default_real_tag

const double default_real_tag[] = { -1, -2, -3, -4, -5, -6, -7, -8 }

Definition at line 30 of file h5portable.cpp.

Referenced by create_mesh(), and test_read_real_tag().

◆ EPS

const double EPS = std::numeric_limits< double >::epsilon()

◆ INTERVALS

◆ mesh_int_tag

const int mesh_int_tag[] = { 1134, -1134 }

Definition at line 29 of file h5portable.cpp.

Referenced by create_mesh(), and test_read_int_tag().

◆ mesh_real_tag

const double mesh_real_tag[] = { 8, 7, 6, 5, 4, 3, 2, 1 }

Definition at line 31 of file h5portable.cpp.

Referenced by create_mesh(), and test_read_real_tag().

◆ NUM_QUAD

const size_t NUM_QUAD = INTERVALS * INTERVALS

Definition at line 35 of file h5portable.cpp.

Referenced by create_mesh(), and test_elements().

◆ NUM_VERT

const size_t NUM_VERT = ( INTERVALS + 1 ) * ( INTERVALS + 1 )

Definition at line 34 of file h5portable.cpp.

Referenced by create_mesh(), and test_read_vertices().

◆ Z