MOAB: Mesh Oriented datABase  (version 5.2.1)
mgen_test.cpp
Go to the documentation of this file.
00001 #include "moab/Core.hpp"
00002 #include "moab/MeshGeneration.hpp"
00003 #include "TestUtil.hpp"
00004 #include "moab/ProgOptions.hpp"
00005 
00006 #ifdef MOAB_HAVE_MPI
00007 #include "moab_mpi.h"
00008 #include "moab/ParallelComm.hpp"
00009 #include "MBParallelConventions.h"
00010 #endif
00011 
00012 using namespace moab;
00013 using std::string;
00014 
00015 int main( int argc, char* argv[] )
00016 {
00017     int proc_id = 0, size = 1;
00018 #ifdef MOAB_HAVE_MPI
00019     MPI_Init( &argc, &argv );
00020     MPI_Comm_rank( MPI_COMM_WORLD, &proc_id );
00021     MPI_Comm_size( MPI_COMM_WORLD, &size );
00022 #endif
00023     Core mcore;
00024     Interface* mb = &mcore;
00025     EntityHandle fileset;
00026     MeshGeneration::BrickOpts opts;
00027     // default options
00028     opts.A = opts.B = opts.C = 2;
00029     opts.M = opts.N = opts.K = 1;
00030     opts.blockSize           = 4;
00031     opts.xsize = opts.ysize = opts.zsize = 1.;
00032     opts.ui                              = CartVect( 1., 0, 0. );
00033     opts.uj                              = CartVect( 0., 1., 0. );
00034     opts.uk                              = CartVect( 0., 0., 1. );
00035     opts.newMergeMethod = opts.quadratic = opts.keep_skins = opts.tetra = false;
00036     opts.adjEnts = opts.parmerge = false;
00037     opts.GL                      = 0;
00038 
00039     ProgOptions popts;
00040 
00041     popts.addOpt< int >( string( "blockSize,b" ), string( "Block size of mesh (default=4)" ), &opts.blockSize );
00042     popts.addOpt< int >( string( "xproc,M" ), string( "Number of processors in x dir (default=1)" ), &opts.M );
00043     popts.addOpt< int >( string( "yproc,N" ), string( "Number of processors in y dir (default=1)" ), &opts.N );
00044     popts.addOpt< int >( string( "zproc,K" ), string( "Number of processors in z dir (default=1)" ), &opts.K );
00045 
00046     popts.addOpt< int >( string( "xblocks,A" ), string( "Number of blocks on a task in x dir (default=2)" ), &opts.A );
00047     popts.addOpt< int >( string( "yblocks,B" ), string( "Number of blocks on a task in y dir (default=2)" ), &opts.B );
00048     popts.addOpt< int >( string( "zblocks,C" ), string( "Number of blocks on a task in x dir (default=2)" ), &opts.C );
00049 
00050     popts.addOpt< double >( string( "xsize,x" ), string( "Total size in x direction (default=1.)" ), &opts.xsize );
00051     popts.addOpt< double >( string( "ysize,y" ), string( "Total size in y direction (default=1.)" ), &opts.ysize );
00052     popts.addOpt< double >( string( "zsize,z" ), string( "Total size in z direction (default=1.)" ), &opts.zsize );
00053 
00054     popts.addOpt< void >( "newMerge,w", "use new merging method", &opts.newMergeMethod );
00055 
00056     popts.addOpt< void >( "quadratic,q", "use hex 27 elements", &opts.quadratic );
00057 
00058     popts.addOpt< void >( "keep_skins,k", "keep skins with shared entities", &opts.keep_skins );
00059 
00060     popts.addOpt< void >( "tetrahedrons,t", "generate tetrahedrons", &opts.tetra );
00061 
00062     popts.addOpt< void >( "faces_edges,f", "create all faces and edges", &opts.adjEnts );
00063 
00064     popts.addOpt< int >( string( "ghost_layers,g" ), string( "Number of ghost layers (default=0)" ), &opts.GL );
00065 
00066     popts.addOpt< void >( "parallel_merge,p", "use parallel mesh merge, not vertex ID based merge", &opts.parmerge );
00067 
00068     popts.parseCommandLine( argc, argv );
00069 
00070     ErrorCode rval = mb->create_meshset( MESHSET_SET, fileset );MB_CHK_ERR( rval );
00071 
00072 #ifdef MOAB_HAVE_MPI
00073     ParallelComm* pc     = new ParallelComm( mb, MPI_COMM_WORLD );
00074     MeshGeneration* mgen = new MeshGeneration( mb, pc, fileset );
00075 #else
00076     MeshGeneration* mgen = new MeshGeneration( mb, 0, fileset );
00077 #endif
00078 
00079     rval = mgen->BrickInstance( opts );MB_CHK_ERR( rval );
00080 
00081     return 0;
00082 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines