1 #ifndef GET_FILE_OPTIONS_H
2 #define GET_FILE_OPTIONS_H
10 namespace point_locator
15 template <
typename String = std::string,
16 typename String_vector = std::vector< std::string >,
17 typename Char_vector = std::vector< const char* > >
52 std::vector< std::string >& meshFiles,
53 std::string& interpTag,
54 std::string& gNormTag,
55 std::string& ssNormTag,
56 std::vector< const char* >& ssTagNames,
57 std::vector< const char* >& ssTagValues,
58 std::string& readOpts,
60 std::string& writeOpts,
68 readOpts =
"PARALLEL=READ_PART;PARTITION=PARALLEL_PARTITION;PARTITION_DISTRIBUTE;"
69 "PARALLEL_RESOLVE_SHARED_ENTS;PARALLEL_GHOSTS=3.0.1;CPUTIME";
71 writeOpts =
"PARALLEL=WRITE_PART;CPUTIME";
73 std::string defaultDbgFile = argv[0];
76 bool haveMeshes =
false;
77 bool haveInterpTag =
false;
82 if( argc > 1 && argv[1] == std::string(
"-h" ) )
90 if( argv[npos] == std::string(
"-meshes" ) )
95 meshFiles.resize( numFiles );
96 for(
int i = 0; i < numFiles; i++ )
99 meshFiles[i] = argv[npos++];
102 std::cerr <<
" ERROR - missing correct number of mesh filenames" << std::endl;
109 else if( argv[npos] == std::string(
"-itag" ) )
114 interpTag = argv[npos++];
117 std::cerr <<
" ERROR - missing <interp_tag>" << std::endl;
121 haveInterpTag =
true;
123 else if( argv[npos] == std::string(
"-gnorm" ) )
128 gNormTag = argv[npos++];
131 std::cerr <<
" ERROR - missing <gnorm_tag>" << std::endl;
135 else if( argv[npos] == std::string(
"-ssnorm" ) )
140 ssNormTag = argv[npos++];
143 std::cerr <<
" ERROR - missing <ssnorm_tag>" << std::endl;
149 char* opts = argv[npos++];
150 char sep1[1] = {
';' };
151 char sep2[1] = {
'=' };
152 bool end_vals_seen =
false;
153 std::vector< char* > tmpTagOpts;
156 for(
char* i = strtok( opts, sep1 ); i; i = strtok( 0, sep1 ) )
158 tmpTagOpts.push_back( i );
162 for(
unsigned int j = 0; j < tmpTagOpts.size(); j++ )
164 char* e = strtok( tmpTagOpts[j], sep2 );
165 ssTagNames.push_back( e );
166 e = strtok( 0, sep2 );
173 std::cerr <<
" ERROR - new value seen after end of values "
174 "in <ssnorm_selection>"
181 ssTagValues.push_back( (
const char*)valp );
186 end_vals_seen =
true;
187 ssTagValues.push_back( (
const char*)0 );
193 std::cerr <<
" ERROR - missing <ssnorm_selection>" << std::endl;
197 else if( argv[npos] == std::string(
"-ropts" ) )
202 readOpts = argv[npos++];
205 std::cerr <<
" ERROR - missing <roptions>" << std::endl;
209 else if( argv[npos] == std::string(
"-outfile" ) )
214 outFile = argv[npos++];
217 std::cerr <<
" ERROR - missing <out_file>" << std::endl;
221 else if( argv[npos] == std::string(
"-wopts" ) )
226 writeOpts = argv[npos++];
229 std::cerr <<
" ERROR - missing <woptions>" << std::endl;
233 else if( argv[npos] == std::string(
"-dbgout" ) )
239 dbgFile = argv[npos++];
241 dbgFile = defaultDbgFile;
246 std::cerr <<
" ERROR - Unrecognized parameter:" << argv[npos] << std::endl;
247 std::cerr <<
" Skipping..." << std::endl;
254 meshFiles.resize( 2 );
255 meshFiles[0] = std::string( TestDir +
"/64bricks_1khex.h5m" );
256 meshFiles[1] = std::string( TestDir +
"/64bricks_12ktet.h5m" );
257 std::cout <<
"Mesh files not entered; using default files " << meshFiles[0] <<
" and " << meshFiles[1]
263 interpTag =
"vertex_field";
264 std::cout <<
"Interpolation field name not given, using default of " << interpTag << std::endl;
267 #ifdef MOAB_HAVE_HDF5
270 std::cout <<
"No arguments given; using output file dum.h5m." << std::endl;
279 template <
typename Options >
282 return get_file_options( argc, argv, o.meshFiles, o.interpTag, o.gNormTag, o.ssNormTag, o.ssTagNames,
283 o.ssTagValues, o.readOpts, o.outFile, o.writeOpts, o.dbgFile, o.help );