47 po::options_description desc(
"Available options");
50 "Produce this help message.")
52 "Print the list of available modules.")
53 (
"output-points,n", po::value<int>(),
54 "Output at n equipspaced points along the collapsed coordinates (for .dat, .vtk).")
56 "Write error of fields for regression checking")
58 "Force the output to be written without any checks")
59 (
"range,r", po::value<string>(),
60 "Define output range i.e. (-r xmin,xmax,ymin,ymax,zmin,zmax) "
61 "in which any vertex is contained.")
62 (
"nprocs", po::value<int>(),
63 "Used to define nprocs if running serial problem to mimic "
65 (
"onlyshape", po::value<string>(),
66 "Only use element with defined shape type i.e. -onlyshape "
68 (
"procid", po::value<int>(),
69 "Process as single procid of a partition of size nproc "
70 "(-nproc must be specified).")
71 (
"modules-opt,p", po::value<string>(),
72 "Print options for a module.")
73 (
"module,m", po::value<vector<string> >(),
74 "Specify modules which are to be used.")
75 (
"useSessionVariables",
76 "Use variables defined in session for output")
78 "Enable verbose mode.");
80 po::options_description hidden(
"Hidden options");
82 (
"input-file", po::value<vector<string> >(),
"Input filename");
84 po::options_description cmdline_options;
85 cmdline_options.add(hidden).add(desc);
87 po::options_description visible(
"Allowed options");
90 po::positional_options_description p;
91 p.add(
"input-file", -1);
97 po::store(po::command_line_parser(argc, argv).
98 options(cmdline_options).positional(p).run(), vm);
101 catch (
const std::exception& e)
103 cerr << e.what() << endl;
109 if (vm.count(
"modules-list"))
115 if (vm.count(
"modules-opt"))
118 boost::split(tmp1, vm[
"modules-opt"].as<string>(),
119 boost::is_any_of(
":"));
121 if (tmp1.size() != 2)
123 cerr <<
"ERROR: To specify a module, use one of in, out or proc "
124 <<
"together with the filename; for example in:vtk." << endl;
128 if (tmp1[0] !=
"in" && tmp1[0] !=
"out" && tmp1[0] !=
"proc")
130 cerr <<
"ERROR: Invalid module type " << tmp1[0] << endl;
140 else if (tmp1[0] ==
"out")
144 else if (tmp1[0] ==
"proc")
152 cerr <<
"Options for module " << tmp1[1] <<
":" << endl;
157 if (vm.count(
"help") || vm.count(
"input-file") != 1) {
158 cerr <<
"Usage: FieldConvert [options] inputfile.ext1 outputfile.ext2"
162 cout <<
"Example Usage: \n" << endl;
163 cout <<
"\t FieldConvert -m vorticity file.xml file.fld file_vort.fld "
165 cout <<
"(This will add vorticity to file file.fld and put it in a "
166 "new file file_vort.fld) " << endl;
168 cout <<
"\t FieldConvert file.xml file_vort.fld file_vort.dat " << endl;
169 cout <<
"(process file_vort.fld and make a tecplot output "
170 "file_vort.dat) " << endl;
176 "Must specify input(s) and/or output file.");
177 vector<string> inout = vm[
"input-file"].as<vector<string> >();
193 if(vm.count(
"procid"))
198 "Must specify --nprocs when using --procid option");
199 nprocs = vm[
"nprocs"].as<
int>();
200 rank = vm[
"procid"].as<
int>();
202 f->m_comm = boost::shared_ptr<FieldConvertComm>(
208 "ParallelMPI", argc, argv);
214 "Serial", argc, argv);
218 vector<ModuleSharedPtr> modules;
219 vector<string> modcmds;
221 if (vm.count(
"verbose"))
226 if (vm.count(
"module"))
228 modcmds = vm[
"module"].as<vector<string> >();
232 modcmds.insert(modcmds.begin(), inout.begin(), inout.end()-1);
233 modcmds.push_back(*(inout.end()-1));
234 int nInput = inout.size()-1;
238 for (
int i = 0; i < modcmds.size(); ++i)
245 boost::split(tmp1, modcmds[i], boost::is_any_of(
":"));
247 if (i < nInput || i == modcmds.size() - 1)
258 if (tmp1.size() == 1)
260 int dot = tmp1[0].find_last_of(
'.') + 1;
261 string ext = tmp1[0].substr(dot, tmp1[0].length() - dot);
265 string tmp2 = tmp1[0].substr(0,dot-1);
266 dot = tmp2.find_last_of(
'.') + 1;
267 ext = tmp1[0].substr(dot,tmp1[0].length()-dot);
271 tmp1.push_back(
string(i < nInput ?
"infile=" :
"outfile=")
276 module.second = tmp1[1];
277 tmp1.push_back(
string(i < nInput ?
"infile=" :
"outfile=")
285 module.second = tmp1[0];
291 modules.push_back(mod);
295 inputModule = boost::dynamic_pointer_cast<
InputModule>(mod);
296 inputModule->
AddFile(module.second, tmp1[0]);
300 for (
int j = offset; j < tmp1.size(); ++j)
303 boost::split(tmp2, tmp1[j], boost::is_any_of(
"="));
305 if (tmp2.size() == 1)
307 mod->RegisterConfig(tmp2[0],
"1");
309 else if (tmp2.size() == 2)
311 mod->RegisterConfig(tmp2[0], tmp2[1]);
315 cerr <<
"ERROR: Invalid module configuration: format is "
316 <<
"either :arg or :arg=val" << endl;
326 bool RequiresEquiSpaced =
false;
327 for (
int i = 0; i < modules.size(); ++i)
329 if(modules[i]->GetRequireEquiSpaced())
331 RequiresEquiSpaced =
true;
334 if (RequiresEquiSpaced)
336 for (
int i = 0; i < modules.size(); ++i)
338 modules[i]->SetRequireEquiSpaced(
true);
342 for (
int i = 0; i < modules.size(); ++i)
344 modules[i]->Process(vm);
#define ASSERTL0(condition, msg)
void PrintAvailableClasses(std::ostream &pOut=std::cout)
Prints the available classes to stdout.
pair< ModuleType, string > ModuleKey
tBaseSharedPtr CreateInstance(tKey idKey BOOST_PP_COMMA_IF(MAX_PARAM) BOOST_PP_ENUM_BINARY_PARAMS(MAX_PARAM, tParam, x))
Create an instance of the class referred to by idKey.
CommFactory & GetCommFactory()
boost::shared_ptr< InputModule > InputModuleSharedPtr
bool ModuleExists(tKey idKey)
Checks if a particular module is available.
boost::shared_ptr< Module > ModuleSharedPtr
boost::shared_ptr< Field > FieldSharedPtr
ModuleFactory & GetModuleFactory()