www.mooseframework.org
Parser.C
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://www.mooseframework.org
3 //*
4 //* All rights reserved, see COPYRIGHT for full restrictions
5 //* https://github.com/idaholab/moose/blob/master/COPYRIGHT
6 //*
7 //* Licensed under LGPL 2.1, please see LICENSE for details
8 //* https://www.gnu.org/licenses/lgpl-2.1.html
9 
10 // MOOSE includes
11 #include "MooseUtils.h"
12 #include "MooseInit.h"
13 #include "InputParameters.h"
14 #include "ActionFactory.h"
15 #include "Action.h"
16 #include "Factory.h"
17 #include "MooseObjectAction.h"
18 #include "ActionWarehouse.h"
19 #include "EmptyAction.h"
20 #include "FEProblem.h"
21 #include "MooseMesh.h"
22 #include "Executioner.h"
23 #include "MooseApp.h"
24 #include "MooseEnum.h"
25 #include "MultiMooseEnum.h"
26 #include "MultiApp.h"
27 #include "GlobalParamsAction.h"
28 #include "SyntaxTree.h"
29 #include "InputFileFormatter.h"
30 #include "YAMLFormatter.h"
31 #include "MooseTypes.h"
32 #include "CommandLine.h"
33 #include "JsonSyntaxTree.h"
34 #include "SystemInfo.h"
35 #include "MooseUtils.h"
36 
37 #include "libmesh/parallel.h"
38 #include "libmesh/fparser.hh"
39 
40 // Regular expression includes
41 #include "pcrecpp.h"
42 
43 // C++ includes
44 #include <string>
45 #include <map>
46 #include <fstream>
47 #include <iomanip>
48 #include <algorithm>
49 #include <cstdlib>
50 
53  _app(app),
54  _factory(app.getFactory()),
55  _action_wh(action_wh),
56  _action_factory(app.getActionFactory()),
57  _syntax(_action_wh.syntax()),
58  _syntax_formatter(nullptr),
59  _sections_read(false),
60  _current_params(nullptr),
61  _current_error_stream(nullptr)
62 {
63 }
64 
66 
67 bool
68 isSectionActive(std::string path, hit::Node * root)
69 {
70  hit::Node * n = root->find(path);
71  while (n)
72  {
73  hit::Node * section = n->parent();
74  if (section)
75  {
76  auto actives = section->find("active");
77  auto inactives = section->find("inactive");
78 
79  // only check current level, not nested ones
80  if (actives && actives->type() == hit::NodeType::Field && actives->parent() == section)
81  {
82  auto vars = section->param<std::vector<std::string>>("active");
83  bool have_var = false;
84  for (auto & var : vars)
85  if (n->path() == hit::pathNorm(var))
86  have_var = true;
87  if (!have_var)
88  return false;
89  }
90  // only check current level, not nested ones
91  if (inactives && inactives->type() == hit::NodeType::Field && inactives->parent() == section)
92  {
93  auto vars = section->param<std::vector<std::string>>("inactive");
94  for (auto & var : vars)
95  if (n->path() == hit::pathNorm(var))
96  return false;
97  }
98  }
99  n = section;
100  }
101  return true;
102 }
103 
104 class DupParamWalker : public hit::Walker
105 {
106 public:
107  DupParamWalker(std::string fname) : _fname(fname) {}
108  void walk(const std::string & fullpath, const std::string & /*nodepath*/, hit::Node * n) override
109  {
110  std::string prefix = n->type() == hit::NodeType::Field ? "parameter" : "section";
111 
112  if (_have.count(fullpath) > 0)
113  {
114  auto existing = _have[fullpath];
115  if (_duplicates.count(fullpath) == 0)
116  {
117  errors.push_back(
118  hit::errormsg(_fname, existing, prefix, " '", fullpath, "' supplied multiple times"));
119  _duplicates.insert(fullpath);
120  }
121  errors.push_back(
122  hit::errormsg(_fname, n, prefix, " '", fullpath, "' supplied multiple times"));
123  }
124  _have[n->fullpath()] = n;
125  }
126 
127  std::vector<std::string> errors;
128 
129 private:
130  std::string _fname;
131  std::set<std::string> _duplicates;
132  std::map<std::string, hit::Node *> _have;
133 };
134 
135 std::vector<std::string>
136 findSimilar(std::string param, std::vector<std::string> options)
137 {
138  std::vector<std::string> candidates;
139  if (options.size() == 0)
140  return candidates;
141 
142  int mindist = MooseUtils::levenshteinDist(options[0], param);
143  for (auto & opt : options)
144  {
145  int dist = MooseUtils::levenshteinDist(opt, param);
146  // magic number heuristics to get similarity distance cutoff
147  int dist_cutoff = 1 + param.size() / 5;
148  if (dist > dist_cutoff || dist > mindist)
149  continue;
150 
151  if (dist < mindist)
152  {
153  mindist = dist;
154  candidates.clear();
155  }
156  candidates.push_back(opt);
157  }
158  return candidates;
159 }
160 
161 std::vector<std::string>
162 Parser::listValidParams(std::string & section_name)
163 {
164  bool dummy;
165  std::string registered_identifier = _syntax.isAssociated(section_name, &dummy);
166  auto iters = _syntax.getActions(registered_identifier);
167 
168  std::vector<std::string> paramlist;
169  for (auto it = iters.first; it != iters.second; ++it)
170  {
171  auto params = _action_factory.getValidParams(it->second._action);
172  for (const auto & it : params)
173  paramlist.push_back(it.first);
174  }
175  return paramlist;
176 }
177 
178 class UnusedWalker : public hit::Walker
179 {
180 public:
181  UnusedWalker(std::string fname, std::set<std::string> used, Parser & p)
182  : _fname(fname), _used(used), _parser(p)
183  {
184  }
185 
186  void walk(const std::string & fullpath, const std::string & nodename, hit::Node * n) override
187  {
188  // the line() > 0 check allows us to skip nodes that were merged into this tree (i.e. CLI
189  // args) because their unused params are checked+reported independently of the ones in the
190  // main tree.
191  if (!_used.count(fullpath) && nodename != "active" && nodename != "inactive" &&
192  isSectionActive(fullpath, n->root()) && n->line() > 0)
193  {
194  auto section_name = fullpath.substr(0, fullpath.rfind("/"));
195  auto paramlist = _parser.listValidParams(section_name);
196  auto candidates = findSimilar(nodename, paramlist);
197  if (candidates.size() > 0)
198  errors.push_back(hit::errormsg(_fname,
199  n,
200  "unused parameter '",
201  fullpath,
202  "'\n",
203  " Did you mean '",
204  candidates[0],
205  "'?"));
206  else
207  errors.push_back(hit::errormsg(_fname, n, "unused parameter '", fullpath, "'"));
208  }
209  }
210 
211  std::vector<std::string> errors;
212 
213 private:
214  std::string _fname;
215  std::set<std::string> _used;
217 };
218 
219 class BadActiveWalker : public hit::Walker
220 {
221 public:
222  BadActiveWalker(std::string fname) : _fname(fname) {}
223  void walk(const std::string & /*fullpath*/,
224  const std::string & /*nodepath*/,
225  hit::Node * section) override
226  {
227  auto actives = section->find("active");
228  auto inactives = section->find("inactive");
229 
230  if (actives && inactives && actives->type() == hit::NodeType::Field &&
231  inactives->type() == hit::NodeType::Field && actives->parent() == inactives->parent())
232  {
233  errors.push_back(hit::errormsg(
234  _fname, section, "'active' and 'inactive' parameters both provided in section"));
235  return;
236  }
237 
238  // ensures we don't recheck deeper nesting levels
239  if (actives && actives->type() == hit::NodeType::Field && actives->parent() == section)
240  {
241  auto vars = section->param<std::vector<std::string>>("active");
242  std::string msg = "";
243  for (auto & var : vars)
244  {
245  if (!section->find(var))
246  msg += var + ", ";
247  }
248  if (msg.size() > 0)
249  {
250  msg = msg.substr(0, msg.size() - 2);
251  errors.push_back(hit::errormsg(_fname,
252  section,
253  "variables listed as active (",
254  msg,
255  ") in section '",
256  section->fullpath(),
257  "' not found in input"));
258  }
259  }
260  // ensures we don't recheck deeper nesting levels
261  if (inactives && inactives->type() == hit::NodeType::Field && inactives->parent() == section)
262  {
263  auto vars = section->param<std::vector<std::string>>("inactive");
264  std::string msg = "";
265  for (auto & var : vars)
266  {
267  if (!section->find(var))
268  msg += var + ", ";
269  }
270  if (msg.size() > 0)
271  {
272  msg = msg.substr(0, msg.size() - 2);
273  errors.push_back(hit::errormsg(_fname,
274  section,
275  "variables listed as inactive (",
276  msg,
277  ") in section '",
278  section->fullpath(),
279  "' not found in input"));
280  }
281  }
282  }
283  std::vector<std::string> errors;
284 
285 private:
286  std::string _fname;
287 };
288 
289 std::string
290 Parser::getFileName(bool stripLeadingPath) const
291 {
292  if (!stripLeadingPath)
293  return _input_filename;
294 
295  std::string filename;
296  size_t pos = _input_filename.find_last_of('/');
297  if (pos != std::string::npos)
298  filename = _input_filename.substr(pos + 1);
299  else
300  filename = _input_filename;
301 
302  return filename;
303 }
304 
305 void
306 Parser::walkRaw(std::string /*fullpath*/, std::string /*nodepath*/, hit::Node * n)
307 {
308  InputParameters active_list_params = validParams<Action>();
310 
311  std::string section_name = n->fullpath();
312  std::string curr_identifier = n->fullpath();
313 
314  // Before we retrieve any actions or build any objects, make sure that the section they are in
315  // is active
316  if (!isSectionActive(curr_identifier, _root.get()))
317  return;
318 
319  // Extract the block parameters before constructing the action
320  // There may be more than one Action registered for a given section in which case we need to
321  // build them all
322  bool is_parent;
323  std::string registered_identifier = _syntax.isAssociated(section_name, &is_parent);
324 
325  // We need to retrieve a list of Actions associated with the current identifier
326  auto iters = _syntax.getActions(registered_identifier);
327  if (iters.first == iters.second)
328  {
329  _errmsg += hit::errormsg(getFileName(),
330  n,
331  "section '",
332  curr_identifier,
333  "' does not have an associated \"Action\".\nDid you misspell it?") +
334  "\n";
335  return;
336  }
337 
338  for (auto it = iters.first; it != iters.second; ++it)
339  {
340  if (is_parent)
341  continue;
342  if (_syntax.isDeprecatedSyntax(registered_identifier))
343  mooseDeprecated(hit::errormsg(
344  getFileName(), n, _syntax.deprecatedActionSyntaxMessage(registered_identifier)));
345 
346  params = _action_factory.getValidParams(it->second._action);
347 
348  params.set<ActionWarehouse *>("awh") = &_action_wh;
349 
350  extractParams(curr_identifier, params);
351 
352  // Add the parsed syntax to the parameters object for consumption by the Action
353  params.set<std::string>("task") = it->second._task;
354  params.set<std::string>("registered_identifier") = registered_identifier;
355  params.blockLocation() = _input_filename + ":" + std::to_string(n->line());
356  params.blockFullpath() = n->fullpath();
357 
358  // Create the Action
359  std::shared_ptr<Action> action_obj =
360  _action_factory.create(it->second._action, MooseUtils::shortName(curr_identifier), params);
361 
362  {
363  // extract the MooseObject params if necessary
364  std::shared_ptr<MooseObjectAction> object_action =
366  if (object_action)
367  {
368  object_action->getObjectParams().blockLocation() = params.blockLocation();
369  object_action->getObjectParams().blockFullpath() = params.blockFullpath();
370  extractParams(curr_identifier, object_action->getObjectParams());
371  object_action->getObjectParams()
372  .set<std::vector<std::string>>("control_tags")
373  .push_back(MooseUtils::baseName(curr_identifier));
374  }
375  }
376 
377  // add it to the warehouse
378  _action_wh.addActionBlock(action_obj);
379  }
380 }
381 
382 void
383 Parser::walk(const std::string & fullpath, const std::string & nodepath, hit::Node * n)
384 {
385  // skip sections that were manually processed first.
386  for (auto & sec : _secs_need_first)
387  if (nodepath == sec)
388  return;
389  walkRaw(fullpath, nodepath, n);
390 }
391 
392 std::string
393 Parser::hitCLIFilter(std::string appname, const std::vector<std::string> & argv)
394 {
395  std::string hit_text;
396  bool afterDoubleDash = false;
397  for (std::size_t i = 1; i < argv.size(); i++)
398  {
399  std::string arg(argv[i]);
400 
401  // all args after a "--" are hit parameters
402  if (arg == "--")
403  {
404  afterDoubleDash = true;
405  continue;
406  } // otherwise try to guess if a hit params have started by looking for "=" and "/"
407  else if (arg.find("=", 0) != std::string::npos)
408  afterDoubleDash = true;
409 
410  // skip arguments with no equals sign
411  if (arg.find("=", 0) == std::string::npos)
412  continue;
413  // skip cli flags (i.e. start with dash)
414  else if (arg.find("-", 0) == 0)
415  continue;
416  // skip over args that don't look like or are before hit parameters
417  else if (!afterDoubleDash)
418  continue;
419  else if (appname == "main")
420  {
421  auto pos = arg.find(":", 0);
422  if (pos == 0) // trim leading colon
423  arg = arg.substr(pos + 1, arg.size() - pos - 1);
424  else if (pos != std::string::npos && pos < arg.find("=", 0)) // param is for non-main subapp
425  continue;
426  }
427  else if (appname != "main") // app we are loading is a multiapp subapp
428  {
429  std::string name;
430  std::string num;
431  pcrecpp::RE("(.*?)" // Match the multiapp name
432  "(\\d+)" // math the multiapp number
433  )
434  .FullMatch(appname, &name, &num);
435  auto pos = arg.find(":", 0);
436  if (pos == 0)
437  ; // cli param is ":" prefixed meaning global for all main+subapps
438  else if (pos == std::string::npos) // param is for main app - skip
439  continue;
440  else if (arg.substr(0, pos) != appname &&
441  arg.substr(0, pos) != name) // param is for different multiapp - skip
442  {
443  _app.commandLine()->markHitParam(i);
444  continue;
445  }
446  arg = arg.substr(pos + 1, arg.size() - pos - 1); // trim off subapp name prefix
447  }
448 
449  try
450  {
451  hit::check("CLI_ARG", arg);
452  hit_text += " " + arg;
453  // handle case where bash ate quotes around an empty string after the "="
454  if (arg.find("=", 0) == arg.size() - 1)
455  hit_text += "''";
456  _app.commandLine()->markHitParamUsed(i);
457  }
458  catch (hit::ParseError & err)
459  {
460  // bash might have eaten quotes around a hit string value or vector
461  // so try quoting after the "=" and reparse
462  auto quoted = arg;
463  auto pos = quoted.find("=", 0);
464  if (pos != std::string::npos)
465  quoted = arg.substr(0, pos + 1) + "'" + arg.substr(pos + 1, quoted.size() - pos) + "'";
466  try
467  {
468  hit::check("CLI_ARG", quoted);
469  hit_text += " " + quoted;
470  _app.commandLine()->markHitParamUsed(i);
471  }
472  catch (hit::ParseError & err)
473  {
474  mooseError("invalid hit in arg '", arg, "': ", err.what());
475  }
476  }
477  }
478  return hit_text;
479 }
480 
481 void
482 Parser::parse(const std::string & input_filename)
483 {
484  // Save the filename
485  char abspath[PATH_MAX + 1];
486  realpath(input_filename.c_str(), abspath);
487  _input_filename = std::string(abspath);
488 
489  // vector for initializing active blocks
490  std::vector<std::string> all = {"__all__"};
491 
493 
494  std::ifstream f(_input_filename);
495  std::string input((std::istreambuf_iterator<char>(f)), std::istreambuf_iterator<char>());
496 
497  try
498  {
499  _root.reset(hit::parse(_input_filename, input));
500  auto cli_input = hitCLIFilter(_app.name(), _app.commandLine()->getArguments());
501 
502  _cli_root.reset(hit::parse("CLI_ARGS", cli_input));
503  hit::explode(_cli_root.get());
504  hit::explode(_root.get());
505  hit::merge(_cli_root.get(), _root.get());
506  }
507  catch (hit::ParseError & err)
508  {
509  mooseError(err.what());
510  }
511 
512  // expand ${bla} parameter values and mark/include variables used in expansions as "used". This
513  // MUST occur before parameter extraction - otherwise parameters will get wrong values.
514  hit::RawEvaler raw;
515  hit::EnvEvaler env;
516  hit::ReplaceEvaler repl;
517  FuncParseEvaler fparse_ev;
518  hit::BraceExpander exw(_input_filename);
519  exw.registerEvaler("raw", raw);
520  exw.registerEvaler("env", env);
521  exw.registerEvaler("fparse", fparse_ev);
522  exw.registerEvaler("replace", repl);
523  _root->walk(&exw);
524  for (auto & var : exw.used)
525  _extracted_vars.insert(var);
526  for (auto & msg : exw.errors)
527  _errmsg += msg + "\n";
528 
529  // do as much error checking as early as possible so that errors are more useful instead
530  // of surprising and disconnected from what caused them.
533  _root->walk(&dw, hit::NodeType::Field);
534  _root->walk(&bw, hit::NodeType::Section);
535  for (auto & msg : dw.errors)
536  _errmsg += msg + "\n";
537  for (auto & msg : bw.errors)
538  _errmsg += msg + "\n";
539 
540  // There are a few order dependent actions that have to be built first in
541  // order for the parser and application to function properly:
542  //
543  // SetupDebugAction: This action can contain an option for monitoring the parser progress. It must
544  // be parsed first to capture all of the parsing output.
545  //
546  // GlobalParamsAction: This action is checked during the parameter extraction routines of all
547  // subsequent blocks. It must be parsed early since it must exist during
548  // subsequent parameter extraction.
549  //
550  // DynamicObjectRegistration: This action must be built before any MooseObjectActions are built.
551  // This is because we retrieve valid parameters from the Factory
552  // during parse time. Objects must be registered before
553  // validParameters can be retrieved.
554  auto syntax = _syntax.getSyntaxByAction("SetupDebugAction");
555  std::copy(syntax.begin(), syntax.end(), std::back_inserter(_secs_need_first));
556 
557  syntax = _syntax.getSyntaxByAction("GlobalParamsAction");
558  std::copy(syntax.begin(), syntax.end(), std::back_inserter(_secs_need_first));
559 
560  syntax = _syntax.getSyntaxByAction("DynamicObjectRegistrationAction");
561  std::copy(syntax.begin(), syntax.end(), std::back_inserter(_secs_need_first));
562 
563  // walk all the sections extracting paramters from each into InputParameters objects
564  for (auto & sec : _secs_need_first)
565  {
566  auto n = _root->find(sec);
567  if (n)
568  walkRaw(n->parent()->fullpath(), n->path(), n);
569  }
570  _root->walk(this, hit::NodeType::Section);
571 
572  if (_errmsg.size() > 0)
574 }
575 
576 // Checks the input and the way it has been used and emits any errors/warnings.
577 // This has to be a separate function because for we don't know if some parameters were unused
578 // until all the multiapps/subapps have been fully initialized - which isn't complete until
579 // *after* all the other member functions on Parser have been run. So this is here to be
580 // externally called at the right time.
581 void
582 Parser::errorCheck(const Parallel::Communicator & comm, bool warn_unused, bool err_unused)
583 {
584  // this if guard is important in case the simulation was not configured via parsed input text -
585  // e.g. configured programatically.
586  if (!_root || !_cli_root)
587  return;
588 
590  UnusedWalker uwcli("CLI_ARG", _extracted_vars, *this);
591 
592  _root->walk(&uw);
593  _cli_root->walk(&uwcli);
594 
595  auto cli = _app.commandLine();
596  if (warn_unused)
597  {
598  for (auto arg : cli->unused(comm))
599  _warnmsg += hit::errormsg("CLI_ARG",
600  nullptr,
601  "unused command line parameter '",
602  cli->getArguments()[arg],
603  "'") +
604  "\n";
605  for (auto & msg : uwcli.errors)
606  _warnmsg += msg + "\n";
607  for (auto & msg : uw.errors)
608  _warnmsg += msg + "\n";
609  }
610  else if (err_unused)
611  {
612  for (auto arg : cli->unused(comm))
613  _errmsg += hit::errormsg("CLI_ARG",
614  nullptr,
615  "unused command line parameter '",
616  cli->getArguments()[arg],
617  "'") +
618  "\n";
619  for (auto & msg : uwcli.errors)
620  _errmsg += msg + "\n";
621  for (auto & msg : uw.errors)
622  _errmsg += msg + "\n";
623  }
624 
625  if (_warnmsg.size() > 0)
627  if (_errmsg.size() > 0)
629 }
630 
631 void
633 {
634  switch (type)
635  {
636  case INPUT_FILE:
637  _syntax_formatter = libmesh_make_unique<InputFileFormatter>(dump_mode);
638  break;
639  case YAML:
640  _syntax_formatter = libmesh_make_unique<YAMLFormatter>(dump_mode);
641  break;
642  default:
643  mooseError("Unrecognized Syntax Formatter requested");
644  break;
645  }
646 }
647 
648 void
650 {
651  std::vector<std::pair<std::string, Syntax::ActionInfo>> all_names;
652 
653  for (const auto & iter : _syntax.getAssociatedTypes())
654  root.addSyntaxType(iter.first, iter.second);
655 
656  for (const auto & iter : _syntax.getAssociatedActions())
657  {
658  Syntax::ActionInfo act_info = iter.second;
664  if (act_info._task == "")
665  act_info._task = _action_factory.getTaskName(act_info._action);
666 
667  all_names.push_back(std::make_pair(iter.first, act_info));
668  }
669 
670  for (const auto & act_names : all_names)
671  {
672  const auto & act_info = act_names.second;
673  const std::string & action = act_info._action;
674  const std::string & task = act_info._task;
675  const std::string act_name = act_names.first;
676  InputParameters action_obj_params = _action_factory.getValidParams(action);
677  bool params_added = root.addParameters("",
678  act_name,
679  false,
680  action,
681  true,
682  &action_obj_params,
683  _syntax.getLineInfo(act_name, action, ""),
684  "");
685 
686  if (params_added)
687  {
688  auto tasks = _action_factory.getTasksByAction(action);
689  for (auto & t : tasks)
690  {
691  auto info = _action_factory.getLineInfo(action, t);
692  root.addActionTask(act_name, action, t, info);
693  }
694  }
695 
701  if (action_obj_params.have_parameter<bool>("isObjectAction") &&
702  action_obj_params.get<bool>("isObjectAction"))
703  {
705  moose_obj != _factory.registeredObjectsEnd();
706  ++moose_obj)
707  {
708  InputParameters moose_obj_params = (moose_obj->second)();
709  // Now that we know that this is a MooseObjectAction we need to see if it has been
710  // restricted
711  // in any way by the user.
712  const std::vector<std::string> & buildable_types = action_obj_params.getBuildableTypes();
713 
714  // See if the current Moose Object syntax belongs under this Action's block
715  if ((buildable_types.empty() || // Not restricted
716  std::find(buildable_types.begin(), buildable_types.end(), moose_obj->first) !=
717  buildable_types.end()) && // Restricted but found
718  moose_obj_params.have_parameter<std::string>("_moose_base") && // Has a registered base
719  _syntax.verifyMooseObjectTask(moose_obj_params.get<std::string>("_moose_base"),
720  task) && // and that base is associated
721  action_obj_params.mooseObjectSyntaxVisibility() && // and the Action says it's visible
722  moose_obj->first.find("<JACOBIAN>") ==
723  std::string::npos) // And it is not a Jacobian templated AD object
724  {
725  std::string name;
726  size_t pos = 0;
727  bool is_action_params = false;
728  bool is_type = false;
729  if (act_name[act_name.size() - 1] == '*')
730  {
731  pos = act_name.size();
732 
733  if (!action_obj_params.collapseSyntaxNesting())
734  name = act_name.substr(0, pos - 1) + moose_obj->first;
735  else
736  {
737  name = act_name.substr(0, pos - 1) + "/<type>/" + moose_obj->first;
738  is_action_params = true;
739  }
740  }
741  else
742  {
743  name = act_name + "/<type>/" + moose_obj->first;
744  is_type = true;
745  }
746 
747  moose_obj_params.set<std::string>("type") = moose_obj->first;
748 
749  auto lineinfo = _factory.getLineInfo(moose_obj->first);
750  std::string classname = _factory.associatedClassName(moose_obj->first);
751  root.addParameters(act_name,
752  name,
753  is_type,
754  moose_obj->first,
755  is_action_params,
756  &moose_obj_params,
757  lineinfo,
758  classname);
759  }
760  }
761  }
762  }
763  root.addGlobal();
764 }
765 
766 void
767 Parser::buildFullTree(const std::string & search_string)
768 {
769  std::vector<std::pair<std::string, Syntax::ActionInfo>> all_names;
770 
771  for (const auto & iter : _syntax.getAssociatedActions())
772  {
773  Syntax::ActionInfo act_info = iter.second;
779  if (act_info._task == "")
780  act_info._task = _action_factory.getTaskName(act_info._action);
781 
782  all_names.push_back(std::pair<std::string, Syntax::ActionInfo>(iter.first, act_info));
783  }
784 
785  for (const auto & act_names : all_names)
786  {
787  InputParameters action_obj_params = _action_factory.getValidParams(act_names.second._action);
788  _syntax_formatter->insertNode(
789  act_names.first, act_names.second._action, true, &action_obj_params);
790 
791  const std::string & task = act_names.second._task;
792  std::string act_name = act_names.first;
793 
799  if (action_obj_params.have_parameter<bool>("isObjectAction") &&
800  action_obj_params.get<bool>("isObjectAction"))
801  {
803  moose_obj != _factory.registeredObjectsEnd();
804  ++moose_obj)
805  {
806  InputParameters moose_obj_params = (moose_obj->second)();
811  const std::vector<std::string> & buildable_types = action_obj_params.getBuildableTypes();
812 
813  // See if the current Moose Object syntax belongs under this Action's block
814  if ((buildable_types.empty() || // Not restricted
815  std::find(buildable_types.begin(), buildable_types.end(), moose_obj->first) !=
816  buildable_types.end()) && // Restricted but found
817  moose_obj_params.have_parameter<std::string>("_moose_base") && // Has a registered base
818  _syntax.verifyMooseObjectTask(moose_obj_params.get<std::string>("_moose_base"),
819  task) && // and that base is associated
820  action_obj_params.mooseObjectSyntaxVisibility() && // and the Action says it's visible
821  moose_obj->first.find("<JACOBIAN>") ==
822  std::string::npos) // And it is not a Jacobian templated AD object
823  {
824  std::string name;
825  size_t pos = 0;
826  bool is_action_params = false;
827  if (act_name[act_name.size() - 1] == '*')
828  {
829  pos = act_name.size();
830 
831  // Remove <RESIDUAL> append for AD objects
832  std::string obj_name = moose_obj->first;
833  removeSubstring(obj_name, "<RESIDUAL>");
834 
835  if (!action_obj_params.collapseSyntaxNesting())
836  name = act_name.substr(0, pos - 1) + obj_name;
837  else
838  {
839  name = act_name.substr(0, pos - 1) + "/<type>/" + moose_obj->first;
840  is_action_params = true;
841  }
842  }
843  else
844  {
845  name = act_name + "/<type>/" + moose_obj->first;
846  }
847 
848  moose_obj_params.set<std::string>("type") = moose_obj->first;
849 
850  _syntax_formatter->insertNode(
851  name, moose_obj->first, is_action_params, &moose_obj_params);
852  }
853  }
854  }
855  }
856 
857  // Do not change to _console, we need this printed to the stdout in all cases
858  Moose::out << _syntax_formatter->print(search_string) << std::flush;
859 }
860 
861 /**************************************************************************************************
862  **************************************************************************************************
863  * Parameter Extraction Routines *
864  **************************************************************************************************
865  **************************************************************************************************/
866 using std::string;
867 
868 // Template Specializations for retrieving special types from the input file
869 template <>
870 void Parser::setScalarParameter<RealVectorValue, RealVectorValue>(
871  const std::string & full_name,
872  const std::string & short_name,
873  InputParameters::Parameter<RealVectorValue> * param,
874  bool in_global,
875  GlobalParamsAction * global_block);
876 
877 template <>
878 void Parser::setScalarParameter<Point, Point>(const std::string & full_name,
879  const std::string & short_name,
880  InputParameters::Parameter<Point> * param,
881  bool in_global,
882  GlobalParamsAction * global_block);
883 
884 template <>
885 void Parser::setScalarParameter<PostprocessorName, PostprocessorName>(
886  const std::string & full_name,
887  const std::string & short_name,
888  InputParameters::Parameter<PostprocessorName> * param,
889  bool in_global,
890  GlobalParamsAction * global_block);
891 
892 template <>
893 void Parser::setScalarParameter<MooseEnum, MooseEnum>(const std::string & full_name,
894  const std::string & short_name,
895  InputParameters::Parameter<MooseEnum> * param,
896  bool in_global,
897  GlobalParamsAction * global_block);
898 
899 template <>
900 void Parser::setScalarParameter<MultiMooseEnum, MultiMooseEnum>(
901  const std::string & full_name,
902  const std::string & short_name,
903  InputParameters::Parameter<MultiMooseEnum> * param,
904  bool in_global,
905  GlobalParamsAction * global_block);
906 
907 template <>
908 void Parser::setScalarParameter<ExecFlagEnum, ExecFlagEnum>(
909  const std::string & full_name,
910  const std::string & short_name,
911  InputParameters::Parameter<ExecFlagEnum> * param,
912  bool in_global,
913  GlobalParamsAction * global_block);
914 
915 template <>
916 void Parser::setScalarParameter<RealTensorValue, RealTensorValue>(
917  const std::string & full_name,
918  const std::string & short_name,
919  InputParameters::Parameter<RealTensorValue> * param,
920  bool in_global,
921  GlobalParamsAction * global_block);
922 
923 // Vectors
924 template <>
925 void Parser::setVectorParameter<RealVectorValue, RealVectorValue>(
926  const std::string & full_name,
927  const std::string & short_name,
928  InputParameters::Parameter<std::vector<RealVectorValue>> * param,
929  bool in_global,
930  GlobalParamsAction * global_block);
931 
932 template <>
933 void
934 Parser::setVectorParameter<Point, Point>(const std::string & full_name,
935  const std::string & short_name,
936  InputParameters::Parameter<std::vector<Point>> * param,
937  bool in_global,
938  GlobalParamsAction * global_block);
939 
940 template <>
941 void Parser::setVectorParameter<MooseEnum, MooseEnum>(
942  const std::string & full_name,
943  const std::string & short_name,
944  InputParameters::Parameter<std::vector<MooseEnum>> * param,
945  bool in_global,
946  GlobalParamsAction * global_block);
947 
948 template <>
949 void Parser::setVectorParameter<VariableName, VariableName>(
950  const std::string & full_name,
951  const std::string & short_name,
952  InputParameters::Parameter<std::vector<VariableName>> * param,
953  bool in_global,
954  GlobalParamsAction * global_block);
955 
956 void
957 Parser::extractParams(const std::string & prefix, InputParameters & p)
958 {
959  std::ostringstream error_stream;
960  static const std::string global_params_task = "set_global_params";
961  static const std::string global_params_block_name =
962  _syntax.getSyntaxByAction("GlobalParamsAction").front();
963 
964  ActionIterator act_iter = _action_wh.actionBlocksWithActionBegin(global_params_task);
965  GlobalParamsAction * global_params_block = nullptr;
966 
967  // We are grabbing only the first
968  if (act_iter != _action_wh.actionBlocksWithActionEnd(global_params_task))
969  global_params_block = dynamic_cast<GlobalParamsAction *>(*act_iter);
970 
971  // Set a pointer to the current InputParameters object being parsed so that it can be referred
972  // to
973  // in the extraction routines
974  _current_params = &p;
975  _current_error_stream = &error_stream;
976  for (const auto & it : p)
977  {
978  bool found = false;
979  bool in_global = false;
980  std::string orig_name = prefix + "/" + it.first;
981  std::string full_name = orig_name;
982 
983  // Mark parameters appearing in the input file or command line
984  if (_root->find(full_name) && _root->find(full_name)->type() == hit::NodeType::Field)
985  {
986  p.set_attributes(it.first, false);
987  _extracted_vars.insert(
988  full_name); // Keep track of all variables extracted from the input file
989  found = true;
990  p.inputLocation(it.first) =
991  _input_filename + ":" + std::to_string(_root->find(full_name)->line());
992  p.paramFullpath(it.first) = full_name;
993  }
994  // Wait! Check the GlobalParams section
995  else if (global_params_block)
996  {
997  full_name = global_params_block_name + "/" + it.first;
998  if (_root->find(full_name))
999  {
1000  p.set_attributes(it.first, false);
1001  _extracted_vars.insert(
1002  full_name); // Keep track of all variables extracted from the input file
1003  found = true;
1004  in_global = true;
1005  p.inputLocation(it.first) =
1006  _input_filename + ":" + std::to_string(_root->find(full_name)->line());
1007  p.paramFullpath(it.first) = full_name;
1008  }
1009  }
1010 
1011  if (!found)
1012  {
1019  // In the case where we have OutFileName but it wasn't actually found in the input filename,
1020  // we will populate it with the actual parsed filename which is available here in the
1021  // parser.
1022 
1023  InputParameters::Parameter<OutFileBase> * scalar_p =
1024  dynamic_cast<InputParameters::Parameter<OutFileBase> *>(it.second);
1025  if (scalar_p)
1026  {
1027  std::string input_file_name = getFileName();
1028  mooseAssert(input_file_name != "", "Input Filename is nullptr");
1029  size_t pos = input_file_name.find_last_of('.');
1030  mooseAssert(pos != std::string::npos, "Unable to determine suffix of input file name");
1031  scalar_p->set() = input_file_name.substr(0, pos) + "_out";
1032  p.set_attributes(it.first, false);
1033  }
1034  }
1035  else
1036  {
1037  if (p.isPrivate(it.first))
1038  mooseError("The parameter '",
1039  full_name,
1040  "' is a private parameter and should not be used in an input file.");
1041 
1042  auto par = it.second;
1043  auto short_name = it.first;
1044 
1045 #define setscalarvaltype(ptype, base, range) \
1046  else if (par->type() == demangle(typeid(ptype).name())) \
1047  setScalarValueTypeParameter<ptype, range, base>( \
1048  full_name, \
1049  short_name, \
1050  dynamic_cast<InputParameters::Parameter<ptype> *>(par), \
1051  in_global, \
1052  global_params_block)
1053 #define setscalar(ptype, base) \
1054  else if (par->type() == demangle(typeid(ptype).name())) \
1055  setScalarParameter<ptype, base>(full_name, \
1056  short_name, \
1057  dynamic_cast<InputParameters::Parameter<ptype> *>(par), \
1058  in_global, \
1059  global_params_block)
1060 #define setfpath(ptype) \
1061  else if (par->type() == demangle(typeid(ptype).name())) \
1062  setFilePathParam<ptype>(full_name, \
1063  short_name, \
1064  dynamic_cast<InputParameters::Parameter<ptype> *>(par), \
1065  p, \
1066  in_global, \
1067  global_params_block)
1068 #define setvector(ptype, base) \
1069  else if (par->type() == demangle(typeid(std::vector<ptype>).name())) \
1070  setVectorParameter<ptype, base>( \
1071  full_name, \
1072  short_name, \
1073  dynamic_cast<InputParameters::Parameter<std::vector<ptype>> *>(par), \
1074  in_global, \
1075  global_params_block)
1076 #define setvectorfpath(ptype) \
1077  else if (par->type() == demangle(typeid(std::vector<ptype>).name())) \
1078  setVectorFilePathParam<ptype>( \
1079  full_name, \
1080  short_name, \
1081  dynamic_cast<InputParameters::Parameter<std::vector<ptype>> *>(par), \
1082  p, \
1083  in_global, \
1084  global_params_block)
1085 #define setvectorvector(ptype) \
1086  else if (par->type() == demangle(typeid(std::vector<std::vector<ptype>>).name())) \
1087  setDoubleIndexParameter<ptype>( \
1088  full_name, \
1089  short_name, \
1090  dynamic_cast<InputParameters::Parameter<std::vector<std::vector<ptype>>> *>(par), \
1091  in_global, \
1092  global_params_block)
1093 
1097  // built-ins
1098  // NOTE: Similar dynamic casting is done in InputParameters.C, please update appropriately
1099  if (false)
1100  ;
1101  setscalarvaltype(Real, double, Real);
1102  setscalarvaltype(int, int, long);
1103  setscalarvaltype(unsigned short, unsigned int, long);
1104  setscalarvaltype(long, int, long);
1105  setscalarvaltype(unsigned int, unsigned int, long);
1106  setscalarvaltype(unsigned long, unsigned int, long);
1107  setscalarvaltype(long int, int64_t, long);
1108  setscalarvaltype(unsigned long long, unsigned int, long);
1109 
1110  setscalar(bool, bool);
1111  setscalar(SubdomainID, int);
1112  setscalar(BoundaryID, int);
1113 
1114  // string and string-subclass types
1115  setscalar(string, string);
1116  setscalar(SubdomainName, string);
1117  setscalar(BoundaryName, string);
1118  setfpath(FileName);
1119  setfpath(MeshFileName);
1120  setfpath(FileNameNoExtension);
1121  setscalar(OutFileBase, string);
1122  setscalar(VariableName, string);
1123  setscalar(NonlinearVariableName, string);
1124  setscalar(AuxVariableName, string);
1125  setscalar(FunctionName, string);
1126  setscalar(UserObjectName, string);
1127  setscalar(VectorPostprocessorName, string);
1128  setscalar(IndicatorName, string);
1129  setscalar(MarkerName, string);
1130  setscalar(MultiAppName, string);
1131  setscalar(OutputName, string);
1132  setscalar(MaterialPropertyName, string);
1133  setscalar(MaterialName, string);
1134  setscalar(DistributionName, string);
1135  setscalar(SamplerName, string);
1136  setscalar(TagName, string);
1137  setscalar(MeshGeneratorName, string);
1138 
1139  setscalar(PostprocessorName, PostprocessorName);
1140 
1141  // Moose Compound Scalars
1142  setscalar(RealVectorValue, RealVectorValue);
1143  setscalar(Point, Point);
1144  setscalar(MooseEnum, MooseEnum);
1145  setscalar(MultiMooseEnum, MultiMooseEnum);
1146  setscalar(RealTensorValue, RealTensorValue);
1147  setscalar(ExecFlagEnum, ExecFlagEnum);
1148 
1149  // vector types
1150  setvector(Real, double);
1151  setvector(int, int);
1152  setvector(long, int);
1153  setvector(unsigned int, int);
1154 
1155 // We need to be able to parse 8-byte unsigned types when
1156 // libmesh is configured --with-dof-id-bytes=8. Officially,
1157 // libmesh uses uint64_t in that scenario, which is usually
1158 // equivalent to 'unsigned long long'. Note that 'long long'
1159 // has been around since C99 so most C++ compilers support it,
1160 // but presumably uint64_t is the "most standard" way to get a
1161 // 64-bit unsigned type, so we'll stick with that here.
1162 #if LIBMESH_DOF_ID_BYTES == 8
1163  setvector(uint64_t, int);
1164 #endif
1165 
1166  setvector(SubdomainID, int);
1167  setvector(BoundaryID, int);
1168  setvector(RealVectorValue, double);
1169  setvector(Point, Point);
1170  setvector(MooseEnum, MooseEnum);
1171 
1172  setvector(string, string);
1173  setvectorfpath(FileName);
1174  setvectorfpath(FileNameNoExtension);
1175  setvectorfpath(MeshFileName);
1176  setvector(SubdomainName, string);
1177  setvector(BoundaryName, string);
1178  setvector(NonlinearVariableName, string);
1179  setvector(AuxVariableName, string);
1180  setvector(FunctionName, string);
1181  setvector(UserObjectName, string);
1182  setvector(IndicatorName, string);
1183  setvector(MarkerName, string);
1184  setvector(MultiAppName, string);
1185  setvector(PostprocessorName, string);
1186  setvector(VectorPostprocessorName, string);
1187  setvector(OutputName, string);
1188  setvector(MaterialPropertyName, string);
1189  setvector(MaterialName, string);
1190  setvector(DistributionName, string);
1191  setvector(SamplerName, string);
1192  setvector(TagName, string);
1193  setvector(VariableName, VariableName);
1194  setvector(MeshGeneratorName, string);
1195 
1196  // Double indexed types
1197  setvectorvector(Real);
1198  setvectorvector(int);
1199  setvectorvector(long);
1200  setvectorvector(unsigned int);
1201  setvectorvector(unsigned long long);
1202 
1203 // See vector type explanation
1204 #if LIBMESH_DOF_ID_BYTES == 8
1205  setvectorvector(uint64_t);
1206 #endif
1207 
1208  setvectorvector(SubdomainID);
1209  setvectorvector(BoundaryID);
1210  setvectorvector(string);
1211  setvectorvector(FileName);
1212  setvectorvector(FileNameNoExtension);
1213  setvectorvector(MeshFileName);
1214  setvectorvector(SubdomainName);
1215  setvectorvector(BoundaryName);
1216  setvectorvector(VariableName);
1217  setvectorvector(NonlinearVariableName);
1218  setvectorvector(AuxVariableName);
1219  setvectorvector(FunctionName);
1220  setvectorvector(UserObjectName);
1221  setvectorvector(IndicatorName);
1222  setvectorvector(MarkerName);
1223  setvectorvector(MultiAppName);
1224  setvectorvector(PostprocessorName);
1225  setvectorvector(VectorPostprocessorName);
1226  setvectorvector(MarkerName);
1227  setvectorvector(OutputName);
1228  setvectorvector(MaterialPropertyName);
1229  setvectorvector(MaterialName);
1230  setvectorvector(DistributionName);
1231  setvectorvector(SamplerName);
1232  else
1233  {
1234  mooseError("unsupported type '", par->type(), "' for input parameter '", full_name, "'");
1235  }
1236 
1237 #undef setscalarValueType
1238 #undef setscalar
1239 #undef setvector
1240 #undef setvectorvector
1241  }
1242  }
1243 
1244  // All of the parameters for this object have been extracted. See if there are any errors
1245  if (!error_stream.str().empty())
1246  mooseError(error_stream.str());
1247 
1248  // Here we will see if there are any auto build vectors that need to be created
1249  std::map<std::string, std::pair<std::string, std::string>> auto_build_vectors =
1250  p.getAutoBuildVectors();
1251  for (const auto & it : auto_build_vectors)
1252  {
1253  // We'll autogenerate values iff the requested vector is not valid but both the base and
1254  // number
1255  // are valid
1256  const std::string & base_name = it.second.first;
1257  const std::string & num_repeat = it.second.second;
1258 
1259  if (!p.isParamValid(it.first) && p.isParamValid(base_name) && p.isParamValid(num_repeat))
1260  {
1261  unsigned int vec_size = p.get<unsigned int>(num_repeat);
1262  const std::string & name = p.get<std::string>(base_name);
1263 
1264  std::vector<VariableName> variable_names(vec_size);
1265  for (unsigned int i = 0; i < vec_size; ++i)
1266  {
1267  std::ostringstream oss;
1268  oss << name << i;
1269  variable_names[i] = oss.str();
1270  }
1271 
1272  // Finally set the autogenerated vector into the InputParameters object
1273  p.set<std::vector<VariableName>>(it.first) = variable_names;
1274  }
1275  }
1276 }
1277 
1278 template <typename T>
1279 bool
1280 toBool(const std::string & /*s*/, T & /*val*/)
1281 {
1282  return false;
1283 }
1284 
1285 template <>
1286 bool
1287 toBool<bool>(const std::string & s, bool & val)
1288 {
1289  return hit::toBool(s, &val);
1290 }
1291 
1292 template <typename T, typename Base>
1293 void
1294 Parser::setScalarParameter(const std::string & full_name,
1295  const std::string & short_name,
1296  InputParameters::Parameter<T> * param,
1297  bool in_global,
1298  GlobalParamsAction * global_block)
1299 {
1300 
1301  try
1302  {
1303  param->set() = _root->param<Base>(full_name);
1304  }
1305  catch (hit::Error & err)
1306  {
1307  auto strval = _root->param<std::string>(full_name);
1308 
1309  // handle the case where the user put a number inside quotes
1310  auto & t = typeid(T);
1311  if (t == typeid(int) || t == typeid(unsigned int) || t == typeid(SubdomainID) ||
1312  t == typeid(BoundaryID) || t == typeid(double))
1313  {
1314  try
1315  {
1316  param->set() = MooseUtils::convert<T>(strval, true);
1317  }
1318  catch (std::invalid_argument & /*e*/)
1319  {
1320  const std::string format_type = (t == typeid(double)) ? "float" : "integer";
1321  _errmsg += hit::errormsg(_input_filename,
1322  _root->find(full_name),
1323  "invalid ",
1324  format_type,
1325  " syntax for parameter: ",
1326  full_name,
1327  "=",
1328  strval) +
1329  "\n";
1330  }
1331  }
1332  else if (t == typeid(bool))
1333  {
1334  bool isbool = toBool(strval, param->set());
1335  if (!isbool)
1336  _errmsg += hit::errormsg(_input_filename,
1337  _root->find(full_name),
1338  "invalid boolean syntax for parameter: ",
1339  full_name,
1340  "=",
1341  strval) +
1342  "\n";
1343  }
1344  else
1345  throw;
1346  }
1347 
1348  if (in_global)
1349  {
1350  global_block->remove(short_name);
1351  global_block->setScalarParam<T>(short_name) = param->get();
1352  }
1353 }
1354 
1355 template <typename T>
1356 void
1357 Parser::setFilePathParam(const std::string & full_name,
1358  const std::string & short_name,
1359  InputParameters::Parameter<T> * param,
1360  InputParameters & params,
1361  bool in_global,
1362  GlobalParamsAction * global_block)
1363 {
1364  std::string prefix;
1365  std::string postfix = _root->param<std::string>(full_name);
1366  size_t pos = _input_filename.find_last_of('/');
1367  if (pos != std::string::npos && postfix[0] != '/' && !postfix.empty())
1368  prefix = _input_filename.substr(0, pos + 1);
1369 
1370  params.rawParamVal(short_name) = postfix;
1371  param->set() = prefix + postfix;
1372 
1373  if (in_global)
1374  {
1375  global_block->remove(short_name);
1376  global_block->setScalarParam<T>(short_name) = param->get();
1377  }
1378 }
1379 
1380 template <typename T, typename UP_T, typename Base>
1381 void
1382 Parser::setScalarValueTypeParameter(const std::string & full_name,
1383  const std::string & short_name,
1384  InputParameters::Parameter<T> * param,
1385  bool in_global,
1386  GlobalParamsAction * global_block)
1387 {
1388  setScalarParameter<T, Base>(full_name, short_name, param, in_global, global_block);
1389 
1390  // If this is a range checked param, we need to make sure that the value falls within the
1391  // requested range
1392  mooseAssert(_current_params, "Current params is nullptr");
1393 
1394  _current_params->rangeCheck<T, UP_T>(full_name, short_name, param, *_current_error_stream);
1395 }
1396 
1397 template <typename T, typename Base>
1398 void
1399 Parser::setVectorParameter(const std::string & full_name,
1400  const std::string & short_name,
1401  InputParameters::Parameter<std::vector<T>> * param,
1402  bool in_global,
1403  GlobalParamsAction * global_block)
1404 {
1405  std::vector<T> vec;
1406  if (_root->find(full_name))
1407  {
1408  try
1409  {
1410  auto tmp = _root->param<std::vector<Base>>(full_name);
1411  for (auto val : tmp)
1412  vec.push_back(val);
1413  }
1414  catch (hit::Error & err)
1415  {
1416  _errmsg += hit::errormsg(_input_filename, _root->find(full_name), err.what()) + "\n";
1417  return;
1418  }
1419  }
1420 
1421  param->set() = vec;
1422 
1423  if (in_global)
1424  {
1425  global_block->remove(short_name);
1426  global_block->setVectorParam<T>(short_name).resize(param->get().size());
1427  for (unsigned int i = 0; i < vec.size(); ++i)
1428  global_block->setVectorParam<T>(short_name)[i] = param->get()[i];
1429  }
1430 }
1431 
1432 template <typename T>
1433 void
1434 Parser::setVectorFilePathParam(const std::string & full_name,
1435  const std::string & short_name,
1436  InputParameters::Parameter<std::vector<T>> * param,
1437  InputParameters & params,
1438  bool in_global,
1439  GlobalParamsAction * global_block)
1440 {
1441  std::vector<T> vec;
1442  std::vector<std::string> rawvec;
1443  if (_root->find(full_name))
1444  {
1445  auto tmp = _root->param<std::vector<std::string>>(full_name);
1446  params.rawParamVal(short_name) = _root->param<std::string>(full_name);
1447  for (auto val : tmp)
1448  {
1449  std::string prefix;
1450  std::string postfix = val;
1451  size_t pos = _input_filename.find_last_of('/');
1452  if (pos != std::string::npos && postfix[0] != '/')
1453  prefix = _input_filename.substr(0, pos + 1);
1454  rawvec.push_back(postfix);
1455  vec.push_back(prefix + postfix);
1456  }
1457  }
1458 
1459  param->set() = vec;
1460 
1461  if (in_global)
1462  {
1463  global_block->remove(short_name);
1464  global_block->setVectorParam<T>(short_name).resize(param->get().size());
1465  for (unsigned int i = 0; i < vec.size(); ++i)
1466  global_block->setVectorParam<T>(short_name)[i] = param->get()[i];
1467  }
1468 }
1469 
1470 template <typename T>
1471 void
1472 Parser::setDoubleIndexParameter(const std::string & full_name,
1473  const std::string & short_name,
1474  InputParameters::Parameter<std::vector<std::vector<T>>> * param,
1475  bool in_global,
1476  GlobalParamsAction * global_block)
1477 {
1478  // Get the full string assigned to the variable full_name
1479  std::string buffer = _root->param<std::string>(full_name);
1480 
1481  // split vector at delim ;
1482  // NOTE: the substrings are _not_ of type T yet
1483  std::vector<std::string> first_tokenized_vector;
1484  MooseUtils::tokenize(buffer, first_tokenized_vector, 1, ";");
1485  param->set().resize(first_tokenized_vector.size());
1486 
1487  for (unsigned j = 0; j < first_tokenized_vector.size(); ++j)
1488  if (!MooseUtils::tokenizeAndConvert<T>(first_tokenized_vector[j], param->set()[j]))
1489  {
1490  _errmsg +=
1491  hit::errormsg(
1492  _input_filename, _root->find(full_name), "invalid format for parameter ", full_name) +
1493  "\n";
1494  return;
1495  }
1496 
1497  if (in_global)
1498  {
1499  global_block->remove(short_name);
1500  global_block->setDoubleIndexParam<T>(short_name).resize(first_tokenized_vector.size());
1501  for (unsigned j = 0; j < first_tokenized_vector.size(); ++j)
1502  {
1503  global_block->setDoubleIndexParam<T>(short_name)[j].resize(param->get()[j].size());
1504  for (unsigned int i = 0; i < param->get()[j].size(); ++i)
1505  global_block->setDoubleIndexParam<T>(short_name)[j][i] = param->get()[j][i];
1506  }
1507  }
1508 }
1509 
1510 template <typename T>
1511 void
1512 Parser::setScalarComponentParameter(const std::string & full_name,
1513  const std::string & short_name,
1514  InputParameters::Parameter<T> * param,
1515  bool in_global,
1516  GlobalParamsAction * global_block)
1517 {
1518  std::vector<double> vec;
1519  try
1520  {
1521  vec = _root->param<std::vector<double>>(full_name);
1522  }
1523  catch (hit::Error & err)
1524  {
1525  _errmsg += hit::errormsg(_input_filename, _root->find(full_name), err.what()) + "\n";
1526  return;
1527  }
1528 
1529  if (vec.size() != LIBMESH_DIM)
1530  {
1531  _errmsg += hit::errormsg(_input_filename,
1532  _root->find(full_name),
1533  "wrong number of values in scalar component parameter ",
1534  full_name,
1535  ": size ",
1536  vec.size(),
1537  " is not a multiple of ",
1538  LIBMESH_DIM) +
1539  "\n";
1540  return;
1541  }
1542 
1543  T value;
1544  for (unsigned int i = 0; i < vec.size(); ++i)
1545  value(i) = Real(vec[i]);
1546 
1547  param->set() = value;
1548  if (in_global)
1549  {
1550  global_block->remove(short_name);
1551  global_block->setScalarParam<T>(short_name) = value;
1552  }
1553 }
1554 
1555 template <typename T>
1556 void
1557 Parser::setVectorComponentParameter(const std::string & full_name,
1558  const std::string & short_name,
1559  InputParameters::Parameter<std::vector<T>> * param,
1560  bool in_global,
1561  GlobalParamsAction * global_block)
1562 {
1563  std::vector<double> vec;
1564  try
1565  {
1566  vec = _root->param<std::vector<double>>(full_name);
1567  }
1568  catch (hit::Error & err)
1569  {
1570  _errmsg += hit::errormsg(_input_filename, _root->find(full_name), err.what()) + "\n";
1571  return;
1572  }
1573 
1574  if (vec.size() % LIBMESH_DIM)
1575  {
1576  _errmsg += hit::errormsg(_input_filename,
1577  _root->find(full_name),
1578  "wrong number of values in vector component parameter ",
1579  full_name,
1580  ": size ",
1581  vec.size(),
1582  " is not a multiple of ",
1583  LIBMESH_DIM) +
1584  "\n";
1585  return;
1586  }
1587 
1588  std::vector<T> values;
1589  for (unsigned int i = 0; i < vec.size() / LIBMESH_DIM; ++i)
1590  {
1591  T value;
1592  for (int j = 0; j < LIBMESH_DIM; ++j)
1593  value(j) = Real(vec[i * LIBMESH_DIM + j]);
1594  values.push_back(value);
1595  }
1596 
1597  param->set() = values;
1598 
1599  if (in_global)
1600  {
1601  global_block->remove(short_name);
1602  global_block->setVectorParam<T>(short_name).resize(vec.size(), values[0]);
1603  for (unsigned int i = 0; i < vec.size() / LIBMESH_DIM; ++i)
1604  global_block->setVectorParam<T>(short_name)[i] = values[0];
1605  }
1606 }
1607 
1608 template <>
1609 void
1610 Parser::setScalarParameter<RealVectorValue, RealVectorValue>(
1611  const std::string & full_name,
1612  const std::string & short_name,
1613  InputParameters::Parameter<RealVectorValue> * param,
1614  bool in_global,
1615  GlobalParamsAction * global_block)
1616 {
1617  setScalarComponentParameter(full_name, short_name, param, in_global, global_block);
1618 }
1619 
1620 template <>
1621 void
1622 Parser::setScalarParameter<Point, Point>(const std::string & full_name,
1623  const std::string & short_name,
1624  InputParameters::Parameter<Point> * param,
1625  bool in_global,
1626  GlobalParamsAction * global_block)
1627 {
1628  setScalarComponentParameter(full_name, short_name, param, in_global, global_block);
1629 }
1630 
1631 template <>
1632 void
1633 Parser::setScalarParameter<MooseEnum, MooseEnum>(const std::string & full_name,
1634  const std::string & short_name,
1635  InputParameters::Parameter<MooseEnum> * param,
1636  bool in_global,
1637  GlobalParamsAction * global_block)
1638 {
1639  MooseEnum current_param = param->get();
1640 
1641  std::string value = _root->param<std::string>(full_name);
1642 
1643  param->set() = value;
1644  if (in_global)
1645  {
1646  global_block->remove(short_name);
1647  global_block->setScalarParam<MooseEnum>(short_name) = current_param;
1648  }
1649 }
1650 
1651 template <>
1652 void
1653 Parser::setScalarParameter<MultiMooseEnum, MultiMooseEnum>(
1654  const std::string & full_name,
1655  const std::string & short_name,
1656  InputParameters::Parameter<MultiMooseEnum> * param,
1657  bool in_global,
1658  GlobalParamsAction * global_block)
1659 {
1660  MultiMooseEnum current_param = param->get();
1661 
1662  auto vec = _root->param<std::vector<std::string>>(full_name);
1663 
1664  std::string raw_values;
1665  for (unsigned int i = 0; i < vec.size(); ++i)
1666  raw_values += ' ' + vec[i];
1667 
1668  param->set() = raw_values;
1669 
1670  if (in_global)
1671  {
1672  global_block->remove(short_name);
1673  global_block->setScalarParam<MultiMooseEnum>(short_name) = current_param;
1674  }
1675 }
1676 
1677 template <>
1678 void
1679 Parser::setScalarParameter<ExecFlagEnum, ExecFlagEnum>(
1680  const std::string & full_name,
1681  const std::string & short_name,
1682  InputParameters::Parameter<ExecFlagEnum> * param,
1683  bool in_global,
1684  GlobalParamsAction * global_block)
1685 {
1686  ExecFlagEnum current_param = param->get();
1687  auto vec = _root->param<std::vector<std::string>>(full_name);
1688 
1689  std::string raw_values;
1690  for (unsigned int i = 0; i < vec.size(); ++i)
1691  raw_values += ' ' + vec[i];
1692 
1693  param->set() = raw_values;
1694 
1695  if (in_global)
1696  {
1697  global_block->remove(short_name);
1698  global_block->setScalarParam<ExecFlagEnum>(short_name) = current_param;
1699  }
1700 }
1701 
1702 template <>
1703 void
1704 Parser::setScalarParameter<RealTensorValue, RealTensorValue>(
1705  const std::string & full_name,
1706  const std::string & short_name,
1707  InputParameters::Parameter<RealTensorValue> * param,
1708  bool in_global,
1709  GlobalParamsAction * global_block)
1710 {
1711  auto vec = _root->param<std::vector<double>>(full_name);
1712  if (vec.size() != LIBMESH_DIM * LIBMESH_DIM)
1713  {
1714  _errmsg += hit::errormsg(_input_filename,
1715  _root->find(full_name),
1716  "invalid RealTensorValue parameter ",
1717  full_name,
1718  ": size is ",
1719  vec.size(),
1720  " but should be ",
1721  LIBMESH_DIM * LIBMESH_DIM) +
1722  "\n";
1723  return;
1724  }
1725 
1726  RealTensorValue value;
1727  for (int i = 0; i < LIBMESH_DIM; ++i)
1728  for (int j = 0; j < LIBMESH_DIM; ++j)
1729  value(i, j) = Real(vec[i * LIBMESH_DIM + j]);
1730 
1731  param->set() = value;
1732  if (in_global)
1733  {
1734  global_block->remove(short_name);
1735  global_block->setScalarParam<RealTensorValue>(short_name) = value;
1736  }
1737 }
1738 
1739 // Specialization for coupling a Real value where a postprocessor would be needed in MOOSE
1740 template <>
1741 void
1742 Parser::setScalarParameter<PostprocessorName, PostprocessorName>(
1743  const std::string & full_name,
1744  const std::string & short_name,
1745  InputParameters::Parameter<PostprocessorName> * param,
1746  bool in_global,
1747  GlobalParamsAction * global_block)
1748 {
1749  PostprocessorName pps_name = _root->param<std::string>(full_name);
1750  param->set() = pps_name;
1751 
1752  Real real_value = -std::numeric_limits<Real>::max();
1753  std::istringstream ss(pps_name);
1754 
1755  if (ss >> real_value && ss.eof())
1756  _current_params->setDefaultPostprocessorValue(short_name, real_value);
1757 
1758  if (in_global)
1759  {
1760  global_block->remove(short_name);
1761  global_block->setScalarParam<PostprocessorName>(short_name) = pps_name;
1762  }
1763 }
1764 
1765 template <>
1766 void
1767 Parser::setVectorParameter<RealVectorValue, RealVectorValue>(
1768  const std::string & full_name,
1769  const std::string & short_name,
1770  InputParameters::Parameter<std::vector<RealVectorValue>> * param,
1771  bool in_global,
1772  GlobalParamsAction * global_block)
1773 {
1774  setVectorComponentParameter(full_name, short_name, param, in_global, global_block);
1775 }
1776 
1777 template <>
1778 void
1779 Parser::setVectorParameter<Point, Point>(const std::string & full_name,
1780  const std::string & short_name,
1781  InputParameters::Parameter<std::vector<Point>> * param,
1782  bool in_global,
1783  GlobalParamsAction * global_block)
1784 {
1785  setVectorComponentParameter(full_name, short_name, param, in_global, global_block);
1786 }
1787 
1788 template <>
1789 void
1790 Parser::setVectorParameter<MooseEnum, MooseEnum>(
1791  const std::string & full_name,
1792  const std::string & short_name,
1793  InputParameters::Parameter<std::vector<MooseEnum>> * param,
1794  bool in_global,
1795  GlobalParamsAction * global_block)
1796 {
1797  std::vector<MooseEnum> enum_values = param->get();
1798  std::vector<std::string> values(enum_values.size());
1799  for (unsigned int i = 0; i < values.size(); ++i)
1800  values[i] = static_cast<std::string>(enum_values[i]);
1801 
1806  std::vector<std::string> vec;
1807  if (_root->find(full_name))
1808  {
1809  vec = _root->param<std::vector<std::string>>(full_name);
1810  param->set().resize(vec.size(), enum_values[0]);
1811  }
1812 
1813  for (unsigned int i = 0; i < vec.size(); ++i)
1814  param->set()[i] = vec[i];
1815 
1816  if (in_global)
1817  {
1818  global_block->remove(short_name);
1819  global_block->setVectorParam<MooseEnum>(short_name).resize(vec.size(), enum_values[0]);
1820  for (unsigned int i = 0; i < vec.size(); ++i)
1821  global_block->setVectorParam<MooseEnum>(short_name)[i] = values[0];
1822  }
1823 }
1824 
1829 template <>
1830 void
1831 Parser::setVectorParameter<VariableName, VariableName>(
1832  const std::string & full_name,
1833  const std::string & short_name,
1834  InputParameters::Parameter<std::vector<VariableName>> * param,
1835  bool /*in_global*/,
1836  GlobalParamsAction * /*global_block*/)
1837 {
1838  auto vec = _root->param<std::vector<std::string>>(full_name);
1839  auto strval = _root->param<std::string>(full_name);
1840  std::vector<VariableName> var_names(vec.size());
1841 
1842  bool has_var_names = false;
1843  for (unsigned int i = 0; i < vec.size(); ++i)
1844  {
1845  VariableName var_name = vec[i];
1846 
1847  Real real_value;
1848  std::istringstream ss(var_name);
1849 
1850  // If we are able to convert this value into a Real, then set a default coupled value
1851  // NOTE: parameter must be either all default or no defaults
1852  if (ss >> real_value && ss.eof())
1853  _current_params->defaultCoupledValue(short_name, real_value, i);
1854  else
1855  {
1856  var_names[i] = var_name;
1857  has_var_names = true;
1858  }
1859  }
1860 
1861  if (has_var_names)
1862  {
1863  param->set().resize(vec.size());
1864 
1865  for (unsigned int i = 0; i < vec.size(); ++i)
1866  if (var_names[i] == "")
1867  {
1868  _errmsg +=
1869  hit::errormsg(
1870  _input_filename,
1871  _root->find(full_name),
1872  "invalid value for ",
1873  full_name,
1874  ":\n"
1875  " MOOSE does not currently support a coupled vector where some parameters are ",
1876  "reals and others are variables") +
1877  "\n";
1878  return;
1879  }
1880  else
1881  param->set()[i] = var_names[i];
1882  }
1883 }
const std::string & name() const
Get the name of the object.
Definition: MooseApp.h:73
void setScalarParameter(const std::string &full_name, const std::string &short_name, InputParameters::Parameter< T > *param, bool in_global, GlobalParamsAction *global_block)
Helper functions for setting parameters of arbitrary types - bodies are in the .C file since they are...
Definition: Parser.C:1294
void addSyntaxType(const std::string &path, const std::string type)
Add an associated type to a block.
void setScalarValueTypeParameter(const std::string &full_name, const std::string &short_name, InputParameters::Parameter< T > *param, bool in_global, GlobalParamsAction *global_block)
Definition: Parser.C:1382
const std::multimap< std::string, std::string > & getAssociatedTypes() const
Get a multimap of registered associations of syntax with type.
Definition: Syntax.C:304
std::pair< std::multimap< std::string, ActionInfo >::const_iterator, std::multimap< std::string, ActionInfo >::const_iterator > getActions(const std::string &syntax) const
Returns a pair of multimap iterators to all the ActionInfo objects associated with a given piece of s...
Definition: Syntax.C:280
A MultiMooseEnum object to hold "execute_on" flags.
Definition: ExecFlagEnum.h:24
MooseApp & _app
The MooseApp this Parser is part of.
Definition: Parser.h:238
void walkRaw(std::string fullpath, std::string nodepath, hit::Node *n)
Definition: Parser.C:306
InputParameters validParams< EmptyAction >()
Definition: EmptyAction.C:20
void tokenize(const std::string &str, std::vector< T > &elements, unsigned int min_len=1, const std::string &delims="/")
This function will split the passed in string on a set of delimiters appending the substrings to the ...
Definition: MooseUtils.h:428
std::string & rawParamVal(const std::string &param)
Get/set a string representing the raw, unmodified token text for the given param. ...
bool toBool< bool >(const std::string &s, bool &val)
Definition: Parser.C:1287
std::list< Action * >::iterator ActionIterator
alias to hide implementation details
const std::multimap< std::string, ActionInfo > & getAssociatedActions() const
Return all Syntax to Action associations.
Definition: Syntax.C:310
std::string _warnmsg
Definition: Parser.h:268
std::vector< std::string > errors
Definition: Parser.C:283
registeredMooseObjectIterator registeredObjectsEnd()
Access to registered object iterator (end)
Definition: Factory.h:338
void mooseObjectSyntaxVisibility(bool visibility)
Mutators for controlling whether or not the outermost level of syntax will be collapsed when printed...
VectorValue< Real > RealVectorValue
Definition: Assembly.h:31
InputParameters getValidParams(const std::string &name)
Definition: ActionFactory.C:70
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:207
void addActionTask(const std::string &path, const std::string &action, const std::string &task, const FileLineInfo &lineinfo)
Add a task to the tree.
std::shared_ptr< CommandLine > commandLine() const
Get the command line.
Definition: MooseApp.h:300
std::set< std::string > _used
Definition: Parser.C:215
std::string associatedClassName(const std::string &name) const
Get the associated class name for an object name.
Definition: Factory.C:298
std::vector< std::string > _secs_need_first
Definition: Parser.h:235
SyntaxFormatterType
Definition: Parser.h:100
std::set< std::string > getTasksByAction(const std::string &action) const
const std::vector< std::string > & getBuildableTypes() const
Returns the list of buildable types as a std::vector<std::string>
FileLineInfo getLineInfo(const std::string &syntax, const std::string &action, const std::string &task) const
Gets the file and line where the syntax/action/task combo was registered.
Definition: Syntax.C:316
T & set(const std::string &name, bool quiet_mode=false)
Returns a writable reference to the named parameters.
Parser & _parser
Definition: Parser.C:216
Base class for MOOSE-based applications.
Definition: MooseApp.h:59
Storage for action instances.
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
void walk(const std::string &fullpath, const std::string &nodepath, hit::Node *n)
Definition: Parser.C:383
virtual ~Parser()
Definition: Parser.C:65
void addActionBlock(std::shared_ptr< Action > blk)
This method add an Action instance to the warehouse.
FileLineInfo getLineInfo(const std::string &name, const std::string &task) const
Gets file and line information where an action was registered.
std::unique_ptr< T_DEST, T_DELETER > dynamic_pointer_cast(std::unique_ptr< T_SRC, T_DELETER > &src)
These are reworked from https://stackoverflow.com/a/11003103.
void extractParams(const std::string &prefix, InputParameters &p)
This function attempts to extract values from the input file based on the contents of the passed para...
Definition: Parser.C:957
Syntax & _syntax
Reference to an object that defines input file syntax.
Definition: Parser.h:246
std::map< std::string, paramsPtr >::iterator registeredMooseObjectIterator
alias for registered Object iterator
Definition: Factory.h:138
std::string hitCLIFilter(std::string appname, const std::vector< std::string > &argv)
Definition: Parser.C:393
bool isSectionActive(std::string path, hit::Node *root)
Definition: Parser.C:68
std::set< std::string > _duplicates
Definition: Parser.C:131
std::vector< T > & setVectorParam(const std::string &name)
Holds the syntax in a Json::Value tree.
std::vector< std::vector< T > > & setDoubleIndexParam(const std::string &name)
std::string _action
Definition: Syntax.h:25
FileLineInfo getLineInfo(const std::string &name) const
Gets file and line information where an object was initially registered.
Definition: Factory.C:286
std::vector< std::string > getSyntaxByAction(const std::string &action, const std::string &task="")
Retrieve the syntax associated with the passed in action type string.
Definition: Syntax.C:192
std::string shortName(const std::string &name)
Function for stripping name after the file / in parser block.
Definition: MooseUtils.C:363
std::string _input_filename
The input file name that is used for parameter extraction.
Definition: Parser.h:252
bool checkFileReadable(const std::string &filename, bool check_line_endings=false, bool throw_on_unreadable=true)
Checks to see if a file is readable (exists and permissions)
Definition: MooseUtils.C:146
bool isDeprecatedSyntax(const std::string &syntax) const
Returns a Boolean indicating whether the syntax has been deprecated through a call to deprecateAction...
Definition: Syntax.C:186
std::string _fname
Definition: Parser.C:130
void initSyntaxFormatter(SyntaxFormatterType type, bool dump_mode)
Creates a syntax formatter for printing.
Definition: Parser.C:632
std::unique_ptr< hit::Node > _cli_root
Definition: Parser.h:233
std::string isAssociated(const std::string &real_id, bool *is_parent) const
Method for determining whether a piece of syntax is associated with an Action TODO: I need a better n...
Definition: Syntax.C:218
std::vector< std::string > listValidParams(std::string &section_name)
Definition: Parser.C:162
InputParameters & getObjectParams()
Retreive the parameters of the object to be created by this action.
BadActiveWalker(std::string fname)
Definition: Parser.C:222
void setDoubleIndexParameter(const std::string &full_name, const std::string &short_name, InputParameters::Parameter< std::vector< std::vector< T >>> *param, bool in_global, GlobalParamsAction *global_block)
Template method for setting any double indexed type parameter read from the input file or command lin...
Definition: Parser.C:1472
bool addParameters(const std::string &parent_path, const std::string &path, bool is_type, const std::string &action, bool is_action, InputParameters *params, const FileLineInfo &lineinfo, const std::string &classname)
Add parameters to the tree.
void mooseUnused(Args &&... args)
Warning message used to notify the users of unused parts of their input files Really used internally ...
Definition: MooseError.h:228
std::map< std::string, hit::Node * > _have
Definition: Parser.C:132
boundary_id_type BoundaryID
T & setScalarParam(const std::string &name)
An inteface for the _console for outputting to the Console object.
void setVectorParameter(const std::string &full_name, const std::string &short_name, InputParameters::Parameter< std::vector< T >> *param, bool in_global, GlobalParamsAction *global_block)
Template method for setting any vector type parameter read from the input file or command line...
Definition: Parser.C:1399
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type It sho...
Definition: MooseEnum.h:31
void mooseDeprecated(Args &&... args)
Emit a deprecated code/feature message with the given stringified, concatenated args.
Definition: MooseError.h:236
subdomain_id_type SubdomainID
std::vector< std::string > errors
Definition: Parser.C:211
std::unique_ptr< SyntaxTree > _syntax_formatter
Object for holding the syntax parse tree.
Definition: Parser.h:249
Parser(MooseApp &app, ActionWarehouse &action_wh)
Definition: Parser.C:51
std::string _errmsg
Definition: Parser.h:267
std::set< std::string > _extracted_vars
The set of all variables extracted from the input file.
Definition: Parser.h:255
void rangeCheck(const std::string &full_name, const std::string &short_name, InputParameters::Parameter< T > *param, std::ostream &oss=Moose::out)
Runs a range on the supplied parameter if it exists and throws an error if that check fails...
registeredMooseObjectIterator registeredObjectsBegin()
Access to registered object iterator (begin)
Definition: Factory.h:333
void setVectorComponentParameter(const std::string &full_name, const std::string &short_name, InputParameters::Parameter< std::vector< T >> *param, bool in_global, GlobalParamsAction *global_block)
Template method for setting several multivalue "scalar" type parameter read from the input file or co...
Definition: Parser.C:1557
ActionWarehouse & _action_wh
Action warehouse that will be filled by actions.
Definition: Parser.h:242
std::string getTaskName(const std::string &action)
Definition: ActionFactory.C:90
std::ostringstream * _current_error_stream
The current stream object used for capturing errors during extraction.
Definition: Parser.h:264
void setVectorFilePathParam(const std::string &full_name, const std::string &short_name, InputParameters::Parameter< std::vector< T >> *param, InputParameters &params, bool in_global, GlobalParamsAction *global_block)
Sets an input parameter representing a vector of file paths using input file data.
Definition: Parser.C:1434
std::string _task
Definition: Syntax.h:26
void removeSubstring(std::string &main, const std::string &sub)
find, erase, length algorithm for removing a substring from a string
Definition: MooseUtils.C:915
MatType type
std::string baseName(const std::string &name)
Function for string the information before the final / in a parser block.
Definition: MooseUtils.C:369
unsigned int get(unsigned int i) const
Indexing operator Operator to retrieve an item from the MultiMooseEnum.
void walk(const std::string &fullpath, const std::string &, hit::Node *n) override
Definition: Parser.C:108
PetscInt n
DupParamWalker(std::string fname)
Definition: Parser.C:107
std::unique_ptr< hit::Node > _root
Definition: Parser.h:234
void setFilePathParam(const std::string &full_name, const std::string &short_name, InputParameters::Parameter< T > *param, InputParameters &params, bool in_global, GlobalParamsAction *global_block)
Sets an input parameter representing a file path using input file data.
Definition: Parser.C:1357
void errorCheck(const Parallel::Communicator &comm, bool warn_unused, bool err_unused)
Definition: Parser.C:582
std::string getFileName(bool stripLeadingPath=true) const
Return the filename that was parsed.
Definition: Parser.C:290
MPI_Comm comm
std::shared_ptr< Action > create(const std::string &action, const std::string &action_name, InputParameters parameters)
Definition: ActionFactory.C:41
void addGlobal()
Add the global section to the output.
int levenshteinDist(const std::string &s1, const std::string &s2)
Computes and returns the Levenshtein distance between strings s1 and s2.
Definition: MooseUtils.C:64
bool verifyMooseObjectTask(const std::string &base, const std::string &task) const
Returns a Boolean indicating whether a task is associated with on of the MOOSE pluggable systems (BAS...
Definition: Syntax.C:286
ActionIterator actionBlocksWithActionEnd(const std::string &task)
InputParameters * _current_params
The current parameter object for which parameters are being extracted.
Definition: Parser.h:261
void buildJsonSyntaxTree(JsonSyntaxTree &tree) const
Use MOOSE Factories to construct a parameter tree for documentation or echoing input.
Definition: Parser.C:649
void walk(const std::string &fullpath, const std::string &nodename, hit::Node *n) override
Definition: Parser.C:186
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type It sho...
bool toBool(const std::string &, T &)
Definition: Parser.C:1280
UnusedWalker(std::string fname, std::set< std::string > used, Parser &p)
Definition: Parser.C:181
std::string deprecatedActionSyntaxMessage(const std::string syntax)
Returns the deprecation message for a given syntax that has been deprecated by deprecateActionSyntax...
Definition: Syntax.C:175
ActionIterator actionBlocksWithActionBegin(const std::string &task)
Iterators to the Actions in the warehouse.
void collapseSyntaxNesting(bool collapse)
Mutators for controlling whether or not the outermost level of syntax will be collapsed when printed...
TensorValue< Real > RealTensorValue
Definition: MooseTypes.h:132
void setScalarComponentParameter(const std::string &full_name, const std::string &short_name, InputParameters::Parameter< T > *param, bool in_global, GlobalParamsAction *global_block)
Template method for setting any multivalue "scalar" type parameter read from the input file or comman...
Definition: Parser.C:1512
Factory & _factory
The Factory associated with that MooseApp.
Definition: Parser.h:240
ActionFactory & _action_factory
The Factory that builds actions.
Definition: Parser.h:244
std::vector< std::string > findSimilar(std::string param, std::vector< std::string > options)
Definition: Parser.C:136
std::string & blockLocation()
Get/set a string representing the location (i.e.
void parse(const std::string &input_filename)
Parse an input file consisting of hit syntax and setup objects in the MOOSE derived application...
Definition: Parser.C:482
std::string _fname
Definition: Parser.C:214
Class for parsing input files.
Definition: Parser.h:97
std::vector< std::string > errors
Definition: Parser.C:127
void walk(const std::string &, const std::string &, hit::Node *section) override
Definition: Parser.C:223
InputParameters validParams< Action >()
Definition: Action.C:22
void buildFullTree(const std::string &search_string)
Use MOOSE Factories to construct a full parse tree for documentation or echoing input.
Definition: Parser.C:767
std::string _fname
Definition: Parser.C:286
void remove(const std::string &name)
This function is here to remove parameters of a type so that global parameters can potentially use th...