Mesh Oriented datABase
(version 5.4.1)
Array-based unstructured mesh datastructure
|
Go to the source code of this file.
Defines | |
#define | MESH_DIR "." |
Functions | |
int | main (int argc, char **argv) |
Variables | |
string | test_file_name = string( MESH_DIR ) + string( "/3k-tri-sphere.vtk" ) |
string | part_file_name |
int | nparts |
#define MESH_DIR "." |
Definition at line 15 of file ReadPartFile.cpp.
int main | ( | int | argc, |
char ** | argv | ||
) |
Definition at line 22 of file ReadPartFile.cpp.
References moab::Interface::add_entities(), moab::Range::begin(), moab::Interface::create_meshset(), moab::Interface::delete_entities(), moab::Range::end(), ErrorCode, moab::Interface::get_entities_by_dimension(), moab::Interface::get_entities_by_type(), moab::Interface::load_mesh(), mb, MB_CHK_ERR, MBENTITYSET, MESHSET_SET, nparts, part_file_name, moab::Range::size(), moab::Interface::tag_get_data(), moab::Interface::tag_get_handle(), moab::Interface::tag_set_data(), test_file_name, and moab::Interface::write_file().
{ // Get MOAB instance Interface* mb = new( std::nothrow ) Core; if( NULL == mb ) return 1; // Need option handling here for input filename if( argc > 4 ) { // User has input a mesh file test_file_name = argv[1]; part_file_name = argv[2]; nparts = atoi( argv[3] ); } else { cerr << " usage is " << argv[0] << " <input file> <part file> <#parts> <output file> \n"; exit( 0 ); } ifstream inFile; inFile.open( part_file_name.c_str() ); if( !inFile ) { cerr << "Unable to open file " << part_file_name << "\n"; exit( 1 ); // call system to stop } // Load the mesh from file ErrorCode rval = mb->load_mesh( test_file_name.c_str() );MB_CHK_ERR( rval ); // Get sets entities, by type Range sets; rval = mb->get_entities_by_type( 0, MBENTITYSET, sets );MB_CHK_ERR( rval ); // Output the number of sets cout << "Number of sets is " << sets.size() << endl; // remove the sets that have a PARALLEL_PARTITION tag Tag tag; rval = mb->tag_get_handle( "PARALLEL_PARTITION", tag );MB_CHK_ERR( rval ); int i = 0; int num_deleted_sets = 0; for( Range::iterator it = sets.begin(); it != sets.end(); it++, i++ ) { EntityHandle eh = *it; // cout << " set :" << mb->id_from_handle(eh) <<"\n"; int val = -1; rval = mb->tag_get_data( tag, &eh, 1, &val ); if( val != -1 ) { num_deleted_sets++; rval = mb->delete_entities( &eh, 1 ); // delete the set, we will have a new partition soon } } if( num_deleted_sets ) cout << "delete " << num_deleted_sets << " existing partition sets, and create new ones \n"; Range cells; // get them by dimension 2! rval = mb->get_entities_by_dimension( 0, 2, cells );MB_CHK_ERR( rval ); EntityHandle* psets = new EntityHandle[nparts]; for( int i = 0; i < nparts; i++ ) { rval = mb->create_meshset( MESHSET_SET, psets[i] );MB_CHK_ERR( rval ); rval = mb->tag_set_data( tag, &( psets[i] ), 1, &i );MB_CHK_ERR( rval ); } for( Range::iterator it = cells.begin(); it != cells.end(); it++ ) { int part; EntityHandle eh = *it; inFile >> part; rval = mb->add_entities( psets[part], &eh, 1 );MB_CHK_ERR( rval ); } mb->write_file( argv[4] ); delete mb; return 0; }
int nparts |
Definition at line 21 of file ReadPartFile.cpp.
Referenced by moab::MeshOutputFunctor::assign_global_ids(), main(), MetisPartitioner::partition_mesh(), ZoltanPartitioner::partition_mesh_and_geometry(), moab::ReadSms::read_parallel_info(), MetisPartitioner::write_aggregationtag_partition(), MetisPartitioner::write_partition(), and ZoltanPartitioner::write_partition().
string part_file_name |
string test_file_name = string( MESH_DIR ) + string( "/3k-tri-sphere.vtk" ) |
Definition at line 19 of file ReadPartFile.cpp.