20 int myID = 0, numprocs = 1;
21 MPI_Init( &argc, &argv );
22 MPI_Comm_rank( MPI_COMM_WORLD, &myID );
23 MPI_Comm_size( MPI_COMM_WORLD, &numprocs );
28 std::string mtag =
"";
30 double merge_tol = 1.0e-4;
32 LONG_DESC <<
"mbmerge tool has the ability to merge nodes in a mesh. For skin-based merge with "
34 "files parallel options is also supported."
36 <<
"If no method is specified, the default is simple merge. Simple merge case gets "
37 "all the skins available"
38 <<
" in the mesh file and merges the nodes to obtain a conformal mesh. Options to "
39 "merge all duplicate nodes"
40 <<
" and merging based on a specific tag on the nodes are also supported." << std::endl;
44 opts.addOpt<
void >(
"all,a",
"merge all including interior.", &fall );
45 opts.addOpt< std::string >(
"mergetag name,t",
"merge based on nodes that have a specific tag name assigned",
47 opts.addOpt<
double >(
"mergetolerance,e",
"merge tolerance, default is 1e-4", &merge_tol );
48 opts.addOpt<
void >(
"simple,s",
"simple merge, merge based on skins provided as in the input mesh (Default)",
50 opts.addRequiredArg< std::string >(
"input_file",
"Input file to be merged", &
input_file );
51 opts.addRequiredArg< std::string >(
"output_file",
"Output mesh file name with extension", &output_file );
53 opts.addOpt<
void >(
"file,f",
54 "files based merge using skin for individual meshes. Input file is a file containing names"
55 "of mesh files to be merged (each on a different line). Only works with parallel build",
58 opts.parseCommandLine( argc, argv );
68 std::cerr <<
"Error Opening Mesh File " <<
input_file << std::endl;
73 std::cout <<
"Read input mesh file: " <<
input_file << std::endl;
80 std::cerr <<
"failed to get entities by dimension" << std::endl;
87 std::cerr <<
"unable to get tag: " << mtag <<
" specified" << std::endl;
91 rval = mm.merge_using_integer_tag( verts, tag_for_merge );
94 std::cerr <<
"error in routine merge using integer tag" << std::endl;
100 std::cerr <<
"Error Writing Mesh File " << output_file << std::endl;
105 std::cout <<
"Wrote output mesh file: " << output_file << std::endl;
109 else if( fall ==
true )
115 std::cerr <<
"Error Opening Mesh File " <<
input_file << std::endl;
120 std::cout <<
"Read input mesh file: " <<
input_file << std::endl;
123 rval = mm.merge_all( 0, merge_tol );
126 std::cerr <<
"error in merge_all routine" << std::endl;
132 std::cerr <<
"Error Writing Mesh File " << output_file << std::endl;
137 std::cout <<
"Wrote output mesh file: " << output_file << std::endl;
140 else if( ffile ==
true )
175 getline( file, line );
176 if( myID == count && line !=
"" )
182 std::cerr <<
"Error Opening Mesh File " << line << std::endl;
183 MPI_Abort( MPI_COMM_WORLD, 1 );
189 std::cout <<
"Read input mesh file: " << line << std::endl;
192 count = ( count + 1 ) % numprocs;
198 std::cerr <<
"Error Opening Input File " <<
input_file << std::endl;
199 MPI_Abort( MPI_COMM_WORLD, 1 );
211 std::cerr <<
"Merge Failed" << std::endl;
212 MPI_Abort( MPI_COMM_WORLD, 1 );
217 rval =
mb->
write_file( output_file.c_str(), 0,
"PARALLEL=WRITE_PART" );
220 std::cerr <<
"Writing output file failed. Code:";
223 std::string foo =
"";
225 std::cerr <<
"File Error: " << foo << std::endl;
230 std::cout <<
"Wrote output mesh file: " << output_file << std::endl;
235 MPI_Barrier( MPI_COMM_WORLD );
240 else if( fsimple ==
true )
245 std::cerr <<
"Error Opening Mesh File " <<
input_file << std::endl;
250 std::cout <<
"Read input mesh file: " <<
input_file << std::endl;
257 std::cerr <<
"error getting entities by dimension" << std::endl;
261 rval = mm.merge_entities( ents, merge_tol );
264 std::cerr <<
"error in merge entities routine" << std::endl;
270 std::cerr <<
" Writing Mesh File " << output_file << std::endl;
275 std::cout <<
"Wrote output mesh file: " << output_file << std::endl;
280 std::cerr <<
" Unhandled option " << std::endl;