34 return it->second->buildParameters();
36 mooseError(std::string(
"A '") +
name +
"' is not a registered object\n\n");
42 mooseAssert(parser,
"Not set");
43 mooseAssert(parser->getAppType().size(),
"App type not set");
44 const std::string app_type = parser->getAppType();
46 auto command_line = std::make_unique<CommandLine>(argc, argv);
47 command_line->parse();
50 app_params.
set<
int>(
"_argc") = argc;
51 app_params.set<
char **>(
"_argv") = argv;
52 app_params.set<std::shared_ptr<CommandLine>>(
"_command_line") = std::move(command_line);
53 app_params.set<std::shared_ptr<Parser>>(
"_parser") = std::move(parser);
62 MPI_Comm comm_world_in)
64 mooseDeprecated(
"Please update your main.C to adapt new main function in MOOSE framework, " 65 "see'test/src/main.C in MOOSE as an example of moose::main()'. ");
73 pre_command_line.
parse();
77 const auto & input_filenames = command_line_params.get<std::vector<std::string>>(
"input_file");
78 auto parser = std::make_unique<Parser>(input_filenames);
79 if (input_filenames.size())
82 std::string app_type = command_line_params.get<std::string>(
"app_to_run");
84 app_type = default_app_type;
86 mooseDeprecated(
"Please use [Application] block to specify application type, '--app <AppName>' " 87 "is deprecated and will be removed in a future release.");
89 parser->setAppType(app_type);
92 app_params.
set<
int>(
"_argc") = argc;
93 app_params.set<
char **>(
"_argv") = argv;
95 auto command_line = std::make_unique<CommandLine>(argc, argv);
96 command_line->parse();
97 app_params.set<std::shared_ptr<CommandLine>>(
"_command_line") = std::move(command_line);
101 app_params.set<std::shared_ptr<Parser>>(
"_parser") = std::move(parser);
108 const std::string & name,
110 MPI_Comm comm_world_in)
115 mooseError(
"Object '" + app_type +
"' was not registered.");
116 auto & build_info = it->second;
119 parameters.
set<std::string>(
"_type") = app_type;
124 auto comm = std::make_shared<Parallel::Communicator>(comm_world_in);
126 parameters.
set<std::shared_ptr<Parallel::Communicator>>(
"_comm") = comm;
127 parameters.
set<std::string>(
"_app_name") =
name;
130 mooseError(
"Valid CommandLine object required");
132 std::shared_ptr<CommandLine> command_line =
133 parameters.
get<std::shared_ptr<CommandLine>>(
"_command_line");
134 mooseAssert(command_line->hasParsed(),
"Should have been parsed");
136 command_line->populateCommandLineParams(parameters);
138 build_info->_app_creation_count++;
140 return build_info->build(parameters);
149 mooseError(
"AppFactory::createdAppCount(): '", app_type,
"' is not a registered app");
151 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)
static void addInputParam(InputParameters ¶ms)
This class wraps provides and tracks access to command line parameters.
std::shared_ptr< MooseApp > MooseAppPtr
alias to wrap shared pointer type
void populateCommandLineParams(InputParameters ¶ms)
Populates the command line input parameters from params.
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 MooseAppPtr createAppShared(int argc, char **argv, std::unique_ptr< Parser > parser)
Helper function for creating a MooseApp from command-line arguments and a Parser. ...
static AppFactory & instance()
Get the instance of the AppFactory.
static void addAppParam(InputParameters ¶ms)
void parse()
Performs the parsing, which is the combining of arguments into [name, value] pairs.
InputParameters getValidParams(const std::string &name)
Get valid parameters for the object.