11#include "gperftools/profiler.h"
12#include "gperftools/heap-profiler.h"
16#include "MooseRevision.h"
64#include "libmesh/exodusII_io.h"
65#include "libmesh/mesh_refinement.h"
66#include "libmesh/string_to_enum.h"
67#include "libmesh/checkpoint_io.h"
68#include "libmesh/mesh_base.h"
69#include "libmesh/petsc_solver_exception.h"
72#ifdef LIBMESH_HAVE_DLOPEN
74#include <sys/utsname.h>
77#if __has_include(<torch/xpu.h>)
79#define MOOSE_HAVE_XPU 1
110temporaryBackupMeshPath(
const MooseApp & app,
const std::string & purpose)
112 return std::filesystem::path(app.
getOutputFileBase() +
"_" + purpose +
"_mesh") /
"mesh.cpr";
116readBackupMeshFile(
const std::filesystem::path & path)
118 std::ifstream file(path, std::ios::in | std::ios::binary);
120 mooseError(
"Unable to open temporary mesh backup file ",
121 std::filesystem::absolute(path),
124 return std::string(std::istreambuf_iterator<char>(file), std::istreambuf_iterator<char>());
128writeBackupMeshFile(
const std::filesystem::path & path,
const std::string & contents)
131 if (!std::filesystem::create_directories(path.parent_path(), err) && err)
132 mooseError(
"Unable to create temporary mesh backup directory ",
133 std::filesystem::absolute(path.parent_path()),
137 std::ofstream file(path, std::ios::out | std::ios::binary);
139 mooseError(
"Unable to open temporary mesh backup file ",
140 std::filesystem::absolute(path),
143 file.write(contents.data(), contents.size());
152resetBackupMeshDir(
const std::filesystem::path & mesh_path)
155 std::filesystem::remove_all(mesh_path.parent_path(), err);
158 if (!std::filesystem::create_directories(mesh_path.parent_path(), err) && err)
159 mooseError(
"Unable to create temporary mesh backup directory ",
160 std::filesystem::absolute(mesh_path.parent_path()),
176 const auto mesh_path = temporaryBackupMeshPath(app,
"backup");
179 resetBackupMeshDir(mesh_path);
187 io.write(mesh_path.string());
194 for (
const auto & entry :
std::filesystem::recursive_directory_iterator(mesh_path))
195 if (entry.is_regular_file())
197 const auto relative_path =
198 std::filesystem::relative(entry.path(), mesh_path).generic_string();
199 backup.
mesh_files.emplace_back(relative_path, readBackupMeshFile(entry.path()));
208 std::filesystem::remove_all(mesh_path.parent_path(), err);
218 const auto mesh_path = temporaryBackupMeshPath(app,
"restore");
221 resetBackupMeshDir(mesh_path);
222 for (
const auto & [relative_path, contents] : backup.mesh_files)
223 writeBackupMeshFile(mesh_path / relative_path, contents);
229 auto & mesh_base =
mesh.getMesh();
234 io.read(mesh_path.string());
240 for (
auto & node : mesh_base.node_ptr_range())
242 for (
auto & elem : mesh_base.element_ptr_range())
253 std::filesystem::remove_all(mesh_path.parent_path(), err);
264 "app_to_run",
"--app <type>",
"Specify the application type to run (case-sensitive)");
271 "input_file",
"-i <input file(s)>",
"Specify input file(s); multiple files are merged");
282 params.
addCommandLineParam<
bool>(
"display_version",
"-v --version",
"Print application version");
286 "--mesh-only <optional path>",
288 "Build and output the mesh only (Default: \"<input_file_name>_in.e\")");
291 "--csg-only <optional path>",
293 "Setup and output the input mesh in CSG format only (Default: "
294 "\"<input_file_name>_out_csg.json\")");
298 "Shows the list of Actions as they execute, in order of execution");
301 "show_input",
"--show-input",
"Shows the parsed input file before running the simulation");
304 "show_outputs",
"--show-outputs",
"Shows the output execution time information");
307 "show_controls",
"--show-controls",
"Shows the Control logic available and executed");
311 "no_color",
"--no-color",
"Disable coloring of all Console outputs");
316 "color",
"--color <auto,on,off=on>", colors,
"Whether to use color in console output");
323 "Ignore input file and build a minimal application with Transient executioner");
328 "Starts a process to communicate with development tools using the language server protocol");
330 params.
addCommandLineParam<
bool>(
"dump",
"--dump",
"Shows a dump of available input file syntax");
333 "--dump-search <search>",
334 "Shows a dump of available input syntax matching a search");
335 params.
addCommandLineParam<
bool>(
"registry",
"--registry",
"Lists all known objects and actions");
337 "registry_hit",
"--registry-hit",
"Lists all known objects and actions in hit format");
339 "use_executor",
"--executor",
"Use the new Executor system instead of Executioners");
342 "show_type",
"--show-type",
"Return the name of the application object");
343 params.
addCommandLineParam<
bool>(
"yaml",
"--yaml",
"Dumps all input file syntax in YAML format");
345 "yaml_search",
"--yaml-search",
"Dumps input file syntax matching a search in YAML format");
346 params.
addCommandLineParam<
bool>(
"json",
"--json",
"Dumps all input file syntax in JSON format");
348 "json_search",
"--json-search",
"Dumps input file syntax matching a search in JSON format");
350 "syntax",
"--syntax",
"Dumps the associated Action syntax paths ONLY");
352 "show_docs",
"--docs",
"Print url/path to the documentation website");
354 "show_capabilities",
"--show-capabilities",
"Dumps the capability registry in JSON format.");
356 "required_capabilities",
357 "--required-capabilities",
358 "A list of conditions that is checked against the registered capabilities (see "
359 "--show-capabilities). The executable will terminate early if the conditions are not met.");
361 "testharness_capabilities",
362 "--testharness-capabilities",
363 "Path to JSON from the TestHarness that contains capabilities to be appended.");
366 "check_capabilities",
367 "--check-capabilities",
368 "A list of conditions that is checked against the registered capabilities. Will exit based "
369 "on whether or not the capaiblities are fulfilled. Does not check dynamically loaded apps.");
372 "Check the input file (i.e. requires -i <filename>) and quit");
376 "--show-copyable-inputs",
377 "Shows the directories able to be copied into a user-writable location");
381 "--copy-inputs <dir>",
382 "Copies installed inputs (e.g. tests, examples, etc.) to a directory <appname>_<dir>");
387 "--run <test harness args>",
389 "Runs the inputs in the current directory copied to a "
390 "user-writable location by \"--copy-inputs\"");
393 "list_constructed_objects",
394 "--list-constructed-objects",
395 "List all moose object type names constructed by the master app factory");
399 "--citations [file]",
401 "List the papers (in BibTeX format) that should be cited for the framework, PETSc, and the "
402 "modules and objects used in this simulation; optionally write them to [file] instead of the "
406 "n_threads",
"--n-threads=<n>",
"Runs the specified number of threads per process");
413 "Warn about unused input file options instead of erroring");
416 "error_unused",
"-e --error-unused",
"Error when encountering unused input file options");
420 "-o --error-override",
421 "Error when encountering overridden or parameters supplied multiple times");
424 "error_deprecated",
"--error-deprecated",
"Turn deprecated code messages into Errors");
428 "--distributed-mesh",
429 "Forces the use of a distributed finite element mesh");
436 "--split-mesh <splits>",
437 "Comma-separated list of numbers of chunks to split the mesh into");
441 "split_file",
"--split-file <filename>",
"Name of split mesh file(s) to write/read");
443 params.
addCommandLineParam<
bool>(
"use_split",
"--use-split",
"Use split distributed mesh files");
446 "refinements",
"-r <num refinements>",
"Specify additional initial uniform mesh refinements");
450 "--recover <optional file base>",
452 "Continue the calculation. Without <file base>, the most recent recovery file will be used");
457 "Forcefully load checkpoints despite possible incompatibilities");
463 "Disables the output of the application header.");
467 "test_checkpoint_half_transient",
468 "--test-checkpoint-half-transient",
469 "Run half of a transient with checkpoints enabled; used by the TestHarness");
474 "Test re-running the middle timestep; used by the TestHarness");
479 "Enable floating point exception handling in critical sections of code"
481 " (automatic due to debug build)"
489 "Disable floating point exception handling in critical sections of code"
491 " (unused due to non-debug build)"
498 "no_gdb_backtrace",
"--no-gdb-backtrace",
"Disables gdb backtraces.");
506 "Enable all performance logging for timing; disables screen "
507 "output of performance logs for all Console objects");
510 "no_timing",
"--no-timing",
"Disabled performance logging; overrides -t or --timing");
514 "allow_test_objects",
"--allow-test-objects",
"Register test objects and syntax");
522 "Keep standard output from all processors when running in parallel");
527 "Keep standard output from all processors when running in parallel");
532 "--timpi-sync <type=nbx>",
534 "Changes the sync type used in spare parallel communitations within TIMPI");
539 "--start-in-debugger <debugger>",
540 "Start the application and attach a debugger; this will "
541 "launch xterm windows using <debugger>");
545 "--stop-for-debugger <seconds>",
546 "Pauses the application during startup for <seconds> to allow for connection of debuggers");
549 "perf_graph_live_all",
"--perf-graph-live-all",
"Forces printing of ALL progress messages");
553 "disable_perf_graph_live",
"--disable-perf-graph-live",
"Disables PerfGraph live printing");
557 "automatic_automatic_scaling",
false,
"Whether to turn on automatic scaling by default");
559 const MooseEnum compute_device_type(
"cpu cuda mps hip ceed-cpu ceed-cuda ceed-hip xpu",
"cpu");
564 "The device type we want to run accelerated (libtorch, MFEM) computations on.");
566#ifdef HAVE_GPERFTOOLS
569 "--gperf-profiler-on <ranks>",
570 "To generate profiling report only on comma-separated list of MPI ranks");
575 "--show-data-params",
577 "Show found paths for all DataFileName parameters in the header");
581 "Show registered data paths for searching in the header");
584 params.
addPrivateParam<std::shared_ptr<Parallel::Communicator>>(
"_comm");
590 params.
addPrivateParam<std::unique_ptr<Backup> *>(
"_initial_backup",
nullptr);
592#ifdef MOOSE_MFEM_ENABLED
598 "use_legacy_material_output",
600 "Set false to allow material properties to be output on INITIAL, not just TIMESTEP_END.");
602 "use_legacy_initial_residual_evaluation_behavior",
604 "The legacy behavior performs an often times redundant residual evaluation before the "
605 "solution modifying objects are executed prior to the initial (0th nonlinear iteration) "
606 "residual evaluation. The new behavior skips that redundant residual evaluation unless the "
607 "parameter Executioner/use_pre_SMO_residual is set to true.");
612 "Set true to enable data-driven mesh generation, which is an experimental feature");
616 "--parse-neml2-only",
617 "Executes the [NEML2] block to parse the input file and terminate.");
628 ParallelObject(*parameters.get<
std::shared_ptr<
Parallel::Communicator>>(
637 _comm(getParam<
std::shared_ptr<
Parallel::Communicator>>(
"_comm")),
638 _file_base_set_by_user(false),
639 _output_position_set(false),
640 _start_time_set(false),
642 _global_time_offset(0.0),
644 _action_factory(*this),
645 _action_warehouse(*this, _syntax, _action_factory),
646 _output_warehouse(*this),
647 _parser(getCheckedPointerParam<
std::shared_ptr<
Parser>>(
"_parser")),
648 _command_line(getCheckedPointerParam<
std::shared_ptr<
CommandLine>>(
"_command_line")),
649 _builder(*this, _action_warehouse, *_parser),
650 _restartable_data(
libMesh::n_threads()),
651 _perf_graph(createRecoverablePerfGraph()),
652 _solution_invalidity(createRecoverableSolutionInvalidity()),
653 _rank_map(*_comm, _perf_graph),
654 _use_executor(getParam<bool>(
"use_executor")),
655 _null_executor(NULL),
656 _use_nonlinear(true),
657 _use_eigen_value(false),
658 _enable_unused_check(ERROR_UNUSED),
660 _error_overridden(false),
661 _early_exit_param(
""),
662 _ready_to_exit(false),
664 _initial_from_file(false),
665 _distributed_mesh_on_command_line(getParam<bool>(
"distributed_mesh")),
669 _use_split(getParam<bool>(
"use_split")),
670 _force_restart(getParam<bool>(
"force_restart")),
676 _test_checkpoint_half_transient(parameters.get<bool>(
"test_checkpoint_half_transient")),
677 _test_restep(parameters.get<bool>(
"test_restep")),
678 _check_input(getParam<bool>(
"check_input")),
679 _multiapp_level(isParamValid(
"_multiapp_level") ? getParam<unsigned
int>(
"_multiapp_level")
681 _multiapp_number(isParamValid(
"_multiapp_number") ? getParam<unsigned
int>(
"_multiapp_number")
683 _use_master_mesh(getParam<bool>(
"_use_master_mesh")),
684 _master_mesh(isParamValid(
"_master_mesh") ? getParam<const
MooseMesh *>(
"_master_mesh")
686 _master_displaced_mesh(isParamValid(
"_master_displaced_mesh")
687 ? getParam<const
MooseMesh *>(
"_master_displaced_mesh")
689 _mesh_generator_system(*this),
690 _chain_control_system(*this),
691 _rd_reader(*this, _restartable_data, forceRestart()),
692 _execute_flags(
moose::internal::ExecFlagRegistry::getExecFlagRegistry().getFlags()),
693 _output_buffer_cache(nullptr),
694 _automatic_automatic_scaling(getParam<bool>(
"automatic_automatic_scaling")),
695 _initial_backup(getParam<
std::unique_ptr<
Backup> *>(
"_initial_backup"))
696#ifdef MOOSE_LIBTORCH_ENABLED
698 _libtorch_device(determineLibtorchDeviceType(getParam<
MooseEnum>(
"compute_device")))
700#ifdef MOOSE_MFEM_ENABLED
702 _mfem_device(isParamValid(
"_mfem_device")
703 ? getParam<
std::shared_ptr<
mfem::Device>>(
"_mfem_device")
705 _mfem_devices(isParamValid(
"_mfem_devices") ? getParam<
std::set<
std::string>>(
"_mfem_devices")
706 :
std::set<
std::string>{})
709 if (¶meters != &_pars)
711 const std::string bad_params =
"(InputParameters parameters)";
712 const std::string good_params =
"(const InputParameters & parameters)";
713 const std::string source_constructor = type() +
"::" + type();
716 " copy-constructs its input parameters.\n\n",
717 "This is deprecated and will not be allowed in the future.\n\n",
738 mooseAssert(_command_line->hasParsed(),
"Command line has not parsed");
739 mooseAssert(_parser->queryRoot(),
"Parser has not parsed");
742 const auto & timpi_sync = getParam<std::string>(
"timpi_sync");
745#ifdef HAVE_GPERFTOOLS
746 if (isUltimateMaster())
748 bool has_cpu_profiling =
false;
749 bool has_heap_profiling =
false;
750 static std::string cpu_profile_file;
751 static std::string heap_profile_file;
754 if (std::getenv(
"MOOSE_PROFILE_BASE"))
756 has_cpu_profiling =
true;
758 std::getenv(
"MOOSE_PROFILE_BASE") + std::to_string(_comm->rank()) +
".prof";
760 auto name = MooseUtils::splitFileName(cpu_profile_file);
761 if (!
name.first.empty())
763 if (processor_id() == 0)
770 if (std::getenv(
"MOOSE_HEAP_BASE"))
772 has_heap_profiling =
true;
773 heap_profile_file = std::getenv(
"MOOSE_HEAP_BASE") + std::to_string(_comm->rank());
775 auto name = MooseUtils::splitFileName(heap_profile_file);
776 if (!
name.first.empty())
778 if (processor_id() == 0)
785 if (isParamSetByUser(
"gperf_profiler_on"))
787 auto rankstr = getParam<std::string>(
"gperf_profiler_on");
788 std::vector<processor_id_type> ranks;
791 mooseError(
"Invalid argument for --gperf-profiler-on: '", rankstr,
"'");
792 for (
auto & rank : ranks)
794 if (rank >= _comm->size())
795 mooseError(
"Invalid argument for --gperf-profiler-on: ",
797 " is greater than or equal to ",
799 if (rank == _comm->rank())
801 _cpu_profiling = has_cpu_profiling;
802 _heap_profiling = has_heap_profiling;
808 _cpu_profiling = has_cpu_profiling;
809 _heap_profiling = has_heap_profiling;
813 if (!ProfilerStart(cpu_profile_file.c_str()))
814 mooseError(
"CPU profiler is not started properly");
818 HeapProfilerStart(heap_profile_file.c_str());
819 if (!IsHeapProfilerRunning())
820 mooseError(
"Heap profiler is not started properly");
824 if (std::getenv(
"MOOSE_PROFILE_BASE") || std::getenv(
"MOOSE_HEAP_BASE"))
825 mooseError(
"gperftool is not available for CPU or heap profiling");
829 if (isParamValid(
"language_server") && getParam<bool>(
"language_server"))
830 _output_buffer_cache = Moose::out.rdbuf(
nullptr);
835 _the_warehouse = std::make_unique<TheWarehouse>();
838 _the_warehouse->registerAttribute<
AttribExecOns>(
"exec_ons", 0);
841 _the_warehouse->registerAttribute<
AttribThread>(
"thread", 0);
843 _the_warehouse->registerAttribute<
AttribPreIC>(
"pre_ic", 0);
844 _the_warehouse->registerAttribute<
AttribPreAux>(
"pre_aux");
845 _the_warehouse->registerAttribute<
AttribPostAux>(
"post_aux");
846 _the_warehouse->registerAttribute<
AttribName>(
"name",
"dummy");
847 _the_warehouse->registerAttribute<
AttribSystem>(
"system",
"dummy");
848 _the_warehouse->registerAttribute<
AttribKokkos>(
"kokkos",
false);
849 _the_warehouse->registerAttribute<
AttribVar>(
"variable", -1);
853 _the_warehouse->registerAttribute<
AttribSorted>(
"sorted");
856 _perf_graph.enableLivePrint();
858 if (_check_input && isParamSetByUser(
"recover"))
859 mooseError(
"Cannot run --check-input with --recover. Recover files might not exist");
861 if (isParamSetByUser(
"start_in_debugger") && isUltimateMaster())
863 auto command = getParam<std::string>(
"start_in_debugger");
865 Moose::out <<
"Starting in debugger using: " << command << std::endl;
869 std::stringstream command_stream;
872 command_stream <<
"xterm -e \"echo 'Rank: " << processor_id() <<
" Hostname: " <<
hostname
873 <<
" PID: " << getpid() <<
"'; echo ''; ";
876 if (command.find(
"lldb") != std::string::npos || command.find(
"gdb") != std::string::npos)
877 command_stream << command <<
" -p " << getpid();
881 "\nIf this is truly what you meant then contact moose-users to have a discussion "
882 "about adding your debugger.");
885 command_stream <<
"\"" <<
" & ";
886 std::string command_string = command_stream.str();
887 Moose::out <<
"Running: " << command_string << std::endl;
889 int ret = std::system(command_string.c_str());
893 std::this_thread::sleep_for(std::chrono::seconds(10));
896 if (isParamSetByUser(
"stop_for_debugger") && isUltimateMaster())
898 Moose::out <<
"\nStopping for " << getParam<unsigned int>(
"stop_for_debugger")
899 <<
" seconds to allow attachment from a debugger.\n";
901 Moose::out <<
"\nAll of the processes you can connect to:\n";
902 Moose::out <<
"rank - hostname - pid\n";
909 Moose::err << processor_id() <<
" - " <<
hostname <<
" - " << getpid() <<
"\n";
912 Moose::out <<
"\nWaiting...\n" << std::endl;
915 std::this_thread::sleep_for(std::chrono::seconds(getParam<unsigned int>(
"stop_for_debugger")));
918 if (isParamSetByUser(
"show_actions"))
919 _action_warehouse.showActions(
true);
921 if (_master_mesh && isUltimateMaster())
922 mooseError(
"Mesh can be passed in only for sub-apps");
924 if (_master_displaced_mesh && !_master_mesh)
925 mooseError(
"_master_mesh should have been set when _master_displaced_mesh is set");
927#ifdef MOOSE_MFEM_ENABLED
930 mooseAssert(!isUltimateMaster(),
931 "The MFEM device should only be auto-set for sub-applications");
932 mooseAssert(!_mfem_devices.empty(),
933 "If we are a sub-application and we have an MFEM device object, then we must know "
934 "its configuration string");
944 if (_pars.have_parameter<
bool>(
"use_legacy_dirichlet_bc"))
945 mooseDeprecated(
"The parameter 'use_legacy_dirichlet_bc' is no longer valid.\n\n",
946 "All Dirichlet boundary conditions are preset by default.\n\n",
947 "Remove said parameter in ",
949 " to remove this deprecation warning.");
951 if (_test_restep && _test_checkpoint_half_transient)
952 mooseError(
"Cannot use --test-restep and --test-checkpoint-half-transient together");
954 Moose::out << std::flush;
956#ifdef MOOSE_KOKKOS_ENABLED
957#ifdef MOOSE_ENABLE_KOKKOS_GPU
963std::optional<MooseEnum>
967 return getParam<MooseEnum>(
"compute_device");
973#ifdef HAVE_GPERFTOOLS
1000#ifdef LIBMESH_HAVE_DLOPEN
1003 dlclose(lib_pair.second.library_handle);
1006#ifdef MOOSE_KOKKOS_ENABLED
1014 return MOOSE_VERSION;
1020 return MOOSE_VERSION;
1032 TIME_SECTION(
"setupOptions", 5,
"Setting Up Options");
1035 if (
header().length() && !getParam<bool>(
"suppress_header"))
1038 if (getParam<bool>(
"error_unused"))
1040 else if (getParam<bool>(
"allow_unused"))
1043 if (getParam<bool>(
"error_override"))
1046 if (getParam<bool>(
"trap_fpe"))
1050 if (getParam<bool>(
"no_trap_fpe"))
1051 mooseError(
"Cannot use both \"--trap-fpe\" and \"--no-trap-fpe\" flags.");
1053 else if (getParam<bool>(
"no_trap_fpe"))
1065 auto color = getParam<MooseEnum>(
"color");
1069 if (getParam<bool>(
"no_color"))
1074 char * c_color = std::getenv(
"MOOSE_COLOR");
1076 color.assign(std::string(c_color),
"While assigning environment variable MOOSE_COLOR");
1080 if (color ==
"auto")
1082 else if (color ==
"on")
1084 else if (color ==
"off")
1087 mooseAssert(
false,
"Should not hit");
1090 if (getParam<bool>(
"no_color"))
1091 mooseDeprecated(
"The --no-color flag is deprecated. Use '--color off' instead.");
1100#if !LIBMESH_USING_THREADS
1102 mooseError(
"You specified --n-threads > 1, but there is no threading model active!");
1108 std::optional<std::set<std::string>> ignore_capabilities;
1113 "--testharness-capabilities: Should not be specified without --required-capabilities");
1115 const auto file_path = std::filesystem::absolute(
1116 std::filesystem::path(getParam<std::string>(
"testharness_capabilities")));
1118 std::ifstream file(file_path);
1120 mooseError(
"--testharness-capabilities: Could not open ", file_path);
1122 nlohmann::json root;
1126 if (
const auto it = root.find(
"capabilities"); it != root.end())
1128 if (
const auto it = root.find(
"ignore_capabilities"); it != root.end())
1129 ignore_capabilities = it->
get<std::set<std::string>>();
1131 catch (
const std::exception & e)
1134 "--testharness-capabilities: Failed to load capabilities ", file_path,
":\n", e.what());
1142 const auto & required_capabilities = getParam<std::string>(
"required_capabilities");
1144 CapabilityRegistry::CheckOptions options;
1146 options.certain =
false;
1148 if (ignore_capabilities)
1149 options.ignore_capabilities = *ignore_capabilities;
1151 CapabilityRegistry::CheckResult result;
1157 catch (
const std::exception & e)
1159 mooseError(
"--required-capablities: ", e.what());
1162 if (result.state < CapabilityRegistry::CheckState::UNKNOWN)
1164 mooseInfo(
"Required capabilities '", required_capabilities,
"' not fulfilled.");
1170 if (result.state == CapabilityRegistry::CheckState::UNKNOWN)
1172 required_capabilities,
1173 "' are not specific enough. A comparison test is performed on an undefined "
1174 "capability. Disambiguate this requirement by adding an existence/non-existence "
1175 "requirement. Example: 'unknown<1.2.3' should become 'unknown & unknown<1.2.3' "
1176 "or '!unknown | unknown<1.2.3'");
1181 if (getParam<bool>(
"minimal"))
1184 else if (getParam<bool>(
"display_version"))
1191 else if (getParam<bool>(
"help"))
1199 const std::string search =
1200 isParamSetByUser(
"dump_search") ? getParam<std::string>(
"dump_search") :
"";
1205 TIME_SECTION(
"dump", 1,
"Building Syntax Tree");
1210 if ((tree.
getRoot()).is_object())
1216 Moose::out <<
"\n### START DUMP DATA ###\n"
1217 << formatter.
toString(tree.
getRoot()) <<
"\n### END DUMP DATA ###" << std::endl;
1222 mooseError(
"Search parameter '", search,
"' was not found in the registered syntax.");
1224 else if (getParam<bool>(
"registry"))
1228 Moose::out <<
"Label\tType\tName\tClass\tFile\n";
1231 for (
auto & entry : objmap)
1232 for (
auto & obj : entry.second)
1233 Moose::out << entry.first <<
"\tobject\t" << obj->name() <<
"\t" << obj->_classname <<
"\t"
1234 << obj->_file <<
"\n";
1237 for (
auto & entry : actmap)
1239 for (
auto & act : entry.second)
1240 Moose::out << entry.first <<
"\taction\t" << act->_name <<
"\t" << act->_classname <<
"\t"
1241 << act->_file <<
"\n";
1246 else if (getParam<bool>(
"registry_hit"))
1250 Moose::out <<
"### START REGISTRY DATA ###\n";
1252 hit::Section root(
"");
1253 auto sec =
new hit::Section(
"registry");
1255 auto objsec =
new hit::Section(
"objects");
1256 sec->addChild(objsec);
1259 for (
auto & entry : objmap)
1260 for (
auto & obj : entry.second)
1262 auto ent =
new hit::Section(
"entry");
1263 objsec->addChild(ent);
1264 ent->addChild(
new hit::Field(
"label", hit::Field::Kind::String, entry.first));
1265 ent->addChild(
new hit::Field(
"type", hit::Field::Kind::String,
"object"));
1266 ent->addChild(
new hit::Field(
"name", hit::Field::Kind::String, obj->name()));
1267 ent->addChild(
new hit::Field(
"class", hit::Field::Kind::String, obj->_classname));
1268 ent->addChild(
new hit::Field(
"file", hit::Field::Kind::String, obj->_file));
1271 auto actsec =
new hit::Section(
"actions");
1272 sec->addChild(actsec);
1274 for (
auto & entry : actmap)
1275 for (
auto & act : entry.second)
1277 auto ent =
new hit::Section(
"entry");
1278 actsec->addChild(ent);
1279 ent->addChild(
new hit::Field(
"label", hit::Field::Kind::String, entry.first));
1280 ent->addChild(
new hit::Field(
"type", hit::Field::Kind::String,
"action"));
1281 ent->addChild(
new hit::Field(
"task", hit::Field::Kind::String, act->_name));
1282 ent->addChild(
new hit::Field(
"class", hit::Field::Kind::String, act->_classname));
1283 ent->addChild(
new hit::Field(
"file", hit::Field::Kind::String, act->_file));
1286 Moose::out << root.render();
1288 Moose::out <<
"\n### END REGISTRY DATA ###\n";
1294 const std::string search =
1295 isParamSetByUser(
"yaml_search") ? getParam<std::string>(
"yaml_search") :
"";
1306 const std::string search =
1307 isParamSetByUser(
"json_search") ? getParam<std::string>(
"json_search") :
"";
1314 "json",
"**START JSON DATA**\n",
"\n**END JSON DATA**", tree.
getRoot().dump(2));
1318 else if (getParam<bool>(
"syntax"))
1323 std::stringstream ss;
1324 for (
const auto & it :
syntax)
1325 ss << it.first <<
"\n";
1330 else if (getParam<bool>(
"show_type"))
1334 Moose::out <<
"MooseApp Type: " <<
type() << std::endl;
1338 else if (getParam<bool>(
"show_capabilities"))
1342 "**START JSON DATA**\n",
1343 "\n**END JSON DATA**",
1352 const auto & capabilities = getParam<std::string>(
"check_capabilities");
1354 CapabilityRegistry::CheckResult result;
1359 catch (
const std::exception & e)
1361 mooseError(
"--check-capablities: ", e.what());
1364 const bool pass = result.state == CapabilityRegistry::CheckState::CERTAIN_PASS;
1365 _console <<
"Capabilities '" << capabilities <<
"' are " << (pass ?
"" :
"not ") <<
"fulfilled."
1379 const auto & recover = getParam<std::string>(
"recover");
1387 auto isExclusiveParamSetByUser =
1388 [
this](
const std::vector<std::string> & group,
const std::string & param)
1392 for (
const auto & p : group)
1394 mooseError(
"Parameters '" + p +
"' and '" + param +
1395 "' are mutually exclusive. Please choose only one of them.");
1400 const std::vector<std::string> final_task_params = {
1401 "csg_only",
"mesh_only",
"split_mesh",
"parse_neml2_only"};
1402 if (isExclusiveParamSetByUser(final_task_params,
"csg_only"))
1406 mooseError(
"--csg-only cannot be used in conjunction with --distributed-mesh");
1409 mooseError(
"--csg-only is not compatible with any mesh splitting options");
1411 mooseError(
"--csg-only cannot be used in conjunction with -r refinements option");
1413 mooseError(
"--csg-only option cannot be used as a Subapp");
1415 mooseError(
"--csg-only option cannot be used in recovery mode");
1426 else if (isExclusiveParamSetByUser(final_task_params,
"mesh_only"))
1440 else if (isExclusiveParamSetByUser(final_task_params,
"split_mesh"))
1448 else if (isExclusiveParamSetByUser(final_task_params,
"parse_neml2_only"))
1460 mooseAssert(common_actions.size() <= 1,
"Should not be more than one CommonOutputAction");
1461 const Action * common = common_actions.empty() ? nullptr : *common_actions.begin();
1474 size_t pos = base.find_last_of(
'.');
1489 mooseError(
"You specified --check-input, but did not provide an input file. Add -i "
1490 "<inputfile> to your command line.");
1492 mooseError(
"No input files specified. Add -i <inputfile> to your command line.");
1494 else if (
isParamValid(
"language_server") && getParam<bool>(
"language_server"))
1519 Moose::out << std::flush;
1522const std::vector<std::string> &
1525 mooseAssert(
_parser,
"Parser is not set");
1526 return _parser->getInputFileNames();
1532 mooseAssert(
_parser,
"Parser is not set");
1533 return _parser->getLastInputFileName();
1556 multi_app->setAppOutputFileBase();
1564 TIME_SECTION(
"runInputFile", 3);
1592 else if (getParam<bool>(
"list_constructed_objects"))
1597 std::stringstream ss;
1601 "list_constructed_objects",
"**START OBJECT DATA**\n",
"\n**END OBJECT DATA**", ss.str());
1623 "Something went wrong, we should only get here if _check_input is true.");
1625 "Incompatible command line arguments provided. --check-input cannot be called with ",
1630 mooseError(
"The Executor is being called without being initialized. This is likely "
1632 "incompatible command line arguments");
1636 for (
auto app : apps)
1637 for (
unsigned int i = 0; i < app->numLocalApps(); i++)
1644 TIME_SECTION(
"executeExecutioner", 3);
1657 if (!result.convergedAll())
1670 mooseError(
"No executioner was specified (go fix your input file)");
1701 "MooseApp::hasRestartRecoverFileBase() instead.");
1712 case RESTARTABLE_FILTER::RECOVERABLE:
1720std::vector<std::filesystem::path>
1723 TIME_SECTION(
"backup", 2,
"Backing Up Application to File");
1728 return writer.
write(folder_base);
1731std::unique_ptr<Backup>
1734 TIME_SECTION(
"backup", 2,
"Backing Up Application");
1740 auto backup = std::make_unique<Backup>();
1741 packMeshBackup(*
this, *
backup);
1763 TIME_SECTION(
"restore", 2,
"Restoring Application from File");
1776 TIME_SECTION(
"restore", 2,
"Restoring Application");
1781 mooseError(
"MooseApp::restore(): Provided backup is not initialized");
1784 mooseAssert(
header,
"Header not available");
1786 auto data = std::move(
backup->data);
1787 mooseAssert(data,
"Data not available");
1811std::unique_ptr<Backup>
1815 mooseError(
"MooseApp::finalizeRestore(): Not currently restoring");
1820 std::unique_ptr<Backup>
backup;
1824 if (
auto header_string_input =
dynamic_cast<StringInputStream *
>(input_streams.header.get()))
1826 auto data_string_input =
dynamic_cast<StringInputStream *
>(input_streams.data.get());
1827 mooseAssert(data_string_input,
"Should also be a string input");
1829 auto header_sstream = header_string_input->release();
1830 mooseAssert(header_sstream,
"Header not available");
1832 auto data_sstream = data_string_input->release();
1833 mooseAssert(data_sstream,
"Data not available");
1835 backup = std::make_unique<Backup>();
1836 backup->header = std::move(header_sstream);
1837 backup->data = std::move(data_sstream);
1838 packMeshBackup(*
this, *
backup);
1865 const std::string & name,
1871 mooseError(
"an executor with name '", executor->name(),
"' already exists");
1877 const std::string & name,
1886 mooseAssert(
_parser,
"Not set");
1893 return const_cast<Parser &
>(std::as_const(*this).parser());
1898 std::list<std::string> & possible_roots,
1899 std::list<std::string> & current_branch)
1906 if (std::find(current_branch.begin(), current_branch.end(), current_executor_name) !=
1907 current_branch.end())
1909 std::stringstream exec_names_string;
1911 auto branch_it = current_branch.begin();
1913 exec_names_string << *branch_it++;
1915 for (; branch_it != current_branch.end(); ++branch_it)
1916 exec_names_string <<
", " << *branch_it;
1918 exec_names_string <<
", " << current_executor_name;
1920 mooseError(
"Executor cycle detected: ", exec_names_string.str());
1923 current_branch.push_back(current_executor_name);
1928 for (
const auto & param : params)
1930 if (params.have_parameter<ExecutorName>(param.first))
1932 const auto & dependency_name = params.get<ExecutorName>(param.first);
1934 possible_roots.remove(dependency_name);
1936 if (!dependency_name.empty())
1945 current_branch.pop_back();
1956 std::list<std::string> possibly_root;
1959 std::map<std::string, bool> already_built;
1962 std::list<std::string> possible_roots;
1965 std::list<std::string> current_branch;
1975 const auto &
name = params_entry.first;
1981 possible_roots.emplace_back(
name);
1987 if (possible_roots.size() > 1)
1989 auto root_string_it = possible_roots.begin();
1991 std::stringstream roots_string;
1993 roots_string << *root_string_it++;
1995 for (; root_string_it != possible_roots.end(); ++root_string_it)
1996 roots_string <<
", " << *root_string_it;
1998 mooseError(
"Multiple Executor roots found: ", roots_string.str());
2013 if (fail_if_not_found)
2034 TIME_SECTION(
"run", 3);
2035 if (getParam<bool>(
"show_docs"))
2039 mooseError(
"could not locate installed tests to run (unresolved binary/app name)");
2042 mooseError(
"no installed documentation found");
2048 std::ifstream ifs(docmsgfile);
2049 std::string content((std::istreambuf_iterator<char>(ifs)),
2050 (std::istreambuf_iterator<char>()));
2051 content.replace(content.find(
"$LOCAL_SITE_HOME"), content.length(), docmsg);
2055 Moose::out << docmsg <<
"\n";
2070 TIME_SECTION(
"setup", 2,
"Setting Up");
2076 mooseAssert(
_parser->getThrowOnError(),
"Should be true");
2084 catch (std::exception & err)
2091 TIME_SECTION(
"execute", 2,
"Executing");
2098 Moose::err <<
"Syntax OK" << std::endl;
2115 "Constructed object '" + objname +
"' is not registered");
2117 citations.insert(app_citations.begin(), app_citations.end());
2122 std::string backend =
"libMesh";
2123#ifdef MOOSE_MFEM_ENABLED
2128 citations.insert(backend_citations.begin(), backend_citations.end());
2136 for (
const auto i : make_range(multi_app->numLocalApps()))
2137 multi_app->localApp(i)->collectCitations(citations);
2144 std::map<std::string, std::string> citations;
2151 std::vector<std::string> flattened;
2152 flattened.reserve(citations.size() * 2);
2153 for (
const auto & [key, bibtex] : citations)
2155 flattened.push_back(key);
2156 flattened.push_back(bibtex);
2158 _comm->allgather(flattened);
2159 for (std::size_t i = 0; i + 1 < flattened.size(); i += 2)
2161 [[maybe_unused]]
const auto [it, inserted] = citations.emplace(flattened[i], flattened[i + 1]);
2162 mooseAssert(inserted || it->second == flattened[i + 1],
2163 "The same citation key was registered with different BibTeX entries");
2169 for (
const auto & citation : citations)
2178 if (getParam<bool>(
"show_inputs"))
2181 std::vector<std::string> dirs;
2184 if (installable_inputs ==
"")
2187 <<
"Show inputs has not been overriden in this application.\nContact the developers of "
2188 "this appication and request that they override \"MooseApp::getInstallableInputs\".\n";
2192 mooseAssert(!show_inputs_syntax.empty(),
"show_inputs sytnax should not be empty");
2195 Moose::out <<
"The following directories are installable into a user-writeable directory:\n\n"
2196 << installable_inputs <<
'\n'
2197 <<
"\nTo install one or more directories of inputs, execute the binary with the \""
2198 << show_inputs_syntax[0] <<
"\" flag. e.g.:\n$ "
2199 <<
_command_line->getExecutableName() <<
' ' << show_inputs_syntax[0] <<
' '
2218 if (
comm().size() > 1)
2219 mooseError(
"The --copy-inputs option should not be ran in parallel");
2222 auto dir_to_copy = getParam<std::string>(
"copy_inputs");
2224 if (dir_to_copy.empty())
2225 mooseError(
"Error retrieving directory to copy");
2226 if (dir_to_copy.back() !=
'/')
2233 mooseError(
"could not locate installed tests to run (unresolved binary/app name)");
2239 " to get a list of installable directories.");
2243 auto dst_dir =
_command_line->getExecutableNameBase() +
"/" + dir_to_copy;
2245 if (cmdname.find_first_of(
"/") != std::string::npos)
2246 cmdname = cmdname.substr(cmdname.find_first_of(
"/") + 1, std::string::npos);
2250 "The directory \"./",
2252 "\" already exists.\nTo update/recopy the contents of this directory, rename (\"mv ",
2254 " new_dir_name\") or remove (\"rm -r ",
2256 "\") the existing directory.\nThen re-run \"",
2262 std::string cmd =
"mkdir -p " + dst_dir +
"; rsync -av " + src_dir +
" " + dst_dir;
2264 TIME_SECTION(
"copy_inputs", 2,
"Copying Inputs");
2266 mooseAssert(
comm().size() == 1,
"Should be run in serial");
2267 const auto return_value = system(cmd.c_str());
2268 if (!WIFEXITED(return_value))
2272 Moose::out <<
"Directory successfully copied into ./" << dst_dir <<
'\n';
2283 if (
comm().size() > 1)
2284 mooseError(
"The --run option should not be ran in parallel");
2287 const auto find_run_it = std::as_const(*_command_line).findCommandLineParam(
"run");
2288 const auto & cl_entries = std::as_const(*_command_line).getEntries();
2289 mooseAssert(find_run_it != cl_entries.end(),
"Didn't find the option");
2290 std::string test_args;
2291 for (
auto it = std::next(find_run_it); it != cl_entries.end(); ++it)
2292 for (
const auto & arg : it->raw_args)
2294 test_args +=
" " + arg;
2303 mooseError(
"Could not locate binary name relative to installed location");
2307 "Could not locate installed tests from the current working directory:",
2309 ".\nMake sure you are executing this command from within a writable installed inputs ",
2310 "directory.\nRun \"",
2312 " --copy-inputs <dir>\" to copy the contents of <dir> to a \"./",
2314 "_<dir>\" directory.\nChange into that directory and try \"",
2316 " --run <dir>\" again.");
2320 setenv(
"MOOSE_TEST_RUNNER_APP_NAME",
appBinaryName().c_str(),
true);
2323 Moose::out <<
"Working Directory: " << working_dir <<
"\nRunning Command: " << cmd << std::endl;
2324 mooseAssert(
comm().size() == 1,
"Should be run in serial");
2325 const auto return_value = system(cmd.c_str());
2326 if (!WIFEXITED(return_value))
2338 const std::string_view doc)
2344 catch (
const std::exception & e)
2361std::list<std::string>
2365 std::list<std::string> checkpoint_dirs;
2372 for (
const auto & action : actions)
2376 if (!moose_object_action)
2380 if (moose_object_action->
getParam<std::string>(
"type") ==
"Checkpoint")
2384 const std::string cp_dir =
2387 checkpoint_dirs.push_back(cp_dir +
"_cp");
2390 return checkpoint_dirs;
2393std::list<std::string>
2428 std::string library_name(app_name);
2431 size_t pos = library_name.find(
"App");
2432 if (pos != library_name.length() - 3)
2433 mooseError(
"Invalid application name: ", library_name);
2434 library_name.erase(pos);
2438 QUOTE(METHOD) +
".la";
2444 std::string app_name(library_name);
2447 if (pcrecpp::RE(
"lib(.+?)(?:-\\w+)?\\.la").Replace(
"\\1", &app_name) == 0)
2448 mooseError(
"Invalid library name: ", app_name);
2459 if (!metaname.empty() && tid != 0)
2461 "The meta data storage for '", metaname,
"' is not threaded, so the tid must be zero.");
2463 mooseAssert(metaname.empty() ||
2465 "The desired meta data name does not exist: " + metaname);
2474 if (data->typeId() != stored_data->
typeId())
2475 mooseError(
"Type mismatch found in RestartableData registration of '",
2477 "'\n\n Stored type: ",
2478 stored_data->
type(),
2483 stored_data = &data_map.addData(std::move(data));
2488 return *stored_data;
2493 std::unique_ptr<RestartableDataValue> data,
2498 mooseDeprecated(
"The use of MooseApp::registerRestartableData with a data name is "
2499 "deprecated.\n\nUse the call without a name instead.");
2501 mooseAssert(
name == data->name(),
"Inconsistent name");
2512 return it->second.first.hasData(
name);
2522 "The meta data storage for '", metaname,
"' is not threaded, so the tid must be zero.");
2528 mooseError(
"Unable to find RestartableDataValue object with name " +
name +
2529 " in RestartableDataMap");
2536 const std::filesystem::path & folder_base)
2544 reader.
setInput(meta_data_folder_base);
2556std::vector<std::filesystem::path>
2558 const std::filesystem::path & folder_base)
2561 mooseError(
"MooseApp::writeRestartableMetaData(): Should only run on processor 0");
2567 return writer.
write(meta_data_folder_base);
2570std::vector<std::filesystem::path>
2573 std::vector<std::filesystem::path> paths;
2579 paths.insert(paths.end(), map_paths.begin(), map_paths.end());
2587 std::string library_path,
2588 const std::string & library_name,
2591#ifdef LIBMESH_HAVE_DLOPEN
2593 params.
set<std::string>(
"app_name") = app_name;
2595 params.
set<std::string>(
"registration_method") = app_name +
"__registerApps";
2596 params.
set<std::string>(
"library_path") = library_path;
2598 const auto effective_library_name =
2600 params.
set<std::string>(
"library_name") = effective_library_name;
2601 params.
set<
bool>(
"library_load_dependencies") = lib_load_deps;
2604 std::ostringstream oss;
2606 auto successfully_loaded =
false;
2608 oss <<
'"' << app_name <<
"\" is not a registered application name.\n"
2609 <<
"No search paths were set. We made no attempts to locate the corresponding library "
2618 oss <<
'"' << app_name <<
"\" is not a registered application name.\n"
2619 <<
"Unable to locate library archive for \"" << app_name
2620 <<
"\".\nWe attempted to locate the library archive \"" << effective_library_name
2621 <<
"\" in the following paths:\n\t";
2625 successfully_loaded =
true;
2628 if (!successfully_loaded)
2630 oss <<
"\nMake sure you have compiled the library and either set the \"library_path\" "
2631 "variable in your input file or exported \"MOOSE_LIBRARY_PATH\".\n";
2637 libmesh_ignore(app_name, library_path, library_name, lib_load_deps);
2638 mooseError(
"Dynamic Loading is either not supported or was not detected by libMesh configure.");
2647 std::string library_path,
2648 const std::string & library_name)
2650#ifdef LIBMESH_HAVE_DLOPEN
2652 params.
set<std::string>(
"app_name") = app_name;
2654 params.
set<std::string>(
"registration_method") = app_name +
"__registerAll";
2655 params.
set<std::string>(
"library_path") = library_path;
2656 params.
set<std::string>(
"library_name") =
2662 params.
set<
bool>(
"library_load_dependencies") =
false;
2666 libmesh_ignore(app_name, factory, action_factory,
syntax, library_path, library_name);
2667 mooseError(
"Dynamic Loading is either not supported or was not detected by libMesh configure.");
2675 const auto library_name = params.
get<std::string>(
"library_name");
2678 for (
const auto & path : paths)
2681 path +
'/' + library_name, params, params.
get<
bool>(
"library_load_dependencies"));
2687 const bool load_dependencies)
2690 std::string dl_lib_filename;
2694 pcrecpp::RE re_deps(
"(/\\S*\\.la)");
2696 std::ifstream la_handle(library_filename.c_str());
2697 if (la_handle.is_open())
2699 while (std::getline(la_handle, line))
2702 if (line.find(
"dlname=") != std::string::npos)
2705 dl_lib_filename = line.substr(8, line.size() - 9);
2707 if (line.find(
"dependency_libs=") != std::string::npos)
2709 if (load_dependencies)
2711 pcrecpp::StringPiece input(line);
2712 pcrecpp::StringPiece depend_library;
2713 while (re_deps.FindAndConsume(&input, &depend_library))
2727 if (dl_lib_filename.empty())
2730 const auto & [dir, file_name] = MooseUtils::splitFileName(library_filename);
2746#ifdef LIBMESH_HAVE_DLOPEN
2747 void *
const lib_handle = dlopen(dl_lib_full_path.c_str(), RTLD_LAZY);
2749 void *
const lib_handle =
nullptr;
2755 "\" exists and has proper permissions, but cannot by dynamically loaded.\nThis "
2756 "generally means that the loader was unable to load one or more of the "
2757 "dependencies listed in the supplied library (see otool or ldd).\n",
2764 auto insert_ret =
_lib_handles.insert(std::make_pair(file_name, lib_info));
2765 mooseAssert(insert_ret.second ==
true,
"Error inserting into lib_handles map");
2767 dyn_lib_it = insert_ret.first;
2771 const auto registration_method = params.
get<std::string>(
"registration_method");
2772 auto & entry_sym_from_curr_lib = dyn_lib_it->second.entry_symbols;
2774 if (entry_sym_from_curr_lib.find(registration_method) == entry_sym_from_curr_lib.end())
2780#ifdef LIBMESH_HAVE_DLOPEN
2781 void * registration_handle =
2782 dlsym(dyn_lib_it->second.library_handle, registration_method.c_str());
2784 void * registration_handle =
nullptr;
2787 if (registration_handle)
2793 using register_app_t = void (*)();
2794 register_app_t *
const reg_ptr =
reinterpret_cast<register_app_t *
>(®istration_handle);
2801 register_app_t *
const reg_ptr =
reinterpret_cast<register_app_t *
>(®istration_handle);
2811 entry_sym_from_curr_lib.insert(registration_method);
2816#if defined(DEBUG) && defined(LIBMESH_HAVE_DLOPEN)
2820 if (!registration_handle)
2822 registration_method,
2826 "This doesn't necessarily indicate an error condition unless you believe that "
2827 "the method should exist in that library.\n",
2834std::set<std::string>
2838 std::set<std::string> paths;
2840 paths.insert(it.first);
2845std::set<std::string>
2848 std::set<std::string> paths;
2850 if (!library_path.empty())
2852 std::vector<std::string> tmp_paths;
2855 paths.insert(tmp_paths.begin(), tmp_paths.end());
2858 char * moose_lib_path_env = std::getenv(
"MOOSE_LIBRARY_PATH");
2859 if (moose_lib_path_env)
2861 std::string moose_lib_path(moose_lib_path_env);
2862 std::vector<std::string> tmp_paths;
2865 paths.insert(tmp_paths.begin(), tmp_paths.end());
2880 return std::string(
"");
2898 TIME_SECTION(
"createMinimalApp", 3,
"Creating Minimal App");
2904 action_params.
set<std::string>(
"type") =
"GeneratedMesh";
2907 std::shared_ptr<MooseObjectAction> action = std::static_pointer_cast<MooseObjectAction>(
2913 params.
set<
unsigned int>(
"nx") = 1;
2923 action_params.
set<std::string>(
"type") =
"Transient";
2926 std::shared_ptr<MooseObjectAction> action = std::static_pointer_cast<MooseObjectAction>(
2931 params.
set<
unsigned int>(
"num_steps") = 1;
2932 params.
set<Real>(
"dt") = 1;
2942 action_params.
set<
bool>(
"_solve") =
false;
2945 std::shared_ptr<Action> action = std::static_pointer_cast<Action>(
2956 action_params.
set<
bool>(
"console") =
false;
2959 std::shared_ptr<Action> action =
2974 [&
name](
const std::shared_ptr<RelationshipManager> & rm)
2983 auto & existing_for_whom = acceptor.
forWhom();
2986 for (
auto & fw : donor.forWhom())
2988 if (std::find(existing_for_whom.begin(), existing_for_whom.end(), fw) ==
2989 existing_for_whom.end())
3013 std::set<std::shared_ptr<RelationshipManager>> rms_to_erase;
3017 if (*existing_rm >= *new_rm)
3020 donateForWhom(*new_rm, *existing_rm);
3025 else if (*new_rm >= *existing_rm)
3026 rms_to_erase.emplace(existing_rm);
3032 for (
const auto & rm_to_erase : rms_to_erase)
3034 donateForWhom(*rm_to_erase, *new_rm);
3046 static const std::string suffix =
"-mesh.cpa.gz";
3050std::filesystem::path
3052 const std::string & map_suffix)
3055 std::filesystem::path(
"meta_data" + map_suffix));
3058std::filesystem::path
3061 auto folder = folder_base;
3062 folder +=
"-restart-" + std::to_string(
processor_id());
3070 return action->parameters().getHitNode();
3087 mooseError(
"The template rm does not exist in our _template_to_clones map");
3089 auto & mesh_to_clone_map = outer_it->second;
3090 auto inner_it = mesh_to_clone_map.find(&
mesh);
3091 if (inner_it == mesh_to_clone_map.end())
3092 mooseError(
"We should have the mesh key in our mesh");
3094 return *inner_it->second;
3104 const MeshBase *
const undisp_lm_mesh =
mesh->getMeshPtr();
3106 if (undisp_lm_mesh &&
hasRMClone(*rm, *undisp_lm_mesh))
3108 undisp_clone = &
getRMClone(*rm, *undisp_lm_mesh);
3109 const_cast<MeshBase *
>(undisp_lm_mesh)->remove_ghosting_functor(*undisp_clone);
3113 MeshBase *
const disp_lm_mesh = displaced_mesh ? &displaced_mesh->getMesh() :
nullptr;
3115 if (disp_lm_mesh &&
hasRMClone(*rm, *disp_lm_mesh))
3117 disp_clone = &
getRMClone(*rm, *disp_lm_mesh);
3118 disp_lm_mesh->remove_ghosting_functor(*disp_clone);
3126 problem.removeAlgebraicGhostingFunctor(*undisp_clone);
3127 problem.removeCouplingGhostingFunctor(*undisp_clone);
3130 auto * dp = problem.getDisplacedProblem().get();
3131 if (dp && disp_clone)
3132 dp->removeAlgebraicGhostingFunctor(*disp_clone);
3143 const DofMap *
const dof_map)
3146 auto it = mesh_to_clone.find(&
mesh);
3147 if (it != mesh_to_clone.end())
3150 auto & clone_rm = *it->second;
3151 if (!clone_rm.dofMap() && dof_map)
3153 clone_rm.
init(moose_mesh,
mesh, dof_map);
3154 else if (clone_rm.dofMap() && dof_map && (clone_rm.dofMap() != dof_map))
3155 mooseError(
"Attempting to create and initialize an existing clone with a different DofMap. "
3156 "This should not happen.");
3166 auto pr = mesh_to_clone.emplace(
3167 std::make_pair(&
const_cast<const MeshBase &
>(
mesh),
3168 dynamic_pointer_cast<RelationshipManager>(template_rm.
clone())));
3169 mooseAssert(pr.second,
"An insertion should have happened");
3170 auto & clone_rm = *pr.first->second;
3171 clone_rm.init(moose_mesh,
mesh, dof_map);
3182 if (rm->attachGeometricEarly())
3193 if (
const MeshBase *
const moose_mesh_base = moose_mesh.
getMeshPtr())
3195 if (moose_mesh_base != &
mesh)
3196 mooseError(
"The MooseMesh MeshBase and the MeshBase we're trying to attach "
3197 "relationship managers to are different");
3202 mesh.allow_remote_element_removal(
false);
3210 bool attach_geometric_rm_final)
3214 if (!rm->isType(rm_type))
3228 if (!rm->attachGeometricEarly() && !attach_geometric_rm_final)
3231 mesh->allowRemoteElementRemoval(
false);
3234 MeshBase & undisp_mesh_base =
mesh->getMesh();
3235 const DofMap *
const undisp_sys_dof_map =
3237 undisp_mesh_base.add_ghosting_functor(
3243 attach_geometric_rm_final && disp_moose_mesh)
3246 const DofMap * disp_sys_dof_map =
nullptr;
3249 disp_mesh_base.add_ghosting_functor(
3253 mooseError(
"The displaced mesh should not yet exist at the time that we are attaching "
3254 "early geometric relationship managers.");
3264 mooseError(
"We must have an executioner by now or else we do not have to data to add "
3265 "algebraic or coupling functors to in MooseApp::attachRelationshipManagers");
3269 auto & undisp_moose_mesh = problem.mesh();
3271 auto & undisp_sys_dof_map = undisp_sys.
dofMap();
3272 auto & undisp_mesh = undisp_moose_mesh.getMesh();
3274 if (rm->useDisplacedMesh() && problem.getDisplacedProblem())
3288 problem.addCouplingGhostingFunctor(
3296 auto & disp_mesh = disp_moose_mesh.getMesh();
3297 const DofMap *
const disp_nl_dof_map = &
displaced_problem.solverSys(0).dofMap();
3306 problem.addCouplingGhostingFunctor(
3311 problem.addAlgebraicGhostingFunctor(
3323std::vector<std::pair<std::string, std::string>>
3326 std::vector<std::pair<std::string, std::string>> info_strings;
3331 std::stringstream oss;
3332 oss << rm->getInfo();
3334 auto & for_whom = rm->forWhom();
3336 if (!for_whom.empty())
3343 info_strings.emplace_back(std::make_pair(
Moose::stringify(rm->getType()), oss.str()));
3354 std::map<std::string, unsigned int> counts;
3356 for (
auto & gf : as_range(
mesh->getMesh().ghosting_functors_begin(),
3357 mesh->getMesh().ghosting_functors_end()))
3362 counts[demangle(
typeid(*gf).name())]++;
3365 for (
const auto & pair : counts)
3366 info_strings.emplace_back(std::make_pair(
3367 "Default", pair.first + (pair.second > 1 ?
" x " + std::to_string(pair.second) :
"")));
3378 std::map<std::string, unsigned int> counts;
3380 for (
auto & gf : as_range(d_mesh->getMesh().ghosting_functors_begin(),
3381 d_mesh->getMesh().ghosting_functors_end()))
3386 counts[demangle(
typeid(*gf).name())]++;
3389 for (
const auto & pair : counts)
3390 info_strings.emplace_back(
3391 std::make_pair(
"Default",
3392 pair.first + (pair.second > 1 ?
" x " + std::to_string(pair.second) :
"") +
3393 " for DisplacedMesh"));
3396 return info_strings;
3408 std::vector<std::string> not_declared;
3410 for (
const auto & data : meta_data)
3411 if (!data.declared())
3412 not_declared.push_back(data.name());
3414 if (!not_declared.empty())
3416 std::ostringstream oss;
3422 "' meta-data properties were retrieved but never declared: ",
3436 mooseError(
"Unable to find RestartableDataMap object for the supplied name '",
3438 "', did you call registerRestartableDataMapName in the application constructor?");
3439 return iter->second.first;
3451 if (!suffix.empty())
3452 std::transform(suffix.begin(), suffix.end(), suffix.begin(), ::tolower);
3453 suffix.insert(0,
"_");
3463 mooseError(
"MooseApp::getRestartableDataMapName: The name '",
name,
"' is not registered");
3464 return it->second.second;
3473 std::make_unique<RestartableData<PerfGraph>>(
"perf_graph",
3477 getParam<bool>(
"perf_graph_live_all"),
3478 !getParam<bool>(
"disable_perf_graph_live"));
3490 auto solution_invalidity =
3491 std::make_unique<RestartableData<SolutionInvalidity>>(
"solution_invalidity",
nullptr, *
this);
3505#ifdef MOOSE_LIBTORCH_ENABLED
3509 const auto pname =
"--compute-device";
3510 if (device_enum ==
"cuda")
3513 if (!torch::cuda::is_available())
3514 mooseError(pname,
"=cuda: CUDA support is not available in the linked libtorch library");
3515 return torch::kCUDA;
3517 mooseError(pname,
"=cuda: CUDA is not supported on your platform");
3520 else if (device_enum ==
"mps")
3523 if (!torch::mps::is_available())
3524 mooseError(pname,
"=mps: MPS support is not available in the linked libtorch library");
3527 mooseError(pname,
"=mps: MPS is not supported on your platform");
3530 else if (device_enum ==
"xpu")
3532#ifdef MOOSE_HAVE_XPU
3533 if (!torch::xpu::is_available())
3534 mooseError(pname,
"=xpu: XPU support is not available in the linked libtorch library");
3537 mooseError(pname,
"=xpu: XPU is not supported in the current application");
3540 else if (device_enum !=
"cpu")
3543 "' is not currently supported by the MOOSE libtorch integration.");
3550 const std::string & start_marker,
3551 const std::string & end_marker,
3552 const std::string & data)
const
3557 Moose::out << start_marker << data << end_marker << std::endl;
3562 const auto & filename = getParam<std::string>(param);
3564 std::ofstream out(filename.c_str());
3567 std::ofstream out(filename.c_str());
3568 out << data << std::flush;
3572 mooseError(
"Unable to open file `", filename,
"` for writing ", param,
" data to it.");
3578 const std::string_view doc)
3586 const std::string_view doc)
3593 const std::string_view value,
3594 const std::string_view doc)
3602 const std::string_view doc)
3609 ::mooseDeprecated(
"MooseApp::addCapability() is deprecated (adding capability '",
3611 "'); use one of MooseApp::add[Bool,Int,String]Capability instead.");
3628#ifdef MOOSE_MFEM_ENABLED
3635 auto string_set = std::set<std::string>(string_vec.begin(), string_vec.end());
3638 _mfem_device = std::make_shared<mfem::Device>(device_string);
3640 _mfem_device->SetGPUAwareMPI(mfem::GetEnv(
"MFEM_GPU_AWARE_MPI") ?
true : gpu_aware_mpi);
3643 else if (!device_string.empty() && string_set !=
_mfem_devices)
3646 MooseUtils::join(string_set,
" "),
3647 "', but we have already "
3648 "configured the MFEM device "
3649 "object with the devices '",
void mooseDeprecatedNoTrace(Args &&... args)
Emit a deprecated code/feature message with the given stringified, concatenated args.
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application.
void mooseDeprecated(Args &&... args)
Emit a deprecated code/feature message with the given stringified, concatenated args.
std::string RestartableDataMapName
std::shared_ptr< DisplacedProblem > displaced_problem
if(!dmm->_nl) SETERRQ(PETSC_COMM_WORLD
std::unordered_set< std::string > DataNames
void ErrorVector unsigned int
Specialized factory for generic Action System objects.
std::shared_ptr< Action > create(const std::string &action, const std::string &action_name, InputParameters ¶meters)
InputParameters getValidParams(const std::string &name)
const std::shared_ptr< MooseMesh > & getDisplacedMesh() const
void setFinalTask(const std::string &task)
std::shared_ptr< MooseMesh > & mesh()
const Action * getCurrentAction() const
void clear()
This method deletes all of the Actions in the warehouse.
const std::string & getCurrentTaskName() const
const std::shared_ptr< MooseMesh > & getMesh() const
std::vector< const T * > getActions()
Retrieve all actions in a specific type ordered by their names.
std::shared_ptr< MooseMesh > & displacedMesh()
void build()
Builds all auto-buildable tasks.
const std::list< Action * > & getActionListByName(const std::string &task) const
Retrieve a constant list of Action pointers associated with the passed in task.
void executeAllActions()
This method loops over all actions in the warehouse and executes them.
void addActionBlock(std::shared_ptr< Action > blk)
This method add an Action instance to the warehouse.
Generic AppFactory class for building Application objects.
static AppFactory & instance()
Get the instance of the AppFactory.
void clearAppParams(const InputParameters ¶ms, const ClearAppParamsKey)
Clears the stored parameters for the given application parameteres.
AttribBoundaries tracks all boundary IDs associated with an object.
Tracks whether the object is on the displaced mesh.
TODO: delete this later - it is a temporary hack for dealing with inter-system dependencies.
TODO: delete this later - it is a temporary hack for dealing with inter-system dependencies.
TODO: delete this later - it is a temporary hack for dealing with inter-system dependencies.
Residual objects have this attribute.
This attribute describes sorting state.
Tracks the libmesh system number that a MooseObject is associated with.
This class wraps provides and tracks access to command line parameters.
Meta-action for creating common output object parameters This action serves two purpose,...
const ConsoleStream _console
An instance of helper class to write streams to the Console objects.
Executioners are objects that do the actual work of solving your problem.
The Executor class directs the execution flow of simulations.
Specialization of SubProblem for solving nonlinear equations plus auxiliary equations.
virtual std::shared_ptr< const DisplacedProblem > getDisplacedProblem() const
ExecuteMooseObjectWarehouse< MultiApp > & getMultiAppWarehouse()
virtual MooseMesh & mesh() override
SolverSystem & getSolverSystem(unsigned int sys_num)
Get non-constant reference to a solver system.
virtual void meshChanged(bool intermediate_change, bool contract_mesh, bool clean_refinement_flags)
Update data after a mesh change.
Generic factory class for build all sorts of objects.
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)
InputParameters getValidParams(const std::string &name) const
Get valid parameters for the object.
std::vector< std::string > getConstructedObjects() const
Get a list of all constructed Moose Object types.
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...
Holds the syntax in a Json::Value tree.
const nlohmann::json & getRoot() const
Get the root of the tree.
static const std::string allow_data_driven_param
The name of the boolean parameter on the MooseApp that will enable data driven generation.
bool appendingMeshGenerators() const
Whether or not mesh generators are currently being appended (append_mesh_generator task)
Base class for MOOSE-based applications.
const bool _distributed_mesh_on_command_line
This variable indicates that DistributedMesh should be used for the libMesh mesh underlying MooseMesh...
bool _heap_profiling
Memory profiling.
void loadRestartableMetaData(const std::filesystem::path &folder_base)
Loads all available restartable meta data if it is available with the folder base folder_base.
const bool _use_split
Whether or not we are using a (pre-)split mesh (automatically DistributedMesh)
const std::vector< std::string > & getInputFileNames() const
static void addAppParam(InputParameters ¶ms)
processor_id_type processor_id() const
Returns the MPI processor ID of the current processor.
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...
bool hasRestartableDataMap(const RestartableDataMapName &name) const
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 restoreMeshFromInitialBackup(MooseMesh &mesh)
Restore mesh from this app's initial Backup object and consume the mesh checkpoint entries.
const std::shared_ptr< CommandLine > _command_line
The CommandLine object.
Syntax & syntax()
Returns a writable reference to the syntax object.
bool isSplitMesh() const
Whether or not this is a split mesh operation.
void requestCitations()
Handles the –citations command-line option: registers with PETSc the BibTeX entries that should be ci...
void registerRestartableNameWithFilter(const std::string &name, Moose::RESTARTABLE_FILTER filter)
NOTE: This is an internal function meant for MOOSE use only!
std::string getPrintableVersion() const
Non-virtual method for printing out the version string in a consistent format.
void registerRestartableDataMapName(const RestartableDataMapName &name, std::string suffix="")
Reserve a location for storing custom RestartableDataMap objects.
std::set< std::string > getLibrarySearchPaths(const std::string &library_path_from_param) const
Return the paths searched by MOOSE when loading libraries.
MeshGeneratorSystem _mesh_generator_system
The system that manages the MeshGenerators.
void restoreFromInitialBackup(const bool for_restart)
Restores from a "initial" backup, that is, one set in _initial_backup.
const DataNames & getRecoverableData() const
Return a reference to the recoverable data object.
DataNames _recoverable_data_names
Data names that will only be read from the restart file during RECOVERY.
void setStartTime(Real time)
Set the starting time for the simulation.
std::shared_ptr< Executioner > _executioner
Pointer to the executioner of this run (typically build by actions)
bool hasRelationshipManager(const std::string &name) const
Returns a Boolean indicating whether a RelationshipManater exists with the same name.
void setMFEMDevice(const std::string &device_string, bool gpu_aware_mpi, Moose::PassKey< MFEMProblemSolve >)
Create/configure the MFEM device with the provided device_string.
void setOutputPosition(const Point &p)
Tell the app to output in a specific position.
void setOutputFileBase(const std::string &output_file_base)
Override the selection of the output file base name.
bool hasRestartRecoverFileBase() const
Return true if the recovery file base is set.
static void addInputParam(InputParameters ¶ms)
bool forceRestart() const
Whether or not we are forcefully restarting (allowing the load of potentially incompatibie checkpoint...
bool _start_time_set
Whether or not an start time has been set.
std::set< std::shared_ptr< RelationshipManager > > _relationship_managers
The relationship managers that have been added.
std::vector< RestartableDataMap > _restartable_data
Where the restartable data is held (indexed on tid)
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.
bool addRelationshipManager(std::shared_ptr< RelationshipManager > relationship_manager)
Transfers ownership of a RelationshipManager to the application for lifetime management.
bool hasRestartableMetaData(const std::string &name, const RestartableDataMapName &metaname) const
virtual std::string header() const
Returns a string to be printed at the beginning of a simulation.
std::string getOutputFileBase(bool for_non_moose_build_output=false) const
Get the output file base name.
const std::shared_ptr< libMesh::Parallel::Communicator > _comm
The MPI communicator this App is going to use.
std::unique_ptr< TheWarehouse > _the_warehouse
The combined warehouse for storing any MooseObject based object.
bool hasRecoverFileBase() const
virtual void executeExecutioner()
Execute the Executioner that was built.
OutputWarehouse & getOutputWarehouse()
Get the OutputWarehouse objects.
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)
std::map< std::string, std::shared_ptr< Executor > > _executors
Pointers to all of the Executors for this run.
static Moose::Capability & addBoolCapability(const std::string_view capability, const bool value, const std::string_view doc)
Register a boolean capability.
bool runInputs()
Handles the run input parameter logic: Checks to see whether a directory exists in user space and lau...
void setRestart(bool value)
Sets the restart/recover flags.
std::string getFileName(bool stripLeadingPath=true) const
Return the primary (first) filename that was parsed Note: When stripLeadingPath is false,...
bool isRestarting() const
Whether or not this is a "restart" calculation.
virtual bool constructingMeshGenerators() const
Whether this app is constructing mesh generators.
void loadLibraryAndDependencies(const std::string &library_filename, const libMesh::Parameters ¶ms, bool load_dependencies=true)
Recursively loads libraries and dependencies in the proper order to fully register a MOOSE applicatio...
torch::DeviceType determineLibtorchDeviceType(const MooseEnum &device) const
Function to determine the device which should be used by libtorch on this application.
std::unordered_map< std::string, DynamicLibraryInfo > _lib_handles
The library archive (name only), registration method and the handle to the method.
ActionFactory _action_factory
The Factory responsible for building Actions.
SolutionInvalidity & createRecoverableSolutionInvalidity()
Creates a recoverable SolutionInvalidity.
Executioner * getExecutioner() const
Retrieve the Executioner for this App.
void collectCitations(std::map< std::string, std::string > &citations) const
Collects the BibTeX citations for the modules/objects constructed in this app and the finite element ...
virtual void run()
Run the application.
Executor * getExecutor() const
bool _output_position_set
Whether or not an output position has been set for this app.
std::unique_ptr< Backup > backup()
Backs up the application memory in a Backup.
std::map< Moose::RelationshipManagerType, std::set< const RelationshipManager * > > _attached_relationship_managers
The relationship managers that have been attached (type -> RMs)
Real _start_time
The time at which to start the simulation.
const Parser & parser() const
std::vector< std::pair< std::string, std::string > > getRelationshipManagerInfo() const
Returns the Relationship managers info suitable for printing.
bool _recover
Whether or not this is a recovery run.
std::unique_ptr< Backup > finalizeRestore()
Finalizes (closes) the restoration process done in restore().
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 outputMachineReadableData(const std::string ¶m, const std::string &start_marker, const std::string &end_marker, const std::string &data) const
Outputs machine readable data (JSON, YAML, etc.) either to the screen (if no filename was provided as...
std::shared_ptr< mfem::Device > _mfem_device
The MFEM Device object.
static bool isRelocated()
bool meshChangedForBackup() const
Whether this app requires mesh topology data in its next Backup object.
ActionWarehouse _action_warehouse
Where built actions are stored.
static InputParameters validParams()
void removeRelationshipManager(std::shared_ptr< RelationshipManager > relationship_manager)
Purge this relationship manager from meshes and DofMaps and finally from us.
static const std::string & checkpointSuffix()
The file suffix for the checkpoint mesh.
const std::string & getRestartableDataMapName(const RestartableDataMapName &name) const
void addExecutor(const std::string &type, const std::string &name, const InputParameters ¶ms)
void createExecutors()
After adding all of the Executor Params - this function will actually cause all of them to be built.
bool isUltimateMaster() const
Whether or not this app is the ultimate master app.
enum MooseApp::UNUSED_CHECK _enable_unused_check
std::unique_ptr< InputParameterWarehouse > _input_parameter_warehouse
Input parameter storage structure; unique_ptr so we can control its destruction order.
Point _output_position
The output position.
OutputWarehouse _output_warehouse
OutputWarehouse object for this App.
std::list< std::string > getCheckpointDirectories() const
Get all checkpoint directories.
void createMinimalApp()
Method for creating the minimum required actions for an application (no input file)
bool _restored_initial_backup_mesh
Whether mesh topology has been restored from the initial Backup object.
bool hasInitialBackupMesh() const
Whether this app has an initial Backup object with mesh checkpoint entries.
virtual std::string appBinaryName() const
std::shared_ptr< NullExecutor > _null_executor
Used to return an executor that does nothing.
PerfGraph & createRecoverablePerfGraph()
Creates a recoverable PerfGraph.
void deallocateKokkosMemoryPool()
Deallocate Kokkos memory pool.
bool _restart
Whether or not this is a restart run.
void dynamicRegistration(const libMesh::Parameters ¶ms)
Helper method for dynamic loading of objects.
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>
RestartableDataValue & registerRestartableData(std::unique_ptr< RestartableDataValue > data, THREAD_ID tid, bool read_only, const RestartableDataMapName &metaname="")
std::string _output_file_base
The output file basename.
const unsigned int _multiapp_level
Level of multiapp, the master is level 0. This used by the Console to indent output.
void checkMetaDataIntegrity() const
Function to check the integrity of the restartable meta data structure.
void errorCheck()
Runs post-initialization error checking that cannot be run correctly unless the simulation has been f...
RelationshipManager & createRMFromTemplateAndInit(const RelationshipManager &template_rm, MooseMesh &moose_mesh, MeshBase &mesh, const libMesh::DofMap *dof_map=nullptr)
Take an input relationship manager, clone it, and then initialize it with provided mesh and optional ...
const std::string & getLastInputFileName() const
Moose::Builder _builder
Builder for building app related parser tree.
bool _cpu_profiling
CPU profiling.
void dynamicAppRegistration(const std::string &app_name, std::string library_path, const std::string &library_name, bool lib_load_deps)
FEProblemBase & feProblem() const
std::set< std::string > _mfem_devices
MFEM supported devices based on user-provided config.
MooseApp(const InputParameters ¶meters)
Constructor is protected so that this object is constructed through the AppFactory object.
void restore(const std::filesystem::path &folder_base, const bool for_restart)
Restore an application from file.
virtual void preBackup()
Insertion point for other apps that is called before backup()
virtual std::string getInstallableInputs() const
Method to retrieve the installable inputs from a given applications <app>Revision....
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.
RelationshipManager & getRMClone(const RelationshipManager &template_rm, const MeshBase &mesh) const
Return the relationship manager clone originally created from the provided template relationship mana...
std::shared_ptr< Executor > _executor
Pointer to the Executor of this run.
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.
void setExitCode(const int exit_code)
Sets the exit code that the application will exit with.
bool hasRMClone(const RelationshipManager &template_rm, const MeshBase &mesh) const
bool _trap_fpe
Whether or not FPE trapping should be turned on.
void setRecover(bool value)
bool _error_overridden
Indicates whether warnings or errors are displayed when overridden parameters are detected.
std::string getFrameworkVersion() const
Returns the framework version.
const bool _check_input
true if we want to just check the input file
static Moose::Capability & addCapabilityInternal(const std::string_view capability, const Moose::Capability::Value &value, const std::string_view doc)
Internal method for adding a capability.
RestartableDataMap & getRestartableDataMap(const RestartableDataMapName &name)
Return a reference to restartable data for the specific type flag.
void setErrorOverridden()
Set a flag so that the parser will throw an error if overridden parameters are detected.
RestartableDataValue & getRestartableMetaData(const std::string &name, const RestartableDataMapName &metaname, THREAD_ID tid)
bool showInputs() const
Prints a message showing the installable inputs for a given application (if getInstallableInputs has ...
bool isRecovering() const
Whether or not this is a "recover" calculation.
PerfGraph & _perf_graph
The PerfGraph object for this application (recoverable)
virtual void postRestore(const bool)
Insertion point for other apps that is called after restore()
static const std::string MESH_META_DATA_SUFFIX
bool _file_base_set_by_user
Whether or not file base is set through input or setOutputFileBase by MultiApp.
virtual std::string getPrintableName() const
Get printable name of the application.
const std::shared_ptr< Parser > _parser
Parser for parsing the input file (owns the root hit node)
std::string _restart_recover_base
The base name to restart/recover from. If blank then we will find the newest checkpoint file.
RegistrationType
Enumeration for holding the valid types of dynamic registrations allowed.
std::string appNameToLibName(const std::string &app_name) const
Converts an application name to a library name: Examples: AnimalApp -> libanimal-oprof....
bool _split_mesh
Whether or not we are performing a split mesh operation (–split-mesh)
std::list< std::string > getCheckpointFiles() const
Extract all possible checkpoint file names.
int exitCode() const
Get the shell exit code for the application.
virtual void setupOptions()
Setup options based on InputParameters.
static Moose::Capability & addIntCapability(const std::string_view capability, const int value, const std::string_view doc)
Register an integer capability.
std::streambuf * _output_buffer_cache
Cache output buffer so the language server can turn it off then back on.
Syntax _syntax
Syntax of the input file.
bool hasInitialBackup() const
RestartableDataReader _rd_reader
const hit::Node * getCurrentActionHitNode() const
std::optional< MooseEnum > getComputeDevice() const
Get the device accelerated computations are supposed to be running on.
void disableCheckUnusedFlag()
Removes warnings and error checks for unrecognized variables in the input file.
std::string libNameToAppName(const std::string &library_name) const
Converts a library name to an application name:
std::set< std::string > getLoadedLibraryPaths() const
Return the paths of loaded libraries.
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::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...
std::filesystem::path restartFolderBase(const std::filesystem::path &folder_base) const
The file suffix for restartable data.
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 ...
void addExecutorParams(const std::string &type, const std::string &name, const InputParameters ¶ms)
Adds the parameters for an Executor to the list of parameters.
bool copyInputs()
Handles the copy_inputs input parameter logic: Checks to see whether the passed argument is valid (a ...
static Moose::Capability & addStringCapability(const std::string_view capability, const std::string_view value, const std::string_view doc)
Register a string capability.
static const RestartableDataMapName MESH_META_DATA
virtual void runInputFile()
Actually build everything in the input file.
std::string _early_exit_param
Indicates if simulation is ready to exit, and keeps track of which param caused it to exit.
static Moose::Capability & addCapability(const std::string_view capability, const Moose::Capability::Value &value, const std::string_view doc)
Deprecated method for adding a capability.
virtual std::string getVersion() const
Returns the current version of the framework or application (default: framework version).
int _exit_code
The exit code.
InputParameterWarehouse & getInputParameterWarehouse()
Get the InputParameterWarehouse for MooseObjects.
const bool _use_executor
Indicates whether we are operating in the new/experimental executor mode instead of using the legacy ...
Base class for everything in MOOSE with a name and a type.
const InputParameters & parameters() const
Get the parameters of the object.
const std::string & type() const
Get the type of this class.
static InputParameters validParams()
void mooseDeprecated(Args &&... args) const
Emits a deprecation warning prefixed with the object name and type, and a stack trace.
const std::string & name() const
Get the name of the class.
bool isParamSetByUser(const std::string &name) const
Test if the supplied parameter is set by a user, as opposed to not set or set to default.
void mooseError(Args &&... args) const
Emits an error prefixed with object name and type and optionally a file path to the top-level block p...
void mooseWarning(Args &&... args) const
Emits a warning prefixed with object name and type.
const InputParameters & _pars
The object's parameters.
const T & getParam(const std::string &name) const
Retrieve a parameter for the object.
void mooseInfo(Args &&... args) const
bool isParamValid(const std::string &name) const
Test if the supplied parameter is valid.
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type It sho...
MooseMesh wraps a libMesh::Mesh object and enhances its capabilities by caching additional data and s...
MeshBase & getMesh()
Accessor for the underlying libMesh Mesh object.
void prepare()
Calls prepare_for_use() if the underlying MeshBase object isn't prepared, then communicates various b...
const MeshBase * getMeshPtr() const
void allowRemoteElementRemoval(bool allow_removal)
Set whether to allow remote element removal.
InputParameters & getObjectParams()
Retrieve the parameters of the object to be created by this action.
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.
Exception to be thrown whenever we have _throw_on_error set and a mooseError() is emitted.
std::string getPrimaryFileName(bool stripLeadingPath=true) const
Return the primary (first) filename that was parsed.
void build()
Parse an input file (or text string if provided) consisting of hit syntax and setup objects in the MO...
void buildJsonSyntaxTree(JsonSyntaxTree &tree) const
Use MOOSE Factories to construct a parameter tree for documentation or echoing input.
void errorCheck(const libMesh::Parallel::Communicator &comm, bool warn_unused, bool err_unused)
void initSyntaxFormatter(SyntaxFormatterType type, bool dump_mode)
Creates a syntax formatter for printing.
void buildFullTree(const std::string &search_string)
Use MOOSE Factories to construct a full parse tree for documentation or echoing input.
An entry for a single capability.
std::variant< bool, int, std::string > Value
A capability can have a bool, int, or string value.
static Capabilities & getCapabilities(const GetCapabilitiesPassKey)
Get the singleton Capabilities.
Registry of capabilities that checks capability requirements.
const Capability & get(const std::string &capability) const
Get a capability.
Class for storing and utilizing output objects.
void meshChanged()
Calls the meshChanged method for every output object.
void resetFileBase()
Resets the file base for all FileOutput objects.
Class for parsing input files.
Interface for objects interacting with the PerfGraph.
The PerfGraph will hold the master list of all registered performance segments and the head PerfNode.
void setActive(bool active)
Turn on or off timing.
void disableLivePrint()
Completely disables Live Print (cannot be restarted)
static const RegistryEntryBase & objData(const std::string &name)
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.
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.
static bool isRegisteredObj(const std::string &name)
static const std::map< std::string, std::map< std::string, std::string > > & getCitations()
Returns the registered citations, keyed by app/module name and then by BibTeX key (app/module name ->...
static char addKnownLabel(const std::string &label)
addKnownLabel whitelists a label as valid for purposes of the checkLabels function.
RelationshipManagers are used for describing what kinds of non-local resources are needed for an obje...
virtual const std::vector< std::string > & forWhom() const
The object (or Action) this RelationshipManager was built for.
void addForWhom(const std::string &for_whom)
Add another name to for_whom.
void init(MooseMesh &moose_mesh, const MeshBase &mesh, const libMesh::DofMap *dof_map=nullptr)
Called before this RM is attached.
static std::filesystem::path restartableDataFolder(const std::filesystem::path &folder_base)
Storage for restartable data that is ordered based on insertion order.
Reader for restartable data written by the RestartableDataWriter.
void setErrorOnLoadWithDifferentNumberOfProcessors(bool value)
static bool isAvailable(const std::filesystem::path &folder_base)
InputStreams clear()
Clears the contents of the reader (header stream, data stream, header)
void restore(const DataNames &filter_names={})
Restores the restartable data.
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...
Abstract definition of a RestartableData value.
virtual const std::type_info & typeId() const =0
The type ID of the underlying data.
void setDeclared(const SetDeclaredKey)
Sets that this restartable value has been declared.
virtual std::string type() const =0
String identifying the type of parameter stored.
Writer for restartable data, to be read by the RestartableDataReader.
void write(std::ostream &header_stream, std::ostream &data_stream)
Writes the restartable data to header stream header_stream and data stream data_stream.
Concrete definition of a parameter value for a specified type.
A scope guard that guarantees that whatever happens between when it gets created and when it is destr...
The SolutionInvalidity will contain all the information about the occurrence(s) of solution invalidit...
Holding syntax for parsing input files.
const std::multimap< std::string, ActionInfo > & getAssociatedActions() const
Return all Syntax to Action associations.
void registerTaskName(const std::string &task, bool should_auto_build=false)
Method to register a new task.
void addDependency(const std::string &task, const std::string &pre_req)
virtual libMesh::DofMap & dofMap()
Gets writeable reference to the dof map.
GCC9 currently hits a "no type named 'value_type'" error during build if this is removed and iterator...
virtual std::unique_ptr< GhostingFunctor > clone() const=0
const Parallel::Communicator & comm() const
T & set(const std::string &)
const T & get(std::string_view) const
bool tokenizeAndConvert(const std::string &str, std::vector< T > &tokenized_vector, const std::string &delimiter=" \t\n\v\f\r")
tokenizeAndConvert splits a string using delimiter and then converts to type T.
std::string realpath(const std::string &path)
std::filesystem::path pathjoin(const std::filesystem::path &p)
std::string getCurrentWorkingDir()
std::string camelCaseToUnderscore(const std::string &camel_case_name)
void makedirs(const std::string &dir_name, bool throw_on_failure)
std::string installedInputsDir(const std::string &app_name, const std::string &dir_name, const std::string &extra_error_msg)
std::vector< std::string > split(const std::string &str, const std::string &delimiter, std::size_t max_count)
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 ...
std::list< std::string > getFilesInDirs(const std::list< std::string > &directory_list, const bool files_only)
bool pathExists(const std::string &path)
std::string docsDir(const std::string &app_name)
std::string underscoreToCamelCase(const std::string &underscore_name, bool leading_upper_case)
std::string findTestRoot()
bool checkFileReadable(const std::string &filename, bool check_line_endings, bool throw_on_unreadable, bool check_for_git_lfs_pointer)
std::string runTestsExecutable()
PetscErrorCode petscSetupOutput(CommandLine *cmd_line)
void registerPetscCitation(const std::string &bibtex)
Register a BibTeX entry with PETSc's citation list so that it is printed (alongside the run-specific ...
void setSinglePetscOption(const std::string &name, const std::string &value="", FEProblemBase *const problem=nullptr)
A wrapper function for dealing with different versions of PetscOptionsSetValue.
bool _deprecated_is_error
Variable to toggle only deprecated warnings as errors.
bool _throw_on_error
Variable to turn on exceptions during mooseError(), should only be used within MOOSE unit tests or wh...
std::string getExecutableName()
Gets the name of the running executable on Mac OS X and linux.
bool setColorConsole(bool use_color, bool force=false)
Turns color escape sequences on/off for info written to stdout.
void registerAll(Factory &f, ActionFactory &af, Syntax &s)
Register objects that are in MOOSE.
std::string stringify(const T &t)
conversion to string
RelationshipManagerType
Main types of Relationship Managers.
RESTARTABLE_FILTER
The filter type applied to a particular piece of "restartable" data.
bool _warnings_are_errors
Variable to toggle any warning into an error (includes deprecated code warnings)
std::string name(const ElemQuality q)
The following methods are specializations for using the libMesh::Parallel::packed_range_* routines fo...
void libmesh_ignore(const Args &...)
const unsigned int invalid_uint
OStreamProxy err(std::cerr)
void add_command_line_name(const std::string &name)
T command_line_value(const std::string &, T)
Helper class to hold streams for Backup and Restore operations.
std::vector< std::pair< std::string, std::string > > mesh_files
Pairs of checkpoint-relative entry names and binary payloads.