www.mooseframework.org
MooseApp.C
Go to the documentation of this file.
1 /****************************************************************/
2 /* DO NOT MODIFY THIS HEADER */
3 /* MOOSE - Multiphysics Object Oriented Simulation Environment */
4 /* */
5 /* (c) 2010 Battelle Energy Alliance, LLC */
6 /* ALL RIGHTS RESERVED */
7 /* */
8 /* Prepared by Battelle Energy Alliance, LLC */
9 /* Under Contract No. DE-AC07-05ID14517 */
10 /* With the U. S. Department of Energy */
11 /* */
12 /* See COPYRIGHT for full restrictions */
13 /****************************************************************/
14 
15 // MOOSE includes
16 #include "MooseApp.h"
17 #include "MooseRevision.h"
18 #include "AppFactory.h"
19 #include "MooseSyntax.h"
20 #include "MooseInit.h"
21 #include "Executioner.h"
22 #include "PetscSupport.h"
23 #include "Conversion.h"
24 #include "CommandLine.h"
25 #include "InfixIterator.h"
26 #include "MultiApp.h"
27 #include "MeshModifier.h"
28 #include "DependencyResolver.h"
29 #include "MooseUtils.h"
30 #include "MooseObjectAction.h"
32 #include "SystemInfo.h"
33 #include "RestartableDataIO.h"
34 #include "MooseMesh.h"
35 #include "FileOutput.h"
36 #include "ConsoleUtils.h"
37 #include "JsonSyntaxTree.h"
38 #include "JsonInputFileFormatter.h"
39 #include "SONDefinitionFormatter.h"
40 
41 // Regular expression includes
42 #include "pcrecpp.h"
43 
44 #include "libmesh/exodusII_io.h"
45 #include "libmesh/mesh_refinement.h"
46 #include "libmesh/string_to_enum.h"
47 
48 // System include for dynamic library methods
49 #include <dlfcn.h>
50 #include <sys/utsname.h> // utsname
51 
52 // C++ includes
53 #include <numeric> // std::accumulate
54 #include <fstream>
55 
56 #define QUOTE(macro) stringifyName(macro)
57 
58 template <>
61 {
62  InputParameters params;
63 
64  params.addCommandLineParam<bool>(
65  "display_version", "-v --version", false, "Print application version");
66  params.addCommandLineParam<std::string>("input_file", "-i <input_file>", "Specify an input file");
67  params.addCommandLineParam<std::string>(
68  "mesh_only",
69  "--mesh-only [mesh_file_name]",
70  "Setup and Output the input mesh only (Default: \"<input_file_name>_in.e\")");
71 
72  params.addCommandLineParam<bool>("show_input",
73  "--show-input",
74  false,
75  "Shows the parsed input file before running the simulation.");
76  params.addCommandLineParam<bool>(
77  "show_outputs", "--show-outputs", false, "Shows the output execution time information.");
78  params.addCommandLineParam<bool>(
79  "show_controls", "--show-controls", false, "Shows the Control logic available and executed.");
80 
81  params.addCommandLineParam<bool>(
82  "no_color", "--no-color", false, "Disable coloring of all Console outputs.");
83  params.addCommandLineParam<std::string>("color",
84  "--color [auto,on,off]",
85  "default-on",
86  "Whether to use color in console output (default 'on').");
87 
88  params.addCommandLineParam<bool>("help", "-h --help", false, "Displays CLI usage statement.");
89  params.addCommandLineParam<bool>(
90  "minimal",
91  "--minimal",
92  false,
93  "Ignore input file and build a minimal application with Transient executioner.");
94 
95  params.addCommandLineParam<std::string>(
96  "definition", "--definition", "Shows a SON style input definition dump for input validation");
97  params.addCommandLineParam<std::string>(
98  "dump", "--dump [search_string]", "Shows a dump of available input file syntax.");
99  params.addCommandLineParam<std::string>(
100  "yaml", "--yaml", "Dumps input file syntax in YAML format.");
101  params.addCommandLineParam<std::string>(
102  "json", "--json", "Dumps input file syntax in JSON format.");
103  params.addCommandLineParam<bool>(
104  "syntax", "--syntax", false, "Dumps the associated Action syntax paths ONLY");
105  params.addCommandLineParam<bool>("check_input",
106  "--check-input",
107  false,
108  "Check the input file (i.e. requires -i <filename>) and quit.");
109  params.addCommandLineParam<bool>(
110  "list_constructed_objects",
111  "--list-constructed-objects",
112  false,
113  "List all moose object type names constructed by the master app factory.");
114 
115  params.addCommandLineParam<unsigned int>(
116  "n_threads", "--n-threads=<n>", 1, "Runs the specified number of threads per process");
117 
118  params.addCommandLineParam<bool>(
119  "warn_unused", "-w --warn-unused", false, "Warn about unused input file options");
120  params.addCommandLineParam<bool>("error_unused",
121  "-e --error-unused",
122  false,
123  "Error when encountering unused input file options");
124  params.addCommandLineParam<bool>(
125  "error_override",
126  "-o --error-override",
127  false,
128  "Error when encountering overridden or parameters supplied multiple times");
129  params.addCommandLineParam<bool>(
130  "error_deprecated", "--error-deprecated", false, "Turn deprecated code messages into Errors");
131  params.addCommandLineParam<bool>(
132  "allow_deprecated",
133  "--allow-deprecated",
134  false,
135  "Can be used in conjunction with --error to turn off deprecated errors");
136 
137  params.addCommandLineParam<bool>(
138  "distributed_mesh",
139  "--distributed-mesh",
140  false,
141  "The libMesh Mesh underlying MooseMesh should always be a DistributedMesh");
142 
143  params.addCommandLineParam<unsigned int>(
144  "refinements",
145  "-r <n>",
146  0,
147  "Specify additional initial uniform refinements for automatic scaling");
148 
149  params.addCommandLineParam<std::string>("recover",
150  "--recover [file_base]",
151  "Continue the calculation. If file_base is omitted then "
152  "the most recent recovery file will be utilized");
153 
154  params.addCommandLineParam<std::string>("recoversuffix",
155  "--recoversuffix [suffix]",
156  "Use a different file extension, other than cpr, "
157  "for a recovery file");
158 
159  params.addCommandLineParam<bool>("half_transient",
160  "--half-transient",
161  false,
162  "When true the simulation will only run half of "
163  "its specified transient (ie half the "
164  "timesteps). This is useful for testing "
165  "recovery and restart");
166 
167  // No default on these two options, they must not both be valid
168  params.addCommandLineParam<bool>(
169  "trap_fpe",
170  "--trap-fpe",
171  "Enable Floating Point Exception handling in critical sections of "
172  "code. This is enabled automatically in DEBUG mode");
173  params.addCommandLineParam<bool>("no_trap_fpe",
174  "--no-trap-fpe",
175  "Disable Floating Point Exception handling in critical "
176  "sections of code when using DEBUG mode.");
177 
178  params.addCommandLineParam<bool>("error", "--error", false, "Turn all warnings into errors");
179 
180  params.addCommandLineParam<bool>(
181  "timing",
182  "-t --timing",
183  false,
184  "Enable all performance logging for timing purposes. This will disable all "
185  "screen output of performance logs for all Console objects.");
186  params.addCommandLineParam<bool>("no_timing",
187  "--no-timing",
188  false,
189  "Disabled performance logging. Overrides -t or --timing "
190  "if passed in conjunction with this flag");
191 
192  params.addCommandLineParam<bool>(
193  "allow_test_objects", "--allow-test-objects", false, "Register test objects and syntax.");
194 
195  // Options ignored by MOOSE but picked up by libMesh, these are here so that they are displayed in
196  // the application help
197  params.addCommandLineParam<bool>(
198  "keep_cout",
199  "--keep-cout",
200  false,
201  "Keep standard output from all processors when running in parallel");
202  params.addCommandLineParam<bool>(
203  "redirect_stdout",
204  "--redirect-stdout",
205  false,
206  "Keep standard output from all processors when running in parallel");
207 
208  params.addPrivateParam<std::string>("_app_name"); // the name passed to AppFactory::create
209  params.addPrivateParam<std::string>("_type");
210  params.addPrivateParam<int>("_argc");
211  params.addPrivateParam<char **>("_argv");
212  params.addPrivateParam<std::shared_ptr<CommandLine>>("_command_line");
213  params.addPrivateParam<std::shared_ptr<Parallel::Communicator>>("_comm");
214  params.addPrivateParam<unsigned int>("_multiapp_level");
215  params.addPrivateParam<unsigned int>("_multiapp_number");
216 
217  return params;
218 }
219 
221  : ConsoleStreamInterface(*this),
222  ParallelObject(*parameters.get<std::shared_ptr<Parallel::Communicator>>(
223  "_comm")), // Can't call getParam() before pars is set
224  _name(parameters.get<std::string>("_app_name")),
225  _pars(parameters),
226  _type(getParam<std::string>("_type")),
227  _comm(getParam<std::shared_ptr<Parallel::Communicator>>("_comm")),
228  _output_position_set(false),
229  _start_time_set(false),
230  _start_time(0.0),
231  _global_time_offset(0.0),
232  _output_warehouse(*this),
233  _input_parameter_warehouse(new InputParameterWarehouse()),
234  _action_factory(*this),
235  _action_warehouse(*this, _syntax, _action_factory),
236  _parser(*this, _action_warehouse),
237  _use_nonlinear(true),
238  _use_eigen_value(false),
239  _enable_unused_check(WARN_UNUSED),
240  _factory(*this),
241  _error_overridden(false),
242  _ready_to_exit(false),
243  _initial_from_file(false),
244  _distributed_mesh_on_command_line(false),
245  _recover(false),
246  _restart(false),
247  _recover_suffix("cpr"),
248  _half_transient(false),
249  _check_input(getParam<bool>("check_input")),
250  _restartable_data(libMesh::n_threads()),
251  _multiapp_level(
252  isParamValid("_multiapp_level") ? parameters.get<unsigned int>("_multiapp_level") : 0),
253  _multiapp_number(
254  isParamValid("_multiapp_number") ? parameters.get<unsigned int>("_multiapp_number") : 0)
255 {
256  if (isParamValid("_argc") && isParamValid("_argv"))
257  {
258  int argc = getParam<int>("_argc");
259  char ** argv = getParam<char **>("_argv");
260 
261  _sys_info = libmesh_make_unique<SystemInfo>(argc, argv);
262  }
263  if (isParamValid("_command_line"))
264  _command_line = getParam<std::shared_ptr<CommandLine>>("_command_line");
265  else
266  mooseError("Valid CommandLine object required");
267 
268  if (getParam<bool>("error_deprecated") && getParam<bool>("allow_deprecated"))
269  mooseError("Both error deprecated and allowed deprecated were set.");
270 }
271 
273 {
275  _executioner.reset();
276 
278 
279 #ifdef LIBMESH_HAVE_DLOPEN
280  // Close any open dynamic libraries
281  for (const auto & it : _lib_handles)
282  dlclose(it.second);
283 #endif
284 }
285 
286 std::string
288 {
289  return MOOSE_VERSION;
290 }
291 
292 std::string
294 {
295  return MOOSE_VERSION;
296 }
297 
298 std::string
300 {
301  return getPrintableName() + " Version: " + getVersion();
302 }
303 
304 void
306 {
307  // Print the header, this is as early as possible
308  std::string hdr(header() + "\n");
309  if (multiAppLevel() > 0)
311  Moose::out << hdr << std::flush;
312 
313  if (getParam<bool>("error_unused"))
314  setCheckUnusedFlag(true);
315  else if (getParam<bool>("warn_unused"))
316  setCheckUnusedFlag(false);
317 
318  if (getParam<bool>("error_override"))
320 
321  _distributed_mesh_on_command_line = getParam<bool>("distributed_mesh");
322 
323  _half_transient = getParam<bool>("half_transient");
324 
325  // The no_timing flag takes precedence over the timing flag.
326  if (getParam<bool>("no_timing"))
327  _pars.set<bool>("timing") = false;
328 
329  if (isParamValid("trap_fpe") && isParamValid("no_trap_fpe"))
330  mooseError("Cannot use both \"--trap-fpe\" and \"--no-trap-fpe\" flags.");
331  if (isParamValid("trap_fpe"))
332  Moose::_trap_fpe = true;
333  else if (isParamValid("no_trap_fpe"))
334  Moose::_trap_fpe = false;
335 
336  // Turn all warnings in MOOSE to errors (almost see next logic block)
337  Moose::_warnings_are_errors = getParam<bool>("error");
338 
344  if (getParam<bool>("error_deprecated") ||
345  (Moose::_warnings_are_errors && !getParam<bool>("allow_deprecated")))
347  else
349 
350  if (isUltimateMaster()) // makes sure coloring isn't reset incorrectly in multi-app settings
351  {
352  // Toggle the color console off
353  Moose::setColorConsole(true, true); // set default color condition
354  if (getParam<bool>("no_color"))
355  Moose::setColorConsole(false);
356 
357  char * c_color = std::getenv("MOOSE_COLOR");
358  std::string color = "on";
359  if (c_color)
360  color = c_color;
361  if (getParam<std::string>("color") != "default-on")
362  color = getParam<std::string>("color");
363 
364  if (color == "auto")
366  else if (color == "on")
367  Moose::setColorConsole(true, true);
368  else if (color == "off")
369  Moose::setColorConsole(false);
370  else
371  mooseWarning("ignoring invalid --color arg (want 'auto', 'on', or 'off')");
372  }
373 
374  // this warning goes below --color processing to honor that setting for
375  // the warning. And below settings for warnings/error setup.
376  if (getParam<bool>("no_color"))
377  mooseDeprecated("The --no-color flag is deprecated. Use '--color off' instead.");
378 
379 // If there's no threading model active, but the user asked for
380 // --n-threads > 1 on the command line, throw a mooseError. This is
381 // intended to prevent situations where the user has potentially
382 // built MOOSE incorrectly (neither TBB nor pthreads found) and is
383 // asking for multiple threads, not knowing that there will never be
384 // any threads launched.
385 #if !LIBMESH_USING_THREADS
386  if (libMesh::command_line_value("--n-threads", 1) > 1)
387  mooseError("You specified --n-threads > 1, but there is no threading model active!");
388 #endif
389 
390  // Build a minimal running application, ignoring the input file.
391  if (getParam<bool>("minimal"))
393 
394  else if (getParam<bool>("display_version"))
395  {
396  Moose::perf_log.disable_logging();
397  Moose::out << getPrintableVersion() << std::endl;
398  _ready_to_exit = true;
399  return;
400  }
401  else if (getParam<bool>("help"))
402  {
403  Moose::perf_log.disable_logging();
404 
405  _command_line->printUsage();
406  _ready_to_exit = true;
407  }
408  else if (isParamValid("dump"))
409  {
410  Moose::perf_log.disable_logging();
411 
412  // Get command line argument following --dump on command line
413  std::string following_arg = getParam<std::string>("dump");
414 
415  // The argument following --dump is a parameter search string,
416  // which can be empty.
417  std::string param_search;
418  if (!following_arg.empty() && (following_arg.find('-') != 0))
419  param_search = following_arg;
420 
421  JsonSyntaxTree tree(param_search);
423  JsonInputFileFormatter formatter;
424  Moose::out << "### START DUMP DATA ###\n"
425  << formatter.toString(tree.getRoot()) << "\n### END DUMP DATA ###\n";
426  _ready_to_exit = true;
427  }
428  else if (isParamValid("definition"))
429  {
430  Moose::perf_log.disable_logging();
431  JsonSyntaxTree tree("");
433  SONDefinitionFormatter formatter;
434  Moose::out << formatter.toString(tree.getRoot()) << "\n";
435  _ready_to_exit = true;
436  }
437  else if (isParamValid("yaml"))
438  {
439  Moose::perf_log.disable_logging();
440 
442 
443  // Get command line argument following --yaml on command line
444  std::string yaml_following_arg = getParam<std::string>("yaml");
445 
446  // If the argument following --yaml is non-existent or begins with
447  // a dash, call buildFullTree() with an empty string, otherwise
448  // pass the argument following --yaml.
449  if (yaml_following_arg.empty() || (yaml_following_arg.find('-') == 0))
451  else
452  _parser.buildFullTree(yaml_following_arg);
453 
454  _ready_to_exit = true;
455  }
456  else if (isParamValid("json"))
457  {
458  Moose::perf_log.disable_logging();
459 
460  // Get command line argument following --json on command line
461  std::string json_following_arg = getParam<std::string>("json");
462 
463  // The argument following --json is a parameter search string,
464  // which can be empty.
465  std::string search;
466  if (!json_following_arg.empty() && (json_following_arg.find('-') != 0))
467  search = json_following_arg;
468 
469  JsonSyntaxTree tree(search);
471 
472  Moose::out << "**START JSON DATA**\n" << tree.getRoot() << "\n**END JSON DATA**\n";
473  _ready_to_exit = true;
474  }
475  else if (getParam<bool>("syntax"))
476  {
477  Moose::perf_log.disable_logging();
478 
479  std::multimap<std::string, Syntax::ActionInfo> syntax = _syntax.getAssociatedActions();
480  Moose::out << "**START SYNTAX DATA**\n";
481  for (const auto & it : syntax)
482  Moose::out << it.first << "\n";
483  Moose::out << "**END SYNTAX DATA**\n" << std::endl;
484  _ready_to_exit = true;
485  }
486  else if (_input_filename != "" ||
487  isParamValid("input_file")) // They already specified an input filename
488  {
489  if (_input_filename == "")
490  _input_filename = getParam<std::string>("input_file");
491 
492  if (isParamValid("recover"))
493  {
494  // We need to set the flag manually here since the recover parameter is a string type (takes
495  // an optional filename)
496  _recover = true;
497 
498  // Get command line argument following --recover on command line
499  std::string recover_following_arg = getParam<std::string>("recover");
500 
501  // If the argument following --recover is non-existent or begins with
502  // a dash then we are going to eventually find the newest recovery file to use
503  if (!(recover_following_arg.empty() || (recover_following_arg.find('-') == 0)))
504  _recover_base = recover_following_arg;
505  }
506 
507  // Optionally get command line argument following --recoversuffix
508  // on command line. Currently this argument applies to both
509  // recovery and restart files.
510  if (isParamValid("recoversuffix"))
511  {
512  _recover_suffix = getParam<std::string>("recoversuffix");
513  }
514 
517  }
518  else
519  {
520  Moose::perf_log.disable_logging();
521 
522  if (_check_input)
523  mooseError("You specified --check-input, but did not provide an input file. Add -i "
524  "<inputfile> to your command line.");
525 
526  _command_line->printUsage();
527  _ready_to_exit = true;
528  }
529 }
530 
531 void
532 MooseApp::setInputFileName(std::string input_filename)
533 {
534  _input_filename = input_filename;
535 }
536 
537 std::string
539 {
540  return _output_file_base;
541 }
542 
543 void
545 {
546  std::string mesh_file_name;
547  if (!_ready_to_exit && isParamValid("mesh_only"))
548  {
549  meshOnly(getParam<std::string>("mesh_only"));
550  _ready_to_exit = true;
551  }
552 
553  // If ready to exit has been set, then just return
554  if (_ready_to_exit)
555  return;
556 
558 
559  if (getParam<bool>("list_constructed_objects"))
560  {
561  // TODO: ask multiapps for their constructed objects
562  std::vector<std::string> obj_list = _factory.getConstructedObjects();
563  Moose::out << "**START OBJECT DATA**\n";
564  for (const auto & name : obj_list)
565  Moose::out << name << "\n";
566  Moose::out << "**END OBJECT DATA**\n" << std::endl;
567  _ready_to_exit = true;
568  return;
569  }
570 }
571 
572 void
574 {
575  bool warn = _enable_unused_check == WARN_UNUSED;
576  bool err = _enable_unused_check == ERROR_UNUSED;
577  _parser.errorCheck(*_comm, warn, err);
578 
579  auto apps = _executioner->feProblem().getMultiAppWarehouse().getObjects();
580  for (auto app : apps)
581  for (unsigned int i = 0; i < app->numLocalApps(); i++)
582  app->localApp(i)->errorCheck();
583 }
584 
585 void
587 {
588  // If ready to exit has been set, then just return
589  if (_ready_to_exit)
590  return;
591 
592  // run the simulation
593  if (_executioner)
594  {
595 #ifdef LIBMESH_HAVE_PETSC
597 #endif
598 
599  _executioner->init();
600  errorCheck();
601  _executioner->execute();
602  }
603  else
604  mooseError("No executioner was specified (go fix your input file)");
605 }
606 
607 bool
609 {
610  return _recover;
611 }
612 
613 bool
615 {
616  return _restart;
617 }
618 
619 bool
621 {
622  return !_recover_base.empty();
623 }
624 
625 void
626 MooseApp::meshOnly(std::string mesh_file_name)
627 {
633  _action_warehouse.executeActionsWithAction("set_global_params");
635  _action_warehouse.executeActionsWithAction("add_partitioner");
638  _action_warehouse.executeActionsWithAction("add_mesh_modifier");
639  _action_warehouse.executeActionsWithAction("execute_mesh_modifiers");
640  _action_warehouse.executeActionsWithAction("uniform_refine_mesh");
641  _action_warehouse.executeActionsWithAction("setup_mesh_complete");
642 
643  std::shared_ptr<MooseMesh> & mesh = _action_warehouse.mesh();
644 
645  // If no argument specified or if the argument following --mesh-only starts
646  // with a dash, try to build an output filename based on the input mesh filename.
647  if (mesh_file_name.empty() || (mesh_file_name.find('-') == 0))
648  {
649  mesh_file_name = _parser.getFileName();
650  size_t pos = mesh_file_name.find_last_of('.');
651 
652  // Default to writing out an ExodusII mesh base on the input filename.
653  mesh_file_name = mesh_file_name.substr(0, pos) + "_in.e";
654  }
655 
656  // If we're writing an Exodus file, write the Mesh using its logical
657  // element dimension rather than the spatial dimension, unless it's
658  // a 1D Mesh. One reason to prefer this approach is that sidesets
659  // are displayed incorrectly for 2D triangular elements in both
660  // Paraview and Cubit if num_dim==3 in the Exodus file. We do the
661  // same thing in MOOSE's Exodus Output object, so we are mimicking
662  // that behavior here.
663  if (mesh_file_name.find(".e") + 2 == mesh_file_name.size())
664  {
665  ExodusII_IO exio(mesh->getMesh());
666  if (mesh->getMesh().mesh_dimension() != 1)
667  exio.use_mesh_dimension_instead_of_spatial_dimension(true);
668 
669  exio.write(mesh_file_name);
670  }
671  else
672  {
673  // Just write the file using the name requested by the user.
674  mesh->getMesh().write(mesh_file_name);
675  }
676 }
677 
678 void
680 {
681  _recoverable_data.insert(name);
682 }
683 
684 std::shared_ptr<Backup>
686 {
687  FEProblemBase & fe_problem = _executioner->feProblem();
688 
689  RestartableDataIO rdio(fe_problem);
690 
691  return rdio.createBackup();
692 }
693 
694 void
695 MooseApp::restore(std::shared_ptr<Backup> backup, bool for_restart)
696 {
697  // This means that a Backup is coming through to use for restart / recovery
698  // We should just cache it for now
699  if (!_executioner)
700  {
702  return;
703  }
704 
705  FEProblemBase & fe_problem = _executioner->feProblem();
706 
707  RestartableDataIO rdio(fe_problem);
708 
709  rdio.restoreBackup(backup, for_restart);
710 }
711 
712 void
713 MooseApp::setCheckUnusedFlag(bool warn_is_error)
714 {
721  if (_enable_unused_check != ERROR_UNUSED || warn_is_error)
722  _enable_unused_check = warn_is_error ? ERROR_UNUSED : WARN_UNUSED;
723  else
724  mooseInfo("Ignoring request to turn off or warn about unused parameters.\n");
725 }
726 
727 void
729 {
731 }
732 
733 void
735 {
736  _error_overridden = true;
737 }
738 
739 void
741 {
742  Moose::perf_log.push("Full Runtime", "Application");
743 
744  Moose::perf_log.push("Application Setup", "Setup");
745  try
746  {
747  setupOptions();
748  runInputFile();
749  }
750  catch (std::exception & err)
751  {
752  mooseError(err.what());
753  }
754  Moose::perf_log.pop("Application Setup", "Setup");
755 
756  if (!_check_input)
758  else
759  {
760  errorCheck();
761  // Output to stderr, so it is easier for peacock to get the result
762  Moose::err << "Syntax OK" << std::endl;
763  }
764 
765  Moose::perf_log.pop("Full Runtime", "Application");
766 }
767 
768 void
770 {
771  _output_position_set = true;
772  _output_position = p;
774 
775  if (_executioner.get() != NULL)
776  _executioner->parentOutputPositionChanged();
777 }
778 
779 std::list<std::string>
781 {
782  // Extract the CommonOutputAction
783  const auto & common_actions = _action_warehouse.getActionListByName("common_output");
784  mooseAssert(common_actions.size() == 1, "Should be only one common_output Action");
785 
786  const Action * common = *common_actions.begin();
787 
788  // Storage for the directory names
789  std::list<std::string> checkpoint_dirs;
790 
791  // If file_base is set in CommonOutputAction, add this file to the list of potential checkpoint
792  // files
793  if (common->isParamValid("file_base"))
794  checkpoint_dirs.push_back(common->getParam<std::string>("file_base") + "_cp");
795  // Case for normal application or master in a Multiapp setting
796  else if (getOutputFileBase().empty())
797  checkpoint_dirs.push_back(FileOutput::getOutputFileBase(*this, "_out_cp"));
798  // Case for a sub app in a Multiapp setting
799  else
800  checkpoint_dirs.push_back(getOutputFileBase() + "_cp");
801 
802  // Add the directories from any existing checkpoint objects
803  const auto & actions = _action_warehouse.getActionListByName("add_output");
804  for (const auto & action : actions)
805  {
806  // Get the parameters from the MooseObjectAction
807  MooseObjectAction * moose_object_action = static_cast<MooseObjectAction *>(action);
808  const InputParameters & params = moose_object_action->getObjectParams();
809 
810  // Loop through the actions and add the necessary directories to the list to check
811  if (moose_object_action->getParam<std::string>("type") == "Checkpoint")
812  {
813  if (params.isParamValid("file_base"))
814  checkpoint_dirs.push_back(common->getParam<std::string>("file_base") + "_cp");
815  else
816  {
817  std::ostringstream oss;
818  oss << "_" << action->name() << "_cp";
819  checkpoint_dirs.push_back(FileOutput::getOutputFileBase(*this, oss.str()));
820  }
821  }
822  }
823 
824  return MooseUtils::getFilesInDirs(checkpoint_dirs);
825 }
826 
827 void
828 MooseApp::setStartTime(const Real time)
829 {
830  _start_time_set = true;
831  _start_time = time;
832 }
833 
834 std::string
835 MooseApp::getFileName(bool stripLeadingPath) const
836 {
837  return _parser.getFileName(stripLeadingPath);
838 }
839 
842 {
843  return _output_warehouse;
844 }
845 
846 std::string
847 MooseApp::appNameToLibName(const std::string & app_name) const
848 {
849  std::string library_name(app_name);
850 
851  // Strip off the App part (should always be the last 3 letters of the name)
852  size_t pos = library_name.find("App");
853  if (pos != library_name.length() - 3)
854  mooseError("Invalid application name: ", library_name);
855  library_name.erase(pos);
856 
857  // Now get rid of the camel case, prepend lib, and append the method and suffix
858  return std::string("lib") + MooseUtils::camelCaseToUnderscore(library_name) + '-' +
859  QUOTE(METHOD) + ".la";
860 }
861 
862 std::string
863 MooseApp::libNameToAppName(const std::string & library_name) const
864 {
865  std::string app_name(library_name);
866 
867  // Strip off the leading "lib" and trailing ".la"
868  if (pcrecpp::RE("lib(.+?)(?:-\\w+)?\\.la").Replace("\\1", &app_name) == 0)
869  mooseError("Invalid library name: ", app_name);
870 
871  return MooseUtils::underscoreToCamelCase(app_name, true);
872 }
873 
874 void
876 {
877  std::map<std::string, RestartableDataValue *> & restartable_data = _restartable_data[tid];
878 
879  if (restartable_data.find(name) != restartable_data.end())
880  mooseError("Attempted to declare restartable twice with the same name: ", name);
881 
882  restartable_data[name] = data;
883 }
884 
885 void
886 MooseApp::dynamicAppRegistration(const std::string & app_name, std::string library_path)
887 {
888  Parameters params;
889  params.set<std::string>("app_name") = app_name;
890  params.set<RegistrationType>("reg_type") = APPLICATION;
891  params.set<std::string>("registration_method") = app_name + "__registerApps";
892  params.set<std::string>("library_path") = library_path;
893 
894  dynamicRegistration(params);
895 
896  // At this point the application should be registered so check it
897  if (!AppFactory::instance().isRegistered(app_name))
898  {
899  std::ostringstream oss;
900  std::set<std::string> paths = getLoadedLibraryPaths();
901 
902  oss << "Unable to locate library for \"" << app_name
903  << "\".\nWe attempted to locate the library \"" << appNameToLibName(app_name)
904  << "\" in the following paths:\n\t";
905  std::copy(paths.begin(), paths.end(), infix_ostream_iterator<std::string>(oss, "\n\t"));
906  oss << "\n\nMake sure you have compiled the library and either set the \"library_path\" "
907  "variable "
908  << "in your input file or exported \"MOOSE_LIBRARY_PATH\".\n"
909  << "Compiled in debug mode to see the list of libraries checked for dynamic loading "
910  "methods.";
911  mooseError(oss.str());
912  }
913 }
914 
915 void
916 MooseApp::dynamicObjectRegistration(const std::string & app_name,
917  Factory * factory,
918  std::string library_path)
919 {
920  Parameters params;
921  params.set<std::string>("app_name") = app_name;
922  params.set<RegistrationType>("reg_type") = OBJECT;
923  params.set<std::string>("registration_method") = app_name + "__registerObjects";
924  params.set<std::string>("library_path") = library_path;
925 
926  params.set<Factory *>("factory") = factory;
927 
928  dynamicRegistration(params);
929 }
930 
931 void
932 MooseApp::dynamicSyntaxAssociation(const std::string & app_name,
933  Syntax * syntax,
934  ActionFactory * action_factory,
935  std::string library_path)
936 {
937  Parameters params;
938  params.set<std::string>("app_name") = app_name;
939  params.set<RegistrationType>("reg_type") = SYNTAX;
940  params.set<std::string>("registration_method") = app_name + "__associateSyntax";
941  params.set<std::string>("library_path") = library_path;
942 
943  params.set<Syntax *>("syntax") = syntax;
944  params.set<ActionFactory *>("action_factory") = action_factory;
945 
946  dynamicRegistration(params);
947 }
948 
949 void
950 MooseApp::dynamicRegistration(const Parameters & params)
951 {
952  // first convert the app name to a library name
953  std::string library_name = appNameToLibName(params.get<std::string>("app_name"));
954 
955  // Create a vector of paths that we can search inside for libraries
956  std::vector<std::string> paths;
957 
958  std::string library_path = params.get<std::string>("library_path");
959 
960  if (library_path != "")
961  MooseUtils::tokenize(library_path, paths, 1, ":");
962 
963  char * moose_lib_path_env = std::getenv("MOOSE_LIBRARY_PATH");
964  if (moose_lib_path_env)
965  {
966  std::string moose_lib_path(moose_lib_path_env);
967  std::vector<std::string> tmp_paths;
968 
969  MooseUtils::tokenize(moose_lib_path, tmp_paths, 1, ":");
970 
971  // merge the two vectors together (all possible search paths)
972  paths.insert(paths.end(), tmp_paths.begin(), tmp_paths.end());
973  }
974 
975  // Attempt to dynamically load the library
976  for (const auto & path : paths)
977  if (MooseUtils::checkFileReadable(path + '/' + library_name, false, false))
978  loadLibraryAndDependencies(path + '/' + library_name, params);
979  else
980  mooseWarning("Unable to open library file \"",
981  path + '/' + library_name,
982  "\". Double check for spelling errors.");
983 }
984 
985 void
986 MooseApp::loadLibraryAndDependencies(const std::string & library_filename,
987  const Parameters & params)
988 {
989  std::string line;
990  std::string dl_lib_filename;
991 
992  // This RE looks for absolute path libtool filenames (i.e. begins with a slash and ends with a
993  // .la)
994  pcrecpp::RE re_deps("(/\\S*\\.la)");
995 
996  std::ifstream handle(library_filename.c_str());
997  if (handle.is_open())
998  {
999  while (std::getline(handle, line))
1000  {
1001  // Look for the system dependent dynamic library filename to open
1002  if (line.find("dlname=") != std::string::npos)
1003  // Magic numbers are computed from length of this string "dlname=' and line minus that
1004  // string plus quotes"
1005  dl_lib_filename = line.substr(8, line.size() - 9);
1006 
1007  if (line.find("dependency_libs=") != std::string::npos)
1008  {
1009  pcrecpp::StringPiece input(line);
1010  pcrecpp::StringPiece depend_library;
1011  while (re_deps.FindAndConsume(&input, &depend_library))
1012  // Recurse here to load dependent libraries in depth-first order
1013  loadLibraryAndDependencies(depend_library.as_string(), params);
1014 
1015  // There's only one line in the .la file containing the dependency libs so break after
1016  // finding it
1017  break;
1018  }
1019  }
1020  handle.close();
1021  }
1022 
1023  std::string registration_method_name = params.get<std::string>("registration_method");
1024  // Time to load the library, First see if we've already loaded this particular dynamic library
1025  if (_lib_handles.find(std::make_pair(library_filename, registration_method_name)) ==
1026  _lib_handles.end() && // make sure we haven't already loaded this library
1027  dl_lib_filename != "") // AND make sure we have a library name (we won't for static linkage)
1028  {
1029  std::pair<std::string, std::string> lib_name_parts =
1030  MooseUtils::splitFileName(library_filename);
1031 
1032  // Assemble the actual filename using the base path of the *.la file and the dl_lib_filename
1033  std::string dl_lib_full_path = lib_name_parts.first + '/' + dl_lib_filename;
1034 
1035 #ifdef LIBMESH_HAVE_DLOPEN
1036  void * handle = dlopen(dl_lib_full_path.c_str(), RTLD_LAZY);
1037 #else
1038  void * handle = NULL;
1039 #endif
1040 
1041  if (!handle)
1042  mooseError("Cannot open library: ", dl_lib_full_path.c_str(), "\n");
1043 
1044 // get the pointer to the method in the library. The dlsym()
1045 // function returns a null pointer if the symbol cannot be found,
1046 // we also explicitly set the pointer to NULL if dlsym is not
1047 // available.
1048 #ifdef LIBMESH_HAVE_DLOPEN
1049  void * registration_method = dlsym(handle, registration_method_name.c_str());
1050 #else
1051  void * registration_method = NULL;
1052 #endif
1053 
1054  if (!registration_method)
1055  {
1056 // We found a dynamic library that doesn't have a dynamic
1057 // registration method in it. This shouldn't be an error, so
1058 // we'll just move on.
1059 #ifdef DEBUG
1060  mooseWarning("Unable to find extern \"C\" method \"",
1061  registration_method_name,
1062  "\" in library: ",
1063  dl_lib_full_path,
1064  ".\n",
1065  "This doesn't necessarily indicate an error condition unless you believe that "
1066  "the method should exist in that library.\n");
1067 #endif
1068 
1069 #ifdef LIBMESH_HAVE_DLOPEN
1070  dlclose(handle);
1071 #endif
1072  }
1073  else // registration_method is valid!
1074  {
1075  // TODO: Look into cleaning this up
1076  switch (params.get<RegistrationType>("reg_type"))
1077  {
1078  case APPLICATION:
1079  {
1080  typedef void (*register_app_t)();
1081  register_app_t * reg_ptr = reinterpret_cast<register_app_t *>(&registration_method);
1082  (*reg_ptr)();
1083  break;
1084  }
1085  case OBJECT:
1086  {
1087  typedef void (*register_app_t)(Factory *);
1088  register_app_t * reg_ptr = reinterpret_cast<register_app_t *>(&registration_method);
1089  (*reg_ptr)(params.get<Factory *>("factory"));
1090  break;
1091  }
1092  case SYNTAX:
1093  {
1094  typedef void (*register_app_t)(Syntax *, ActionFactory *);
1095  register_app_t * reg_ptr = reinterpret_cast<register_app_t *>(&registration_method);
1096  (*reg_ptr)(params.get<Syntax *>("syntax"), params.get<ActionFactory *>("action_factory"));
1097  break;
1098  }
1099  default:
1100  mooseError("Unhandled RegistrationType");
1101  }
1102 
1103  // Store the handle so we can close it later
1104  _lib_handles.insert(
1105  std::make_pair(std::make_pair(library_filename, registration_method_name), handle));
1106  }
1107  }
1108 }
1109 
1110 std::set<std::string>
1112 {
1113  // Return the paths but not the open file handles
1114  std::set<std::string> paths;
1115  for (const auto & it : _lib_handles)
1116  paths.insert(it.first.first);
1117 
1118  return paths;
1119 }
1120 
1123 {
1125 }
1126 
1127 std::string
1129 {
1130  return std::string("");
1131 }
1132 
1133 void
1134 MooseApp::addMeshModifier(const std::string & modifier_name,
1135  const std::string & name,
1137 {
1138  std::shared_ptr<MeshModifier> mesh_modifier =
1139  _factory.create<MeshModifier>(modifier_name, name, parameters);
1140 
1141  _mesh_modifiers.insert(std::make_pair(MooseUtils::shortName(name), mesh_modifier));
1142 }
1143 
1144 const MeshModifier &
1145 MooseApp::getMeshModifier(const std::string & name) const
1146 {
1147  return *_mesh_modifiers.find(MooseUtils::shortName(name))->second.get();
1148 }
1149 
1150 std::vector<std::string>
1152 {
1153  std::vector<std::string> names;
1154  for (auto & pair : _mesh_modifiers)
1155  names.push_back(pair.first);
1156  return names;
1157 }
1158 
1159 void
1161 {
1163 
1164  // Add all of the dependencies into the resolver and sort them
1165  for (const auto & it : _mesh_modifiers)
1166  {
1167  // Make sure an item with no dependencies comes out too!
1168  resolver.addItem(it.second);
1169 
1170  std::vector<std::string> & modifiers = it.second->getDependencies();
1171  for (const auto & depend_name : modifiers)
1172  {
1173  auto depend_it = _mesh_modifiers.find(depend_name);
1174 
1175  if (depend_it == _mesh_modifiers.end())
1176  mooseError("The MeshModifier \"",
1177  depend_name,
1178  "\" was not created, did you make a "
1179  "spelling mistake or forget to include it "
1180  "in your input file?");
1181 
1182  resolver.insertDependency(it.second, depend_it->second);
1183  }
1184  }
1185 
1186  const auto & ordered_modifiers = resolver.getSortedValues();
1187 
1188  if (ordered_modifiers.size())
1189  {
1190  MooseMesh * mesh = _action_warehouse.mesh().get();
1191  MooseMesh * displaced_mesh = _action_warehouse.displacedMesh().get();
1192 
1193  // Run the MeshModifiers in the proper order
1194  for (const auto & modifier : ordered_modifiers)
1195  modifier->modifyMesh(mesh, displaced_mesh);
1196 
1201  mesh->prepared(false);
1202  if (displaced_mesh)
1203  displaced_mesh->prepared(false);
1204  }
1205 }
1206 
1207 void
1209 {
1210  _mesh_modifiers.clear();
1211 }
1212 
1213 void
1214 MooseApp::setRestart(const bool & value)
1215 {
1216  _restart = value;
1217 
1218  std::shared_ptr<FEProblemBase> fe_problem = _action_warehouse.problemBase();
1219 }
1220 
1221 void
1222 MooseApp::setRecover(const bool & value)
1223 {
1224  _recover = value;
1225 }
1226 
1227 void
1229 {
1230  if (!_cached_backup.get())
1231  mooseError("No cached Backup to restore!");
1232 
1234 
1235  // Release our hold on this Backup
1236  _cached_backup.reset();
1237 }
1238 
1239 void
1241 {
1242  // SetupMeshAction (setup_mesh)
1243  {
1244  // Build the Action parameters
1245  InputParameters action_params = _action_factory.getValidParams("SetupMeshAction");
1246  action_params.set<std::string>("type") = "GeneratedMesh";
1247  action_params.set<std::string>("task") = "setup_mesh";
1248 
1249  // Create The Action
1250  std::shared_ptr<MooseObjectAction> action = std::static_pointer_cast<MooseObjectAction>(
1251  _action_factory.create("SetupMeshAction", "Mesh", action_params));
1252 
1253  // Set the object parameters
1254  InputParameters & params = action->getObjectParams();
1255  params.set<MooseEnum>("dim") = "1";
1256  params.set<unsigned int>("nx") = 1;
1257 
1258  // Add Action to the warehouse
1260  }
1261 
1262  // SetupMeshAction (init_mesh)
1263  {
1264  // Action parameters
1265  InputParameters action_params = _action_factory.getValidParams("SetupMeshAction");
1266  action_params.set<std::string>("type") = "GeneratedMesh";
1267  action_params.set<std::string>("task") = "init_mesh";
1268 
1269  // Build the action
1270  std::shared_ptr<Action> action =
1271  _action_factory.create("SetupMeshAction", "Mesh", action_params);
1273  }
1274 
1275  // Executioner
1276  {
1277  // Build the Action parameters
1278  InputParameters action_params = _action_factory.getValidParams("CreateExecutionerAction");
1279  action_params.set<std::string>("type") = "Transient";
1280 
1281  // Create the action
1282  std::shared_ptr<MooseObjectAction> action = std::static_pointer_cast<MooseObjectAction>(
1283  _action_factory.create("CreateExecutionerAction", "Executioner", action_params));
1284 
1285  // Set the object parameters
1286  InputParameters & params = action->getObjectParams();
1287  params.set<unsigned int>("num_steps") = 1;
1288  params.set<Real>("dt") = 1;
1289 
1290  // Add Action to the warehouse
1292  }
1293 
1294  // Problem
1295  {
1296  // Build the Action parameters
1297  InputParameters action_params = _action_factory.getValidParams("CreateProblemAction");
1298  action_params.set<std::string>("type") = "FEProblem";
1299 
1300  // Create the action
1301  std::shared_ptr<MooseObjectAction> action = std::static_pointer_cast<MooseObjectAction>(
1302  _action_factory.create("CreateProblemAction", "Problem", action_params));
1303 
1304  // Set the object parameters
1305  InputParameters & params = action->getObjectParams();
1306  params.set<bool>("solve") = false;
1307 
1308  // Add Action to the warehouse
1310  }
1311 
1312  // Outputs
1313  {
1314  // Build the Action parameters
1315  InputParameters action_params = _action_factory.getValidParams("CommonOutputAction");
1316  action_params.set<bool>("console") = false;
1317 
1318  // Create action
1319  std::shared_ptr<Action> action =
1320  _action_factory.create("CommonOutputAction", "Outputs", action_params);
1321 
1322  // Add Action to the warehouse
1324  }
1325 
1327 }
virtual void registerRecoverableData(std::string name)
NOTE: This is an internal function meant for MOOSE use only!
Definition: MooseApp.C:679
void setInputFileName(std::string input_file_name)
Set the input file name.
Definition: MooseApp.C:532
std::shared_ptr< MooseObject > create(const std::string &obj_name, const std::string &name, InputParameters parameters, THREAD_ID tid=0, bool print_deprecated=true)
Build an object (must be registered) - THIS METHOD IS DEPRECATED (Use create<T>()) ...
Definition: Factory.C:46
Storage container for all InputParamter objects.
void dynamicSyntaxAssociation(const std::string &app_name, Syntax *syntax, ActionFactory *action_factory, std::string library_path)
Definition: MooseApp.C:932
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:350
virtual void setupOptions()
Setup options based on InputParameters.
Definition: MooseApp.C:305
const moosecontrib::Json::Value & getRoot() const
Get the root of the tree.
const std::multimap< std::string, ActionInfo > & getAssociatedActions() const
Definition: Syntax.h:108
RestartableDatas _restartable_data
Where the restartable data is held (indexed on tid)
Definition: MooseApp.h:705
bool isRecovering() const
Whether or not this is a "recover" calculation.
Definition: MooseApp.C:608
bool _output_position_set
Whether or not an output position has been set for this app.
Definition: MooseApp.h:586
Generic factory class for build all sorts of objects.
Definition: Factory.h:152
void addPrivateParam(const std::string &name, const T &value)
These method add a parameter to the InputParameters object which can be retrieved like any other para...
unsigned int multiAppLevel() const
The MultiApp Level.
Definition: MooseApp.h:465
std::set< std::string > _recoverable_data
Data names that will only be read from the restart file during RECOVERY.
Definition: MooseApp.h:708
static std::string getOutputFileBase(MooseApp &app, std::string suffix="_out")
Returns the default output file base.
Definition: FileOutput.C:112
InputParameters getValidParams(const std::string &name)
Definition: ActionFactory.C:74
void setCheckUnusedFlag(bool warn_is_error=false)
Set a flag so that the parser will either warn or error when unused variables are seen after parsing ...
Definition: MooseApp.C:713
std::list< std::string > getCheckpointFiles()
Extract all possible checkpoint file names.
Definition: MooseApp.C:780
InputParameters & parameters()
Get the parameters of the object.
Definition: MooseApp.h:81
bool _warnings_are_errors
Variable to toggle any warning into an error (includes deprecated code warnings)
Definition: Moose.C:1282
InputParameterWarehouse & getInputParameterWarehouse()
Get the InputParameterWarehouse for MooseObjects.
Definition: MooseApp.C:1122
std::string toString(const moosecontrib::Json::Value &root)
Returns a string representation of the tree in input file format.
virtual std::string getPrintableName() const
Get printable name of the application.
Definition: MooseApp.h:75
void dynamicRegistration(const Parameters &params)
Helper method for dynamic loading of objects.
Definition: MooseApp.C:950
std::shared_ptr< MooseMesh > & displacedMesh()
Class for doing restart.
void mooseError(Args &&...args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:182
void indentMessage(const std::string &prefix, std::string &message, const char *color=COLOR_CYAN)
Indents the supplied message given the prefix and color.
Definition: MooseUtils.C:438
T & set(const std::string &name, bool quiet_mode=false)
Returns a writable reference to the named parameters.
virtual void run()
Run the application.
Definition: MooseApp.C:740
Real _start_time
The time at which to start the simulation.
Definition: MooseApp.h:595
void mooseDeprecated(Args &&...args)
Emit a deprecated code/feature message with the given stringified, concatenated args.
Definition: MooseError.h:202
std::list< std::string > getFilesInDirs(const std::list< std::string > &directory_list)
Retrieves the names of all of the files contained within the list of directories passed into the rout...
Definition: MooseUtils.C:466
const std::list< Action * > & getActionListByName(const std::string &task) const
Retrieve a constant list of Action pointers associated with the passed in task.
MeshModifiers are objects that can modify or add to an existing mesh.
Definition: MeshModifier.h:31
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
bool _check_input
true if we want to just check the input file
Definition: MooseApp.h:672
std::set< std::string > getLoadedLibraryPaths() const
Return the loaded library filenames in a std::vector.
Definition: MooseApp.C:1111
void addActionBlock(std::shared_ptr< Action > blk)
This method add an Action instance to the warehouse.
Syntax _syntax
Syntax of the input file.
Definition: MooseApp.h:604
Syntax & syntax()
Definition: MooseApp.h:134
std::string libNameToAppName(const std::string &library_name) const
Converts a library name to an application name:
Definition: MooseApp.C:863
std::shared_ptr< Backup > _cached_backup
Cache for a Backup to use for restart / recovery.
Definition: MooseApp.h:728
The following methods are specializations for using the libMesh::Parallel::packed_range_* routines fo...
void loadLibraryAndDependencies(const std::string &library_filename, const Parameters &params)
Recursively loads libraries and dependencies in the proper order to fully register a MOOSE applicatio...
Definition: MooseApp.C:986
void executeActionsWithAction(const std::string &name)
This method executes only the actions in the warehouse that satisfy the task passed in...
ActionWarehouse _action_warehouse
Where built actions are stored.
Definition: MooseApp.h:616
std::unique_ptr< SystemInfo > _sys_info
System Information.
Definition: MooseApp.h:631
void mooseInfo(Args &&...args)
Emit an informational message with the given stringified, concatenated args.
Definition: MooseError.h:210
std::string appNameToLibName(const std::string &app_name) const
Converts an application name to a library name: Examples: AnimalApp -> libanimal-oprof.la (assuming METHOD=oprof) ThreeWordAnimalApp -> libthree_word_animal-dbg.la (assuming METHOD=dbg)
Definition: MooseApp.C:847
This class produces a dump of the InputFileParameters in the Standard Object Notation (SON) format fo...
const std::string & name() const
Get the name of the object.
Definition: MooseApp.h:70
Holds the syntax in a Json::Value tree.
Specialization of SubProblem for solving nonlinear equations plus auxiliary equations.
void executeMeshModifiers()
Execute and clear the Mesh Modifiers data structure.
Definition: MooseApp.C:1160
bool _half_transient
Whether or not this simulation should only run half its transient (useful for testing recovery) ...
Definition: MooseApp.h:666
Base class for actions.
Definition: Action.h:39
std::string toString(const JsonVal &root)
returns a string representation of the tree in input file format
virtual void registerRestartableData(std::string name, RestartableDataValue *data, THREAD_ID tid)
Definition: MooseApp.C:875
std::shared_ptr< FEProblemBase > & problemBase()
std::string camelCaseToUnderscore(const std::string &camel_case_name)
Function for converting a camel case name to a name containing underscores.
Definition: MooseUtils.C:281
std::string shortName(const std::string &name)
Function for stripping name after the file / in parser block.
Definition: MooseUtils.C:325
std::string getPrintableVersion() const
Non-virtual method for printing out the version string in a consistent format.
Definition: MooseApp.C:299
std::string getFileName(bool stripLeadingPath=true) const
Return the filename that was parsed.
Definition: Parser.C:293
const std::vector< T > & getSortedValues()
This function also returns dependency resolved values but with a simpler single vector interface...
std::string getOutputFileBase()
Override the selection of the output file base name.
Definition: MooseApp.C:538
std::shared_ptr< MooseMesh > & mesh()
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:121
std::shared_ptr< Backup > backup()
Create a Backup from the current App.
Definition: MooseApp.C:685
Parser _parser
Parser for parsing the input file.
Definition: MooseApp.h:619
bool _start_time_set
Whether or not an start time has been set.
Definition: MooseApp.h:592
std::string getFrameworkVersion() const
Returns the framework version.
Definition: MooseApp.C:287
void initSyntaxFormatter(SyntaxFormatterType type, bool dump_mode)
Creates a syntax formatter for printing.
Definition: Parser.C:617
std::pair< std::string, std::string > splitFileName(std::string full_file)
Function for splitting path and filename.
Definition: MooseUtils.C:251
void restoreCachedBackup()
Restore from a cached backup.
Definition: MooseApp.C:1228
void addMeshModifier(const std::string &modifier_name, const std::string &name, InputParameters parameters)
Add a mesh modifier that will act on the meshes in the system.
Definition: MooseApp.C:1134
bool isParamValid(const std::string &name) const
This method returns parameters that have been initialized in one fashion or another, i.e.
InputParameters & getObjectParams()
Retreive the parameters of the object to be created by this action.
void setErrorOverridden()
Set a flag so that the parser will throw an error if overridden parameters are detected.
Definition: MooseApp.C:734
std::shared_ptr< CommandLine > _command_line
Command line object.
Definition: MooseApp.h:601
bool _restart
Whether or not this is a restart run.
Definition: MooseApp.h:657
bool _deprecated_is_error
Variable to toggle only deprecated warnings as errors.
Definition: Moose.C:1284
std::vector< std::string > getConstructedObjects() const
Get a list of all constructed Moose Object types.
Definition: Factory.C:127
void setStartTime(const Real time)
Set the starting time for the simulation.
Definition: MooseApp.C:828
void meshChanged()
Calls the meshChanged method for every output object.
bool hasRecoverFileBase()
Return true if the recovery file base is set.
Definition: MooseApp.C:620
Specialized factory for generic Action System objects.
Definition: ActionFactory.h:70
An inteface for the _console for outputting to the Console object.
std::shared_ptr< Executioner > _executioner
Pointer to the executioner of this run (typically build by actions)
Definition: MooseApp.h:622
InputParameterWarehouse * _input_parameter_warehouse
Input parameter storage structure (this is a raw pointer so the destruction time can be explicitly co...
Definition: MooseApp.h:610
MooseMesh wraps a libMesh::Mesh object and enhances its capabilities by caching additional data and s...
Definition: MooseMesh.h:74
ActionFactory _action_factory
The Factory responsible for building Actions.
Definition: MooseApp.h:613
PerfLog perf_log
Perflog to be used by applications.
std::string underscoreToCamelCase(const std::string &underscore_name, bool leading_upper_case)
Function for converting an underscore name to a camel case name.
Definition: MooseUtils.C:293
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type It sho...
Definition: MooseEnum.h:37
RegistrationType
Enumeration for holding the valid types of dynamic registrations allowed.
Definition: MooseApp.h:711
enum MooseApp::UNUSED_CHECK _enable_unused_check
bool _recover
Whether or not this is a recovery run.
Definition: MooseApp.h:654
Point _output_position
The output position.
Definition: MooseApp.h:589
void clearMeshModifiers()
Clear all mesh modifers.
Definition: MooseApp.C:1208
InputParameters validParams< MooseApp >()
Definition: MooseApp.C:60
bool _error_overridden
Indicates whether warnings or errors are displayed when overridden parameters are detected...
Definition: MooseApp.h:644
Class for storing and utilizing output objects.
std::string _input_filename
Input file name used.
Definition: MooseApp.h:580
virtual std::string getVersion() const
Returns the current version of the framework or application (default: framework version).
Definition: MooseApp.C:293
std::map< std::pair< std::string, std::string >, void * > _lib_handles
The library, registration method and the handle to the method.
Definition: MooseApp.h:675
static AppFactory & instance()
Get the instance of the AppFactory.
Definition: AppFactory.C:22
This class produces produces a dump of the InputFileParameters that appears like the normal input fil...
void setRestart(const bool &value)
Sets the restart/recover flags.
Definition: MooseApp.C:1214
InputParameters _pars
Parameters of this object.
Definition: MooseApp.h:571
bool _trap_fpe
Variable indicating whether we will enable FPE trapping for this run.
Definition: Moose.C:1262
const T & getParam(const std::string &name)
Retrieve a parameter for the object.
Definition: MooseApp.h:738
void addCommandLineParam(const std::string &name, const std::string &syntax, const std::string &doc_string)
virtual void meshOnly(std::string mesh_file_name)
Don&#39;t run the simulation, just complete all of the mesh preperation steps and exit.
Definition: MooseApp.C:626
virtual void executeExecutioner()
Execute the Executioner that was built.
Definition: MooseApp.C:586
void restore(std::shared_ptr< Backup > backup, bool for_restart=false)
Restore a Backup.
Definition: MooseApp.C:695
std::string _recover_base
The base name to recover from. If blank then we will find the newest recovery file.
Definition: MooseApp.h:660
bool _distributed_mesh_on_command_line
This variable indicates that DistributedMesh should be used for the libMesh mesh underlying MooseMesh...
Definition: MooseApp.h:651
PetscErrorCode petscSetupOutput(CommandLine *cmd_line)
Definition: PetscSupport.C:265
OutputWarehouse _output_warehouse
OutputWarehouse object for this App.
Definition: MooseApp.h:607
std::string _output_file_base
The output file basename.
Definition: MooseApp.h:583
const std::shared_ptr< Parallel::Communicator > _comm
The MPI communicator this App is going to use.
Definition: MooseApp.h:577
bool isParamValid(const std::string &name) const
Definition: MooseApp.h:103
void build()
Builds all auto-buildable tasks.
void errorCheck(const Parallel::Communicator &comm, bool warn_unused, bool err_unused)
Definition: Parser.C:573
virtual void runInputFile()
Actually build everything in the input file.
Definition: MooseApp.C:544
bool setColorConsole(bool use_color, bool force=false)
Turns color escape sequences on/off for info written to stdout.
Definition: Moose.C:1276
Holding syntax for parsing input files.
Definition: Syntax.h:26
std::shared_ptr< Action > create(const std::string &action, const std::string &action_name, InputParameters parameters)
Definition: ActionFactory.C:26
void setOutputPosition(Point p)
Tell the app to output in a specific position.
Definition: MooseApp.C:769
Factory _factory
Definition: MooseApp.h:641
void executeAllActions()
This method loops over all actions in the warehouse and executes them.
bool isRestarting() const
Whether or not this is a "restart" calculation.
Definition: MooseApp.C:614
MooseApp(InputParameters parameters)
Constructor is protected so that this object is constructed through the AppFactory object...
Definition: MooseApp.C:220
std::shared_ptr< Backup > createBackup()
Create a Backup for the current system.
void buildJsonSyntaxTree(JsonSyntaxTree &tree) const
Use MOOSE Factories to construct a parameter tree for documentation or echoing input.
Definition: Parser.C:634
std::string _name
The name of this object.
Definition: MooseApp.h:568
void addItem(const T &value)
Add an independent item to the set.
void dynamicAppRegistration(const std::string &app_name, std::string library_path)
Definition: MooseApp.C:886
const MeshModifier & getMeshModifier(const std::string &name) const
Get a mesh modifier with its name.
Definition: MooseApp.C:1145
std::map< std::string, std::shared_ptr< MeshModifier > > _mesh_modifiers
Holds the mesh modifiers until they have completed, then this structure is cleared.
Definition: MooseApp.h:725
virtual std::string header() const
Returns a string to be printed at the beginning of a simulation.
Definition: MooseApp.C:1128
bool isUltimateMaster()
Whether or not this app is the ultimate master app.
Definition: MooseApp.h:476
void createMinimalApp()
Method for creating the minimum required actions for an application (no input file) ...
Definition: MooseApp.C:1240
std::vector< std::string > getMeshModifierNames() const
Get names of all mesh modifiers Note: This function should be called after all mesh modifiers are add...
Definition: MooseApp.C:1151
bool _ready_to_exit
Definition: MooseApp.h:645
void setRecover(const bool &value)
Definition: MooseApp.C:1222
void clear()
This method deletes all of the Actions in the warehouse.
void disableCheckUnusedFlag()
Removes warnings and error checks for unrecognized variables in the input file.
Definition: MooseApp.C:728
std::string getFileName(bool stripLeadingPath=true) const
Return the filename that was parsed.
Definition: MooseApp.C:835
std::string _recover_suffix
The file suffix to recover from. If blank then we will use "cpr" for binary CheckpointIO.
Definition: MooseApp.h:663
void dynamicObjectRegistration(const std::string &app_name, Factory *factory, std::string library_path)
Thes methods are called to register applications or objects on demand.
Definition: MooseApp.C:916
bool prepared() const
Setter/getter for the _is_prepared flag.
Definition: MooseMesh.C:2086
Abstract definition of a RestartableData value.
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:481
void restoreBackup(std::shared_ptr< Backup > backup, bool for_restart=false)
Restore a Backup for the current system.
OutputWarehouse & getOutputWarehouse()
Get the OutputWarehouse objects.
Definition: MooseApp.C:841
void buildFullTree(const std::string &search_string)
Use MOOSE Factories to construct a full parse tree for documentation or echoing input.
Definition: Parser.C:750
virtual ~MooseApp()
Definition: MooseApp.C:272
unsigned int THREAD_ID
Definition: MooseTypes.h:79
void errorCheck()
Runs post-initialization error checking that cannot be run correctly unless the simulation has been f...
Definition: MooseApp.C:573
const T & getParam(const std::string &name) const
Retrieve a parameter for the object.
Definition: Action.h:139
void insertDependency(const T &key, const T &value)
Insert a dependency pair - the first value or the "key" depends on the second value or the "value"...
void mooseWarning(Args &&...args)
Emit a warning message with the given stringified, concatenated args.
Definition: MooseError.h:194