10 #ifdef HAVE_GPERFTOOLS 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>) 78 #include <torch/xpu.h> 79 #define MOOSE_HAVE_XPU 1 85 #include <sys/types.h> 98 "app_to_run",
"--app <type>",
"Specify the application type to run (case-sensitive)");
105 "input_file",
"-i <input file(s)>",
"Specify input file(s); multiple files are merged");
116 params.
addCommandLineParam<
bool>(
"display_version",
"-v --version",
"Print application version");
120 "--mesh-only <optional path>",
122 "Build and output the mesh only (Default: \"<input_file_name>_in.e\")");
125 "--csg-only <optional path>",
127 "Setup and output the input mesh in CSG format only (Default: " 128 "\"<input_file_name>_out_csg.json\")");
130 "show_input",
"--show-input",
"Shows the parsed input file before running the simulation");
133 "show_outputs",
"--show-outputs",
"Shows the output execution time information");
136 "show_controls",
"--show-controls",
"Shows the Control logic available and executed");
140 "no_color",
"--no-color",
"Disable coloring of all Console outputs");
145 "color",
"--color <auto,on,off=on>", colors,
"Whether to use color in console output");
152 "Ignore input file and build a minimal application with Transient executioner");
157 "Starts a process to communicate with development tools using the language server protocol");
159 params.
addCommandLineParam<
bool>(
"dump",
"--dump",
"Shows a dump of available input file syntax");
162 "--dump-search <search>",
163 "Shows a dump of available input syntax matching a search");
164 params.
addCommandLineParam<
bool>(
"registry",
"--registry",
"Lists all known objects and actions");
166 "registry_hit",
"--registry-hit",
"Lists all known objects and actions in hit format");
168 "use_executor",
"--executor",
"Use the new Executor system instead of Executioners");
171 "show_type",
"--show-type",
"Return the name of the application object");
172 params.
addCommandLineParam<
bool>(
"yaml",
"--yaml",
"Dumps all input file syntax in YAML format");
174 "yaml_search",
"--yaml-search",
"Dumps input file syntax matching a search in YAML format");
175 params.
addCommandLineParam<
bool>(
"json",
"--json",
"Dumps all input file syntax in JSON format");
177 "json_search",
"--json-search",
"Dumps input file syntax matching a search in JSON format");
179 "syntax",
"--syntax",
"Dumps the associated Action syntax paths ONLY");
181 "show_docs",
"--docs",
"Print url/path to the documentation website");
183 "show_capabilities",
"--show-capabilities",
"Dumps the capability registry in JSON format.");
185 "required_capabilities",
186 "--required-capabilities",
187 "A list of conditions that is checked against the registered capabilities (see " 188 "--show-capabilities). The executable will terminate early if the conditions are not met.");
190 "testharness_capabilities",
191 "--testharness-capabilities",
192 "Path to JSON from the TestHarness that contains capabilities to be appended.");
195 "check_capabilities",
196 "--check-capabilities",
197 "A list of conditions that is checked against the registered capabilities. Will exit based " 198 "on whether or not the capaiblities are fulfilled. Does not check dynamically loaded apps.");
201 "Check the input file (i.e. requires -i <filename>) and quit");
205 "--show-copyable-inputs",
206 "Shows the directories able to be copied into a user-writable location");
210 "--copy-inputs <dir>",
211 "Copies installed inputs (e.g. tests, examples, etc.) to a directory <appname>_<dir>");
216 "--run <test harness args>",
218 "Runs the inputs in the current directory copied to a " 219 "user-writable location by \"--copy-inputs\"");
222 "list_constructed_objects",
223 "--list-constructed-objects",
224 "List all moose object type names constructed by the master app factory");
228 "--citations [file]",
230 "List the papers (in BibTeX format) that should be cited for the framework, PETSc, and the " 231 "modules and objects used in this simulation; optionally write them to [file] instead of the " 235 "n_threads",
"--n-threads=<n>",
"Runs the specified number of threads per process");
242 "Warn about unused input file options instead of erroring");
245 "error_unused",
"-e --error-unused",
"Error when encountering unused input file options");
249 "-o --error-override",
250 "Error when encountering overridden or parameters supplied multiple times");
253 "error_deprecated",
"--error-deprecated",
"Turn deprecated code messages into Errors");
257 "--distributed-mesh",
258 "Forces the use of a distributed finite element mesh");
265 "--split-mesh <splits>",
266 "Comma-separated list of numbers of chunks to split the mesh into");
270 "split_file",
"--split-file <filename>",
"Name of split mesh file(s) to write/read");
272 params.
addCommandLineParam<
bool>(
"use_split",
"--use-split",
"Use split distributed mesh files");
275 "refinements",
"-r <num refinements>",
"Specify additional initial uniform mesh refinements");
279 "--recover <optional file base>",
281 "Continue the calculation. Without <file base>, the most recent recovery file will be used");
286 "Forcefully load checkpoints despite possible incompatibilities");
292 "Disables the output of the application header.");
296 "test_checkpoint_half_transient",
297 "--test-checkpoint-half-transient",
298 "Run half of a transient with checkpoints enabled; used by the TestHarness");
303 "Test re-running the middle timestep; used by the TestHarness");
308 "Enable floating point exception handling in critical sections of code" 310 " (automatic due to debug build)" 318 "Disable floating point exception handling in critical sections of code" 320 " (unused due to non-debug build)" 327 "no_gdb_backtrace",
"--no-gdb-backtrace",
"Disables gdb backtraces.");
335 "Enable all performance logging for timing; disables screen " 336 "output of performance logs for all Console objects");
339 "no_timing",
"--no-timing",
"Disabled performance logging; overrides -t or --timing");
343 "allow_test_objects",
"--allow-test-objects",
"Register test objects and syntax");
351 "Keep standard output from all processors when running in parallel");
356 "Keep standard output from all processors when running in parallel");
361 "--timpi-sync <type=nbx>",
363 "Changes the sync type used in spare parallel communitations within TIMPI");
368 "--start-in-debugger <debugger>",
369 "Start the application and attach a debugger; this will " 370 "launch xterm windows using <debugger>");
374 "--stop-for-debugger <seconds>",
375 "Pauses the application during startup for <seconds> to allow for connection of debuggers");
378 "perf_graph_live_all",
"--perf-graph-live-all",
"Forces printing of ALL progress messages");
382 "disable_perf_graph_live",
"--disable-perf-graph-live",
"Disables PerfGraph live printing");
386 "automatic_automatic_scaling",
false,
"Whether to turn on automatic scaling by default");
388 const MooseEnum compute_device_type(
"cpu cuda mps hip ceed-cpu ceed-cuda ceed-hip xpu",
"cpu");
393 "The device type we want to run accelerated (libtorch, MFEM) computations on.");
395 #ifdef HAVE_GPERFTOOLS 398 "--gperf-profiler-on <ranks>",
399 "To generate profiling report only on comma-separated list of MPI ranks");
404 "--show-data-params",
406 "Show found paths for all DataFileName parameters in the header");
410 "Show registered data paths for searching in the header");
413 params.
addPrivateParam<std::shared_ptr<Parallel::Communicator>>(
"_comm");
419 params.
addPrivateParam<std::unique_ptr<Backup> *>(
"_initial_backup",
nullptr);
421 #ifdef MOOSE_MFEM_ENABLED 427 "use_legacy_material_output",
429 "Set false to allow material properties to be output on INITIAL, not just TIMESTEP_END.");
431 "use_legacy_initial_residual_evaluation_behavior",
433 "The legacy behavior performs an often times redundant residual evaluation before the " 434 "solution modifying objects are executed prior to the initial (0th nonlinear iteration) " 435 "residual evaluation. The new behavior skips that redundant residual evaluation unless the " 436 "parameter Executioner/use_pre_SMO_residual is set to true.");
441 "Set true to enable data-driven mesh generation, which is an experimental feature");
445 "--parse-neml2-only",
446 "Executes the [NEML2] block to parse the input file and terminate.");
466 _comm(getParam<
std::shared_ptr<
Parallel::Communicator>>(
"_comm")),
467 _file_base_set_by_user(false),
468 _output_position_set(false),
469 _start_time_set(false),
471 _global_time_offset(0.0),
473 _action_factory(*this),
474 _action_warehouse(*this, _syntax, _action_factory),
475 _output_warehouse(*this),
476 _parser(getCheckedPointerParam<
std::shared_ptr<
Parser>>(
"_parser")),
477 _command_line(getCheckedPointerParam<
std::shared_ptr<
CommandLine>>(
"_command_line")),
478 _builder(*this, _action_warehouse, *_parser),
480 _perf_graph(createRecoverablePerfGraph()),
481 _solution_invalidity(createRecoverableSolutionInvalidity()),
482 _rank_map(*_comm, _perf_graph),
483 _use_executor(getParam<bool>(
"use_executor")),
484 _null_executor(NULL),
485 _use_nonlinear(true),
486 _use_eigen_value(false),
487 _enable_unused_check(ERROR_UNUSED),
489 _error_overridden(false),
490 _early_exit_param(
""),
491 _ready_to_exit(false),
493 _initial_from_file(false),
494 _distributed_mesh_on_command_line(false),
498 _use_split(getParam<bool>(
"use_split")),
499 _force_restart(getParam<bool>(
"force_restart")),
505 _test_checkpoint_half_transient(parameters.
get<bool>(
"test_checkpoint_half_transient")),
506 _test_restep(parameters.
get<bool>(
"test_restep")),
507 _check_input(getParam<bool>(
"check_input")),
508 _multiapp_level(isParamValid(
"_multiapp_level") ? getParam<unsigned
int>(
"_multiapp_level")
510 _multiapp_number(isParamValid(
"_multiapp_number") ? getParam<unsigned
int>(
"_multiapp_number")
512 _use_master_mesh(getParam<bool>(
"_use_master_mesh")),
513 _master_mesh(isParamValid(
"_master_mesh") ? getParam<const
MooseMesh *>(
"_master_mesh")
515 _master_displaced_mesh(isParamValid(
"_master_displaced_mesh")
516 ? getParam<const
MooseMesh *>(
"_master_displaced_mesh")
518 _mesh_generator_system(*this),
519 _chain_control_system(*this),
520 _rd_reader(*this, _restartable_data, forceRestart()),
521 _execute_flags(
moose::internal::ExecFlagRegistry::getExecFlagRegistry().getFlags()),
522 _output_buffer_cache(nullptr),
523 _automatic_automatic_scaling(getParam<bool>(
"automatic_automatic_scaling")),
524 _initial_backup(getParam<
std::unique_ptr<
Backup> *>(
"_initial_backup"))
525 #ifdef MOOSE_LIBTORCH_ENABLED
527 _libtorch_device(determineLibtorchDeviceType(getParam<
MooseEnum>(
"compute_device")))
529 #ifdef MOOSE_MFEM_ENABLED
531 _mfem_device(isParamValid(
"_mfem_device")
532 ? getParam<
std::shared_ptr<mfem::Device>>(
"_mfem_device")
534 _mfem_devices(isParamValid(
"_mfem_devices") ? getParam<
std::set<
std::string>>(
"_mfem_devices")
535 :
std::set<
std::string>{})
538 if (¶meters != &_pars)
540 const std::string bad_params =
"(InputParameters parameters)";
541 const std::string good_params =
"(const InputParameters & parameters)";
542 const std::string source_constructor = type() +
"::" + type();
545 " copy-constructs its input parameters.\n\n",
546 "This is deprecated and will not be allowed in the future.\n\n",
567 mooseAssert(_command_line->hasParsed(),
"Command line has not parsed");
568 mooseAssert(_parser->queryRoot(),
"Parser has not parsed");
571 const auto & timpi_sync = getParam<std::string>(
"timpi_sync");
574 #ifdef HAVE_GPERFTOOLS 575 if (isUltimateMaster())
577 bool has_cpu_profiling =
false;
578 bool has_heap_profiling =
false;
579 static std::string cpu_profile_file;
580 static std::string heap_profile_file;
583 if (std::getenv(
"MOOSE_PROFILE_BASE"))
585 has_cpu_profiling =
true;
587 std::getenv(
"MOOSE_PROFILE_BASE") + std::to_string(_comm->rank()) +
".prof";
589 auto name = MooseUtils::splitFileName(cpu_profile_file);
590 if (!
name.first.empty())
592 if (processor_id() == 0)
599 if (std::getenv(
"MOOSE_HEAP_BASE"))
601 has_heap_profiling =
true;
602 heap_profile_file = std::getenv(
"MOOSE_HEAP_BASE") + std::to_string(_comm->rank());
604 auto name = MooseUtils::splitFileName(heap_profile_file);
605 if (!
name.first.empty())
607 if (processor_id() == 0)
614 if (isParamSetByUser(
"gperf_profiler_on"))
616 auto rankstr = getParam<std::string>(
"gperf_profiler_on");
617 std::vector<processor_id_type> ranks;
620 mooseError(
"Invalid argument for --gperf-profiler-on: '", rankstr,
"'");
621 for (
auto & rank : ranks)
623 if (rank >= _comm->size())
624 mooseError(
"Invalid argument for --gperf-profiler-on: ",
626 " is greater than or equal to ",
628 if (rank == _comm->rank())
630 _cpu_profiling = has_cpu_profiling;
631 _heap_profiling = has_heap_profiling;
637 _cpu_profiling = has_cpu_profiling;
638 _heap_profiling = has_heap_profiling;
642 if (!ProfilerStart(cpu_profile_file.c_str()))
643 mooseError(
"CPU profiler is not started properly");
647 HeapProfilerStart(heap_profile_file.c_str());
648 if (!IsHeapProfilerRunning())
649 mooseError(
"Heap profiler is not started properly");
653 if (std::getenv(
"MOOSE_PROFILE_BASE") || std::getenv(
"MOOSE_HEAP_BASE"))
654 mooseError(
"gperftool is not available for CPU or heap profiling");
658 if (isParamValid(
"language_server") && getParam<bool>(
"language_server"))
659 _output_buffer_cache = Moose::out.rdbuf(
nullptr);
664 _the_warehouse = std::make_unique<TheWarehouse>();
667 _the_warehouse->registerAttribute<
AttribExecOns>(
"exec_ons", 0);
670 _the_warehouse->registerAttribute<
AttribThread>(
"thread", 0);
672 _the_warehouse->registerAttribute<
AttribPreIC>(
"pre_ic", 0);
673 _the_warehouse->registerAttribute<
AttribPreAux>(
"pre_aux");
674 _the_warehouse->registerAttribute<
AttribPostAux>(
"post_aux");
675 _the_warehouse->registerAttribute<
AttribName>(
"name",
"dummy");
676 _the_warehouse->registerAttribute<
AttribSystem>(
"system",
"dummy");
677 _the_warehouse->registerAttribute<
AttribVar>(
"variable", -1);
681 _the_warehouse->registerAttribute<
AttribSorted>(
"sorted");
684 _perf_graph.enableLivePrint();
686 if (_check_input && isParamSetByUser(
"recover"))
687 mooseError(
"Cannot run --check-input with --recover. Recover files might not exist");
689 if (isParamSetByUser(
"start_in_debugger") && isUltimateMaster())
691 auto command = getParam<std::string>(
"start_in_debugger");
693 Moose::out <<
"Starting in debugger using: " << command << std::endl;
697 std::stringstream command_stream;
700 command_stream <<
"xterm -e \"echo 'Rank: " << processor_id() <<
" Hostname: " <<
hostname 701 <<
" PID: " << getpid() <<
"'; echo ''; ";
704 if (command.find(
"lldb") != std::string::npos || command.find(
"gdb") != std::string::npos)
705 command_stream << command <<
" -p " << getpid();
709 "\nIf this is truly what you meant then contact moose-users to have a discussion " 710 "about adding your debugger.");
713 command_stream <<
"\"" <<
" & ";
714 std::string command_string = command_stream.str();
715 Moose::out <<
"Running: " << command_string << std::endl;
717 int ret = std::system(command_string.c_str());
721 std::this_thread::sleep_for(std::chrono::seconds(10));
724 if (isParamSetByUser(
"stop_for_debugger") && isUltimateMaster())
726 Moose::out <<
"\nStopping for " << getParam<unsigned int>(
"stop_for_debugger")
727 <<
" seconds to allow attachment from a debugger.\n";
729 Moose::out <<
"\nAll of the processes you can connect to:\n";
730 Moose::out <<
"rank - hostname - pid\n";
737 Moose::err << processor_id() <<
" - " <<
hostname <<
" - " << getpid() <<
"\n";
740 Moose::out <<
"\nWaiting...\n" << std::endl;
743 std::this_thread::sleep_for(std::chrono::seconds(getParam<unsigned int>(
"stop_for_debugger")));
746 if (_master_mesh && isUltimateMaster())
747 mooseError(
"Mesh can be passed in only for sub-apps");
749 if (_master_displaced_mesh && !_master_mesh)
750 mooseError(
"_master_mesh should have been set when _master_displaced_mesh is set");
752 #ifdef MOOSE_MFEM_ENABLED 755 mooseAssert(!isUltimateMaster(),
756 "The MFEM device should only be auto-set for sub-applications");
757 mooseAssert(!_mfem_devices.empty(),
758 "If we are a sub-application and we have an MFEM device object, then we must know " 759 "its configuration string");
769 if (_pars.have_parameter<
bool>(
"use_legacy_dirichlet_bc"))
770 mooseDeprecated(
"The parameter 'use_legacy_dirichlet_bc' is no longer valid.\n\n",
771 "All Dirichlet boundary conditions are preset by default.\n\n",
772 "Remove said parameter in ",
774 " to remove this deprecation warning.");
776 if (_test_restep && _test_checkpoint_half_transient)
777 mooseError(
"Cannot use --test-restep and --test-checkpoint-half-transient together");
779 Moose::out << std::flush;
781 #ifdef MOOSE_KOKKOS_ENABLED 782 #ifdef MOOSE_ENABLE_KOKKOS_GPU 788 std::optional<MooseEnum>
792 return getParam<MooseEnum>(
"compute_device");
798 #ifdef HAVE_GPERFTOOLS 825 #ifdef LIBMESH_HAVE_DLOPEN 828 dlclose(lib_pair.second.library_handle);
831 #ifdef MOOSE_KOKKOS_ENABLED 839 return MOOSE_VERSION;
845 return MOOSE_VERSION;
857 TIME_SECTION(
"setupOptions", 5,
"Setting Up Options");
860 if (
header().length() && !getParam<bool>(
"suppress_header"))
863 if (getParam<bool>(
"error_unused"))
865 else if (getParam<bool>(
"allow_unused"))
868 if (getParam<bool>(
"error_override"))
873 if (getParam<bool>(
"trap_fpe"))
877 if (getParam<bool>(
"no_trap_fpe"))
878 mooseError(
"Cannot use both \"--trap-fpe\" and \"--no-trap-fpe\" flags.");
880 else if (getParam<bool>(
"no_trap_fpe"))
892 auto color = getParam<MooseEnum>(
"color");
896 if (getParam<bool>(
"no_color"))
901 char * c_color = std::getenv(
"MOOSE_COLOR");
903 color.assign(std::string(c_color),
"While assigning environment variable MOOSE_COLOR");
909 else if (color ==
"on")
911 else if (color ==
"off")
914 mooseAssert(
false,
"Should not hit");
917 if (getParam<bool>(
"no_color"))
918 mooseDeprecated(
"The --no-color flag is deprecated. Use '--color off' instead.");
927 #if !LIBMESH_USING_THREADS 929 mooseError(
"You specified --n-threads > 1, but there is no threading model active!");
935 std::optional<std::set<std::string>> ignore_capabilities;
940 "--testharness-capabilities: Should not be specified without --required-capabilities");
942 const auto file_path = std::filesystem::absolute(
943 std::filesystem::path(getParam<std::string>(
"testharness_capabilities")));
945 std::ifstream file(file_path);
947 mooseError(
"--testharness-capabilities: Could not open ", file_path);
953 if (
const auto it = root.find(
"capabilities"); it != root.end())
955 if (
const auto it = root.find(
"ignore_capabilities"); it != root.end())
956 ignore_capabilities = it->
get<std::set<std::string>>();
958 catch (
const std::exception & e)
961 "--testharness-capabilities: Failed to load capabilities ", file_path,
":\n", e.what());
969 const auto & required_capabilities = getParam<std::string>(
"required_capabilities");
971 CapabilityRegistry::CheckOptions options;
973 options.certain =
false;
975 if (ignore_capabilities)
976 options.ignore_capabilities = *ignore_capabilities;
978 CapabilityRegistry::CheckResult result;
984 catch (
const std::exception & e)
986 mooseError(
"--required-capablities: ", e.what());
989 if (result.state < CapabilityRegistry::CheckState::UNKNOWN)
991 mooseInfo(
"Required capabilities '", required_capabilities,
"' not fulfilled.");
997 if (result.state == CapabilityRegistry::CheckState::UNKNOWN)
999 required_capabilities,
1000 "' are not specific enough. A comparison test is performed on an undefined " 1001 "capability. Disambiguate this requirement by adding an existence/non-existence " 1002 "requirement. Example: 'unknown<1.2.3' should become 'unknown & unknown<1.2.3' " 1003 "or '!unknown | unknown<1.2.3'");
1008 if (getParam<bool>(
"minimal"))
1011 else if (getParam<bool>(
"display_version"))
1018 else if (getParam<bool>(
"help"))
1026 const std::string search =
1027 isParamSetByUser(
"dump_search") ? getParam<std::string>(
"dump_search") :
"";
1032 TIME_SECTION(
"dump", 1,
"Building Syntax Tree");
1037 if ((tree.getRoot()).is_object())
1043 Moose::out <<
"\n### START DUMP DATA ###\n" 1044 << formatter.
toString(tree.getRoot()) <<
"\n### END DUMP DATA ###" << std::endl;
1049 mooseError(
"Search parameter '", search,
"' was not found in the registered syntax.");
1051 else if (getParam<bool>(
"registry"))
1055 Moose::out <<
"Label\tType\tName\tClass\tFile\n";
1058 for (
auto & entry : objmap)
1059 for (
auto & obj : entry.second)
1060 Moose::out << entry.first <<
"\tobject\t" << obj->name() <<
"\t" << obj->_classname <<
"\t" 1061 << obj->_file <<
"\n";
1064 for (
auto & entry : actmap)
1066 for (
auto & act : entry.second)
1067 Moose::out << entry.first <<
"\taction\t" << act->_name <<
"\t" << act->_classname <<
"\t" 1068 << act->_file <<
"\n";
1073 else if (getParam<bool>(
"registry_hit"))
1077 Moose::out <<
"### START REGISTRY DATA ###\n";
1079 hit::Section root(
"");
1080 auto sec =
new hit::Section(
"registry");
1082 auto objsec =
new hit::Section(
"objects");
1083 sec->addChild(objsec);
1086 for (
auto & entry : objmap)
1087 for (
auto & obj : entry.second)
1089 auto ent =
new hit::Section(
"entry");
1090 objsec->addChild(ent);
1091 ent->addChild(
new hit::Field(
"label", hit::Field::Kind::String, entry.first));
1092 ent->addChild(
new hit::Field(
"type", hit::Field::Kind::String,
"object"));
1093 ent->addChild(
new hit::Field(
"name", hit::Field::Kind::String, obj->name()));
1094 ent->addChild(
new hit::Field(
"class", hit::Field::Kind::String, obj->_classname));
1095 ent->addChild(
new hit::Field(
"file", hit::Field::Kind::String, obj->_file));
1098 auto actsec =
new hit::Section(
"actions");
1099 sec->addChild(actsec);
1101 for (
auto & entry : actmap)
1102 for (
auto & act : entry.second)
1104 auto ent =
new hit::Section(
"entry");
1105 actsec->addChild(ent);
1106 ent->addChild(
new hit::Field(
"label", hit::Field::Kind::String, entry.first));
1107 ent->addChild(
new hit::Field(
"type", hit::Field::Kind::String,
"action"));
1108 ent->addChild(
new hit::Field(
"task", hit::Field::Kind::String, act->_name));
1109 ent->addChild(
new hit::Field(
"class", hit::Field::Kind::String, act->_classname));
1110 ent->addChild(
new hit::Field(
"file", hit::Field::Kind::String, act->_file));
1113 Moose::out << root.render();
1115 Moose::out <<
"\n### END REGISTRY DATA ###\n";
1121 const std::string search =
1122 isParamSetByUser(
"yaml_search") ? getParam<std::string>(
"yaml_search") :
"";
1133 const std::string search =
1134 isParamSetByUser(
"json_search") ? getParam<std::string>(
"json_search") :
"";
1141 "json",
"**START JSON DATA**\n",
"\n**END JSON DATA**", tree.
getRoot().dump(2));
1145 else if (getParam<bool>(
"syntax"))
1150 std::stringstream ss;
1151 for (
const auto & it :
syntax)
1152 ss << it.first <<
"\n";
1157 else if (getParam<bool>(
"show_type"))
1161 Moose::out <<
"MooseApp Type: " <<
type() << std::endl;
1165 else if (getParam<bool>(
"show_capabilities"))
1169 "**START JSON DATA**\n",
1170 "\n**END JSON DATA**",
1179 const auto & capabilities = getParam<std::string>(
"check_capabilities");
1181 CapabilityRegistry::CheckResult result;
1186 catch (
const std::exception & e)
1188 mooseError(
"--check-capablities: ", e.what());
1191 const bool pass = result.state == CapabilityRegistry::CheckState::CERTAIN_PASS;
1192 _console <<
"Capabilities '" << capabilities <<
"' are " << (pass ?
"" :
"not ") <<
"fulfilled." 1206 const auto & recover = getParam<std::string>(
"recover");
1214 auto isExclusiveParamSetByUser =
1215 [
this](
const std::vector<std::string> & group,
const std::string & param)
1219 for (
const auto & p : group)
1221 mooseError(
"Parameters '" + p +
"' and '" + param +
1222 "' are mutually exclusive. Please choose only one of them.");
1227 const std::vector<std::string> final_task_params = {
1228 "csg_only",
"mesh_only",
"split_mesh",
"parse_neml2_only"};
1229 if (isExclusiveParamSetByUser(final_task_params,
"csg_only"))
1233 mooseError(
"--csg-only cannot be used in conjunction with --distributed-mesh");
1236 mooseError(
"--csg-only is not compatible with any mesh splitting options");
1238 mooseError(
"--csg-only cannot be used in conjunction with -r refinements option");
1240 mooseError(
"--csg-only option cannot be used as a Subapp");
1242 mooseError(
"--csg-only option cannot be used in recovery mode");
1253 else if (isExclusiveParamSetByUser(final_task_params,
"mesh_only"))
1267 else if (isExclusiveParamSetByUser(final_task_params,
"split_mesh"))
1275 else if (isExclusiveParamSetByUser(final_task_params,
"parse_neml2_only"))
1287 mooseAssert(common_actions.size() <= 1,
"Should not be more than one CommonOutputAction");
1288 const Action * common = common_actions.empty() ? nullptr : *common_actions.begin();
1291 if (common && common->isParamValid(
"file_base"))
1301 size_t pos = base.find_last_of(
'.');
1316 mooseError(
"You specified --check-input, but did not provide an input file. Add -i " 1317 "<inputfile> to your command line.");
1319 mooseError(
"No input files specified. Add -i <inputfile> to your command line.");
1321 else if (
isParamValid(
"language_server") && getParam<bool>(
"language_server"))
1346 Moose::out << std::flush;
1349 const std::vector<std::string> &
1352 mooseAssert(
_parser,
"Parser is not set");
1353 return _parser->getInputFileNames();
1359 mooseAssert(
_parser,
"Parser is not set");
1360 return _parser->getLastInputFileName();
1382 for (
auto & multi_app :
feProblem().getMultiAppWarehouse().getObjects())
1383 multi_app->setAppOutputFileBase();
1391 TIME_SECTION(
"runInputFile", 3);
1419 else if (getParam<bool>(
"list_constructed_objects"))
1424 std::stringstream ss;
1425 for (
const auto & obj :
_factory.getConstructedObjects())
1428 "list_constructed_objects",
"**START OBJECT DATA**\n",
"\n**END OBJECT DATA**", ss.str());
1450 "Something went wrong, we should only get here if _check_input is true.");
1452 "Incompatible command line arguments provided. --check-input cannot be called with ",
1457 mooseError(
"The Executor is being called without being initialized. This is likely " 1459 "incompatible command line arguments");
1463 for (
auto app : apps)
1464 for (
unsigned int i = 0; i < app->numLocalApps(); i++)
1465 app->localApp(i)->errorCheck();
1471 TIME_SECTION(
"executeExecutioner", 3);
1484 if (!result.convergedAll())
1497 mooseError(
"No executioner was specified (go fix your input file)");
1528 "MooseApp::hasRestartRecoverFileBase() instead.");
1539 case RESTARTABLE_FILTER::RECOVERABLE:
1547 std::vector<std::filesystem::path>
1550 TIME_SECTION(
"backup", 2,
"Backing Up Application to File");
1555 return writer.
write(folder_base);
1558 std::unique_ptr<Backup>
1561 TIME_SECTION(
"backup", 2,
"Backing Up Application");
1567 auto backup = std::make_unique<Backup>();
1576 TIME_SECTION(
"restore", 2,
"Restoring Application from File");
1589 TIME_SECTION(
"restore", 2,
"Restoring Application");
1594 mooseError(
"MooseApp::restore(): Provided backup is not initialized");
1597 mooseAssert(
header,
"Header not available");
1599 auto data = std::move(
backup->data);
1600 mooseAssert(data,
"Data not available");
1615 std::unique_ptr<Backup>
1619 mooseError(
"MooseApp::finalizeRestore(): Not currently restoring");
1624 std::unique_ptr<Backup>
backup;
1628 if (
auto header_string_input = dynamic_cast<StringInputStream *>(input_streams.header.get()))
1630 auto data_string_input =
dynamic_cast<StringInputStream *
>(input_streams.data.get());
1631 mooseAssert(data_string_input,
"Should also be a string input");
1633 auto header_sstream = header_string_input->release();
1634 mooseAssert(header_sstream,
"Header not available");
1636 auto data_sstream = data_string_input->release();
1637 mooseAssert(data_sstream,
"Data not available");
1639 backup = std::make_unique<Backup>();
1640 backup->header = std::move(header_sstream);
1641 backup->data = std::move(data_sstream);
1668 const std::string & name,
1674 mooseError(
"an executor with name '", executor->name(),
"' already exists");
1680 const std::string & name,
1689 mooseAssert(
_parser,
"Not set");
1696 return const_cast<Parser &
>(std::as_const(*this).parser());
1701 std::list<std::string> & possible_roots,
1702 std::list<std::string> & current_branch)
1709 if (
std::find(current_branch.begin(), current_branch.end(), current_executor_name) !=
1710 current_branch.end())
1712 std::stringstream exec_names_string;
1714 auto branch_it = current_branch.begin();
1716 exec_names_string << *branch_it++;
1718 for (; branch_it != current_branch.end(); ++branch_it)
1719 exec_names_string <<
", " << *branch_it;
1721 exec_names_string <<
", " << current_executor_name;
1723 mooseError(
"Executor cycle detected: ", exec_names_string.str());
1726 current_branch.push_back(current_executor_name);
1731 for (
const auto & param : params)
1733 if (params.have_parameter<ExecutorName>(param.first))
1735 const auto & dependency_name = params.get<ExecutorName>(param.first);
1737 possible_roots.remove(dependency_name);
1739 if (!dependency_name.empty())
1748 current_branch.pop_back();
1759 std::list<std::string> possibly_root;
1762 std::map<std::string, bool> already_built;
1765 std::list<std::string> possible_roots;
1768 std::list<std::string> current_branch;
1772 auto params =
_factory.getValidParams(
"NullExecutor");
1778 const auto &
name = params_entry.first;
1784 possible_roots.emplace_back(
name);
1790 if (possible_roots.size() > 1)
1792 auto root_string_it = possible_roots.begin();
1794 std::stringstream roots_string;
1796 roots_string << *root_string_it++;
1798 for (; root_string_it != possible_roots.end(); ++root_string_it)
1799 roots_string <<
", " << *root_string_it;
1801 mooseError(
"Multiple Executor roots found: ", roots_string.str());
1816 if (fail_if_not_found)
1837 TIME_SECTION(
"run", 3);
1838 if (getParam<bool>(
"show_docs"))
1842 mooseError(
"could not locate installed tests to run (unresolved binary/app name)");
1845 mooseError(
"no installed documentation found");
1851 std::ifstream ifs(docmsgfile);
1852 std::string content((std::istreambuf_iterator<char>(ifs)),
1853 (std::istreambuf_iterator<char>()));
1854 content.replace(content.find(
"$LOCAL_SITE_HOME"), content.length(), docmsg);
1858 Moose::out << docmsg <<
"\n";
1873 TIME_SECTION(
"setup", 2,
"Setting Up");
1879 mooseAssert(
_parser->getThrowOnError(),
"Should be true");
1887 catch (std::exception &
err)
1894 TIME_SECTION(
"execute", 2,
"Executing");
1901 Moose::err <<
"Syntax OK" << std::endl;
1915 std::map<std::string, std::string> citations;
1916 for (
const auto & objname :
_factory.getConstructedObjects())
1919 "Constructed object '" + objname +
"' is not registered");
1921 citations.insert(app_citations.begin(), app_citations.end());
1927 for (
const auto & citation : citations)
1936 if (getParam<bool>(
"show_inputs"))
1939 std::vector<std::string> dirs;
1942 if (installable_inputs ==
"")
1945 <<
"Show inputs has not been overriden in this application.\nContact the developers of " 1946 "this appication and request that they override \"MooseApp::getInstallableInputs\".\n";
1950 mooseAssert(!show_inputs_syntax.empty(),
"show_inputs sytnax should not be empty");
1953 Moose::out <<
"The following directories are installable into a user-writeable directory:\n\n" 1954 << installable_inputs <<
'\n' 1955 <<
"\nTo install one or more directories of inputs, execute the binary with the \"" 1956 << show_inputs_syntax[0] <<
"\" flag. e.g.:\n$ " 1957 <<
_command_line->getExecutableName() <<
' ' << show_inputs_syntax[0] <<
' ' 1976 if (
comm().size() > 1)
1977 mooseError(
"The --copy-inputs option should not be ran in parallel");
1980 auto dir_to_copy = getParam<std::string>(
"copy_inputs");
1982 if (dir_to_copy.empty())
1983 mooseError(
"Error retrieving directory to copy");
1984 if (dir_to_copy.back() !=
'/')
1991 mooseError(
"could not locate installed tests to run (unresolved binary/app name)");
1997 " to get a list of installable directories.");
2001 auto dst_dir =
_command_line->getExecutableNameBase() +
"/" + dir_to_copy;
2003 if (cmdname.find_first_of(
"/") != std::string::npos)
2004 cmdname = cmdname.substr(cmdname.find_first_of(
"/") + 1, std::string::npos);
2008 "The directory \"./",
2010 "\" already exists.\nTo update/recopy the contents of this directory, rename (\"mv ",
2012 " new_dir_name\") or remove (\"rm -r ",
2014 "\") the existing directory.\nThen re-run \"",
2020 std::string cmd =
"mkdir -p " + dst_dir +
"; rsync -av " + src_dir +
" " + dst_dir;
2022 TIME_SECTION(
"copy_inputs", 2,
"Copying Inputs");
2024 mooseAssert(
comm().size() == 1,
"Should be run in serial");
2025 const auto return_value = system(cmd.c_str());
2026 if (!WIFEXITED(return_value))
2030 Moose::out <<
"Directory successfully copied into ./" << dst_dir <<
'\n';
2041 if (
comm().size() > 1)
2042 mooseError(
"The --run option should not be ran in parallel");
2045 const auto find_run_it = std::as_const(*_command_line).findCommandLineParam(
"run");
2046 const auto & cl_entries = std::as_const(*_command_line).getEntries();
2047 mooseAssert(find_run_it != cl_entries.end(),
"Didn't find the option");
2048 std::string test_args;
2049 for (
auto it = std::next(find_run_it); it != cl_entries.end(); ++it)
2050 for (
const auto & arg : it->raw_args)
2052 test_args +=
" " + arg;
2061 mooseError(
"Could not locate binary name relative to installed location");
2065 "Could not locate installed tests from the current working directory:",
2067 ".\nMake sure you are executing this command from within a writable installed inputs ",
2068 "directory.\nRun \"",
2070 " --copy-inputs <dir>\" to copy the contents of <dir> to a \"./",
2072 "_<dir>\" directory.\nChange into that directory and try \"",
2074 " --run <dir>\" again.");
2078 setenv(
"MOOSE_TEST_RUNNER_APP_NAME",
appBinaryName().c_str(),
true);
2081 Moose::out <<
"Working Directory: " << working_dir <<
"\nRunning Command: " << cmd << std::endl;
2082 mooseAssert(
comm().size() == 1,
"Should be run in serial");
2083 const auto return_value = system(cmd.c_str());
2084 if (!WIFEXITED(return_value))
2096 const std::string_view doc)
2102 catch (
const std::exception & e)
2119 std::list<std::string>
2123 std::list<std::string> checkpoint_dirs;
2130 for (
const auto & action : actions)
2134 if (!moose_object_action)
2138 if (moose_object_action->
getParam<std::string>(
"type") ==
"Checkpoint")
2142 const std::string cp_dir =
2145 checkpoint_dirs.push_back(cp_dir +
"_cp");
2148 return checkpoint_dirs;
2151 std::list<std::string>
2186 std::string library_name(app_name);
2189 size_t pos = library_name.find(
"App");
2190 if (pos != library_name.length() - 3)
2191 mooseError(
"Invalid application name: ", library_name);
2192 library_name.erase(pos);
2196 QUOTE(METHOD) +
".la";
2202 std::string app_name(library_name);
2205 if (pcrecpp::RE(
"lib(.+?)(?:-\\w+)?\\.la").Replace(
"\\1", &app_name) == 0)
2206 mooseError(
"Invalid library name: ", app_name);
2217 if (!metaname.empty() && tid != 0)
2219 "The meta data storage for '", metaname,
"' is not threaded, so the tid must be zero.");
2221 mooseAssert(metaname.empty() ||
2223 "The desired meta data name does not exist: " + metaname);
2232 if (data->typeId() != stored_data->
typeId())
2233 mooseError(
"Type mismatch found in RestartableData registration of '",
2235 "'\n\n Stored type: ",
2236 stored_data->
type(),
2241 stored_data = &data_map.addData(std::move(data));
2246 return *stored_data;
2251 std::unique_ptr<RestartableDataValue> data,
2256 mooseDeprecated(
"The use of MooseApp::registerRestartableData with a data name is " 2257 "deprecated.\n\nUse the call without a name instead.");
2259 mooseAssert(
name == data->name(),
"Inconsistent name");
2270 return it->second.first.hasData(
name);
2280 "The meta data storage for '", metaname,
"' is not threaded, so the tid must be zero.");
2286 mooseError(
"Unable to find RestartableDataValue object with name " +
name +
2287 " in RestartableDataMap");
2294 const std::filesystem::path & folder_base)
2302 reader.
setInput(meta_data_folder_base);
2314 std::vector<std::filesystem::path>
2316 const std::filesystem::path & folder_base)
2319 mooseError(
"MooseApp::writeRestartableMetaData(): Should only run on processor 0");
2325 return writer.
write(meta_data_folder_base);
2328 std::vector<std::filesystem::path>
2331 std::vector<std::filesystem::path> paths;
2337 paths.insert(paths.end(), map_paths.begin(), map_paths.end());
2345 std::string library_path,
2346 const std::string & library_name,
2349 #ifdef LIBMESH_HAVE_DLOPEN 2351 params.
set<std::string>(
"app_name") = app_name;
2353 params.
set<std::string>(
"registration_method") = app_name +
"__registerApps";
2354 params.
set<std::string>(
"library_path") = library_path;
2356 const auto effective_library_name =
2358 params.
set<std::string>(
"library_name") = effective_library_name;
2359 params.
set<
bool>(
"library_load_dependencies") = lib_load_deps;
2362 std::ostringstream oss;
2364 auto successfully_loaded =
false;
2366 oss <<
'"' << app_name <<
"\" is not a registered application name.\n" 2367 <<
"No search paths were set. We made no attempts to locate the corresponding library " 2376 oss <<
'"' << app_name <<
"\" is not a registered application name.\n" 2377 <<
"Unable to locate library archive for \"" << app_name
2378 <<
"\".\nWe attempted to locate the library archive \"" << effective_library_name
2379 <<
"\" in the following paths:\n\t";
2380 std::copy(paths.begin(), paths.end(), infix_ostream_iterator<std::string>(oss,
"\n\t"));
2383 successfully_loaded =
true;
2386 if (!successfully_loaded)
2388 oss <<
"\nMake sure you have compiled the library and either set the \"library_path\" " 2389 "variable in your input file or exported \"MOOSE_LIBRARY_PATH\".\n";
2395 libmesh_ignore(app_name, library_path, library_name, lib_load_deps);
2396 mooseError(
"Dynamic Loading is either not supported or was not detected by libMesh configure.");
2405 std::string library_path,
2406 const std::string & library_name)
2408 #ifdef LIBMESH_HAVE_DLOPEN 2410 params.
set<std::string>(
"app_name") = app_name;
2412 params.
set<std::string>(
"registration_method") = app_name +
"__registerAll";
2413 params.
set<std::string>(
"library_path") = library_path;
2414 params.
set<std::string>(
"library_name") =
2420 params.
set<
bool>(
"library_load_dependencies") =
false;
2425 mooseError(
"Dynamic Loading is either not supported or was not detected by libMesh configure.");
2433 const auto library_name = params.
get<std::string>(
"library_name");
2436 for (
const auto & path : paths)
2439 path +
'/' + library_name, params, params.
get<
bool>(
"library_load_dependencies"));
2445 const bool load_dependencies)
2448 std::string dl_lib_filename;
2452 pcrecpp::RE re_deps(
"(/\\S*\\.la)");
2454 std::ifstream la_handle(library_filename.c_str());
2455 if (la_handle.is_open())
2457 while (std::getline(la_handle, line))
2460 if (line.find(
"dlname=") != std::string::npos)
2463 dl_lib_filename = line.substr(8, line.size() - 9);
2465 if (line.find(
"dependency_libs=") != std::string::npos)
2467 if (load_dependencies)
2469 pcrecpp::StringPiece input(line);
2470 pcrecpp::StringPiece depend_library;
2471 while (re_deps.FindAndConsume(&input, &depend_library))
2485 if (dl_lib_filename.empty())
2488 const auto & [dir, file_name] = MooseUtils::splitFileName(library_filename);
2504 #ifdef LIBMESH_HAVE_DLOPEN 2505 void *
const lib_handle = dlopen(dl_lib_full_path.c_str(), RTLD_LAZY);
2507 void *
const lib_handle =
nullptr;
2513 "\" exists and has proper permissions, but cannot by dynamically loaded.\nThis " 2514 "generally means that the loader was unable to load one or more of the " 2515 "dependencies listed in the supplied library (see otool or ldd).\n",
2522 auto insert_ret =
_lib_handles.insert(std::make_pair(file_name, lib_info));
2523 mooseAssert(insert_ret.second ==
true,
"Error inserting into lib_handles map");
2525 dyn_lib_it = insert_ret.first;
2529 const auto registration_method = params.
get<std::string>(
"registration_method");
2530 auto & entry_sym_from_curr_lib = dyn_lib_it->second.entry_symbols;
2532 if (entry_sym_from_curr_lib.find(registration_method) == entry_sym_from_curr_lib.end())
2538 #ifdef LIBMESH_HAVE_DLOPEN 2539 void * registration_handle =
2540 dlsym(dyn_lib_it->second.library_handle, registration_method.c_str());
2542 void * registration_handle =
nullptr;
2545 if (registration_handle)
2551 using register_app_t =
void (*)();
2552 register_app_t *
const reg_ptr =
reinterpret_cast<register_app_t *
>(®istration_handle);
2559 register_app_t *
const reg_ptr =
reinterpret_cast<register_app_t *
>(®istration_handle);
2569 entry_sym_from_curr_lib.insert(registration_method);
2574 #if defined(DEBUG) && defined(LIBMESH_HAVE_DLOPEN) 2578 if (!registration_handle)
2580 registration_method,
2584 "This doesn't necessarily indicate an error condition unless you believe that " 2585 "the method should exist in that library.\n",
2592 std::set<std::string>
2596 std::set<std::string> paths;
2598 paths.insert(it.first);
2603 std::set<std::string>
2606 std::set<std::string> paths;
2608 if (!library_path.empty())
2610 std::vector<std::string> tmp_paths;
2613 paths.insert(tmp_paths.begin(), tmp_paths.end());
2616 char * moose_lib_path_env = std::getenv(
"MOOSE_LIBRARY_PATH");
2617 if (moose_lib_path_env)
2619 std::string moose_lib_path(moose_lib_path_env);
2620 std::vector<std::string> tmp_paths;
2623 paths.insert(tmp_paths.begin(), tmp_paths.end());
2638 return std::string(
"");
2656 TIME_SECTION(
"createMinimalApp", 3,
"Creating Minimal App");
2662 action_params.
set<std::string>(
"type") =
"GeneratedMesh";
2665 std::shared_ptr<MooseObjectAction> action = std::static_pointer_cast<
MooseObjectAction>(
2671 params.set<
unsigned int>(
"nx") = 1;
2681 action_params.
set<std::string>(
"type") =
"Transient";
2684 std::shared_ptr<MooseObjectAction> action = std::static_pointer_cast<
MooseObjectAction>(
2689 params.
set<
unsigned int>(
"num_steps") = 1;
2690 params.set<
Real>(
"dt") = 1;
2700 action_params.
set<
bool>(
"_solve") =
false;
2703 std::shared_ptr<Action> action = std::static_pointer_cast<
Action>(
2714 action_params.
set<
bool>(
"console") =
false;
2717 std::shared_ptr<Action> action =
2732 [&
name](
const std::shared_ptr<RelationshipManager> & rm)
2741 auto & existing_for_whom = acceptor.
forWhom();
2744 for (
auto & fw : donor.
forWhom())
2746 if (
std::find(existing_for_whom.begin(), existing_for_whom.end(), fw) ==
2747 existing_for_whom.end())
2771 std::set<std::shared_ptr<RelationshipManager>> rms_to_erase;
2775 if (*existing_rm >= *new_rm)
2778 donateForWhom(*new_rm, *existing_rm);
2783 else if (*new_rm >= *existing_rm)
2784 rms_to_erase.emplace(existing_rm);
2790 for (
const auto & rm_to_erase : rms_to_erase)
2792 donateForWhom(*rm_to_erase, *new_rm);
2804 static const std::string suffix =
"-mesh.cpa.gz";
2808 std::filesystem::path
2810 const std::string & map_suffix)
2813 std::filesystem::path(
"meta_data" + map_suffix));
2816 std::filesystem::path
2819 auto folder = folder_base;
2820 folder +=
"-restart-" + std::to_string(
processor_id());
2828 return action->parameters().getHitNode();
2845 mooseError(
"The template rm does not exist in our _template_to_clones map");
2847 auto & mesh_to_clone_map = outer_it->second;
2848 auto inner_it = mesh_to_clone_map.find(&
mesh);
2849 if (inner_it == mesh_to_clone_map.end())
2850 mooseError(
"We should have the mesh key in our mesh");
2852 return *inner_it->second;
2862 const MeshBase *
const undisp_lm_mesh =
mesh->getMeshPtr();
2864 if (undisp_lm_mesh &&
hasRMClone(*rm, *undisp_lm_mesh))
2866 undisp_clone = &
getRMClone(*rm, *undisp_lm_mesh);
2867 const_cast<MeshBase *
>(undisp_lm_mesh)->remove_ghosting_functor(*undisp_clone);
2871 MeshBase *
const disp_lm_mesh = displaced_mesh ? &displaced_mesh->getMesh() :
nullptr;
2873 if (disp_lm_mesh &&
hasRMClone(*rm, *disp_lm_mesh))
2875 disp_clone = &
getRMClone(*rm, *disp_lm_mesh);
2884 problem.removeAlgebraicGhostingFunctor(*undisp_clone);
2885 problem.removeCouplingGhostingFunctor(*undisp_clone);
2888 auto * dp = problem.getDisplacedProblem().get();
2889 if (dp && disp_clone)
2890 dp->removeAlgebraicGhostingFunctor(*disp_clone);
2893 _factory.releaseSharedObjects(*rm);
2901 const DofMap *
const dof_map)
2904 auto it = mesh_to_clone.find(&
mesh);
2905 if (it != mesh_to_clone.end())
2908 auto & clone_rm = *it->second;
2909 if (!clone_rm.dofMap() && dof_map)
2911 clone_rm.init(moose_mesh,
mesh, dof_map);
2912 else if (clone_rm.dofMap() && dof_map && (clone_rm.dofMap() != dof_map))
2913 mooseError(
"Attempting to create and initialize an existing clone with a different DofMap. " 2914 "This should not happen.");
2924 auto pr = mesh_to_clone.emplace(
2925 std::make_pair(&const_cast<const MeshBase &>(
mesh),
2926 dynamic_pointer_cast<RelationshipManager>(template_rm.
clone())));
2927 mooseAssert(pr.second,
"An insertion should have happened");
2928 auto & clone_rm = *pr.first->second;
2929 clone_rm.init(moose_mesh,
mesh, dof_map);
2940 if (rm->attachGeometricEarly())
2953 if (moose_mesh_base != &mesh)
2954 mooseError(
"The MooseMesh MeshBase and the MeshBase we're trying to attach " 2955 "relationship managers to are different");
2968 bool attach_geometric_rm_final)
2972 if (!rm->isType(rm_type))
2986 if (!rm->attachGeometricEarly() && !attach_geometric_rm_final)
2989 mesh->allowRemoteElementRemoval(
false);
2993 const DofMap *
const undisp_sys_dof_map =
3001 attach_geometric_rm_final && disp_moose_mesh)
3004 const DofMap * disp_sys_dof_map =
nullptr;
3011 mooseError(
"The displaced mesh should not yet exist at the time that we are attaching " 3012 "early geometric relationship managers.");
3022 mooseError(
"We must have an executioner by now or else we do not have to data to add " 3023 "algebraic or coupling functors to in MooseApp::attachRelationshipManagers");
3027 auto & undisp_moose_mesh = problem.mesh();
3029 auto & undisp_sys_dof_map = undisp_sys.
dofMap();
3030 auto & undisp_mesh = undisp_moose_mesh.getMesh();
3032 if (rm->useDisplacedMesh() && problem.getDisplacedProblem())
3046 problem.addCouplingGhostingFunctor(
3054 auto & disp_mesh = disp_moose_mesh.getMesh();
3064 problem.addCouplingGhostingFunctor(
3069 problem.addAlgebraicGhostingFunctor(
3081 std::vector<std::pair<std::string, std::string>>
3084 std::vector<std::pair<std::string, std::string>> info_strings;
3089 std::stringstream oss;
3090 oss << rm->getInfo();
3092 auto & for_whom = rm->forWhom();
3094 if (!for_whom.empty())
3098 std::copy(for_whom.begin(), for_whom.end(), infix_ostream_iterator<std::string>(oss,
", "));
3101 info_strings.emplace_back(std::make_pair(
Moose::stringify(rm->getType()), oss.str()));
3112 std::map<std::string, unsigned int> counts;
3120 counts[
demangle(
typeid(*gf).name())]++;
3123 for (
const auto & pair : counts)
3124 info_strings.emplace_back(std::make_pair(
3125 "Default", pair.first + (pair.second > 1 ?
" x " + std::to_string(pair.second) :
"")));
3136 std::map<std::string, unsigned int> counts;
3138 for (
auto & gf :
as_range(d_mesh->getMesh().ghosting_functors_begin(),
3139 d_mesh->getMesh().ghosting_functors_end()))
3144 counts[
demangle(
typeid(*gf).name())]++;
3147 for (
const auto & pair : counts)
3148 info_strings.emplace_back(
3149 std::make_pair(
"Default",
3150 pair.first + (pair.second > 1 ?
" x " + std::to_string(pair.second) :
"") +
3151 " for DisplacedMesh"));
3154 return info_strings;
3166 std::vector<std::string> not_declared;
3168 for (
const auto & data : meta_data)
3169 if (!data.declared())
3170 not_declared.push_back(data.name());
3172 if (!not_declared.empty())
3174 std::ostringstream oss;
3176 not_declared.begin(), not_declared.end(), infix_ostream_iterator<std::string>(oss,
", "));
3180 "' meta-data properties were retrieved but never declared: ",
3194 mooseError(
"Unable to find RestartableDataMap object for the supplied name '",
3196 "', did you call registerRestartableDataMapName in the application constructor?");
3197 return iter->second.first;
3209 if (!suffix.empty())
3210 std::transform(suffix.begin(), suffix.end(), suffix.begin(), ::tolower);
3211 suffix.insert(0,
"_");
3221 mooseError(
"MooseApp::getRestartableDataMapName: The name '",
name,
"' is not registered");
3222 return it->second.second;
3231 std::make_unique<RestartableData<PerfGraph>>(
"perf_graph",
3235 getParam<bool>(
"perf_graph_live_all"),
3236 !getParam<bool>(
"disable_perf_graph_live"));
3248 auto solution_invalidity =
3249 std::make_unique<RestartableData<SolutionInvalidity>>(
"solution_invalidity",
nullptr, *
this);
3263 #ifdef MOOSE_LIBTORCH_ENABLED 3267 const auto pname =
"--compute-device";
3268 if (device_enum ==
"cuda")
3271 if (!torch::cuda::is_available())
3272 mooseError(pname,
"=cuda: CUDA support is not available in the linked libtorch library");
3273 return torch::kCUDA;
3275 mooseError(pname,
"=cuda: CUDA is not supported on your platform");
3278 else if (device_enum ==
"mps")
3281 if (!torch::mps::is_available())
3282 mooseError(pname,
"=mps: MPS support is not available in the linked libtorch library");
3285 mooseError(pname,
"=mps: MPS is not supported on your platform");
3288 else if (device_enum ==
"xpu")
3290 #ifdef MOOSE_HAVE_XPU 3291 if (!torch::xpu::is_available())
3292 mooseError(pname,
"=xpu: XPU support is not available in the linked libtorch library");
3295 mooseError(pname,
"=xpu: XPU is not supported in the current application");
3298 else if (device_enum !=
"cpu")
3301 "' is not currently supported by the MOOSE libtorch integration.");
3308 const std::string & start_marker,
3309 const std::string & end_marker,
3310 const std::string & data)
const 3315 Moose::out << start_marker << data << end_marker << std::endl;
3320 const auto & filename = getParam<std::string>(param);
3322 std::ofstream
out(filename.c_str());
3325 std::ofstream
out(filename.c_str());
3326 out << data << std::flush;
3330 mooseError(
"Unable to open file `", filename,
"` for writing ", param,
" data to it.");
3336 const std::string_view doc)
3344 const std::string_view doc)
3351 const std::string_view value,
3352 const std::string_view doc)
3360 const std::string_view doc)
3367 ::mooseDeprecated(
"MooseApp::addCapability() is deprecated (adding capability '",
3369 "'); use one of MooseApp::add[Bool,Int,String]Capability instead.");
3386 #ifdef MOOSE_MFEM_ENABLED 3393 auto string_set = std::set<std::string>(string_vec.begin(), string_vec.end());
3396 _mfem_device = std::make_shared<mfem::Device>(device_string);
3398 _mfem_device->SetGPUAwareMPI(mfem::GetEnv(
"MFEM_GPU_AWARE_MPI") ?
true : gpu_aware_mpi);
3401 else if (!device_string.empty() && string_set !=
_mfem_devices)
3404 MooseUtils::join(string_set,
" "),
3405 "', but we have already " 3406 "configured the MFEM device " 3407 "object with the devices '",
void makedirs(const std::string &dir_name, bool throw_on_failure)
std::string name(const ElemQuality q)
GhostingFunctorIterator ghosting_functors_begin() const
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.
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...
void mooseInfo(Args &&... args) const
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 ->...
std::string docsDir(const std::string &app_name)
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.
static bool isRelocated()
PerfGraph & _perf_graph
The PerfGraph object for this application (recoverable)
void setOutputPosition(const Point &p)
Tell the app to output in a specific position.
KOKKOS_INLINE_FUNCTION const T * find(const T &target, const T *const begin, const T *const end)
Find a value in an array.
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> ...
static const RegistryEntryBase & objData(const std::string &name)
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)
const InputParameters & _pars
The object's parameters.
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 dynamicRegistration(const libMesh::Parameters ¶ms)
Helper method for dynamic loading of objects.
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::shared_ptr< DisplacedProblem > displaced_problem
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 (owns the root hit node)
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.
const T & getParam(const std::string &name) const
Retrieve a parameter for the object.
bool hasRMClone(const RelationshipManager &template_rm, const MeshBase &mesh) const
torch::DeviceType determineLibtorchDeviceType(const MooseEnum &device) const
Function to determine the device which should be used by libtorch on this application.
bool _file_base_set_by_user
Whether or not file base is set through input or setOutputFileBase by MultiApp.
const Capability & get(const std::string &capability) const
Get a capability.
const Action * getCurrentAction() const
bool _output_position_set
Whether or not an output position has been set for this app.
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...
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)
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 registerTaskName(const std::string &task, bool should_auto_build=false)
Method to register a new task.
static Capabilities & getCapabilities(const GetCapabilitiesPassKey)
Get the singleton Capabilities.
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.
virtual std::unique_ptr< GhostingFunctor > clone() const=0
virtual std::string appBinaryName() const
const InputParameters & parameters() const
Get the parameters of the object.
const std::shared_ptr< MooseMesh > & getMesh() const
std::string getOutputFileBase(bool for_non_moose_build_output=false) const
Get the output file base name.
static void addInputParam(InputParameters ¶ms)
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 deallocateKokkosMemoryPool()
Deallocate Kokkos memory pool.
bool runInputs()
Handles the run input parameter logic: Checks to see whether a directory exists in user space and lau...
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.
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.
bool forceRestart() const
Whether or not we are forcefully restarting (allowing the load of potentially incompatibie checkpoint...
std::filesystem::path restartFolderBase(const std::filesystem::path &folder_base) const
The file suffix for restartable data.
const bool _use_split
Whether or not we are using a (pre-)split mesh (automatically DistributedMesh)
void remove_ghosting_functor(GhostingFunctor &ghosting_functor)
void registerPetscCitation(const std::string &bibtex)
Register a BibTeX entry with PETSc's citation list so that it is printed (alongside the run-specific ...
bool hasRelationshipManager(const std::string &name) const
Returns a Boolean indicating whether a RelationshipManater exists with the same name.
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
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.
bool hasRestartableDataMap(const RestartableDataMapName &name) const
void addActionBlock(std::shared_ptr< Action > blk)
This method add an Action instance to the warehouse.
std::set< std::string > _mfem_devices
MFEM supported devices based on user-provided config.
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.
int exitCode() const
Get the shell exit code for the application.
GhostingFunctorIterator ghosting_functors_end() const
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.
std::string installedInputsDir(const std::string &app_name, const std::string &dir_name, const std::string &extra_error_msg)
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)
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.
Holds the syntax in a Json::Value tree.
Specialization of SubProblem for solving nonlinear equations plus auxiliary equations.
FEProblemBase & feProblem() const
std::shared_ptr< Action > create(const std::string &action, const std::string &action_name, InputParameters ¶meters)
MooseApp(const InputParameters ¶meters)
Constructor is protected so that this object is constructed through the AppFactory object...
std::optional< MooseEnum > getComputeDevice() const
Get the device accelerated computations are supposed to be running on.
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)
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 ...
void setOutputFileBase(const std::string &output_file_base)
Override the selection of the output file base name.
This class wraps provides and tracks access to command line parameters.
int _exit_code
The exit code.
Storage for restartable data that is ordered based on insertion order.
std::shared_ptr< MooseMesh > & mesh()
std::variant< bool, int, std::string > Value
A capability can have a bool, int, or string value.
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 libMesh::DofMap & dofMap()
Gets writeable reference to the dof map.
void allow_remote_element_removal(bool allow)
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.
const std::string & name() const
Get the name of the class.
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 T & get(std::string_view) const
const std::string & getLastInputFileName() const
virtual void preBackup()
Insertion point for other apps that is called before backup()
InputParameters & getObjectParams()
Retrieve 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)
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...
virtual std::unique_ptr< Base > create()=0
Tracks the libmesh system number that a MooseObject is associated with.
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)
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.
Generic AppFactory class for building Application objects.
RESTARTABLE_FILTER
The filter type applied to a particular piece of "restartable" data.
void clearAppParams(const InputParameters ¶ms, const ClearAppParamsKey)
Clears the stored parameters for the given application parameteres.
void mooseDeprecated(Args &&... args) const
Emits a deprecation warning prefixed with the object name and type, and a stack trace.
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.
Specialized factory for generic Action System objects.
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 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)
static Moose::Capability & addIntCapability(const std::string_view capability, const int value, const std::string_view doc)
Register an integer capability.
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()
An entry for a single capability.
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)
const Parser & parser() const
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 std::shared_ptr< CommandLine > _command_line
The CommandLine object.
void errorCheck(const libMesh::Parallel::Communicator &comm, bool warn_unused, bool err_unused)
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.
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.
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.
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...
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.
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.
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...
static bool isRegisteredObj(const std::string &name)
std::filesystem::path pathjoin(const std::filesystem::path &p)
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 setSinglePetscOption(const std::string &name, const std::string &value="", FEProblemBase *const problem=nullptr)
A wrapper function for dealing with different versions of PetscOptionsSetValue.
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)
void add_command_line_name(const std::string &name)
Moose::Builder _builder
Builder for building app related parser tree.
const std::shared_ptr< MooseMesh > & getDisplacedMesh() const
Registry of capabilities that checks capability requirements.
static Moose::Capability & addStringCapability(const std::string_view capability, const std::string_view value, const std::string_view doc)
Register a string capability.
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.
static void addAppParam(InputParameters ¶ms)
bool _cpu_profiling
CPU profiling.
T & set(const std::string &)
if(!dmm->_nl) SETERRQ(PETSC_COMM_WORLD
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.
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.
void mooseWarning(Args &&... args) const
Emits a warning prefixed with object name and type.
Holding syntax for parsing input files.
class infix_ostream_iterator if void
std::unordered_set< std::string > DataNames
static Moose::Capability & addBoolCapability(const std::string_view capability, const bool value, const std::string_view doc)
Register a boolean capability.
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...
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.
std::string getCurrentWorkingDir()
const std::vector< std::string > & getInputFileNames() const
Tracks whether the object is on the displaced mesh.
std::list< std::string > getFilesInDirs(const std::list< std::string > &directory_list, const bool files_only)
InputStreams clear()
Clears the contents of the reader (header stream, data stream, header)
void mooseDeprecatedNoTrace(Args &&... args)
Emit a deprecated code/feature message with the given stringified, concatenated args.
std::unique_ptr< Backup > finalizeRestore()
Finalizes (closes) the restoration process done in restore().
bool isParamValid(const std::string &name) const
Test if the supplied parameter is valid.
const ConsoleStream _console
An instance of helper class to write streams to the Console objects.
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.
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.
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::vector< std::string > split(const std::string &str, const std::string &delimiter, std::size_t max_count)
const std::shared_ptr< libMesh::Parallel::Communicator > _comm
The MPI communicator this App is going to use.
std::string getPrintableVersion() const
Non-virtual method for printing out the version string in a consistent format.
std::shared_ptr< mfem::Device > _mfem_device
The MFEM Device object.
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) ...
void setExitCode(const int exit_code)
Sets the exit code that the application will exit with.
Exception to be thrown whenever we have _throw_on_error set and a mooseError() is emitted...
bool isRecovering() const
Whether or not this is a "recover" calculation.
bool checkFileReadable(const std::string &filename, bool check_line_endings, bool throw_on_unreadable, bool check_for_git_lfs_pointer)
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...
bool copyInputs()
Handles the copy_inputs input parameter logic: Checks to see whether the passed argument is valid (a ...
bool _throw_on_error
Variable to turn on exceptions during mooseError(), should only be used within MOOSE unit tests or wh...
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 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 ...
const Elem & get(const ElemType type_in)
Abstract definition of a RestartableData value.
Class for parsing input files.
void requestCitations()
Handles the –citations command-line option: registers with PETSc the BibTeX entries that should be c...
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()
Gets the name of the running executable on Mac OS X and linux.
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 InputParameters validParams()
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.
void add_ghosting_functor(GhostingFunctor &ghosting_functor)
std::string findTestRoot()
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.
std::string _early_exit_param
Indicates if simulation is ready to exit, and keeps track of which param caused it to exit...
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 ...