Go to the documentation of this file.
10 #ifdef HAVE_GPERFTOOLS
11 #include "gperftools/profiler.h"
52 #include "libmesh/exodusII_io.h"
53 #include "libmesh/mesh_refinement.h"
54 #include "libmesh/string_to_enum.h"
55 #include "libmesh/checkpoint_io.h"
56 #include "libmesh/mesh_base.h"
60 #include <sys/utsname.h>
65 #include <sys/types.h>
71 #define QUOTE(macro) stringifyName(macro)
81 "display_version",
"-v --version",
false,
"Print application version");
82 params.
addCommandLineParam<std::string>(
"input_file",
"-i <input_file>",
"Specify an input file");
85 "--mesh-only [mesh_file_name]",
86 "Setup and Output the input mesh only (Default: \"<input_file_name>_in.e\")");
91 "Shows the parsed input file before running the simulation.");
93 "show_outputs",
"--show-outputs",
false,
"Shows the output execution time information.");
95 "show_controls",
"--show-controls",
false,
"Shows the Control logic available and executed.");
98 "no_color",
"--no-color",
false,
"Disable coloring of all Console outputs.");
100 "--color [auto,on,off]",
102 "Whether to use color in console output (default 'on').");
104 params.
addCommandLineParam<
bool>(
"help",
"-h --help",
false,
"Displays CLI usage statement.");
109 "Ignore input file and build a minimal application with Transient executioner.");
112 "definition",
"--definition",
"Shows a SON style input definition dump for input validation");
114 "dump",
"--dump [search_string]",
"Shows a dump of available input file syntax.");
116 "registry",
"--registry",
"Lists all known objects and actions.");
118 "registry_hit",
"--registry-hit",
"Lists all known objects and actions in hit format.");
121 "apptype",
"--type",
false,
"Return the name of the application object.");
123 "yaml",
"--yaml",
"Dumps input file syntax in YAML format.");
125 "json",
"--json",
"Dumps input file syntax in JSON format.");
127 "syntax",
"--syntax",
false,
"Dumps the associated Action syntax paths ONLY");
131 "Check the input file (i.e. requires -i <filename>) and quit.");
133 "list_constructed_objects",
134 "--list-constructed-objects",
136 "List all moose object type names constructed by the master app factory.");
139 "n_threads",
"--n-threads=<n>", 1,
"Runs the specified number of threads per process");
142 "warn_unused",
"-w --warn-unused",
false,
"Warn about unused input file options");
146 "Error when encountering unused input file options");
149 "-o --error-override",
151 "Error when encountering overridden or parameters supplied multiple times");
153 "error_deprecated",
"--error-deprecated",
false,
"Turn deprecated code messages into Errors");
157 "--distributed-mesh",
159 "The libMesh Mesh underlying MooseMesh should always be a DistributedMesh");
163 "--split-mesh [splits]",
164 "comma-separated list of numbers of chunks to split the mesh into");
167 "--split-file [filename]",
169 "optional name of split mesh file(s) to write/read");
172 "use_split",
"--use-split",
false,
"use split distributed mesh files");
178 "Specify additional initial uniform refinements for automatic scaling");
181 "--recover [file_base]",
182 "Continue the calculation. If file_base is omitted then "
183 "the most recent recovery file will be utilized");
186 "--recoversuffix [suffix]",
187 "Use a different file extension, other than cpr, "
188 "for a recovery file");
193 "When true the simulation will only run half of "
194 "its specified transient (ie half the "
195 "timesteps). This is useful for testing "
196 "recovery and restart");
202 "Enable Floating Point Exception handling in critical sections of "
203 "code. This is enabled automatically in DEBUG mode");
206 "Disable Floating Point Exception handling in critical "
207 "sections of code when using DEBUG mode.");
209 params.
addCommandLineParam<
bool>(
"error",
"--error",
false,
"Turn all warnings into errors");
215 "Enable all performance logging for timing purposes. This will disable all "
216 "screen output of performance logs for all Console objects.");
220 "Disabled performance logging. Overrides -t or --timing "
221 "if passed in conjunction with this flag");
224 "allow_test_objects",
"--allow-test-objects",
false,
"Register test objects and syntax.");
232 "Keep standard output from all processors when running in parallel");
237 "Keep standard output from all processors when running in parallel");
241 "--start-in-debugger <debugger>",
242 "Start the application and attach a debugger. This will "
243 "launch xterm windows using the command you specify for "
247 "--stop-for-debugger [seconds]",
249 "Pauses the application during startup for the "
250 "specified time to allow for connection of debuggers.");
252 "automatic_automatic_scaling",
false,
"Whether to turn on automatic scaling by default.");
259 params.
addPrivateParam<std::shared_ptr<Parallel::Communicator>>(
"_comm");
266 "use_legacy_dirichlet_bc",
268 "Set false to have MOOSE utilize the new and preferred method of setting preset = true as "
269 "default for all DirichletBC and derived objects, which is ideal for the majority of solves "
270 "utilizing this boundary condition type.\nThe old behavior (which is utilized if this is set "
271 "to true) is to set preset = false as the default for DirichletBC and derived objects.");
278 ParallelObject(*parameters.get<
std::shared_ptr<Parallel::Communicator>>(
280 _name(parameters.get<
std::string>(
"_app_name")),
282 _type(getParam<
std::string>(
"_type")),
283 _comm(getParam<
std::shared_ptr<Parallel::Communicator>>(
"_comm")),
284 _perf_graph(
type() +
" (" + name() +
')'),
285 _rank_map(*_comm, _perf_graph),
286 _file_base_set_by_user(false),
287 _output_position_set(false),
288 _start_time_set(false),
290 _global_time_offset(0.0),
291 _output_warehouse(*this),
293 _action_factory(*this),
294 _action_warehouse(*this, _syntax, _action_factory),
295 _parser(*this, _action_warehouse),
296 _use_nonlinear(true),
297 _use_eigen_value(false),
298 _enable_unused_check(WARN_UNUSED),
300 _error_overridden(false),
301 _ready_to_exit(false),
302 _initial_from_file(false),
303 _distributed_mesh_on_command_line(false),
307 _use_split(parameters.get<bool>(
"use_split")),
313 _restart_recover_suffix(
"cpr"),
314 _half_transient(false),
315 _check_input(getParam<bool>(
"check_input")),
316 _restartable_data(
libMesh::n_threads()),
318 isParamValid(
"_multiapp_level") ? parameters.get<unsigned int>(
"_multiapp_level") : 0),
320 isParamValid(
"_multiapp_number") ? parameters.get<unsigned int>(
"_multiapp_number") : 0),
321 _master_mesh(isParamValid(
"_master_mesh") ? parameters.get<const
MooseMesh *>(
"_master_mesh")
323 _master_displaced_mesh(isParamValid(
"_master_displaced_mesh")
324 ? parameters.get<const
MooseMesh *>(
"_master_displaced_mesh")
326 _setup_timer(_perf_graph.registerSection(
"MooseApp::setup", 2)),
327 _setup_options_timer(_perf_graph.registerSection(
"MooseApp::setupOptions", 5)),
328 _run_input_file_timer(_perf_graph.registerSection(
"MooseApp::runInputFile", 3)),
329 _execute_timer(_perf_graph.registerSection(
"MooseApp::execute", 2)),
330 _execute_executioner_timer(_perf_graph.registerSection(
"MooseApp::executeExecutioner", 3)),
331 _restore_timer(_perf_graph.registerSection(
"MooseApp::restore", 2)),
332 _run_timer(_perf_graph.registerSection(
"MooseApp::run", 3)),
333 _execute_mesh_modifiers_timer(_perf_graph.registerSection(
"MooseApp::executeMeshModifiers", 1)),
334 _execute_mesh_generators_timer(
335 _perf_graph.registerSection(
"MooseApp::executeMeshGenerators", 1)),
336 _restore_cached_backup_timer(_perf_graph.registerSection(
"MooseApp::restoreCachedBackup", 2)),
337 _create_minimal_app_timer(_perf_graph.registerSection(
"MooseApp::createMinimalApp", 3)),
338 _automatic_automatic_scaling(getParam<bool>(
"automatic_automatic_scaling")),
339 _popped_final_mesh_generator(false)
341 #ifdef HAVE_GPERFTOOLS
342 if (std::getenv(
"MOOSE_PROFILE_BASE"))
344 static std::string profile_file =
345 std::getenv(
"MOOSE_PROFILE_BASE") + std::to_string(
_comm->rank()) +
".prof";
347 ProfilerStart(profile_file.c_str());
370 int argc = getParam<int>(
"_argc");
371 char ** argv = getParam<char **>(
"_argv");
373 _sys_info = libmesh_make_unique<SystemInfo>(argc, argv);
376 _command_line = getParam<std::shared_ptr<CommandLine>>(
"_command_line");
378 mooseError(
"Valid CommandLine object required");
381 mooseError(
"Cannot run --check-input with --recover. Recover files might not exist");
385 auto command = getParam<std::string>(
"start_in_debugger");
387 Moose::out <<
"Starting in debugger using: " << command << std::endl;
391 std::stringstream command_stream;
395 <<
" PID: " << getpid() <<
"'; echo ''; ";
398 if (command.find(
"lldb") != std::string::npos || command.find(
"gdb") != std::string::npos)
399 command_stream << command <<
" -p " << getpid();
403 "\nIf this is truly what you meant then contact moose-users to have a discussion "
404 "about adding your debugger.");
407 command_stream <<
"\""
410 std::string command_string = command_stream.str();
411 Moose::out <<
"Running: " << command_string << std::endl;
417 std::this_thread::sleep_for(std::chrono::seconds(10));
422 Moose::out <<
"\nStopping for " << getParam<unsigned int>(
"stop_for_debugger")
423 <<
" seconds to allow attachment from a debugger.\n";
425 Moose::out <<
"\nAll of the processes you can connect to:\n";
426 Moose::out <<
"rank - hostname - pid\n";
436 Moose::out <<
"\nWaiting...\n" << std::endl;
439 std::this_thread::sleep_for(std::chrono::seconds(getParam<unsigned int>(
"stop_for_debugger")));
443 mooseError(
"Mesh can be passed in only for sub-apps");
446 mooseError(
"_master_mesh should have been set when _master_displaced_mesh is set");
457 #ifdef HAVE_GPERFTOOLS
467 #ifdef LIBMESH_HAVE_DLOPEN
477 return MOOSE_VERSION;
483 return MOOSE_VERSION;
506 std::string hdr(
header() +
"\n");
509 Moose::out << hdr << std::flush;
511 if (getParam<bool>(
"error_unused"))
513 else if (getParam<bool>(
"warn_unused"))
516 if (getParam<bool>(
"error_override"))
524 if (getParam<bool>(
"no_timing"))
532 mooseError(
"Cannot use both \"--trap-fpe\" and \"--no-trap-fpe\" flags.");
548 if (getParam<bool>(
"no_color"))
551 char * c_color = std::getenv(
"MOOSE_COLOR");
552 std::string color =
"on";
555 if (getParam<std::string>(
"color") !=
"default-on")
556 color = getParam<std::string>(
"color");
560 else if (color ==
"on")
562 else if (color ==
"off")
565 mooseWarning(
"ignoring invalid --color arg (want 'auto', 'on', or 'off')");
570 if (getParam<bool>(
"no_color"))
571 mooseDeprecated(
"The --no-color flag is deprecated. Use '--color off' instead.");
579 #if !LIBMESH_USING_THREADS
580 if (libMesh::command_line_value(
"--n-threads", 1) > 1)
581 mooseError(
"You specified --n-threads > 1, but there is no threading model active!");
585 if (getParam<bool>(
"minimal"))
588 else if (getParam<bool>(
"display_version"))
595 else if (getParam<bool>(
"help"))
607 std::string following_arg = getParam<std::string>(
"dump");
611 std::string param_search;
612 if (!following_arg.empty() && (following_arg.find(
'-') != 0))
613 param_search = following_arg;
618 Moose::out <<
"### START DUMP DATA ###\n"
624 Moose::out <<
"Label\tType\tName\tClass\tFile\n";
627 for (
auto & entry : objmap)
629 for (
auto & obj : entry.second)
631 std::string
name = obj._name;
635 name = obj._classname;
637 Moose::out << entry.first <<
"\tobject\t" <<
name <<
"\t" << obj._classname <<
"\t"
638 << obj._file <<
"\n";
643 for (
auto & entry : actmap)
645 for (
auto & act : entry.second)
646 Moose::out << entry.first <<
"\taction\t" << act._name <<
"\t" << act._classname <<
"\t"
647 << act._file <<
"\n";
654 Moose::out <<
"### START REGISTRY DATA ###\n";
656 hit::Section root(
"");
657 auto sec =
new hit::Section(
"registry");
659 auto objsec =
new hit::Section(
"objects");
660 sec->addChild(objsec);
663 for (
auto & entry : objmap)
665 for (
auto & obj : entry.second)
667 std::string
name = obj._name;
671 name = obj._classname;
673 auto ent =
new hit::Section(
"entry");
674 objsec->addChild(ent);
675 ent->addChild(
new hit::Field(
"label", hit::Field::Kind::String, entry.first));
676 ent->addChild(
new hit::Field(
"type", hit::Field::Kind::String,
"object"));
677 ent->addChild(
new hit::Field(
"name", hit::Field::Kind::String,
name));
678 ent->addChild(
new hit::Field(
"class", hit::Field::Kind::String, obj._classname));
679 ent->addChild(
new hit::Field(
"file", hit::Field::Kind::String, obj._file));
683 auto actsec =
new hit::Section(
"actions");
684 sec->addChild(actsec);
686 for (
auto & entry : actmap)
688 for (
auto & act : entry.second)
690 auto ent =
new hit::Section(
"entry");
691 actsec->addChild(ent);
692 ent->addChild(
new hit::Field(
"label", hit::Field::Kind::String, entry.first));
693 ent->addChild(
new hit::Field(
"type", hit::Field::Kind::String,
"action"));
694 ent->addChild(
new hit::Field(
"task", hit::Field::Kind::String, act._name));
695 ent->addChild(
new hit::Field(
"class", hit::Field::Kind::String, act._classname));
696 ent->addChild(
new hit::Field(
"file", hit::Field::Kind::String, act._file));
700 Moose::out << root.render();
702 Moose::out <<
"\n### END REGISTRY DATA ###\n";
721 std::string yaml_following_arg = getParam<std::string>(
"yaml");
726 if (yaml_following_arg.empty() || (yaml_following_arg.find(
'-') == 0))
738 std::string json_following_arg = getParam<std::string>(
"json");
743 if (!json_following_arg.empty() && (json_following_arg.find(
'-') != 0))
744 search = json_following_arg;
749 Moose::out <<
"**START JSON DATA**\n" << tree.
getRoot() <<
"\n**END JSON DATA**\n";
752 else if (getParam<bool>(
"syntax"))
757 Moose::out <<
"**START SYNTAX DATA**\n";
758 for (
const auto & it :
syntax)
759 Moose::out << it.first <<
"\n";
760 Moose::out <<
"**END SYNTAX DATA**\n" << std::endl;
763 else if (getParam<bool>(
"apptype"))
766 Moose::out <<
"MooseApp Type: " <<
type() << std::endl;
782 std::string recover_following_arg = getParam<std::string>(
"recover");
786 if (!(recover_following_arg.empty() || (recover_following_arg.find(
'-') == 0)))
819 mooseAssert(common_actions.size() == 1,
"Should be only one common_output Action");
821 const Action * common = *common_actions.begin();
824 if (common->isParamValid(
"file_base"))
833 size_t pos = base.find_last_of(
'.');
847 mooseError(
"You specified --check-input, but did not provide an input file. Add -i "
848 "<inputfile> to your command line.");
883 else if (getParam<bool>(
"list_constructed_objects"))
888 Moose::out <<
"**START OBJECT DATA**\n";
889 for (
const auto &
name : obj_list)
890 Moose::out <<
name <<
"\n";
891 Moose::out <<
"**END OBJECT DATA**\n" << std::endl;
903 auto apps =
_executioner->feProblem().getMultiAppWarehouse().getObjects();
904 for (
auto app : apps)
905 for (
unsigned int i = 0; i < app->numLocalApps(); i++)
906 app->localApp(i)->errorCheck();
921 #ifdef LIBMESH_HAVE_PETSC
930 mooseError(
"No executioner was specified (go fix your input file)");
967 "MooseApp::hasRestartRecoverFileBase() instead.");
978 case RESTARTABLE_FILTER::RECOVERABLE:
986 std::shared_ptr<Backup>
1020 mooseInfo(
"Ignoring request to turn off or warn about unused parameters.\n");
1046 catch (std::exception & err)
1060 Moose::err <<
"Syntax OK" << std::endl;
1075 std::list<std::string>
1079 std::list<std::string> checkpoint_dirs;
1086 for (
const auto & action : actions)
1089 MooseObjectAction * moose_object_action = dynamic_cast<MooseObjectAction *>(action);
1090 if (!moose_object_action)
1094 if (moose_object_action->
getParamTempl<std::string>(
"type") ==
"Checkpoint")
1095 checkpoint_dirs.push_back(params.get<std::string>(
"file_base") +
"_cp");
1098 return checkpoint_dirs;
1101 std::list<std::string>
1130 std::string library_name(app_name);
1133 size_t pos = library_name.find(
"App");
1134 if (pos != library_name.length() - 3)
1135 mooseError(
"Invalid application name: ", library_name);
1136 library_name.erase(pos);
1140 QUOTE(METHOD) +
".la";
1146 std::string app_name(library_name);
1149 if (pcrecpp::RE(
"lib(.+?)(?:-\\w+)?\\.la").Replace(
"\\1", &app_name) == 0)
1150 mooseError(
"Invalid library name: ", app_name);
1157 std::unique_ptr<RestartableDataValue> data,
1159 bool mesh_meta_data,
1168 if (!insert_pair.second)
1170 auto & data = insert_pair.first->second;
1176 mooseError(
"Attempted to declare restartable mesh meta data twice with the same name: ",
1180 data.declared =
true;
1184 return *insert_pair.first->second.value;
1189 std::string library_path,
1190 const std::string & library_name)
1192 #ifdef LIBMESH_HAVE_DLOPEN
1194 params.set<std::string>(
"app_name") = app_name;
1196 params.set<std::string>(
"registration_method") = app_name +
"__registerApps";
1197 params.set<std::string>(
"library_path") = library_path;
1198 params.set<std::string>(
"library_name") = library_name;
1205 std::ostringstream oss;
1208 oss <<
"Unable to locate library for \"" << app_name
1209 <<
"\".\nWe attempted to locate the library \"" <<
appNameToLibName(app_name)
1210 <<
"\" in the following paths:\n\t";
1212 oss <<
"\n\nMake sure you have compiled the library and either set the \"library_path\" "
1214 <<
"in your input file or exported \"MOOSE_LIBRARY_PATH\".\n"
1215 <<
"Compiled in debug mode to see the list of libraries checked for dynamic loading "
1220 mooseError(
"Dynamic Loading is either not supported or was not detected by libMesh configure.");
1229 std::string library_path,
1230 const std::string & library_name)
1232 #ifdef LIBMESH_HAVE_DLOPEN
1234 params.set<std::string>(
"app_name") = app_name;
1236 params.set<std::string>(
"registration_method") = app_name +
"__registerAll";
1237 params.set<std::string>(
"library_path") = library_path;
1238 params.set<std::string>(
"library_name") = library_name;
1240 params.set<
Factory *>(
"factory") = factory;
1242 params.set<
ActionFactory *>(
"action_factory") = action_factory;
1246 mooseError(
"Dynamic Loading is either not supported or was not detected by libMesh configure.");
1253 std::string library_name;
1255 if (params.get<std::string>(
"library_name").empty())
1258 library_name = params.get<std::string>(
"library_name");
1261 std::vector<std::string> paths;
1263 std::string library_path = params.get<std::string>(
"library_path");
1265 if (library_path !=
"")
1268 char * moose_lib_path_env = std::getenv(
"MOOSE_LIBRARY_PATH");
1269 if (moose_lib_path_env)
1271 std::string moose_lib_path(moose_lib_path_env);
1272 std::vector<std::string> tmp_paths;
1277 paths.insert(paths.end(), tmp_paths.begin(), tmp_paths.end());
1281 for (
const auto & path : paths)
1286 path +
'/' + library_name,
1287 "\". Double check for spelling errors.");
1292 const Parameters & params)
1295 std::string dl_lib_filename;
1299 pcrecpp::RE re_deps(
"(/\\S*\\.la)");
1301 std::ifstream handle(library_filename.c_str());
1302 if (handle.is_open())
1304 while (std::getline(handle, line))
1307 if (line.find(
"dlname=") != std::string::npos)
1310 dl_lib_filename = line.substr(8, line.size() - 9);
1312 if (line.find(
"dependency_libs=") != std::string::npos)
1314 pcrecpp::StringPiece input(line);
1315 pcrecpp::StringPiece depend_library;
1316 while (re_deps.FindAndConsume(&input, &depend_library))
1328 std::string registration_method_name = params.get<std::string>(
"registration_method");
1330 if (
_lib_handles.find(std::make_pair(library_filename, registration_method_name)) ==
1332 dl_lib_filename !=
"")
1334 std::pair<std::string, std::string> lib_name_parts =
1338 std::string dl_lib_full_path = lib_name_parts.first +
'/' + dl_lib_filename;
1342 #ifdef LIBMESH_HAVE_DLOPEN
1343 void * handle = dlopen(dl_lib_full_path.c_str(), RTLD_LAZY);
1345 void * handle =
nullptr;
1351 "\" exists and has proper permissions, but cannot by dynamically loaded.\nThis "
1352 "generally means that the loader was unable to load one or more of the "
1353 "dependencies listed in the supplied library (see otool or ldd).\n");
1359 #ifdef LIBMESH_HAVE_DLOPEN
1360 void * registration_method = dlsym(handle, registration_method_name.c_str());
1362 void * registration_method =
nullptr;
1365 if (!registration_method)
1372 registration_method_name,
1376 "This doesn't necessarily indicate an error condition unless you believe that "
1377 "the method should exist in that library.\n");
1380 #ifdef LIBMESH_HAVE_DLOPEN
1391 typedef void (*register_app_t)();
1392 register_app_t * reg_ptr = reinterpret_cast<register_app_t *>(®istration_method);
1399 register_app_t * reg_ptr = reinterpret_cast<register_app_t *>(®istration_method);
1400 (*reg_ptr)(params.get<
Factory *>(
"factory"),
1402 params.get<
Syntax *>(
"syntax"));
1411 std::make_pair(std::make_pair(library_filename, registration_method_name), handle));
1416 std::set<std::string>
1420 std::set<std::string> paths;
1422 paths.insert(it.first.first);
1436 return std::string(
"");
1441 const std::string & name,
1444 std::shared_ptr<MeshModifier> mesh_modifier =
1456 std::vector<std::string>
1459 std::vector<std::string> names;
1461 names.push_back(pair.first);
1480 std::vector<std::string> & modifiers = it.second->getDependencies();
1481 for (
const auto & depend_name : modifiers)
1488 "\" was not created, did you make a "
1489 "spelling mistake or forget to include it "
1490 "in your input file?");
1498 if (ordered_modifiers.size())
1504 for (
const auto & modifier : ordered_modifiers)
1505 modifier->modifyMesh(mesh, displaced_mesh);
1526 const std::string & name,
1529 std::shared_ptr<MeshGenerator> mesh_generator =
1541 std::vector<std::string>
1544 std::vector<std::string> names;
1546 names.push_back(pair.first);
1550 std::unique_ptr<MeshBase> &
1555 outputs.push_back(
nullptr);
1557 return outputs.back();
1575 std::vector<std::string> & generators = it.second->getDependencies();
1576 for (
const auto & depend_name : generators)
1583 "\" was not created, did you make a "
1584 "spelling mistake or forget to include it "
1585 "in your input file?");
1593 if (ordered_generators.size())
1595 auto & final_generators = ordered_generators.back();
1603 const auto ancestor_list = resolver.
getAncestors(final_generators.back());
1604 if (ancestor_list.size() != resolver.
size())
1608 std::set<std::shared_ptr<MeshGenerator>> ancestors(ancestor_list.begin(),
1609 ancestor_list.end());
1613 decltype(ancestors) all(allValues.begin(), allValues.end());
1615 decltype(ancestors) ind_tree;
1616 std::set_difference(all.begin(),
1620 std::inserter(ind_tree, ind_tree.end()));
1622 std::ostringstream oss;
1623 oss <<
"Your MeshGenerator tree contains multiple possible generator outputs :\n\""
1625 <<
" and one or more of the following from an independent set: \"";
1627 for (
const auto & gen : ind_tree)
1636 oss <<
"\"\n\nThis may be due to a missing dependency or may be intentional. Please "
1637 "select the final MeshGenerator in\nthe [Mesh] block with the \"final_generator\" "
1638 "parameter or add additional dependencies to remove the ambiguity.";
1651 for (
const auto & generator_set : ordered_generators)
1653 for (
const auto & generator : generator_set)
1655 auto name = generator->name();
1657 auto current_mesh = generator->generate();
1664 auto & first_output = *outputs.begin();
1666 first_output = std::move(current_mesh);
1668 const auto & copy_from = *first_output;
1670 auto output_it = ++outputs.begin();
1673 for (; output_it != outputs.end(); ++output_it)
1674 (*output_it) = copy_from.clone();
1699 std::unique_ptr<MeshBase>
1703 mooseError(
"MooseApp::getMeshGeneratorMesh is being called for a second time. You cannot do "
1704 "this because the final generated mesh was popped from its storage container the "
1705 "first time this method was called");
1708 mooseError(
"No generated mesh to retrieve. Your input file should contain either a [Mesh] or "
1709 "[MeshGenerators] block.");
1716 mooseError(
"Multiple generated meshes exist while retrieving the final Mesh. This means that "
1717 "the selection of the final mesh is non-deterministic.");
1719 return std::move(*mesh_unique_ptr_ptr);
1763 action_params.
set<std::string>(
"type") =
"GeneratedMesh";
1766 std::shared_ptr<MooseObjectAction> action = std::static_pointer_cast<MooseObjectAction>(
1772 params.set<
unsigned int>(
"nx") = 1;
1782 action_params.
set<std::string>(
"type") =
"Transient";
1785 std::shared_ptr<MooseObjectAction> action = std::static_pointer_cast<MooseObjectAction>(
1790 params.
set<
unsigned int>(
"num_steps") = 1;
1791 params.set<Real>(
"dt") = 1;
1801 action_params.
set<
bool>(
"_solve") =
false;
1804 std::shared_ptr<Action> action = std::static_pointer_cast<Action>(
1815 action_params.
set<
bool>(
"console") =
false;
1818 std::shared_ptr<Action> action =
1839 ExecFlagType & non_const_flag = const_cast<ExecFlagType &>(flag);
1842 non_const_flag.
setID(it->id());
1854 [&
name](
const std::shared_ptr<RelationshipManager> & rm) {
1855 return rm->name() ==
name;
1873 if (*rm == *relationship_manager)
1877 auto & existing_for_whom = rm->forWhom();
1881 for (
auto & fw : relationship_manager->forWhom())
1883 if (std::find(existing_for_whom.begin(), existing_for_whom.end(), fw) ==
1884 existing_for_whom.end())
1904 if (rm->isType(rm_type))
1920 mesh->getMesh().add_ghosting_functor(*rm);
1937 problem.mesh().getMesh().add_ghosting_functor(*rm);
1940 if (rm->useDisplacedMesh() && problem.getDisplacedProblem())
1947 auto &
dof_map = problem.getNonlinearSystemBase().dofMap();
1948 dof_map.add_coupling_functor(*rm,
false);
1958 problem.getDisplacedProblem()->addAlgebraicGhostingFunctor(*rm,
false);
1964 auto &
dof_map = problem.getNonlinearSystemBase().dofMap();
1965 dof_map.add_coupling_functor(*rm,
false);
1975 problem.addAlgebraicGhostingFunctor(*rm,
false);
1982 std::vector<std::pair<std::string, std::string>>
1985 std::vector<std::pair<std::string, std::string>> info_strings;
1990 std::stringstream oss;
1991 oss << rm->getInfo();
1993 auto & for_whom = rm->forWhom();
1995 if (!for_whom.empty())
2002 info_strings.emplace_back(std::make_pair(
Moose::stringify(rm->getType()), oss.str()));
2010 std::unordered_map<std::string, unsigned int> counts;
2012 for (
auto & gf : as_range(mesh->getMesh().ghosting_functors_begin(),
2013 mesh->getMesh().ghosting_functors_end()))
2015 const auto * gf_ptr = dynamic_cast<const RelationshipManager *>(gf);
2018 counts[demangle(
typeid(*gf).name())]++;
2021 for (
const auto pair : counts)
2022 info_strings.emplace_back(std::make_pair(
2023 "Default", pair.first + (pair.second > 1 ?
" x " + std::to_string(pair.second) :
"")));
2026 return info_strings;
2033 rm->dofmap_reinit();
2046 std::vector<std::string> not_declared;
2049 if (!pair.second.declared)
2050 not_declared.push_back(pair.first);
2052 if (!not_declared.empty())
2054 std::ostringstream oss;
2058 mooseError(
"The following Mesh meta-data properties were retrieved but never declared: ",
void checkMeshMetaDataIntegrity() const
Function to check the integrity of the MeshMetaData data structure.
RegistrationType
Enumeration for holding the valid types of dynamic registrations allowed.
PerfLog perf_log
Perflog to be used by applications.
void restoreBackup(std::shared_ptr< Backup > backup, bool for_restart=false)
Restore a Backup for the current system.
InputParameterWarehouse & getInputParameterWarehouse()
Get the InputParameterWarehouse for MooseObjects.
void executeMeshModifiers()
Execute and clear the Mesh Modifiers data structure.
An inteface for the _console for outputting to the Console object.
RestartableDataMap _mesh_meta_data_map
Data specifically associated with the mesh (meta-data) that will read from the restart file early dur...
RESTARTABLE_FILTER
The filter type applied to a particular piece of "restartable" data.
const std::set< ExecFlagType > & items() const
Reference the all the available items.
bool prepared() const
Setter/getter for the _is_prepared flag.
void registerTaskName(const std::string &task, bool should_auto_build=false)
Method to register a new task.
bool hasRecoverFileBase() const
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...
std::list< std::unique_ptr< MeshBase > * > _final_generated_meshes
The final Mesh that is generated by the generators.
PerfGraph _perf_graph
The PerfGraph object for this applciation.
std::shared_ptr< MooseObject > create(const std::string &obj_name, const std::string &name, InputParameters ¶meters, THREAD_ID tid=0, bool print_deprecated=true)
Build an object (must be registered) - THIS METHOD IS DEPRECATED (Use create<T>())
defineLegacyParams(MooseApp)
const std::string & type() const
Get the type of this object as a string.
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".
Parser _parser
Parser for parsing the input file.
bool _split_mesh
Whether or not we are performing a split mesh operation (–split-mesh)
virtual void run()
Run the application.
void setErrorOverridden()
Set a flag so that the parser will throw an error if overridden parameters are detected.
const std::string _type
The string representation of the type of this object as registered (see registerApp(AppName))
OutputWarehouse & getOutputWarehouse()
Get the OutputWarehouse objects.
virtual void executeExecutioner()
Execute the Executioner that was built.
void setStartTime(Real time)
Set the starting time for the simulation.
InputParameters getValidParams(const std::string &name)
virtual void restore(std::shared_ptr< Backup > backup, bool for_restart=false)
Restore a Backup.
bool _restart
Whether or not this is a restart run.
void setFinalMeshGeneratorName(const std::string &generator_name)
Set final mesh generator name.
const std::shared_ptr< Parallel::Communicator > _comm
The MPI communicator this App is going to use.
int getNextValidID() const
Compute the next valid ID.
const int & id() const
Return the numeric, name, or raw name.
virtual void runInputFile()
Actually build everything in the input file.
const std::vector< T > & getSortedValues()
This function also returns dependency resolved values but with a simpler single vector interface.
void addAvailableFlags(const ExecFlagType &flag, Args... flags)
Add additional execute_on flags to the list of possible flags.
void dynamicAllRegistration(const std::string &app_name, Factory *factory, ActionFactory *action_factory, Syntax *syntax, std::string library_path, const std::string &library_name)
Thes methods are called to register applications or objects on demand.
Real _start_time
The time at which to start the simulation.
std::list< std::string > getCheckpointDirectories() const
Get all checkpoint directories.
void meshReinitForRMs()
Loop through RMs and call mesh_reinit.
static void checkLabels(const std::set< std::string > &known_labels={})
This runs error checking to make sure that all objects and actions in the registry have valid labels.
std::shared_ptr< MooseMesh > & mesh()
void restoreCachedBackup()
Restore from a cached backup.
void setBackupObject(std::shared_ptr< Backup > backup)
Method for setting the backup object to be restored at a later time.
The following methods are specializations for using the libMesh::Parallel::packed_range_* routines fo...
bool setColorConsole(bool use_color, bool force=false)
Turns color escape sequences on/off for info written to stdout.
void loadLibraryAndDependencies(const std::string &library_filename, const Parameters ¶ms)
Recursively loads libraries and dependencies in the proper order to fully register a MOOSE applicatio...
MeshGenerators are objects that can modify or add to an existing mesh.
bool _error_overridden
Indicates whether warnings or errors are displayed when overridden parameters are detected.
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type It sho...
std::map< std::string, std::list< std::unique_ptr< MeshBase > > > _mesh_generator_outputs
Holds the output for each mesh generator - including duplicates needed downstream.
void build()
Builds all auto-buildable tasks.
const PerfID _execute_mesh_generators_timer
std::map< std::string, std::shared_ptr< MeshModifier > > _mesh_modifiers
Holds the mesh modifiers until they have completed, then this structure is cleared.
void clearMeshGenerators()
Clear all mesh modifers.
virtual std::string getPrintableName() const
Get printable name of the application.
const MooseMesh * _master_displaced_mesh
The displaced mesh from master app.
std::string hostname()
Get the hostname the current process is running on.
TODO: delete this later - it is a temporary hack for dealing with inter-system dependencies.
const PerfID _restore_cached_backup_timer
virtual void checkRegistryLabels()
void clearMeshModifiers()
Clear all mesh modifers.
std::unique_ptr< MeshBase > getMeshGeneratorMesh(bool check_unique=true)
Get the generated mesh generated by executeMeshGenerators();.
void buildFullTree(const std::string &search_string)
Use MOOSE Factories to construct a full parse tree for documentation or echoing input.
std::shared_ptr< CommandLine > _command_line
Command line object.
void addActionBlock(std::shared_ptr< Action > blk)
This method add an Action instance to the warehouse.
void registerExecFlags(Factory &factory)
std::string getFrameworkVersion() const
Returns the framework version.
bool _start_time_set
Whether or not an start time has been set.
std::string getFileName(bool stripLeadingPath=true) const
Return the filename that was parsed.
std::set< std::string > getLoadedLibraryPaths() const
Return the loaded library filenames in a std::set.
std::shared_ptr< Executioner > _executioner
Pointer to the executioner of this run (typically build by actions)
std::string underscoreToCamelCase(const std::string &underscore_name, bool leading_upper_case)
Function for converting an underscore name to a camel case name.
unsigned int _multiapp_level
Level of multiapp, the master is level 0. This used by the Console to indent output.
bool isParamValid(const std::string &name) const
const PerfID _execute_mesh_modifiers_timer
void clear()
This method deletes all of the Actions in the warehouse.
void dynamicRegistration(const Parameters ¶ms)
Helper method for dynamic loading of objects.
std::string getInputFileName() const
Returns the input file name that was set with setInputFileName.
const std::multimap< std::string, ActionInfo > & getAssociatedActions() const
Return all Syntax to Action associations.
bool _distributed_mesh_on_command_line
This variable indicates that DistributedMesh should be used for the libMesh mesh underlying MooseMesh...
bool isUseSplit() const
Whether or not we are running with pre-split (distributed mesh)
const std::string _name
The name of this object.
ActionFactory _action_factory
The Factory responsible for building Actions.
void errorCheck()
Runs post-initialization error checking that cannot be run correctly unless the simulation has been f...
static const std::map< std::string, std::vector< RegistryEntry > > & allObjects()
Returns a per-label keyed map of all MooseObjects in the registry.
bool _trap_fpe
Variable indicating whether we will enable FPE trapping for this run.
ExecFlagEnum _execute_flags
Execution flags for this App.
std::unique_ptr< SystemInfo > _sys_info
System Information.
std::vector< std::string > getMeshGeneratorNames() const
Get names of all mesh generators Note: This function should be called after all mesh generators are a...
processor_id_type processor_id() const
Returns the MPI processor ID of the current processor.
const MeshModifier & getMeshModifier(const std::string &name) const
Get a mesh modifier with its name.
Syntax & syntax()
Returns a writable reference to the syntax object.
const T & getParamTempl(const std::string &name) const
Retrieve a parameter for the object.
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.
void setRecover(bool value)
virtual std::string getVersion() const
Returns the current version of the framework or application (default: framework version).
PetscErrorCode petscSetupOutput(CommandLine *cmd_line)
std::string stringify(const T &t)
conversion to string
void addItem(const T &value)
Add an independent item to the set.
const std::list< Action * > & getActionListByName(const std::string &task) const
Retrieve a constant list of Action pointers associated with the passed in task.
void mooseInfo(Args &&... args)
Emit an informational message with the given stringified, concatenated args.
const PerfID _restore_timer
std::string _input_filename
Input file name used.
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application.
Abstract definition of a RestartableData value.
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 ...
bool isUltimateMaster()
Whether or not this app is the ultimate master app.
void dofMapReinitForRMs()
Loop through RMs and call dofmap_reinit.
void mooseWarning(Args &&... args)
Emit a warning message with the given stringified, concatenated args.
const bool _use_split
Whether or not we are using a (pre-)split mesh (automatically DistributedMesh)
bool _deprecated_is_error
Variable to toggle only deprecated warnings as errors.
static char addKnownLabel(const std::string &label)
addKnownLabel whitelists a label as valid for purposes of the checkLabels function.
const moosecontrib::Json::Value & getRoot() const
Get the root of the tree.
Class for storing and utilizing output objects.
const PerfID _create_minimal_app_timer
std::vector< std::string > getConstructedObjects() const
Get a list of all constructed Moose Object types.
void setID(const int &id)
Method to change the ID of the item, but only if it is an INVALID_ID.
InputParameters _pars
Parameters of this object.
bool hasRelationshipManager(const std::string &name) const
Returns a Boolean indicating whether a RelationshipManater exists with the same name.
std::shared_ptr< Action > create(const std::string &action, const std::string &action_name, InputParameters ¶meters)
MooseApp(InputParameters parameters)
Constructor is protected so that this object is constructed through the AppFactory object.
const MooseMesh * _master_mesh
The mesh from master app.
void setFinalTask(const std::string &task)
std::string _final_generator_name
The final mesh generator name to use.
std::size_t size() const
Returns the number of unique items stored in the dependency resolver.
Struct and Aliases for Restartable/Recoverable structures.
std::string shortName(const std::string &name)
Function for stripping name after the file / in parser block.
bool _popped_final_mesh_generator
Whether the mesh generator MeshBase has been popped off its storage container and is no longer access...
void setOutputPosition(const Point &p)
Tell the app to output in a specific position.
RelationshipManagerType
Main types of Relationship Managers.
const std::vector< std::vector< T > > & getSortedValuesSets()
Returns a vector of sets that represent dependency resolved values.
unsigned int multiAppLevel() const
The MultiApp Level.
std::unique_ptr< TheWarehouse > _the_warehouse
The combined warehouse for storing any MooseObject based object.
std::string _restart_recover_suffix
The file suffix to restart/recover from. If blank then we will use the binary restart suffix.
bool _warnings_are_errors
Variable to toggle any warning into an error (includes deprecated code warnings)
std::string libNameToAppName(const std::string &library_name) const
Converts a library name to an application name:
const MeshGenerator & getMeshGenerator(const std::string &name) const
Get a mesh generator with its name.
std::string appNameToLibName(const std::string &app_name) const
Converts an application name to a library name: Examples: AnimalApp -> libanimal-oprof....
const std::string & name() const
Get the name of the object.
const std::shared_ptr< MooseMesh > & getMesh() const
std::set< MooseEnumItem >::const_iterator find(const MooseEnumItem &other) const
Locate an item.
std::string getPrintableVersion() const
Non-virtual method for printing out the version string in a consistent format.
void mooseDeprecated(Args &&... args)
Emit a deprecated code/feature message with the given stringified, concatenated args.
bool _half_transient
Whether or not this simulation should only run half its transient (useful for testing recovery)
RestartableDataValue & registerRestartableData(const std::string &name, std::unique_ptr< RestartableDataValue > data, THREAD_ID tid, bool mesh_meta_data, bool read_only)
Class for containing MooseEnum item information.
const PerfID _execute_executioner_timer
std::vector< std::string > getMeshModifierNames() const
Get names of all mesh modifiers Note: This function should be called after all mesh modifiers are add...
bool hasRestartRecoverFileBase() const
Return true if the recovery file base is set.
Generic factory class for build all sorts of objects.
std::vector< std::pair< std::string, std::string > > getRelationshipManagerInfo() const
Returns the Relationship managers info suitable for printing.
Specialized factory for generic Action System objects.
std::list< std::string > getCheckpointFiles() const
Extract all possible checkpoint file names.
std::string _restart_recover_base
The base name to restart/recover from. If blank then we will find the newest checkpoint file.
const PerfID _run_input_file_timer
std::string _output_file_base
The output file basename.
Holding syntax for parsing input files.
Syntax _syntax
Syntax of the input file.
void setActive(bool active)
Turn on or off timing.
const PerfID _setup_options_timer
bool isRecovering() const
Whether or not this is a "recover" calculation.
InputParameters & getObjectParams()
Retreive the parameters of the object to be created by this action.
void initSyntaxFormatter(SyntaxFormatterType type, bool dump_mode)
Creates a syntax formatter for printing.
DataNames _recoverable_data_names
Data names that will only be read from the restart file during RECOVERY.
std::string camelCaseToUnderscore(const std::string &camel_case_name)
Function for converting a camel case name to a name containing underscores.
void meshChanged()
Calls the meshChanged method for every output object.
TODO: delete this later - it is a temporary hack for dealing with inter-system dependencies.
std::string getFileName(bool stripLeadingPath=true) const
Return the filename that was parsed Note: When stripLeadingPath is false, this function returns the s...
std::pair< std::string, std::string > splitFileName(std::string full_file)
Function for splitting path and filename.
void registerAll(Factory &f, ActionFactory &af, Syntax &s)
Register objects that are in MOOSE.
std::vector< std::shared_ptr< RelationshipManager > > _relationship_managers
virtual std::shared_ptr< Backup > backup()
Create a Backup from the current App.
static AppFactory & instance()
Get the instance of the AppFactory.
bool addRelationshipManager(std::shared_ptr< RelationshipManager > relationship_manager)
Transfers ownership of a RelationshipManager to the application for lifetime management.
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)
Holds the syntax in a Json::Value tree.
MooseMesh wraps a libMesh::Mesh object and enhances its capabilities by caching additional data and s...
virtual std::string header() const
Returns a string to be printed at the beginning of a simulation.
Base class for MOOSE-based applications.
ActionWarehouse _action_warehouse
Where built actions are stored.
const std::string & name() const
const PerfID _execute_timer
bool isSplitMesh() const
Whether or not this is a split mesh operation.
void setInputFileName(const std::string &input_file_name)
Set the input file name.
void parse(const std::string &input_filename)
Parse an input file consisting of hit syntax and setup objects in the MOOSE derived application.
void registerRestartableNameWithFilter(const std::string &name, Moose::RESTARTABLE_FILTER filter)
NOTE: This is an internal function meant for MOOSE use only!
const std::list< T > getAncestors(const T &key)
Returns a list of all values that a given key depends on.
static InputParameters validParams()
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 ...
std::unique_ptr< MeshBase > & getMeshGeneratorOutput(const std::string &name)
Get a refernce to a pointer that will be the output of the MeshGenerator named name.
if(nl->nonlinearSolver() ->matvec &&nl->nonlinearSolver() ->residual_and_jacobian_object)
static const int INVALID_ID
void addExecFlag(const ExecFlagType &flag)
WARNING: This is an internal method for MOOSE, if you need the add new ExecFlagTypes then use the reg...
virtual void setupOptions()
Setup options based on InputParameters.
void disableCheckUnusedFlag()
Removes warnings and error checks for unrecognized variables in the input file.
void executeAllActions()
This method loops over all actions in the warehouse and executes them.
RestartableDataMaps _restartable_data
Where the restartable data is held (indexed on tid)
void indentMessage(const std::string &prefix, std::string &message, const char *color=COLOR_CYAN)
Indents the supplied message given the prefix and color.
static const std::map< std::string, std::vector< RegistryEntry > > & allActions()
Returns a per-label keyed map of all Actions in the registry.
void errorCheck(const Parallel::Communicator &comm, bool warn_unused, bool err_unused)
A scope guard that guarantees that whatever happens between when it gets created and when it is destr...
InputParameters & parameters()
Get the parameters of the object.
bool isRestarting() const
Whether or not this is a "restart" calculation.
std::shared_ptr< Backup > createBackup()
Create a Backup for the current system.
Specialization of SubProblem for solving nonlinear equations plus auxiliary equations.
enum MooseApp::UNUSED_CHECK _enable_unused_check
bool _recover
Whether or not this is a recovery run.
InputParameterWarehouse * _input_parameter_warehouse
Input parameter storage structure (this is a raw pointer so the destruction time can be explicitly co...
const PerfID _setup_timer
Timers.
void setRestart(bool value)
Sets the restart/recover flags.
Point _output_position
The output position.
void addMeshGenerator(const std::string &generator_name, const std::string &name, InputParameters parameters)
Add a mesh generator that will act on the meshes in the system.
void dynamicAppRegistration(const std::string &app_name, std::string library_path, const std::string &library_name)
void addDependency(const std::string &task, const std::string &pre_req)
Method to insert a new task in the list of existing tasks at the specified location.
bool _output_position_set
Whether or not an output position has been set for this app.
void executeMeshGenerators()
Execute and clear the Mesh Generators data structure.
void buildJsonSyntaxTree(JsonSyntaxTree &tree) const
Use MOOSE Factories to construct a parameter tree for documentation or echoing input.
MeshModifiers are objects that can modify or add to an existing mesh.
bool _trap_fpe
Whether or not FPE trapping should be turned on.
std::map< std::string, std::shared_ptr< MeshGenerator > > _mesh_generators
Holds the mesh generators until they have completed, then this structure is cleared.
std::string getOutputFileBase(bool for_non_moose_build_output=false) const
Get the output file base name.
std::shared_ptr< Backup > _cached_backup
Cache for a Backup to use for restart / recovery.
OutputWarehouse _output_warehouse
OutputWarehouse object for this App.
bool _check_input
true if we want to just check the input file
void createMinimalApp()
Method for creating the minimum required actions for an application (no input file)
bool _file_base_set_by_user
Whether or not file base is set through input or setOutputFileBase by MultiApp.
std::shared_ptr< MooseMesh > & displacedMesh()
std::map< std::pair< std::string, std::string >, void * > _lib_handles
The library, registration method and the handle to the method.
void attachRelationshipManagers(Moose::RelationshipManagerType rm_type)
Attach the relationship managers of the given type Note: Geometric relationship managers that are sup...