Load a part of a file
To run: LoadPartial [file] [tag_name] [val1] [val2] ...
In this example, it is shown how to load only a part of one file; the file must be organized in sets. (cherry-picking only the sets we want) The sets to load are identified by a tag name and the tag values for the sets of interest. This procedure is used when reading in parallel, as each processor will load only its part of the file, identified either by partition or by material/block sets by default, this example will load parallel partition sets with values 1, 2, and 5 from ../MeshFiles/unittest/64bricks_1khex.h5m The example will always write the output to a file name part.h5m
#include <iostream>
#include <vector>
#define NTAGVALS 3
using namespace std;
{
if( argc > 1 )
filename = string( argv[1] );
else
filename = string(
MESH_DIR ) + string(
"/64bricks_512hex_256part.h5m" );
if( argc > 2 )
tagName = string( argv[2] );
else
tagName = "USERTAG";
if( argc > 3 )
{
tagValues.resize( argc - 3, 0 );
for( int i = 3; i < argc; ++i )
tagValues[i - 3] = atoi( argv[i] );
}
else
{
for( unsigned i = 0; i < tagValues.size(); ++i )
tagValues[i] = 2 * i + 1;
}
if( argc > 1 && argc < 4 )
cout << " usage is " << argv[0] << " <file> <tag_name> <value1> <value2> .. \n";
}
int main(
int argc,
char** argv )
{
Interface*
mb =
new( std::nothrow ) Core;
if( NULL ==
mb )
return 1;
std::string filename, tagname;
#ifdef MOAB_HAVE_HDF5
rval =
mb->tag_get_handle(
"HANDLEID", handleid_tag );
{
Range verts;
vector< long > valsTag( verts.size() );
rval =
mb->tag_get_data( handleid_tag, verts, &valsTag[0] );
if(
MB_SUCCESS == rval ) cout <<
"First 2 long values recovered: " << valsTag[0] <<
" " << valsTag[1] <<
"\n";
}
rval =
mb->write_file(
"part.h5m" );
MB_CHK_SET_ERR( rval,
"Failed to write partial file" );
cout << "Wrote successfully part.h5m.\n";
#else
std::cout << "Configure MOAB with HDF5 to build and use this example correctly.\n";
#endif
return 0;
}