10 #ifdef HAVE_GPERFTOOLS 11 #include "gperftools/profiler.h" 12 #include "gperftools/heap-profiler.h" 16 #include "MooseRevision.h" 61 #include "libmesh/exodusII_io.h" 62 #include "libmesh/mesh_refinement.h" 63 #include "libmesh/string_to_enum.h" 64 #include "libmesh/checkpoint_io.h" 65 #include "libmesh/mesh_base.h" 68 #ifdef LIBMESH_HAVE_DLOPEN 70 #include <sys/utsname.h> 76 #include <sys/types.h> 82 #define QUOTE(macro) stringifyName(macro) 90 "Specify the application that should be used to run the input file. This must match an " 91 "application name registered to the application factory. Note that this option is " 104 "display_version",
"-v --version",
false,
"Print application version");
108 "--mesh-only [mesh_file_name]",
109 "Setup and Output the input mesh only (Default: \"<input_file_name>_in.e\")");
114 "Shows the parsed input file before running the simulation.");
116 "show_outputs",
"--show-outputs",
false,
"Shows the output execution time information.");
118 "show_controls",
"--show-controls",
false,
"Shows the Control logic available and executed.");
121 "no_color",
"--no-color",
false,
"Disable coloring of all Console outputs.");
123 "--color [auto,on,off]",
125 "Whether to use color in console output (default 'on').");
127 params.
addCommandLineParam<
bool>(
"help",
"-h --help",
false,
"Displays CLI usage statement.");
132 "Ignore input file and build a minimal application with Transient executioner.");
137 "Starts a process to communicate with development tools using the language server protocol");
140 "definition",
"--definition",
"Shows a SON style input definition dump for input validation");
142 "dump",
"--dump [search_string]",
"Shows a dump of available input file syntax.");
144 "registry",
"--registry",
"Lists all known objects and actions.");
146 "registry_hit",
"--registry-hit",
"Lists all known objects and actions in hit format.");
148 "use_executor",
"--executor",
false,
"Use the new Executor system instead of Executioners");
151 "apptype",
"--type",
false,
"Return the name of the application object.");
153 "yaml",
"--yaml",
"Dumps input file syntax in YAML format.");
155 "json",
"--json",
"Dumps input file syntax in JSON format.");
157 "syntax",
"--syntax",
false,
"Dumps the associated Action syntax paths ONLY");
159 "show_docs",
"--docs",
false,
"print url/path to the documentation website");
163 "Check the input file (i.e. requires -i <filename>) and quit.");
166 "--show-copyable-inputs",
167 "Shows the directories able to be installed (copied) into a user-writable location");
170 "--copy-inputs <dir>",
171 "Copies installed inputs (e.g. tests, examples, etc.) to " 172 "an directory named <appname>_<dir>.");
175 "Runs the inputs in the current directory copied to a " 176 "user-writable location by \"--copy-inputs\"");
179 "list_constructed_objects",
180 "--list-constructed-objects",
182 "List all moose object type names constructed by the master app factory.");
185 "n_threads",
"--n-threads=<n>", 1,
"Runs the specified number of threads per process");
190 "Warn about unused input file options instead of erroring.");
194 "Error when encountering unused input file options");
197 "-o --error-override",
199 "Error when encountering overridden or parameters supplied multiple times");
201 "error_deprecated",
"--error-deprecated",
false,
"Turn deprecated code messages into Errors");
205 "--distributed-mesh",
207 "The libMesh Mesh underlying MooseMesh should always be a DistributedMesh");
211 "--split-mesh [splits]",
212 "comma-separated list of numbers of chunks to split the mesh into");
215 "--split-file [filename]",
217 "optional name of split mesh file(s) to write/read");
220 "use_split",
"--use-split",
false,
"use split distributed mesh files");
226 "Specify additional initial uniform mesh refinements for grid convergence studies");
229 "--recover [file_base]",
230 "Continue the calculation. If file_base is omitted then " 231 "the most recent recovery file will be utilized");
234 "--test-checkpoint-half-transient",
236 "When true the simulation will only run half of " 237 "its specified transient (ie half the " 238 "timesteps) with checkpoints enabled. " 239 "This is useful for testing recovery and restart " 240 "and should only be used in the test harness.");
243 "--output-wall-time-interval [interval]",
244 "The target wall time interval (in seconds) at " 245 "which to write to output. " 246 "USE FOR TEST SUITE PROBLEMS ONLY, FOR ALL OTHER USES " 247 "SEE THE wall_time_interval IN DERIVED Output OBJECTS.");
253 "Enable Floating Point Exception handling in critical sections of " 254 "code. This is enabled automatically in DEBUG mode");
257 "Disable Floating Point Exception handling in critical " 258 "sections of code when using DEBUG mode.");
260 params.
addCommandLineParam<
bool>(
"error",
"--error",
false,
"Turn all warnings into errors");
266 "Enable all performance logging for timing purposes. This will disable all " 267 "screen output of performance logs for all Console objects.");
271 "Disabled performance logging. Overrides -t or --timing " 272 "if passed in conjunction with this flag");
275 "allow_test_objects",
"--allow-test-objects",
false,
"Register test objects and syntax.");
283 "Keep standard output from all processors when running in parallel");
288 "Keep standard output from all processors when running in parallel");
292 "--timpi-sync <sync type>",
294 "Changes the sync type used in spare parallel communitations within the TIMPI library " 295 "(advanced option).");
299 "--start-in-debugger <debugger>",
300 "Start the application and attach a debugger. This will " 301 "launch xterm windows using the command you specify for " 305 "--stop-for-debugger [seconds]",
307 "Pauses the application during startup for the " 308 "specified time to allow for connection of debuggers.");
311 "--perf-graph-live-all",
313 "Forces printing of ALL progress messages.");
316 "--disable-perf-graph-live",
318 "Disables PerfGraph Live Printing.");
321 "automatic_automatic_scaling",
false,
"Whether to turn on automatic scaling by default.");
323 #ifdef HAVE_GPERFTOOLS 326 "--gperf-profiler-on [ranks]",
327 "To generate profiling report only on comma-separated list of MPI ranks.");
335 params.
addPrivateParam<std::shared_ptr<Parallel::Communicator>>(
"_comm");
340 params.
addPrivateParam<std::unique_ptr<Backup> *>(
"_initial_backup",
nullptr);
344 "use_legacy_material_output",
346 "Set false to allow material properties to be output on INITIAL, not just TIMESTEP_END.");
351 "Set true to enable data-driven mesh generation, which is an experimental feature");
361 ParallelObject(*parameters.
get<
std::shared_ptr<Parallel::Communicator>>(
364 parameters.
get<
std::string>(
"_app_name"),
368 _comm(getParam<
std::shared_ptr<Parallel::Communicator>>(
"_comm")),
369 _file_base_set_by_user(false),
370 _output_position_set(false),
371 _start_time_set(false),
373 _global_time_offset(0.0),
375 _action_factory(*this),
376 _action_warehouse(*this, _syntax, _action_factory),
377 _output_warehouse(*this),
378 _parser(parameters.
get<
std::shared_ptr<
Parser>>(
"_parser")),
379 _builder(*this, _action_warehouse, _parser),
381 _perf_graph(createRecoverablePerfGraph()),
382 _solution_invalidity(createRecoverableSolutionInvalidity()),
383 _rank_map(*_comm, _perf_graph),
384 _use_executor(parameters.
get<bool>(
"use_executor")),
385 _null_executor(NULL),
386 _use_nonlinear(true),
387 _use_eigen_value(false),
388 _enable_unused_check(ERROR_UNUSED),
390 _error_overridden(false),
391 _ready_to_exit(false),
392 _initial_from_file(false),
393 _distributed_mesh_on_command_line(false),
397 _use_split(parameters.
get<bool>(
"use_split")),
403 _test_checkpoint_half_transient(false),
404 _check_input(getParam<bool>(
"check_input")),
406 isParamValid(
"_multiapp_level") ? parameters.
get<unsigned
int>(
"_multiapp_level") : 0),
408 isParamValid(
"_multiapp_number") ? parameters.
get<unsigned
int>(
"_multiapp_number") : 0),
409 _master_mesh(isParamValid(
"_master_mesh") ? parameters.
get<const
MooseMesh *>(
"_master_mesh")
411 _master_displaced_mesh(isParamValid(
"_master_displaced_mesh")
412 ? parameters.
get<const
MooseMesh *>(
"_master_displaced_mesh")
414 _mesh_generator_system(*this),
415 _rd_reader(*this, _restartable_data),
416 _execute_flags(
moose::internal::ExecFlagRegistry::getExecFlagRegistry().getFlags()),
417 _output_buffer_cache(nullptr),
418 _automatic_automatic_scaling(getParam<bool>(
"automatic_automatic_scaling")),
419 _initial_backup(getParam<
std::unique_ptr<
Backup> *>(
"_initial_backup"))
422 const auto & timpi_sync =
parameters.
get<std::string>(
"timpi_sync");
423 const_cast<Parallel::Communicator &
>(
comm()).sync_type(timpi_sync);
425 #ifdef HAVE_GPERFTOOLS 428 bool has_cpu_profiling =
false;
429 bool has_heap_profiling =
false;
430 static std::string cpu_profile_file;
431 static std::string heap_profile_file;
434 if (std::getenv(
"MOOSE_PROFILE_BASE"))
436 has_cpu_profiling =
true;
438 std::getenv(
"MOOSE_PROFILE_BASE") + std::to_string(
_comm->rank()) +
".prof";
441 if (!
name.first.empty())
450 if (std::getenv(
"MOOSE_HEAP_BASE"))
452 has_heap_profiling =
true;
453 heap_profile_file = std::getenv(
"MOOSE_HEAP_BASE") + std::to_string(
_comm->rank());
456 if (!
name.first.empty())
467 auto rankstr = getParam<std::string>(
"gperf_profiler_on");
468 std::vector<processor_id_type> ranks;
471 mooseError(
"Invalid argument for --gperf-profiler-on: '", rankstr,
"'");
472 for (
auto & rank : ranks)
474 if (rank >=
_comm->size())
475 mooseError(
"Invalid argument for --gperf-profiler-on: ",
477 " is greater than or equal to ",
479 if (rank ==
_comm->rank())
493 if (!ProfilerStart(cpu_profile_file.c_str()))
494 mooseError(
"CPU profiler is not started properly");
498 HeapProfilerStart(heap_profile_file.c_str());
499 if (!IsHeapProfilerRunning())
500 mooseError(
"Heap profiler is not started properly");
504 if (std::getenv(
"MOOSE_PROFILE_BASE") || std::getenv(
"MOOSE_HEAP_BASE"))
505 mooseError(
"gperftool is not available for CPU or heap profiling");
537 int argc = getParam<int>(
"_argc");
538 char ** argv = getParam<char **>(
"_argv");
540 _sys_info = std::make_unique<SystemInfo>(argc, argv);
545 mooseError(
"Valid CommandLine object required");
548 mooseError(
"Cannot run --check-input with --recover. Recover files might not exist");
552 auto command = getParam<std::string>(
"start_in_debugger");
554 Moose::out <<
"Starting in debugger using: " << command << std::endl;
558 std::stringstream command_stream;
562 <<
" PID: " << getpid() <<
"'; echo ''; ";
565 if (command.find(
"lldb") != std::string::npos || command.find(
"gdb") != std::string::npos)
566 command_stream << command <<
" -p " << getpid();
570 "\nIf this is truly what you meant then contact moose-users to have a discussion " 571 "about adding your debugger.");
574 command_stream <<
"\"" 577 std::string command_string = command_stream.str();
578 Moose::out <<
"Running: " << command_string << std::endl;
580 int ret = std::system(command_string.c_str());
584 std::this_thread::sleep_for(std::chrono::seconds(10));
589 Moose::out <<
"\nStopping for " << getParam<unsigned int>(
"stop_for_debugger")
590 <<
" seconds to allow attachment from a debugger.\n";
592 Moose::out <<
"\nAll of the processes you can connect to:\n";
593 Moose::out <<
"rank - hostname - pid\n";
603 Moose::out <<
"\nWaiting...\n" << std::endl;
606 std::this_thread::sleep_for(std::chrono::seconds(getParam<unsigned int>(
"stop_for_debugger")));
610 mooseError(
"Mesh can be passed in only for sub-apps");
613 mooseError(
"_master_mesh should have been set when _master_displaced_mesh is set");
622 mooseDeprecated(
"The parameter 'use_legacy_dirichlet_bc' is no longer valid.\n\n",
623 "All Dirichlet boundary conditions are preset by default.\n\n",
624 "Remove said parameter in ",
626 " to remove this deprecation warning.");
628 Moose::out << std::flush;
633 #ifdef HAVE_GPERFTOOLS 655 #ifdef LIBMESH_HAVE_DLOPEN 658 dlclose(lib_pair.second.library_handle);
665 return MOOSE_VERSION;
671 return MOOSE_VERSION;
683 TIME_SECTION(
"setupOptions", 5,
"Setting Up Options");
687 if (hdr.length() != 0)
691 Moose::out << hdr << std::endl;
694 if (getParam<bool>(
"error_unused"))
696 else if (getParam<bool>(
"allow_unused"))
699 if (getParam<bool>(
"error_override"))
708 const auto output_wall_time_interval = getParam<Real>(
"output_wall_time_interval");
709 if (output_wall_time_interval <= 0)
710 mooseError(
"--output-wall-time-interval must be greater than zero.");
714 if (getParam<bool>(
"no_timing"))
722 mooseError(
"Cannot use both \"--trap-fpe\" and \"--no-trap-fpe\" flags.");
738 if (getParam<bool>(
"no_color"))
741 char * c_color = std::getenv(
"MOOSE_COLOR");
742 std::string color =
"on";
745 if (getParam<std::string>(
"color") !=
"default-on")
746 color = getParam<std::string>(
"color");
750 else if (color ==
"on")
752 else if (color ==
"off")
755 mooseWarning(
"ignoring invalid --color arg (want 'auto', 'on', or 'off')");
760 if (getParam<bool>(
"no_color"))
761 mooseDeprecated(
"The --no-color flag is deprecated. Use '--color off' instead.");
769 #if !LIBMESH_USING_THREADS 771 mooseError(
"You specified --n-threads > 1, but there is no threading model active!");
775 if (getParam<bool>(
"minimal"))
778 else if (getParam<bool>(
"display_version"))
784 else if (getParam<bool>(
"help"))
792 std::string following_arg = getParam<std::string>(
"dump");
796 std::string param_search;
797 if (!following_arg.empty() && (following_arg.find(
'-') != 0))
798 param_search = following_arg;
803 TIME_SECTION(
"dump", 1,
"Building Syntax Tree");
811 Moose::out <<
"\n### START DUMP DATA ###\n" 812 << formatter.
toString(tree.
getRoot()) <<
"\n### END DUMP DATA ###" << std::endl;
819 Moose::out <<
"Label\tType\tName\tClass\tFile\n";
822 for (
auto & entry : objmap)
823 for (
auto & obj : entry.second)
824 Moose::out << entry.first <<
"\tobject\t" << obj->name() <<
"\t" << obj->_classname <<
"\t" 825 << obj->_file <<
"\n";
828 for (
auto & entry : actmap)
830 for (
auto & act : entry.second)
831 Moose::out << entry.first <<
"\taction\t" << act->_name <<
"\t" << act->_classname <<
"\t" 832 << act->_file <<
"\n";
841 Moose::out <<
"### START REGISTRY DATA ###\n";
843 hit::Section root(
"");
844 auto sec =
new hit::Section(
"registry");
846 auto objsec =
new hit::Section(
"objects");
847 sec->addChild(objsec);
850 for (
auto & entry : objmap)
851 for (
auto & obj : entry.second)
853 auto ent =
new hit::Section(
"entry");
854 objsec->addChild(ent);
855 ent->addChild(
new hit::Field(
"label", hit::Field::Kind::String, entry.first));
856 ent->addChild(
new hit::Field(
"type", hit::Field::Kind::String,
"object"));
857 ent->addChild(
new hit::Field(
"name", hit::Field::Kind::String, obj->name()));
858 ent->addChild(
new hit::Field(
"class", hit::Field::Kind::String, obj->_classname));
859 ent->addChild(
new hit::Field(
"file", hit::Field::Kind::String, obj->_file));
862 auto actsec =
new hit::Section(
"actions");
863 sec->addChild(actsec);
865 for (
auto & entry : actmap)
866 for (
auto & act : entry.second)
868 auto ent =
new hit::Section(
"entry");
869 actsec->addChild(ent);
870 ent->addChild(
new hit::Field(
"label", hit::Field::Kind::String, entry.first));
871 ent->addChild(
new hit::Field(
"type", hit::Field::Kind::String,
"action"));
872 ent->addChild(
new hit::Field(
"task", hit::Field::Kind::String, act->_name));
873 ent->addChild(
new hit::Field(
"class", hit::Field::Kind::String, act->_classname));
874 ent->addChild(
new hit::Field(
"file", hit::Field::Kind::String, act->_file));
877 Moose::out << root.render();
879 Moose::out <<
"\n### END REGISTRY DATA ###\n";
889 Moose::out <<
"%-START-SON-DEFINITION-%\n" 900 std::string yaml_following_arg = getParam<std::string>(
"yaml");
905 if (yaml_following_arg.empty() || (yaml_following_arg.find(
'-') == 0))
917 std::string json_following_arg = getParam<std::string>(
"json");
922 if (!json_following_arg.empty() && (json_following_arg.find(
'-') != 0))
923 search = json_following_arg;
928 Moose::out <<
"**START JSON DATA**\n" << tree.
getRoot().dump(2) <<
"\n**END JSON DATA**\n";
931 else if (getParam<bool>(
"syntax"))
936 Moose::out <<
"**START SYNTAX DATA**\n";
937 for (
const auto & it :
syntax)
938 Moose::out << it.first <<
"\n";
939 Moose::out <<
"**END SYNTAX DATA**\n" << std::endl;
942 else if (getParam<bool>(
"apptype"))
946 Moose::out <<
"MooseApp Type: " <<
type() << std::endl;
958 std::string recover_following_arg = getParam<std::string>(
"recover");
962 if (!(recover_following_arg.empty() || (recover_following_arg.find(
'-') == 0)))
994 mooseAssert(common_actions.size() <= 1,
"Should not be more than one CommonOutputAction");
995 const Action * common = common_actions.empty() ? nullptr : *common_actions.begin();
998 if (common && common->isParamValid(
"file_base"))
1007 size_t pos = base.find_last_of(
'.');
1019 mooseError(
"No input files specified. Add -i <inputfile> to your command line.");
1040 mooseError(
"You specified --check-input, but did not provide an input file. Add -i " 1041 "<inputfile> to your command line.");
1048 Moose::out << std::flush;
1051 const std::vector<std::string> &
1054 mooseAssert(
_parser,
"Parser is not set");
1055 return _parser->getInputFileNames();
1061 mooseAssert(
_parser,
"Parser is not set");
1062 return _parser->getLastInputFileName();
1084 for (
auto & multi_app :
feProblem().getMultiAppWarehouse().getObjects())
1085 multi_app->setAppOutputFileBase();
1093 TIME_SECTION(
"runInputFile", 3);
1103 else if (getParam<bool>(
"list_constructed_objects"))
1108 Moose::out <<
"**START OBJECT DATA**\n";
1109 for (
const auto &
name : obj_list)
1110 Moose::out <<
name <<
"\n";
1111 Moose::out <<
"**END OBJECT DATA**\n" << std::endl;
1124 for (
auto app : apps)
1125 for (
unsigned int i = 0; i < app->numLocalApps(); i++)
1126 app->localApp(i)->errorCheck();
1132 TIME_SECTION(
"executeExecutioner", 3);
1146 if (!result.convergedAll())
1157 mooseError(
"No executioner was specified (go fix your input file)");
1188 "MooseApp::hasRestartRecoverFileBase() instead.");
1199 case RESTARTABLE_FILTER::RECOVERABLE:
1207 std::vector<std::filesystem::path>
1210 TIME_SECTION(
"backup", 2,
"Backing Up Application to File");
1215 return writer.
write(folder_base);
1218 std::unique_ptr<Backup>
1221 TIME_SECTION(
"backup", 2,
"Backing Up Application");
1227 auto backup = std::make_unique<Backup>();
1236 TIME_SECTION(
"restore", 2,
"Restoring Application from File");
1249 TIME_SECTION(
"restore", 2,
"Restoring Application");
1254 mooseError(
"MooseApp::resore(): Provided backup is not initialized");
1257 mooseAssert(
header,
"Header not available");
1259 auto data = std::move(
backup->data);
1260 mooseAssert(data,
"Data not available");
1275 std::unique_ptr<Backup>
1279 mooseError(
"MooseApp::finalizeRestore(): Not currently restoring");
1284 std::unique_ptr<Backup>
backup;
1288 if (
auto header_string_input = dynamic_cast<StringInputStream *>(input_streams.header.get()))
1290 auto data_string_input =
dynamic_cast<StringInputStream *
>(input_streams.data.get());
1291 mooseAssert(data_string_input,
"Should also be a string input");
1293 auto header_sstream = header_string_input->release();
1294 mooseAssert(header_sstream,
"Header not available");
1296 auto data_sstream = data_string_input->release();
1297 mooseAssert(data_sstream,
"Data not available");
1299 backup = std::make_unique<Backup>();
1300 backup->header = std::move(header_sstream);
1301 backup->data = std::move(data_sstream);
1327 const std::string & name,
1333 mooseError(
"an executor with name '", executor->name(),
"' already exists");
1339 const std::string & name,
1348 mooseAssert(
_parser,
"Not set");
1354 std::list<std::string> & possible_roots,
1355 std::list<std::string> & current_branch)
1362 if (std::find(current_branch.begin(), current_branch.end(), current_executor_name) !=
1363 current_branch.end())
1365 std::stringstream exec_names_string;
1367 auto branch_it = current_branch.begin();
1369 exec_names_string << *branch_it++;
1371 for (; branch_it != current_branch.end(); ++branch_it)
1372 exec_names_string <<
", " << *branch_it;
1374 exec_names_string <<
", " << current_executor_name;
1376 mooseError(
"Executor cycle detected: ", exec_names_string.str());
1379 current_branch.push_back(current_executor_name);
1384 for (
const auto & param : params)
1386 if (params.have_parameter<ExecutorName>(param.first))
1388 const auto & dependency_name = params.get<ExecutorName>(param.first);
1390 possible_roots.remove(dependency_name);
1392 if (!dependency_name.empty())
1401 current_branch.pop_back();
1412 std::list<std::string> possibly_root;
1415 std::map<std::string, bool> already_built;
1418 std::list<std::string> possible_roots;
1421 std::list<std::string> current_branch;
1431 const auto &
name = params_entry.first;
1437 possible_roots.emplace_back(
name);
1443 if (possible_roots.size() > 1)
1445 auto root_string_it = possible_roots.begin();
1447 std::stringstream roots_string;
1449 roots_string << *root_string_it++;
1451 for (; root_string_it != possible_roots.end(); ++root_string_it)
1452 roots_string <<
", " << *root_string_it;
1454 mooseError(
"Multiple Executor roots found: ", roots_string.str());
1469 if (fail_if_not_found)
1490 TIME_SECTION(
"run", 3);
1491 if (
isParamValid(
"show_docs") && getParam<bool>(
"show_docs"))
1495 mooseError(
"could not locate installed tests to run (unresolved binary/app name)");
1498 mooseError(
"no installed documentation found");
1504 std::ifstream ifs(docmsgfile);
1505 std::string content((std::istreambuf_iterator<char>(ifs)),
1506 (std::istreambuf_iterator<char>()));
1507 content.replace(content.find(
"$LOCAL_SITE_HOME"), content.length(), docmsg);
1511 Moose::out << docmsg <<
"\n";
1524 TIME_SECTION(
"setup", 2,
"Setting Up");
1528 catch (std::exception &
err)
1535 TIME_SECTION(
"execute", 2,
"Executing");
1542 Moose::err <<
"Syntax OK" << std::endl;
1552 std::vector<std::string> dirs;
1555 if (installable_inputs ==
"")
1558 <<
"Show inputs has not been overriden in this application.\nContact the developers of " 1559 "this appication and request that they override \"MooseApp::getInstallableInputs\".\n";
1563 mooseAssert(!copy_syntax.empty(),
"copy_inputs sytnax should not be empty");
1566 Moose::out <<
"The following directories are installable into a user-writeable directory:\n\n" 1567 << installable_inputs <<
'\n' 1568 <<
"\nTo install one or more directories of inputs, execute the binary with the \"" 1569 << copy_syntax[0] <<
"\" flag. e.g.:\n$ " <<
_command_line->getExecutableName()
1570 <<
' ' << copy_syntax[0] <<
' ' << dirs[0] <<
'\n';
1589 auto dir_to_copy = getParam<std::string>(
"copy_inputs");
1591 if (dir_to_copy.empty())
1592 mooseError(
"Error retrieving directory to copy");
1593 if (dir_to_copy.back() !=
'/')
1600 mooseError(
"could not locate installed tests to run (unresolved binary/app name)");
1604 "Rerun binary with " +
1606 " to get a list of installable directories.");
1610 auto dst_dir =
_command_line->getExecutableNameBase() +
"/" + dir_to_copy;
1612 if (cmdname.find_first_of(
"/") != std::string::npos)
1613 cmdname = cmdname.substr(cmdname.find_first_of(
"/") + 1, std::string::npos);
1617 "The directory \"./",
1619 "\" already exists.\nTo update/recopy the contents of this directory, rename (\"mv ",
1621 " new_dir_name\") or remove (\"rm -r ",
1623 "\") the existing directory.\nThen re-run \"",
1629 std::string cmd =
"mkdir -p " + dst_dir +
"; rsync -av " + src_dir +
" " + dst_dir;
1631 TIME_SECTION(
"copy_inputs", 2,
"Copying Inputs");
1634 int return_value = 0;
1636 return_value = system(cmd.c_str());
1639 if (WIFEXITED(return_value) && WEXITSTATUS(return_value) != 0)
1640 mooseError(
"Failed to copy the requested directory.");
1641 Moose::out <<
"Directory successfully copied into ./" << dst_dir <<
'\n';
1656 std::string test_args;
1661 test_args +=
" " + *it;
1671 mooseError(
"Could not locate binary name relative to installed location");
1675 "Could not locate installed tests from the current working directory:",
1677 ".\nMake sure you are executing this command from within a writable installed inputs ",
1678 "directory.\nRun \"",
1680 " --copy-inputs <dir>\" to copy the contents of <dir> to a \"./",
1682 "_<dir>\" directory.\nChange into that directory and try \"",
1684 " --run <dir>\" again.");
1688 Moose::out <<
"Working Directory: " << working_dir <<
"\nRunning Command: " << cmd << std::endl;
1689 int return_value = 0;
1691 return_value = system(cmd.c_str());
1694 if (WIFEXITED(return_value) && WEXITSTATUS(return_value) != 0)
1713 std::list<std::string>
1717 std::list<std::string> checkpoint_dirs;
1724 for (
const auto & action : actions)
1728 if (!moose_object_action)
1732 if (moose_object_action->
getParam<std::string>(
"type") ==
"Checkpoint")
1736 const std::string cp_dir =
1739 checkpoint_dirs.push_back(cp_dir +
"_cp");
1742 return checkpoint_dirs;
1745 std::list<std::string>
1774 std::string library_name(app_name);
1777 size_t pos = library_name.find(
"App");
1778 if (pos != library_name.length() - 3)
1779 mooseError(
"Invalid application name: ", library_name);
1780 library_name.erase(pos);
1784 QUOTE(METHOD) +
".la";
1790 std::string app_name(library_name);
1793 if (pcrecpp::RE(
"lib(.+?)(?:-\\w+)?\\.la").Replace(
"\\1", &app_name) == 0)
1794 mooseError(
"Invalid library name: ", app_name);
1805 if (!metaname.empty() && tid != 0)
1807 "The meta data storage for '", metaname,
"' is not threaded, so the tid must be zero.");
1809 mooseAssert(metaname.empty() ||
1811 "The desired meta data name does not exist: " + metaname);
1820 if (data->typeId() != stored_data->
typeId())
1821 mooseError(
"Type mismatch found in RestartableData registration of '",
1823 "'\n\n Stored type: ",
1824 stored_data->
type(),
1829 stored_data = &data_map.addData(std::move(data));
1834 return *stored_data;
1839 std::unique_ptr<RestartableDataValue> data,
1844 mooseDeprecated(
"The use of MooseApp::registerRestartableData with a data name is " 1845 "deprecated.\n\nUse the call without a name instead.");
1847 mooseAssert(
name == data->name(),
"Inconsistent name");
1858 return it->second.first.hasData(
name);
1868 "The meta data storage for '", metaname,
"' is not threaded, so the tid must be zero.");
1874 mooseError(
"Unable to find RestartableDataValue object with name " +
name +
1875 " in RestartableDataMap");
1882 const std::filesystem::path & folder_base)
1890 reader.
setInput(meta_data_folder_base);
1902 std::vector<std::filesystem::path>
1904 const std::filesystem::path & folder_base)
1907 mooseError(
"MooseApp::writeRestartableMetaData(): Should only run on processor 0");
1913 return writer.
write(meta_data_folder_base);
1916 std::vector<std::filesystem::path>
1919 std::vector<std::filesystem::path> paths;
1925 paths.insert(paths.end(), map_paths.begin(), map_paths.end());
1933 std::string library_path,
1934 const std::string & library_name,
1937 #ifdef LIBMESH_HAVE_DLOPEN 1939 params.set<std::string>(
"app_name") = app_name;
1941 params.set<std::string>(
"registration_method") = app_name +
"__registerApps";
1942 params.set<std::string>(
"library_path") = library_path;
1944 const auto effective_library_name =
1946 params.set<std::string>(
"library_name") = effective_library_name;
1947 params.set<
bool>(
"library_load_dependencies") = lib_load_deps;
1950 std::ostringstream oss;
1952 auto successfully_loaded =
false;
1954 oss <<
'"' << app_name <<
"\" is not a registered application name.\n" 1955 <<
"No search paths were set. We made no attempts to locate the corresponding library " 1964 oss <<
'"' << app_name <<
"\" is not a registered application name.\n" 1965 <<
"Unable to locate library archive for \"" << app_name
1966 <<
"\".\nWe attempted to locate the library archive \"" << effective_library_name
1967 <<
"\" in the following paths:\n\t";
1968 std::copy(paths.begin(), paths.end(), infix_ostream_iterator<std::string>(oss,
"\n\t"));
1971 successfully_loaded =
true;
1974 if (!successfully_loaded)
1976 oss <<
"\nMake sure you have compiled the library and either set the \"library_path\" " 1977 "variable in your input file or exported \"MOOSE_LIBRARY_PATH\".\n";
1983 libmesh_ignore(app_name, library_path, library_name, lib_load_deps);
1984 mooseError(
"Dynamic Loading is either not supported or was not detected by libMesh configure.");
1993 std::string library_path,
1994 const std::string & library_name)
1996 #ifdef LIBMESH_HAVE_DLOPEN 1998 params.set<std::string>(
"app_name") = app_name;
2000 params.set<std::string>(
"registration_method") = app_name +
"__registerAll";
2001 params.set<std::string>(
"library_path") = library_path;
2002 params.set<std::string>(
"library_name") =
2005 params.set<
Factory *>(
"factory") = factory;
2007 params.set<
ActionFactory *>(
"action_factory") = action_factory;
2008 params.set<
bool>(
"library_load_dependencies") =
false;
2013 mooseError(
"Dynamic Loading is either not supported or was not detected by libMesh configure.");
2021 const auto library_name = params.get<std::string>(
"library_name");
2024 for (
const auto & path : paths)
2027 path +
'/' + library_name, params, params.get<
bool>(
"library_load_dependencies"));
2032 const Parameters & params,
2033 const bool load_dependencies)
2036 std::string dl_lib_filename;
2040 pcrecpp::RE re_deps(
"(/\\S*\\.la)");
2042 std::ifstream la_handle(library_filename.c_str());
2043 if (la_handle.is_open())
2045 while (std::getline(la_handle, line))
2048 if (line.find(
"dlname=") != std::string::npos)
2051 dl_lib_filename = line.substr(8, line.size() - 9);
2053 if (line.find(
"dependency_libs=") != std::string::npos)
2055 if (load_dependencies)
2057 pcrecpp::StringPiece input(line);
2058 pcrecpp::StringPiece depend_library;
2059 while (re_deps.FindAndConsume(&input, &depend_library))
2073 if (dl_lib_filename.empty())
2092 #ifdef LIBMESH_HAVE_DLOPEN 2093 void *
const lib_handle = dlopen(dl_lib_full_path.c_str(), RTLD_LAZY);
2095 void *
const lib_handle =
nullptr;
2101 "\" exists and has proper permissions, but cannot by dynamically loaded.\nThis " 2102 "generally means that the loader was unable to load one or more of the " 2103 "dependencies listed in the supplied library (see otool or ldd).\n",
2110 auto insert_ret =
_lib_handles.insert(std::make_pair(file_name, lib_info));
2111 mooseAssert(insert_ret.second ==
true,
"Error inserting into lib_handles map");
2113 dyn_lib_it = insert_ret.first;
2117 const auto registration_method = params.get<std::string>(
"registration_method");
2118 auto & entry_sym_from_curr_lib = dyn_lib_it->second.entry_symbols;
2120 if (entry_sym_from_curr_lib.find(registration_method) == entry_sym_from_curr_lib.end())
2126 #ifdef LIBMESH_HAVE_DLOPEN 2127 void * registration_handle =
2128 dlsym(dyn_lib_it->second.library_handle, registration_method.c_str());
2130 void * registration_handle =
nullptr;
2133 if (registration_handle)
2139 using register_app_t =
void (*)();
2140 register_app_t *
const reg_ptr =
reinterpret_cast<register_app_t *
>(®istration_handle);
2147 register_app_t *
const reg_ptr =
reinterpret_cast<register_app_t *
>(®istration_handle);
2148 (*reg_ptr)(params.get<
Factory *>(
"factory"),
2150 params.get<
Syntax *>(
"syntax"));
2157 entry_sym_from_curr_lib.insert(registration_method);
2162 #if defined(DEBUG) && defined(LIBMESH_HAVE_DLOPEN) 2166 if (!registration_handle)
2168 registration_method,
2172 "This doesn't necessarily indicate an error condition unless you believe that " 2173 "the method should exist in that library.\n",
2180 std::set<std::string>
2184 std::set<std::string> paths;
2186 paths.insert(it.first);
2191 std::set<std::string>
2194 std::set<std::string> paths;
2196 if (!library_path.empty())
2198 std::vector<std::string> tmp_paths;
2201 paths.insert(tmp_paths.begin(), tmp_paths.end());
2204 char * moose_lib_path_env = std::getenv(
"MOOSE_LIBRARY_PATH");
2205 if (moose_lib_path_env)
2207 std::string moose_lib_path(moose_lib_path_env);
2208 std::vector<std::string> tmp_paths;
2211 paths.insert(tmp_paths.begin(), tmp_paths.end());
2226 return std::string(
"");
2244 TIME_SECTION(
"createMinimalApp", 3,
"Creating Minimal App");
2250 action_params.
set<std::string>(
"type") =
"GeneratedMesh";
2253 std::shared_ptr<MooseObjectAction> action = std::static_pointer_cast<
MooseObjectAction>(
2259 params.set<
unsigned int>(
"nx") = 1;
2269 action_params.
set<std::string>(
"type") =
"Transient";
2272 std::shared_ptr<MooseObjectAction> action = std::static_pointer_cast<
MooseObjectAction>(
2277 params.
set<
unsigned int>(
"num_steps") = 1;
2278 params.set<
Real>(
"dt") = 1;
2288 action_params.
set<
bool>(
"_solve") =
false;
2291 std::shared_ptr<Action> action = std::static_pointer_cast<
Action>(
2302 action_params.
set<
bool>(
"console") =
false;
2305 std::shared_ptr<Action> action =
2320 [&
name](
const std::shared_ptr<RelationshipManager> & rm)
2329 auto & existing_for_whom = acceptor.
forWhom();
2332 for (
auto & fw : donor.
forWhom())
2334 if (std::find(existing_for_whom.begin(), existing_for_whom.end(), fw) ==
2335 existing_for_whom.end())
2359 std::set<std::shared_ptr<RelationshipManager>> rms_to_erase;
2363 if (*existing_rm >= *new_rm)
2366 donateForWhom(*new_rm, *existing_rm);
2371 else if (*new_rm >= *existing_rm)
2372 rms_to_erase.emplace(existing_rm);
2378 for (
const auto & rm_to_erase : rms_to_erase)
2380 donateForWhom(*rm_to_erase, *new_rm);
2392 static const std::string suffix =
"-mesh.cpr";
2396 std::filesystem::path
2398 const std::string & map_suffix)
2401 std::filesystem::path(
"meta_data" + map_suffix));
2404 std::filesystem::path
2407 auto folder = folder_base;
2408 folder +=
"-restart-" + std::to_string(
processor_id());
2416 return action->parameters().getHitNode();
2433 mooseError(
"The template rm does not exist in our _template_to_clones map");
2435 auto & mesh_to_clone_map = outer_it->second;
2436 auto inner_it = mesh_to_clone_map.find(&
mesh);
2437 if (inner_it == mesh_to_clone_map.end())
2438 mooseError(
"We should have the mesh key in our mesh");
2440 return *inner_it->second;
2450 const MeshBase *
const undisp_lm_mesh =
mesh->getMeshPtr();
2452 if (undisp_lm_mesh &&
hasRMClone(*rm, *undisp_lm_mesh))
2454 undisp_clone = &
getRMClone(*rm, *undisp_lm_mesh);
2455 const_cast<MeshBase *
>(undisp_lm_mesh)->remove_ghosting_functor(*undisp_clone);
2459 MeshBase *
const disp_lm_mesh = displaced_mesh ? &displaced_mesh->getMesh() :
nullptr;
2461 if (disp_lm_mesh &&
hasRMClone(*rm, *disp_lm_mesh))
2463 disp_clone = &
getRMClone(*rm, *disp_lm_mesh);
2464 disp_lm_mesh->remove_ghosting_functor(*disp_clone);
2472 problem.removeAlgebraicGhostingFunctor(*undisp_clone);
2473 problem.removeCouplingGhostingFunctor(*undisp_clone);
2476 auto * dp = problem.getDisplacedProblem().get();
2477 if (dp && disp_clone)
2478 dp->removeAlgebraicGhostingFunctor(*disp_clone);
2489 const DofMap *
const dof_map)
2492 auto it = mesh_to_clone.find(&
mesh);
2493 if (it != mesh_to_clone.end())
2496 auto & clone_rm = *it->second;
2497 if (!clone_rm.dofMap() && dof_map)
2499 clone_rm.init(moose_mesh,
mesh, dof_map);
2500 else if (clone_rm.dofMap() && dof_map && (clone_rm.dofMap() != dof_map))
2501 mooseError(
"Attempting to create and initialize an existing clone with a different DofMap. " 2502 "This should not happen.");
2512 auto pr = mesh_to_clone.emplace(
2513 std::make_pair(&const_cast<const MeshBase &>(
mesh),
2514 dynamic_pointer_cast<RelationshipManager>(template_rm.
clone())));
2515 mooseAssert(pr.second,
"An insertion should have happened");
2516 auto & clone_rm = *pr.first->second;
2517 clone_rm.init(moose_mesh,
mesh, dof_map);
2528 if (rm->attachGeometricEarly())
2536 if (
const MeshBase *
const moose_mesh_base = moose_mesh.
getMeshPtr())
2538 if (moose_mesh_base != &
mesh)
2539 mooseError(
"The MooseMesh MeshBase and the MeshBase we're trying to attach " 2540 "relationship managers to are different");
2545 mesh.allow_remote_element_removal(
false);
2553 bool attach_geometric_rm_final)
2557 if (!rm->isType(rm_type))
2571 if (!rm->attachGeometricEarly() && !attach_geometric_rm_final)
2574 mesh->allowRemoteElementRemoval(
false);
2577 MeshBase & undisp_mesh_base =
mesh->getMesh();
2578 const DofMap *
const undisp_sys_dof_map =
2580 undisp_mesh_base.add_ghosting_functor(
2586 attach_geometric_rm_final && disp_moose_mesh)
2589 const DofMap * disp_sys_dof_map =
nullptr;
2592 disp_mesh_base.add_ghosting_functor(
2596 mooseError(
"The displaced mesh should not yet exist at the time that we are attaching " 2597 "early geometric relationship managers.");
2607 mooseError(
"We must have an executioner by now or else we do not have to data to add " 2608 "algebraic or coupling functors to in MooseApp::attachRelationshipManagers");
2612 auto & undisp_moose_mesh = problem.mesh();
2614 auto & undisp_sys_dof_map = undisp_sys.
dofMap();
2615 auto & undisp_mesh = undisp_moose_mesh.getMesh();
2617 if (rm->useDisplacedMesh() && problem.getDisplacedProblem())
2631 problem.addCouplingGhostingFunctor(
2637 auto & displaced_problem = *problem.getDisplacedProblem();
2638 auto & disp_moose_mesh = displaced_problem.mesh();
2639 auto & disp_mesh = disp_moose_mesh.getMesh();
2640 const DofMap *
const disp_nl_dof_map = &displaced_problem.solverSys(0).dofMap();
2641 displaced_problem.addAlgebraicGhostingFunctor(
2649 problem.addCouplingGhostingFunctor(
2654 problem.addAlgebraicGhostingFunctor(
2666 std::vector<std::pair<std::string, std::string>>
2669 std::vector<std::pair<std::string, std::string>> info_strings;
2674 std::stringstream oss;
2675 oss << rm->getInfo();
2677 auto & for_whom = rm->forWhom();
2679 if (!for_whom.empty())
2683 std::copy(for_whom.begin(), for_whom.end(), infix_ostream_iterator<std::string>(oss,
", "));
2686 info_strings.emplace_back(std::make_pair(
Moose::stringify(rm->getType()), oss.str()));
2697 std::map<std::string, unsigned int> counts;
2699 for (
auto & gf :
as_range(
mesh->getMesh().ghosting_functors_begin(),
2700 mesh->getMesh().ghosting_functors_end()))
2705 counts[
demangle(
typeid(*gf).name())]++;
2708 for (
const auto & pair : counts)
2709 info_strings.emplace_back(std::make_pair(
2710 "Default", pair.first + (pair.second > 1 ?
" x " + std::to_string(pair.second) :
"")));
2721 std::map<std::string, unsigned int> counts;
2723 for (
auto & gf :
as_range(d_mesh->getMesh().ghosting_functors_begin(),
2724 d_mesh->getMesh().ghosting_functors_end()))
2729 counts[
demangle(
typeid(*gf).name())]++;
2732 for (
const auto & pair : counts)
2733 info_strings.emplace_back(
2734 std::make_pair(
"Default",
2735 pair.first + (pair.second > 1 ?
" x " + std::to_string(pair.second) :
"") +
2736 " for DisplacedMesh"));
2739 return info_strings;
2751 std::vector<std::string> not_declared;
2753 for (
const auto & data : meta_data)
2754 if (!data.declared())
2755 not_declared.push_back(data.name());
2757 if (!not_declared.empty())
2759 std::ostringstream oss;
2761 not_declared.begin(), not_declared.end(), infix_ostream_iterator<std::string>(oss,
", "));
2765 "' meta-data properties were retrieved but never declared: ",
2779 mooseError(
"Unable to find RestartableDataMap object for the supplied name '",
2781 "', did you call registerRestartableDataMapName in the application constructor?");
2782 return iter->second.first;
2794 if (!suffix.empty())
2795 std::transform(suffix.begin(), suffix.end(), suffix.begin(), ::tolower);
2796 suffix.insert(0,
"_");
2806 mooseError(
"MooseApp::getRestartableDataMapName: The name '",
name,
"' is not registered");
2807 return it->second.second;
2816 std::make_unique<RestartableData<PerfGraph>>(
"perf_graph",
2820 getParam<bool>(
"perf_graph_live_all"),
2821 !getParam<bool>(
"disable_perf_graph_live"));
2833 auto solution_invalidity =
2834 std::make_unique<RestartableData<SolutionInvalidity>>(
"solution_invalidity",
nullptr, *
this);
std::list< std::string > getCheckpointFiles() const
Extract all possible checkpoint file names.
virtual bool constructingMeshGenerators() const
Whether this app is constructing mesh generators.
std::list< std::string > getCheckpointDirectories() const
Get all checkpoint directories.
RelationshipManager & createRMFromTemplateAndInit(const RelationshipManager &template_rm, MooseMesh &moose_mesh, MeshBase &mesh, const DofMap *dof_map=nullptr)
Take an input relationship manager, clone it, and then initialize it with provided mesh and optional ...
static const std::string & checkpointSuffix()
The file suffix for the checkpoint mesh.
std::string getFileName(bool stripLeadingPath=true) const
Return the primary (first) filename that was parsed Note: When stripLeadingPath is false...
std::string docsDir(const std::string &app_name)
Returns the directory of any installed docs/site.
void build()
Parse an input file (or text string if provided) consisting of hit syntax and setup objects in the MO...
void addExecutorParams(const std::string &type, const std::string &name, const InputParameters ¶ms)
Adds the parameters for an Executor to the list of parameters.
virtual std::string getPrintableName() const
Get printable name of the application.
unsigned int _multiapp_level
Level of multiapp, the master is level 0. This used by the Console to indent output.
virtual std::string getInstallableInputs() const
Method to retrieve the installable inputs from a given applications <app>Revision.h file.
void write(std::ostream &header_stream, std::ostream &data_stream)
Writes the restartable data to header stream header_stream and data stream data_stream.
PerfGraph & _perf_graph
The PerfGraph object for this application (recoverable)
void setOutputPosition(const Point &p)
Tell the app to output in a specific position.
const std::string _type
The string representation of the type of this object as registered (see registerApp(AppName)) ...
std::unordered_map< std::string, std::pair< std::string, std::unique_ptr< InputParameters > > > _executor_params
Used in building the Executors Maps the name of the Executor block to the <type, params> ...
bool isUltimateMaster() const
Whether or not this app is the ultimate master app.
std::map< Moose::RelationshipManagerType, std::set< const RelationshipManager * > > _attached_relationship_managers
The relationship managers that have been attached (type -> RMs)
Reader for restartable data written by the RestartableDataWriter.
std::string _restart_recover_base
The base name to restart/recover from. If blank then we will find the newest checkpoint file...
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 hasRestartableMetaData(const std::string &name, const RestartableDataMapName &metaname) const
virtual void setupOptions()
Setup options based on InputParameters.
PerfGraph & createRecoverablePerfGraph()
Creates a recoverable PerfGraph.
std::string libNameToAppName(const std::string &library_name) const
Converts a library name to an application name:
const unsigned int invalid_uint
RelationshipManagerType
Main types of Relationship Managers.
const std::shared_ptr< Parser > _parser
Parser for parsing the input file.
std::string getFrameworkVersion() const
Returns the framework version.
Base class for everything in MOOSE with a name and a type.
const std::multimap< std::string, ActionInfo > & getAssociatedActions() const
Return all Syntax to Action associations.
void setRecover(bool value)
void buildFullTree(const std::string &search_string)
Use MOOSE Factories to construct a full parse tree for documentation or echoing input.
std::vector< std::pair< std::string, std::string > > getRelationshipManagerInfo() const
Returns the Relationship managers info suitable for printing.
bool hasRMClone(const RelationshipManager &template_rm, const MeshBase &mesh) const
bool _file_base_set_by_user
Whether or not file base is set through input or setOutputFileBase by MultiApp.
const Action * getCurrentAction() const
bool _output_position_set
Whether or not an output position has been set for this app.
Generic factory class for build all sorts of objects.
void addDependency(const std::string &task, const std::string &pre_req)
std::unique_ptr< TheWarehouse > _the_warehouse
The combined warehouse for storing any MooseObject based object.
InputParameters getValidParams(const std::string &name)
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 ...
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
InputParameters & parameters()
Get the parameters of the object.
bool hasInitialBackup() const
void setInput(std::unique_ptr< std::stringstream > header_stream, std::unique_ptr< std::stringstream > data_stream)
Sets the input stream for reading from the stringstreams header_stream and data_stream for the header...
static std::filesystem::path metaDataFolderBase(const std::filesystem::path &folder_base, const std::string &map_suffix)
The file suffix for meta data (header and data)
bool _warnings_are_errors
Variable to toggle any warning into an error (includes deprecated code warnings)
std::string installedInputsDir(const std::string &app_name, const std::string &dir_name, const std::string &extra_error_msg="")
Returns the directory of any installed inputs or the empty string if none are found.
InputParameterWarehouse & getInputParameterWarehouse()
Get the InputParameterWarehouse for MooseObjects.
bool tokenizeAndConvert(const std::string &str, std::vector< T > &tokenized_vector, const std::string &delimiter=" \\\)
tokenizeAndConvert splits a string using delimiter and then converts to type T.
static const RestartableDataMapName MESH_META_DATA
std::unordered_map< RestartableDataMapName, std::pair< RestartableDataMap, std::string > > _restartable_meta_data
General storage for custom RestartableData that can be added to from outside applications.
void dynamicRegistration(const Parameters ¶ms)
Helper method for dynamic loading of objects.
void registerTaskName(const std::string &task, bool should_auto_build=false)
Method to register a new task.
virtual const std::type_info & typeId() const =0
The type ID of the underlying data.
std::shared_ptr< MooseMesh > & displacedMesh()
static const std::map< std::string, std::vector< std::shared_ptr< RegistryEntryBase > > > & allActions()
Returns a per-label keyed map of all Actions in the registry.
void mooseWarning(Args &&... args)
Emit a warning message with the given stringified, concatenated args.
virtual std::string appBinaryName() const
const std::shared_ptr< MooseMesh > & getMesh() const
std::string getOutputFileBase(bool for_non_moose_build_output=false) const
Get the output file base name.
T * get(const std::unique_ptr< T > &u)
The MooseUtils::get() specializations are used to support making forwards-compatible code changes fro...
RelationshipManager & getRMClone(const RelationshipManager &template_rm, const MeshBase &mesh) const
Return the relationship manager clone originally created from the provided template relationship mana...
void setFinalTask(const std::string &task)
void registerRestartableNameWithFilter(const std::string &name, Moose::RESTARTABLE_FILTER filter)
NOTE: This is an internal function meant for MOOSE use only!
virtual void run()
Run the application.
std::shared_ptr< MooseObject > create(const std::string &obj_name, const std::string &name, const InputParameters ¶meters, THREAD_ID tid=0, bool print_deprecated=true)
void removeRelationshipManager(std::shared_ptr< RelationshipManager > relationship_manager)
Purge this relationship manager from meshes and DofMaps and finally from us.
Real _start_time
The time at which to start the simulation.
Writer for restartable data, to be read by the RestartableDataReader.
This attribute describes sorting state.
void createExecutors()
After adding all of the Executor Params - this function will actually cause all of them to be built...
void recursivelyCreateExecutors(const std::string ¤t_executor_name, std::list< std::string > &possible_roots, std::list< std::string > ¤t_branch)
Internal function used to recursively create the executor objects.
std::filesystem::path restartFolderBase(const std::filesystem::path &folder_base) const
The file suffix for restartable data.
std::pair< std::filesystem::path, std::filesystem::path > splitFileName(const T &full_file)
Function for splitting path and filename.
unsigned int multiAppLevel() const
The MultiApp Level.
InputParameters getValidParams(const std::string &name) const
Get valid parameters for the object.
const std::string _name
The name of this object.
bool hasRelationshipManager(const std::string &name) const
Returns a Boolean indicating whether a RelationshipManater exists with the same name.
std::list< std::string > getFilesInDirs(const std::list< std::string > &directory_list, const bool files_only=true)
Retrieves the names of all of the files contained within the list of directories passed into the rout...
bool _check_input
true if we want to just check the input file
TODO: delete this later - it is a temporary hack for dealing with inter-system dependencies.
const Parallel::Communicator & comm() const
bool isParamValid(const std::string &name) const
bool hasRestartableDataMap(const RestartableDataMapName &name) const
void addActionBlock(std::shared_ptr< Action > blk)
This method add an Action instance to the warehouse.
Syntax _syntax
Syntax of the input file.
Syntax & syntax()
Returns a writable reference to the syntax object.
std::map< std::string, std::shared_ptr< Executor > > _executors
Pointers to all of the Executors for this run.
std::vector< std::filesystem::path > writeRestartableMetaData(const RestartableDataMapName &name, const std::filesystem::path &folder_base)
Writes the restartable meta data for name with a folder base of folder_base.
ExecuteMooseObjectWarehouse< MultiApp > & getMultiAppWarehouse()
bool _trap_fpe
Whether or not FPE trapping should be turned on.
const Parallel::Communicator & _communicator
processor_id_type processor_id() const
Returns the MPI processor ID of the current processor.
static const std::map< std::string, std::vector< std::shared_ptr< RegistryEntryBase > > > & allObjects()
Returns a per-label keyed map of all MooseObjects in the registry.
The following methods are specializations for using the libMesh::Parallel::packed_range_* routines fo...
Helper class to hold streams for Backup and Restore operations.
const hit::Node * getCurrentActionHitNode() const
ActionWarehouse _action_warehouse
Where built actions are stored.
std::string realpath(const std::string &path)
Wrapper around PetscGetRealPath, which is a cross-platform replacement for realpath.
RestartableDataReader _rd_reader
void checkMetaDataIntegrity() const
Function to check the integrity of the restartable meta data structure.
const std::list< Action * > & getActionListByName(const std::string &task) const
Retrieve a constant list of Action pointers associated with the passed in task.
virtual const std::vector< std::string > & forWhom() const
The object (or Action) this RelationshipManager was built for.
static InputParameters validParams()
bool isRestarting() const
Whether or not this is a "restart" calculation.
bool isSplitMesh() const
Whether or not this is a split mesh operation.
RestartableDataMap & getRestartableDataMap(const RestartableDataMapName &name)
Return a reference to restartable data for the specific type flag.
std::unique_ptr< SystemInfo > _sys_info
System Information.
Holds the syntax in a Json::Value tree.
Specialization of SubProblem for solving nonlinear equations plus auxiliary equations.
virtual const std::string & name() const
Get the name of the class.
std::string hostname()
Get the hostname the current process is running on.
FEProblemBase & feProblem() const
std::shared_ptr< Action > create(const std::string &action, const std::string &action_name, InputParameters ¶meters)
void allowRemoteElementRemoval(bool allow_removal)
Set whether to allow remote element removal.
std::vector< RestartableDataMap > _restartable_data
Where the restartable data is held (indexed on tid)
std::string camelCaseToUnderscore(const std::string &camel_case_name)
Function for converting a camel case name to a name containing underscores.
void setOutputFileBase(const std::string &output_file_base)
Override the selection of the output file base name.
Storage for restartable data that is ordered based on insertion order.
std::shared_ptr< MooseMesh > & mesh()
TODO: delete this later - it is a temporary hack for dealing with inter-system dependencies.
MeshGeneratorSystem _mesh_generator_system
The system that manages the MeshGenerators.
void attachRelationshipManagers(Moose::RelationshipManagerType rm_type, bool attach_geometric_rm_final=false)
Attach the relationship managers of the given type Note: Geometric relationship managers that are sup...
const MeshBase * getMeshPtr() const
bool _start_time_set
Whether or not an start time has been set.
virtual DofMap & dofMap()
Gets writeable reference to the dof map.
void libmesh_ignore(const Args &...)
void possiblyLoadRestartableMetaData(const RestartableDataMapName &name, const std::filesystem::path &folder_base)
Loads the restartable meta data for name if it is available with the folder base folder_base.
void addMainCommandLineParams(InputParameters ¶ms)
Adds the command line parameters needed from within main, which will also need to be added to MooseAp...
bool copyInputs() const
Handles the copy_inputs input parameter logic: Checks to see whether the passed argument is valid (a ...
bool showInputs() const
Prints a message showing the installable inputs for a given application (if getInstallableInputs has ...
bool addRelationshipManager(std::shared_ptr< RelationshipManager > relationship_manager)
Transfers ownership of a RelationshipManager to the application for lifetime management.
RestartableDataValue & getRestartableMetaData(const std::string &name, const RestartableDataMapName &metaname, THREAD_ID tid)
std::shared_ptr< NullExecutor > _null_executor
Used to return an executor that does nothing.
const std::string & getLastInputFileName() const
virtual void preBackup()
Insertion point for other apps that is called before backup()
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.
void resetFileBase()
Resets the file base for all FileOutput objects.
virtual void postRestore(const bool)
Insertion point for other apps that is called after restore()
T command_line_value(const std::string &, T)
Tracks the libmesh system number that a MooseObject is associated with.
std::shared_ptr< CommandLine > _command_line
Command line object.
const std::vector< std::shared_ptr< T > > & getObjects(THREAD_ID tid=0) const
Retrieve complete vector to the all/block/boundary restricted objects for a given thread...
bool _restart
Whether or not this is a restart run.
Real value(unsigned n, unsigned alpha, unsigned beta, Real x)
void indentMessage(const std::string &prefix, std::string &message, const char *color=COLOR_CYAN, bool dont_indent_first_line=true, const std::string &post_prefix=": ")
Indents the supplied message given the prefix and color.
std::unique_ptr< Backup > backup()
Backs up the application memory in a Backup.
bool _deprecated_is_error
Variable to toggle only deprecated warnings as errors.
RESTARTABLE_FILTER
The filter type applied to a particular piece of "restartable" data.
void meshChanged()
Calls the meshChanged method for every output object.
void setErrorOnLoadWithDifferentNumberOfProcessors(bool value)
void setActive(bool active)
Turn on or off timing.
RestartableDataValue & registerRestartableData(std::unique_ptr< RestartableDataValue > data, THREAD_ID tid, bool read_only, const RestartableDataMapName &metaname="")
SimpleRange< IndexType > as_range(const std::pair< IndexType, IndexType > &p)
void initSyntaxFormatter(SyntaxFormatterType type, bool dump_mode)
Creates a syntax formatter for printing.
bool runInputs() const
Handles the run input parameter logic: Checks to see whether a directory exists in user space and lau...
Specialized factory for generic Action System objects.
bool checkFileReadable(const std::string &filename, bool check_line_endings=false, bool throw_on_unreadable=true, bool check_for_git_lfs_pointer=true)
Checks to see if a file is readable (exists and permissions)
An inteface for the _console for outputting to the Console object.
void setRestart(bool value)
Sets the restart/recover flags.
AttribBoundaries tracks all boundary IDs associated with an object.
std::shared_ptr< Executioner > _executioner
Pointer to the executioner of this run (typically build by actions)
MooseMesh wraps a libMesh::Mesh object and enhances its capabilities by caching additional data and s...
ActionFactory _action_factory
The Factory responsible for building Actions.
std::string runTestsExecutable()
Returns the location of either a local repo run_tests script - or an installed test executor script i...
void disableLivePrint()
Completely disables Live Print (cannot be restarted)
const std::string & type() const
Get the type of this class.
void restoreFromInitialBackup(const bool for_restart)
Restores from a "initial" backup, that is, one set in _initial_backup.
std::string underscoreToCamelCase(const std::string &underscore_name, bool leading_upper_case)
Function for converting an underscore name to a camel case name.
const T & getParam(const std::string &name) const
Retrieve a parameter for the object.
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type It sho...
RegistrationType
Enumeration for holding the valid types of dynamic registrations allowed.
Executioners are objects that do the actual work of solving your problem.
enum MooseApp::UNUSED_CHECK _enable_unused_check
bool _recover
Whether or not this is a recovery run.
void buildJsonSyntaxTree(JsonSyntaxTree &tree) const
Use MOOSE Factories to construct a parameter tree for documentation or echoing input.
Point _output_position
The output position.
void mooseDeprecated(Args &&... args)
Emit a deprecated code/feature message with the given stringified, concatenated args.
const nlohmann::json & getRoot() const
Get the root of the tree.
bool _error_overridden
Indicates whether warnings or errors are displayed when overridden parameters are detected...
virtual std::string getVersion() const
Returns the current version of the framework or application (default: framework version).
SolutionInvalidity & createRecoverableSolutionInvalidity()
Creates a recoverable SolutionInvalidity.
bool _heap_profiling
Memory profiling.
const MooseMesh *const _master_displaced_mesh
The displaced mesh from master app.
std::string getPrimaryFileName(bool stripLeadingPath=true) const
Return the primary (first) filename that was parsed.
TODO: delete this later - it is a temporary hack for dealing with inter-system dependencies.
std::string stringify(const T &t)
conversion to string
Class for storing and utilizing output objects.
std::string demangle(const char *name)
void addForWhom(const std::string &for_whom)
Add another name to for_whom.
Interface for objects interacting with the PerfGraph.
Executioner * getExecutioner() const
Retrieve the Executioner for this App.
std::set< std::string > getLibrarySearchPaths(const std::string &library_path_from_param) const
Return the paths searched by MOOSE when loading libraries.
void broadcast(T &data, const unsigned int root_id=0, const bool identical_sizes=false) const
The SolutionInvalidity will contain all the information about the occurrence(s) of solution invalidit...
std::unordered_map< std::string, DynamicLibraryInfo > _lib_handles
The library archive (name only), registration method and the handle to the method.
static std::filesystem::path restartableDataFolder(const std::filesystem::path &folder_base)
virtual std::string type() const =0
String identifying the type of parameter stored.
static AppFactory & instance()
Get the instance of the AppFactory.
Residual objects have this attribute.
void releaseSharedObjects(const MooseObject &moose_object, THREAD_ID tid=0)
Releases any shared resources created as a side effect of creating an object through the Factory::cre...
const std::string & getCurrentTaskName() const
const std::string & getRestartableDataMapName(const RestartableDataMapName &name) const
bool hasRecoverFileBase() const
std::map< const RelationshipManager *, std::map< const MeshBase *, std::unique_ptr< RelationshipManager > > > _template_to_clones
Map from a template relationship manager to a map in which the key-value pairs represent the MeshBase...
bool hasRestartRecoverFileBase() const
Return true if the recovery file base is set.
void registerRestartableDataMapName(const RestartableDataMapName &name, std::string suffix="")
Reserve a location for storing custom RestartableDataMap objects.
void restore(const std::filesystem::path &folder_base, const bool for_restart)
Restore an application from file.
InputParameters _pars
Parameters of this object.
bool _trap_fpe
Variable indicating whether we will enable FPE trapping for this run.
void loadRestartableMetaData(const std::filesystem::path &folder_base)
Loads all available restartable meta data if it is available with the folder base folder_base...
std::filesystem::path pathjoin(const std::filesystem::path &p)
const T & getParam(const std::string &name)
Retrieve a parameter for the object.
virtual void executeExecutioner()
Execute the Executioner that was built.
bool _distributed_mesh_on_command_line
This variable indicates that DistributedMesh should be used for the libMesh mesh underlying MooseMesh...
void addExecutor(const std::string &type, const std::string &name, const InputParameters ¶ms)
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
virtual std::shared_ptr< const DisplacedProblem > getDisplacedProblem() const
RelationshipManagers are used for describing what kinds of non-local resources are needed for an obje...
PetscErrorCode petscSetupOutput(CommandLine *cmd_line)
Moose::Builder _builder
Builder for building app related parser tree.
const std::shared_ptr< MooseMesh > & getDisplacedMesh() const
bool _test_checkpoint_half_transient
Whether or not this simulation should only run half its transient (useful for testing recovery) ...
std::string RestartableDataMapName
std::set< std::shared_ptr< RelationshipManager > > _relationship_managers
The relationship managers that have been added.
OutputWarehouse _output_warehouse
OutputWarehouse object for this App.
std::string _output_file_base
The output file basename.
std::streambuf * _output_buffer_cache
Cache output buffer so the language server can turn it off then back on.
const std::shared_ptr< Parallel::Communicator > _comm
The MPI communicator this App is going to use.
static void addAppParam(InputParameters ¶ms)
bool _cpu_profiling
CPU profiling.
Concrete definition of a parameter value for a specified type.
void build()
Builds all auto-buildable tasks.
void registerAll(Factory &f, ActionFactory &af, Syntax &s)
Register objects that are in MOOSE.
virtual void runInputFile()
Actually build everything in the input file.
void errorCheck(const Parallel::Communicator &comm, bool warn_unused, bool err_unused)
bool setColorConsole(bool use_color, bool force=false)
Turns color escape sequences on/off for info written to stdout.
virtual std::string header() const
Returns a string to be printed at the beginning of a simulation.
Holding syntax for parsing input files.
class infix_ostream_iterator if void
std::unordered_set< std::string > DataNames
std::vector< std::string > getConstructedObjects() const
Get a list of all constructed Moose Object types.
static const std::string MESH_META_DATA_SUFFIX
SolverSystem & getSolverSystem(unsigned int sys_num)
Get non-constant reference to a solver system.
void executeAllActions()
This method loops over all actions in the warehouse and executes them.
std::unique_ptr< InputParameterWarehouse > _input_parameter_warehouse
Input parameter storage structure; unique_ptr so we can control its destruction order.
virtual std::unique_ptr< GhostingFunctor > clone() const
std::string getCurrentWorkingDir()
Returns the current working directory as a string.
const std::vector< std::string > & getInputFileNames() const
Tracks whether the object is on the displaced mesh.
InputStreams clear()
Clears the contents of the reader (header stream, data stream, header)
MooseApp(InputParameters parameters)
Constructor is protected so that this object is constructed through the AppFactory object...
void makedirs(const std::string &dir_name, bool throw_on_failure=false)
Recursively make directories.
std::unique_ptr< Backup > finalizeRestore()
Finalizes (closes) the restoration process done in restore().
bool appendingMeshGenerators() const
Whether or not mesh generators are currently being appended (append_mesh_generator task) ...
static const std::string allow_data_driven_param
The name of the boolean parameter on the MooseApp that will enable data driven generation.
void restore(const DataNames &filter_names={})
Restores the restartable data.
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.
void loadLibraryAndDependencies(const std::string &library_filename, const Parameters ¶ms, bool load_dependencies=true)
Recursively loads libraries and dependencies in the proper order to fully register a MOOSE applicatio...
const DataNames & getRecoverableData() const
Return a reference to the recoverable data object.
void setDeclared(const SetDeclaredKey)
Sets that this restartable value has been declared.
std::string getPrintableVersion() const
Non-virtual method for printing out the version string in a consistent format.
std::vector< const T * > getActions()
Retrieve all actions in a specific type ordered by their names.
bool pathExists(const std::string &path)
void createMinimalApp()
Method for creating the minimum required actions for an application (no input file) ...
bool isRecovering() const
Whether or not this is a "recover" calculation.
DataNames _recoverable_data_names
Data names that will only be read from the restart file during RECOVERY.
Executor * getExecutor() const
The PerfGraph will hold the master list of all registered performance segments and the head PerfNode...
const MooseMesh *const _master_mesh
The mesh from master app.
void clear()
This method deletes all of the Actions in the warehouse.
A scope guard that guarantees that whatever happens between when it gets created and when it is destr...
void disableCheckUnusedFlag()
Removes warnings and error checks for unrecognized variables in the input file.
bool _split_mesh
Whether or not we are performing a split mesh operation (–split-mesh)
void ErrorVector unsigned int
const bool _use_executor
Indicates whether we are operating in the new/experimental executor mode instead of using the legacy ...
Abstract definition of a RestartableData value.
Class for parsing input files.
Meta-action for creating common output object parameters This action serves two purpose, first it adds common output object parameters.
OutputWarehouse & getOutputWarehouse()
Get the OutputWarehouse objects.
std::string getExecutableName()
This function returns the name of the running executable.
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)
static char addKnownLabel(const std::string &label)
addKnownLabel whitelists a label as valid for purposes of the checkLabels function.
void setStartTime(Real time)
Set the starting time for the simulation.
std::shared_ptr< Executor > _executor
Pointer to the Executor of this run.
The Executor class directs the execution flow of simulations.
std::string findTestRoot()
Searches in the current working directory and then recursively up in each parent directory looking fo...
void errorCheck()
Runs post-initialization error checking that cannot be run correctly unless the simulation has been f...
std::set< std::string > getLoadedLibraryPaths() const
Return the paths of loaded libraries.
static bool isAvailable(const std::filesystem::path &folder_base)
void dynamicAppRegistration(const std::string &app_name, std::string library_path, const std::string &library_name, bool lib_load_deps)
std::unique_ptr< Backup > *const _initial_backup
The backup for use in initial setup; this will get set from the _initial_backup input parameter that ...