57 po::options_description desc(
"Available options");
62 "Produce this help message.")
64 "Print the list of available modules.")
65 (
"output-points,n", po::value<int>(),
66 "Output at n equipspaced points along the "
67 "collapsed coordinates (for .dat, .vtu).")
68 (
"output-points-hom-z", po::value<int>(),
69 "Number of planes in the z-direction for output of "
70 "Homogeneous 1D expansion(for .dat, .vtu).")
72 "Write error of fields for regression checking")
74 "Force the output to be written without any checks")
75 (
"range,r", po::value<string>(),
76 "Define output range i.e. (-r xmin,xmax,ymin,ymax,zmin,zmax) "
77 "in which any vertex is contained.")
79 "Do not use equispaced output.")
80 (
"nparts", po::value<int>(),
81 "Define nparts if running serial problem to mimic "
82 "parallel run with many partitions.")
83 (
"npz", po::value<int>(),
84 "Used to define number of partitions in z for Homogeneous1D "
85 "expansions for parallel runs.")
86 (
"onlyshape", po::value<string>(),
87 "Only use element with defined shape type i.e. -onlyshape "
89 (
"part-only", po::value<int>(),
90 "Partition into specified npart partitions and exit")
91 (
"part-only-overlapping", po::value<int>(),
92 "Partition into specified npart overlapping partitions and exit")
93 (
"modules-opt,p", po::value<string>(),
94 "Print options for a module.")
95 (
"module,m", po::value<vector<string> >(),
96 "Specify modules which are to be used.")
97 (
"useSessionVariables",
98 "Use variables defined in session for output")
99 (
"useSessionExpansion",
100 "Use expansion defined in session.")
102 "Enable verbose mode.");
105 po::options_description hidden(
"Hidden options");
109 (
"input-file", po::value<vector<string> >(),
"Input filename");
112 po::options_description cmdline_options;
113 cmdline_options.add(hidden).add(desc);
115 po::options_description visible(
"Allowed options");
118 po::positional_options_description
p;
119 p.add(
"input-file", -1);
121 po::variables_map vm;
125 po::store(po::command_line_parser(argc, argv)
126 .options(cmdline_options)
132 catch (
const std::exception &e)
134 cerr << e.what() << endl;
139 #ifdef NEKTAR_DISABLE_BACKUPS
140 vm.insert(std::make_pair(
"forceoutput", po::variable_value()));
144 if (vm.count(
"modules-list"))
150 if (vm.count(
"modules-opt"))
153 boost::split(tmp1, vm[
"modules-opt"].as<string>(),
154 boost::is_any_of(
":"));
156 if (tmp1.size() != 2)
158 cerr <<
"ERROR: To specify a module, use one of in, out or proc "
159 <<
"together with the filename; for example in:vtk." << endl;
163 if (tmp1[0] !=
"in" && tmp1[0] !=
"out" && tmp1[0] !=
"proc")
165 cerr <<
"ERROR: Invalid module type " << tmp1[0] << endl;
175 else if (tmp1[0] ==
"out")
179 else if (tmp1[0] ==
"proc")
187 cerr <<
"Options for module " << tmp1[1] <<
":" << endl;
192 if (vm.count(
"help") || vm.count(
"input-file") != 1)
194 cerr <<
"Usage: FieldConvert [options] inputfile.ext1 outputfile.ext2"
198 cout <<
"Example Usage: \n" << endl;
199 cout <<
"\t FieldConvert -m vorticity file.xml file.fld file_vort.fld "
201 cout <<
"(This will add vorticity to file file.fld and put it in a "
202 "new file file_vort.fld) "
205 cout <<
"\t FieldConvert file.xml file_vort.fld file_vort.dat " << endl;
206 cout <<
"(process file_vort.fld and make a tecplot output "
214 "Must specify input(s) and/or output file.");
215 vector<string> inout = vm[
"input-file"].as<vector<string>>();
238 if (vm.count(
"nparts"))
241 MPInprocs = MPIComm->GetSize();
242 MPIrank = MPIComm->GetRank();
244 nParts = vm[
"nparts"].as<
int>();
247 "Serial", argc, argv);
256 if (vm.count(
"nparts"))
258 nParts = vm[
"nparts"].as<
int>();
265 vector<ModuleSharedPtr> modules;
266 vector<string> modcmds;
270 if (vm.count(
"verbose"))
275 if (vm.count(
"module"))
277 modcmds = vm[
"module"].as<vector<string>>();
281 modcmds.insert(modcmds.begin(), inout.begin(), inout.end() - 1);
282 modcmds.push_back(*(inout.end() - 1));
284 int nInput = inout.size() - 1;
290 if (vm.count(
"part-only") || vm.count(
"part-only-overlapping"))
292 nInput = inout.size();
298 for (
int i = 0; i < modcmds.size(); ++i)
304 boost::split(tmp1, modcmds[i], boost::is_any_of(
":"));
306 if (i < nInput || i == modcmds.size() - 1)
310 if (tmp1.size() > 1 && tmp1.back() ==
"out")
323 if (tmp1.size() == 1)
331 guess = InputModule::GuessFormat(tmp1[0]);
339 cout <<
"Using input module " << guess
340 <<
" for: " << tmp1[0] << endl;
343 module.second = guess;
344 tmp1.push_back(
string(
"infile=" + tmp1[0]));
348 int dot = tmp1[0].find_last_of(
'.') + 1;
349 string ext = tmp1[0].substr(dot, tmp1[0].length() - dot);
353 if (ext.back() == fs::path::preferred_separator)
360 string tmp2 = tmp1[0].substr(0, dot - 1);
361 dot = tmp2.find_last_of(
'.') + 1;
362 ext = tmp1[0].substr(dot, tmp1[0].length() - dot);
374 module.second = tmp1[1];
385 module.second = tmp1[0];
390 modules.push_back(mod);
394 inputModule = std::dynamic_pointer_cast<InputModule>(mod);
395 inputModule->AddFile(module.second, tmp1[0]);
399 outfilename = tmp1[0];
404 mod->RegisterConfig(
"writemultiplefiles");
408 for (
int j = offset; j < tmp1.size(); ++j)
411 boost::split(tmp2, tmp1[j], boost::is_any_of(
"="));
413 if (tmp2.size() == 1)
415 mod->RegisterConfig(tmp2[0]);
417 else if (tmp2.size() == 2)
419 mod->RegisterConfig(tmp2[0], tmp2[1]);
423 cerr <<
"ERROR: Invalid module configuration: format is "
424 <<
"either :arg or :arg=val" << endl;
435 for (
int i = 0; i < modules.size(); ++i)
437 ++modulesCount[modules[i]->GetModulePriority()];
443 module.second = string(
"equispacedoutput");
445 modules.push_back(mod);
452 if (vm.count(
"range") && f->m_declareExpansionAsContField)
454 ASSERTL0(
false,
"Can't use range option with module requiring "
455 "a continuous expansion.");
458 bool verbose = (f->m_verbose && f->m_comm->TreatAsRankZero());
467 for (
int p = MPIrank;
p < nParts;
p += MPInprocs)
473 cout << endl <<
"Processing partition: " <<
p << endl;
477 partComm = std::shared_ptr<FieldConvertComm>(
490 f->m_comm = partComm;
498 for (
int i = 0; i < modules.size(); ++i)
500 if (modules[i]->GetModulePriority() == priority)
513 for (i = 0; i < modules.size(); ++i)
515 if (boost::iequals(modules[i]->GetModuleName(),
"OutputFld"))
521 if (i != modules.size())
531 module.second = string(
"info");
534 mod->RegisterConfig(
"nparts",
535 boost::lexical_cast<string>(nParts));
538 if (f->m_writeBndFld)
541 int dot = outfilename.find_last_of(
'.') + 1;
543 outfilename.substr(dot, outfilename.length() - dot);
544 string name = outfilename.substr(0, dot - 1);
546 for (
int b = 0; b < f->m_bndRegionsToWrite.size(); ++b)
548 string outfilenew =
name +
"_b" +
549 boost::lexical_cast<string>(
550 f->m_bndRegionsToWrite[b]) +
552 mod->RegisterConfig(
"outfile", outfilenew);
558 mod->RegisterConfig(
"outfile", outfilename);
571 ss << cpuTime <<
"s";
572 cout <<
"Total CPU Time: " << setw(8) << left << ss.str() << endl;
void PrintExecutionSequence(vector< ModuleSharedPtr > &modules)
void RunModule(ModuleSharedPtr module, po::variables_map &vm, bool verbose)
void CheckModules(vector< ModuleSharedPtr > &modules)
tBaseSharedPtr CreateInstance(tKey idKey, tParam... args)
Create an instance of the class referred to by idKey.
void PrintAvailableClasses(std::ostream &pOut=std::cout)
Prints the available classes to stdout.
NekDouble TimePerTest(unsigned int n)
Returns amount of seconds per iteration in a test with n iterations.
std::shared_ptr< Field > FieldSharedPtr
std::pair< ModuleType, std::string > ModuleKey
std::shared_ptr< InputModule > InputModuleSharedPtr
std::shared_ptr< Module > ModuleSharedPtr
ModuleFactory & GetModuleFactory()
CommFactory & GetCommFactory()
std::shared_ptr< Comm > CommSharedPtr
Pointer to a Communicator object.