33 return it->second->buildParameters();
35 mooseError(std::string(
"A '") +
name +
"' is not a registered object\n\n");
42 std::unique_ptr<Parser> parser,
43 MPI_Comm comm_world_in)
45 auto command_line = std::make_shared<CommandLine>(argc, argv);
49 command_line->addCommandLineOptionsFromParams(which_app_param);
52 if (!command_line->search(
"app_to_run", app_type))
53 app_type = default_app_type;
55 mooseDeprecated(
"Please use [Application] block to specify application type, '--app <AppName>' " 56 "is deprecated and will be removed in a future release.");
59 parser->setAppType(app_type);
61 app_params.
set<
int>(
"_argc") = argc;
62 app_params.set<
char **>(
"_argv") = argv;
63 app_params.set<std::shared_ptr<CommandLine>>(
"_command_line") = command_line;
67 app_params.set<std::shared_ptr<Parser>>(
"_parser") = std::move(parser);
76 MPI_Comm comm_world_in)
78 mooseDeprecated(
"Please update your main.C to adapt new main function in MOOSE framework, " 79 "see'test/src/main.C in MOOSE as an example of moose::main()'. ");
81 auto command_line = std::make_shared<CommandLine>(argc, argv);
84 which_app_param.addCommandLineParam<std::vector<std::string>>(
87 "Specify one or multiple input files. Multiple files get merged into a single simulation " 90 command_line->addCommandLineOptionsFromParams(which_app_param);
92 std::vector<std::string> input_filenames;
93 command_line->search(
"input_file", input_filenames);
95 auto parser = std::make_unique<Parser>(input_filenames);
96 if (input_filenames.size())
100 command_line->addCommandLineOptionsFromParams(which_app_param);
102 std::string app_type;
103 if (!command_line->search(
"app_to_run", app_type))
104 app_type = default_app_type;
106 mooseDeprecated(
"Please use [Application] block to specify application type, '--app <AppName>' " 107 "is deprecated and will be removed in a future release.");
109 parser->setAppType(app_type);
112 app_params.
set<
int>(
"_argc") = argc;
113 app_params.set<
char **>(
"_argv") = argv;
114 app_params.set<std::shared_ptr<CommandLine>>(
"_command_line") = command_line;
118 app_params.set<std::shared_ptr<Parser>>(
"_parser") = std::move(parser);
125 const std::string & name,
127 MPI_Comm comm_world_in)
132 mooseError(
"Object '" + app_type +
"' was not registered.");
133 auto & build_info = it->second;
136 parameters.
set<std::string>(
"_type") = app_type;
141 auto comm = std::make_shared<Parallel::Communicator>(comm_world_in);
143 parameters.
set<std::shared_ptr<Parallel::Communicator>>(
"_comm") = comm;
144 parameters.
set<std::string>(
"_app_name") =
name;
147 mooseError(
"Valid CommandLine object required");
149 std::shared_ptr<CommandLine> command_line =
150 parameters.
get<std::shared_ptr<CommandLine>>(
"_command_line");
151 command_line->addCommandLineOptionsFromParams(parameters);
152 command_line->populateInputParams(parameters);
154 build_info->_app_creation_count++;
156 return build_info->build(parameters);
165 mooseError(
"AppFactory::createdAppCount(): '", app_type,
"' is not a registered app");
167 return it->second->_app_creation_count;
std::string name(const ElemQuality q)
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
MooseAppPtr createShared(const std::string &app_type, const std::string &name, InputParameters parameters, MPI_Comm COMM_WORLD_IN)
Build an application object (must be registered)
std::shared_ptr< MooseApp > MooseAppPtr
alias to wrap shared pointer type
Generic AppFactory class for building Application objects.
AppFactoryBuildInfoMap _name_to_build_info
std::size_t createdAppCount(const std::string &app_type) const
void mooseDeprecated(Args &&... args)
Emit a deprecated code/feature message with the given stringified, concatenated args.
static AppFactory & instance()
Get the instance of the AppFactory.
static MooseAppPtr createAppShared(const std::string &default_app_type, int argc, char **argv, std::unique_ptr< Parser > parser, MPI_Comm comm_word=MPI_COMM_WORLD)
Helper function for creating a MooseApp from command-line arguments and a Parser. ...
static void addAppParam(InputParameters ¶ms)
InputParameters getValidParams(const std::string &name)
Get valid parameters for the object.