Go to the source code of this file.
Macros | |
#define | NTAGVALS 3 |
Functions | |
ErrorCode | get_file_options (int argc, char **argv, string &filename, string &tagName, vector< int > &tagValues) |
int | main (int argc, char **argv) |
#define NTAGVALS 3 |
Definition at line 21 of file LoadPartial.cpp.
ErrorCode get_file_options | ( | int | argc, |
char ** | argv, | ||
string & | filename, | ||
string & | tagName, | ||
vector< int > & | tagValues | ||
) |
Definition at line 27 of file LoadPartial.cpp.
28 {
29 // Get mesh filename
30 if( argc > 1 )
31 filename = string( argv[1] );
32 else
33 filename = string( MESH_DIR ) + string( "/64bricks_512hex_256part.h5m" );
34
35 // Get tag selection options
36 if( argc > 2 )
37 tagName = string( argv[2] );
38 else
39 tagName = "USERTAG";
40
41 if( argc > 3 )
42 {
43 tagValues.resize( argc - 3, 0 );
44 for( int i = 3; i < argc; ++i )
45 tagValues[i - 3] = atoi( argv[i] );
46 }
47 else
48 {
49 for( unsigned i = 0; i < tagValues.size(); ++i )
50 tagValues[i] = 2 * i + 1;
51 }
52
53 if( argc > 1 && argc < 4 ) // print usage
54 cout << " usage is " << argv[0] << " <file> <tag_name> <value1> <value2> .. \n";
55 return MB_SUCCESS;
56 }
References MB_SUCCESS, and MESH_DIR.
Referenced by main().
int main | ( | int | argc, |
char ** | argv | ||
) |
Definition at line 58 of file LoadPartial.cpp.
59 {
60 // Get MOAB instance
61 Interface* mb = new( std::nothrow ) Core;
62 if( NULL == mb ) return 1;
63
64 std::string filename, tagname;
65 vector< int > tagvals( NTAGVALS ); // Allocate for a maximum of 5 tag values
66 ErrorCode rval = get_file_options( argc, argv, filename, tagname, tagvals );MB_CHK_ERR( rval );
67
68 #ifdef MOAB_HAVE_HDF5
69 // This file is in the mesh files directory
70 rval = mb->load_file( filename.c_str(), 0, 0, PARALLEL_PARTITION_TAG_NAME, tagvals.data(), (int)tagvals.size() );MB_CHK_SET_ERR( rval, "Failed to read" );
71
72 // If HANDLEID tag present, convert to long, and see what we read from file
73 Tag handleid_tag;
74 rval = mb->tag_get_handle( "HANDLEID", handleid_tag );
75 if( MB_SUCCESS == rval )
76 {
77 // Convert a few values for a few vertices
78 Range verts;
79 rval = mb->get_entities_by_type( 0, MBVERTEX, verts );MB_CHK_SET_ERR( rval, "Failed to get vertices" );
80 vector< long > valsTag( verts.size() );
81 rval = mb->tag_get_data( handleid_tag, verts, &valsTag[0] );
82 if( MB_SUCCESS == rval ) cout << "First 2 long values recovered: " << valsTag[0] << " " << valsTag[1] << "\n";
83 }
84
85 rval = mb->write_file( "part.h5m" );MB_CHK_SET_ERR( rval, "Failed to write partial file" );
86 cout << "Wrote successfully part.h5m.\n";
87
88 #else
89 std::cout << "Configure MOAB with HDF5 to build and use this example correctly.\n";
90 #endif
91 delete mb;
92 return 0;
93 }
References ErrorCode, moab::Core::get_entities_by_type(), get_file_options(), moab::Core::load_file(), mb, MB_CHK_ERR, MB_CHK_SET_ERR, MB_SUCCESS, MBVERTEX, NTAGVALS, PARALLEL_PARTITION_TAG_NAME, moab::Range::size(), moab::Core::tag_get_data(), moab::Core::tag_get_handle(), and moab::Core::write_file().