53 po::options_description desc(
"Available options");
57 (
"help,h",
"Produce this help message.")
58 (
"modules-list,l",
"Print the list of available modules.")
59 (
"modules-opt,p", po::value<string>(),
60 "Print options for a module.")
61 (
"module,m", po::value<vector<string> >(),
62 "Specify modules which are to be used.")
63 (
"verbose,v",
"Enable verbose output.");
66 po::options_description hidden(
"Hidden options");
70 (
"input-file", po::value<vector<string> >(),
"Input filename");
73 po::options_description cmdline_options;
74 cmdline_options.add(hidden).add(desc);
76 po::options_description visible(
"Allowed options");
79 po::positional_options_description
p;
80 p.add(
"input-file", -1);
86 po::store(po::command_line_parser(argc, argv)
87 .options(cmdline_options)
93 catch (
const std::exception &e)
95 cerr << e.what() << endl;
101 auto logOutput = std::make_shared<StreamOutput>(std::cout);
102 Logger
log(logOutput, vm.count(
"verbose") ? VERBOSE : INFO);
105 if (vm.count(
"modules-list"))
111 if (vm.count(
"modules-opt"))
114 boost::split(tmp1, vm[
"modules-opt"].as<string>(),
115 boost::is_any_of(
":"));
117 if (tmp1.size() != 2)
119 cerr <<
"ERROR: To specify a module, use one of in, out or proc "
120 <<
"together with the filename; for example in:vtk." << endl;
124 if (tmp1[0] !=
"in" && tmp1[0] !=
"out" && tmp1[0] !=
"proc")
126 cerr <<
"ERROR: Invalid module type " << tmp1[0] << endl;
136 else if (tmp1[0] ==
"out")
140 else if (tmp1[0] ==
"proc")
145 MeshSharedPtr m = std::shared_ptr<Mesh>(
new Mesh());
148 cerr <<
"Options for module " << tmp1[1] <<
":" << endl;
154 if (vm.count(
"help") || vm.count(
"input-file") != 1)
156 cerr <<
"Usage: NekMesh [options] inputfile.ext1 outputfile.ext2"
162 vector<string> inout = vm[
"input-file"].as<vector<string>>();
164 if (inout.size() < 2)
166 cerr <<
"ERROR: You must specify an input and output file." << endl;
180 MeshSharedPtr mesh = std::shared_ptr<Mesh>(
new Mesh());
184 for (
int i = 1; i < argc; i++)
186 ss << argv[i] <<
" ";
188 mesh->m_metadata[
"NekMeshCommandLine"] = ss.str();
190 vector<ModuleSharedPtr> modules;
191 vector<string> modcmds;
193 if (vm.count(
"module"))
195 modcmds = vm[
"module"].as<vector<string>>();
199 modcmds.insert(modcmds.begin(), inout[0]);
200 modcmds.push_back(inout[1]);
203 size_t maxModName = 0;
205 for (
int i = 0; i < modcmds.size(); ++i)
212 boost::split(tmp1, modcmds[i], boost::is_any_of(
":"));
214 if (i == 0 || i == modcmds.size() - 1)
225 if (tmp1.size() == 1)
227 int dot = tmp1[0].find_last_of(
'.') + 1;
228 string ext = tmp1[0].substr(dot, tmp1[0].length() - dot);
232 string tmp = tmp1[0].substr(0, tmp1[0].length() - 3);
233 dot = tmp.find_last_of(
'.') + 1;
234 ext = tmp.substr(dot, tmp.length() - dot);
238 tmp1.push_back(
string(i == 0 ?
"infile=" :
"outfile=") +
243 module.second = tmp1[1];
244 tmp1.push_back(
string(i == 0 ?
"infile=" :
"outfile=") +
252 module.second = tmp1[0];
258 modules.push_back(mod);
261 for (
int j = offset; j < tmp1.size(); ++j)
264 boost::split(tmp2, tmp1[j], boost::is_any_of(
"="));
266 if (tmp2.size() == 1)
268 mod->RegisterConfig(tmp2[0]);
270 else if (tmp2.size() == 2)
272 mod->RegisterConfig(tmp2[0], tmp2[1]);
276 cerr <<
"ERROR: Invalid module configuration: format is "
277 <<
"either :arg or :arg=val" << endl;
286 std::string modName = mod->GetModuleName();
287 maxModName = std::max(maxModName, modName.length());
290 log.SetPrefixLen(maxModName);
293 for (
int i = 0; i < modules.size(); ++i)
299 modules[i]->GetLogger().SetPrefixLen(maxModName);
300 modules[i]->Process();
302 catch (NekMeshError &e)
308 log.SetPrefix(modules[i]->GetModuleName());
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::pair< ModuleType, std::string > ModuleKey
std::shared_ptr< Module > ModuleSharedPtr
ModuleFactory & GetModuleFactory()
scalarT< T > log(scalarT< T > in)