MOAB: Mesh Oriented datABase  (version 5.4.1)
pcomm_serial.cpp
Go to the documentation of this file.
00001 #include "moab/ParallelComm.hpp"
00002 #include "MBParallelConventions.h"
00003 #include "MBTagConventions.hpp"
00004 #include "moab/Core.hpp"
00005 #include "moab/FileOptions.hpp"
00006 #include "ReadParallel.hpp"
00007 #include "TestUtil.hpp"
00008 #include <vector>
00009 
00010 using namespace moab;
00011 
00012 void print_usage( char* argv )
00013 {
00014     std::cout << "Usage: " << argv << " nprocs filename" << std::endl;
00015 }
00016 
00017 int main( int argc, char* argv[] )
00018 {
00019 #ifdef MOAB_HAVE_MPI
00020     MPI_Init( &argc, &argv );
00021 #else
00022 #define MPI_COMM_WORLD 0
00023 #endif
00024 
00025     if( 1 < argc && !strcmp( argv[1], "-h" ) )
00026     {
00027         print_usage( argv[0] );
00028         return 0;
00029     }
00030 
00031     int nprocs = 2;
00032     std::string ptag_name( "GEOM_DIMENSION" );
00033     std::vector< int > partition_tag_vals;
00034     std::string filename = TestDir + "unittest/ptest.cub";
00035     if( argc > 1 ) nprocs = atoi( argv[1] );
00036     if( argc > 2 ) filename = std::string( argv[2] );
00037     if( argc > 3 )
00038     {
00039         ptag_name = argv[3];
00040         if( argc > 4 ) partition_tag_vals.push_back( atoi( argv[4] ) );
00041     }
00042     else
00043         partition_tag_vals.push_back( 3 );
00044 
00045     if( 0 == nprocs )
00046     {
00047         print_usage( argv[0] );
00048         return 1;
00049     }
00050 
00051     ErrorCode rval;
00052     Core* moab = new Core[nprocs]();
00053     std::vector< ParallelComm* > pc( nprocs );
00054     for( int i = 0; i < nprocs; i++ )
00055     {
00056         pc[i] = new ParallelComm( &moab[i], MPI_COMM_WORLD );
00057         pc[i]->set_rank( i );
00058         pc[i]->set_size( nprocs );
00059     }
00060 
00061     std::vector< int > pa_vec;
00062     pa_vec.push_back( ReadParallel::PA_READ );
00063     pa_vec.push_back( ReadParallel::PA_GET_FILESET_ENTS );
00064     pa_vec.push_back( ReadParallel::PA_DELETE_NONLOCAL );
00065     bool partition_distrib = true;
00066 
00067     FileOptions fopts( NULL );
00068 
00069     const char* fnames = filename.c_str();
00070     for( int i = 0; i < nprocs; i++ )
00071     {
00072         ReadParallel rp( moab + i, pc[i] );
00073         rval = rp.load_file( &fnames, 1, 0, ReadParallel::POPT_READ_DELETE, ptag_name, partition_tag_vals,
00074                              partition_distrib, false, pa_vec, fopts, NULL, NULL, i, false, -1, -1, -1, -1, 0, 0 );CHECK_ERR( rval );
00075     }
00076 
00077     rval = ParallelComm::resolve_shared_ents( &pc[0], nprocs, 0, 3 );CHECK_ERR( rval );
00078 
00079     // exchange interface cells
00080     rval = ParallelComm::exchange_ghost_cells( &pc[0], nprocs, -1, -1, 0, 0, true );CHECK_ERR( rval );
00081 
00082     // now 1 layer of hex ghosts
00083     rval = ParallelComm::exchange_ghost_cells( &pc[0], nprocs, 3, 2, 1, 0, true );CHECK_ERR( rval );
00084 
00085     // now 1 layer of hex ghosts with face/edges
00086     rval = ParallelComm::exchange_ghost_cells( &pc[0], nprocs, 3, 2, 1, 3, true );CHECK_ERR( rval );
00087 
00088     for( int i = 0; i < nprocs; i++ )
00089         delete pc[i];
00090 
00091     delete[] moab;
00092 
00093 #ifdef MOAB_HAVE_MPI
00094     MPI_Finalize();
00095 #endif
00096 
00097     return 0;
00098 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines