- Examples
- GenLargeMesh.cpp.
Definition at line 87 of file GenLargeMesh.cpp.
93 MPI_Init( &argc, &argv );
97 bopts.
A = bopts.
B = bopts.
C = 2;
98 bopts.
M = bopts.
N = bopts.
K = 1;
110 opts.
addOpt<
int >( string(
"blockSize,b" ), string(
"Block size of mesh (default=4)" ), &bopts.
blockSize );
111 opts.
addOpt<
int >( string(
"xproc,M" ), string(
"Number of processors in x dir (default=1)" ), &bopts.
M );
112 opts.
addOpt<
int >( string(
"yproc,N" ), string(
"Number of processors in y dir (default=1)" ), &bopts.
N );
113 opts.
addOpt<
int >( string(
"zproc,K" ), string(
"Number of processors in z dir (default=1)" ), &bopts.
K );
115 opts.
addOpt<
int >( string(
"xblocks,A" ), string(
"Number of blocks on a task in x dir (default=2)" ), &bopts.
A );
116 opts.
addOpt<
int >( string(
"yblocks,B" ), string(
"Number of blocks on a task in y dir (default=2)" ), &bopts.
B );
117 opts.
addOpt<
int >( string(
"zblocks,C" ), string(
"Number of blocks on a task in x dir (default=2)" ), &bopts.
C );
119 opts.
addOpt<
double >( string(
"xsize,x" ), string(
"Total size in x direction (default=1.)" ), &bopts.
xsize );
120 opts.
addOpt<
double >( string(
"ysize,y" ), string(
"Total size in y direction (default=1.)" ), &bopts.
ysize );
121 opts.
addOpt<
double >( string(
"zsize,z" ), string(
"Total size in z direction (default=1.)" ), &bopts.
zsize );
125 opts.
addOpt<
void >(
"quadratic,q",
"use hex 27 elements", &bopts.
quadratic );
127 opts.
addOpt<
void >(
"keep_skins,k",
"keep skins with shared entities", &bopts.
keep_skins );
129 opts.
addOpt<
void >(
"tetrahedrons,t",
"generate tetrahedrons", &bopts.
tetra );
131 opts.
addOpt<
void >(
"faces_edges,f",
"create all faces and edges", &bopts.
adjEnts );
133 opts.
addOpt<
int >( string(
"ghost_layers,g" ), string(
"Number of ghost layers (default=0)" ), &bopts.
GL );
135 vector< string > intTagNames;
137 opts.
addOpt<
string >(
"int_tag_vert,i",
"add integer tag on vertices", &firstIntTag );
139 vector< string > doubleTagNames;
140 string firstDoubleTag;
141 opts.
addOpt<
string >(
"double_tag_cell,d",
"add double tag on cells", &firstDoubleTag );
143 string outFileName =
"GenLargeMesh.h5m";
144 opts.
addOpt<
string >(
"outFile,o",
"Specify the output file name string (default GenLargeMesh.h5m)",
147 #ifdef MOAB_HAVE_HDF5_PARALLEL
149 opts.
addOpt<
void >(
"readback,r",
"read back the generated mesh", &readb );
151 bool readAndGhost =
false;
152 opts.
addOpt<
void >(
"readAndGhost,G",
"read back the generated mesh and ghost one layer", &readAndGhost );
155 opts.
addOpt<
void >(
"parallel_merge,p",
"use parallel mesh merge, not vertex ID based merge", &bopts.
parmerge );
157 opts.
addOpt<
void >(
"no_save,n",
"do not save the file", &nosave );
175 int rank = 0,
size = 1;
178 MPI_Comm_rank( MPI_COMM_WORLD, &rank );
179 MPI_Comm_size( MPI_COMM_WORLD, &
size );
191 clock_t tt = clock();
200 cout <<
"generate local mesh: " << ( clock() - tt ) / (
double)CLOCKS_PER_SEC <<
" seconds" << endl;
202 cout <<
"number of elements on rank 0: " << all3dcells.
size() << endl;
203 cout <<
"Total number of elements " << all3dcells.
size() *
size << endl;
204 cout <<
"Element type: " << ( bopts.
tetra ?
"MBTET" :
"MBHEX" )
205 <<
" order:" << ( bopts.
quadratic ?
"quadratic" :
"linear" ) << endl;
212 #ifdef MOAB_HAVE_HDF5_PARALLEL
213 rval =
mb->
write_file( outFileName.c_str(), 0,
";;PARALLEL=WRITE_PART;CPUTIME;", &fileset, 1 );
MB_CHK_SET_ERR( rval,
"Can't write in parallel" );
220 cout <<
"write file " << outFileName <<
" in " << ( clock() - tt ) / (
double)CLOCKS_PER_SEC <<
" seconds"
226 size_t nLocalVerts = verts.
size();
227 size_t nLocalCells = all3dcells.
size();
231 #ifdef MOAB_HAVE_HDF5_PARALLEL
232 if( !nosave && readb )
236 std::string read_opts(
"PARALLEL=READ_PART;PARTITION=PARALLEL_PARTITION;PARALLEL_RESOLVE_"
237 "SHARED_ENTS;CPUTIME;" );
238 if( readAndGhost ) read_opts +=
"PARALLEL_GHOSTS=3.0.1;";
239 rval = mb2.
load_file( outFileName.c_str(), 0, read_opts.c_str() );
MB_CHK_SET_ERR( rval,
"Can't read in parallel" );
242 cout <<
"read back file " << outFileName <<
" with options: \n"
243 << read_opts <<
" in " << ( clock() - tt ) / (
double)CLOCKS_PER_SEC <<
" seconds" << endl;
250 if( readAndGhost &&
size > 1 )
254 ParallelComm* pcomm2 = ParallelComm::get_pcomm( &mb2, 0 );
255 if( NULL == pcomm2 )
MB_SET_ERR( MB_FAILURE,
"can't get parallel comm." );
259 if( nverts.
size() != nLocalVerts && ncells.
size() != nLocalCells )
261 MB_SET_ERR( MB_FAILURE,
"Reading back the output file led to inconsistent number of entities." );
References moab::MeshGeneration::BrickOpts::A, ProgOptions::addOpt(), moab::MeshGeneration::BrickOpts::adjEnts, moab::MeshGeneration::BrickOpts::B, moab::MeshGeneration::BrickOpts::blockSize, moab::MeshGeneration::BrickInstance(), moab::MeshGeneration::BrickOpts::C, moab::Core::create_meshset(), moab::Core::delete_mesh(), ErrorCode, moab::ParallelComm::filter_pstatus(), moab::Core::get_entities_by_dimension(), moab::ParallelComm::get_pcomm(), ProgOptions::getOptAllArgs(), moab::MeshGeneration::BrickOpts::GL, moab::MeshGeneration::BrickOpts::K, moab::MeshGeneration::BrickOpts::keep_skins, moab::Core::load_file(), moab::MeshGeneration::BrickOpts::M, mb, MB_CHK_ERR, MB_CHK_SET_ERR, MB_SET_ERR, MESHSET_SET, moab::MeshGeneration::BrickOpts::N, moab::MeshGeneration::BrickOpts::newMergeMethod, moab::MeshGeneration::BrickOpts::parmerge, ProgOptions::parseCommandLine(), PSTATUS_GHOST, PSTATUS_NOT, moab::MeshGeneration::BrickOpts::quadratic, size, moab::Range::size(), moab::MeshGeneration::BrickOpts::tetra, moab::MeshGeneration::BrickOpts::ui, moab::MeshGeneration::BrickOpts::uj, moab::MeshGeneration::BrickOpts::uk, moab::Core::write_file(), moab::MeshGeneration::BrickOpts::xsize, moab::MeshGeneration::BrickOpts::ysize, and moab::MeshGeneration::BrickOpts::zsize.