34 return it->second->buildParameters();
36 mooseError(std::string(
"A '") +
name +
"' is not a registered object\n\n");
45 mooseError(
"AppFactory::getAppParams(): Parameters for application with ID ",
id,
" not found");
56 "AppFactory::clearAppParams(): Parameters for application with ID ",
id,
" not found");
62 mooseAssert(parser,
"Not set");
63 mooseAssert(parser->getAppType().size(),
"App type not set");
64 const std::string app_type = parser->getAppType();
66 auto command_line = std::make_unique<CommandLine>(argc, argv);
67 command_line->parse();
70 app_params.
set<
int>(
"_argc") = argc;
71 app_params.set<
char **>(
"_argv") = argv;
72 app_params.set<std::shared_ptr<CommandLine>>(
"_command_line") = std::move(command_line);
73 app_params.set<std::shared_ptr<Parser>>(
"_parser") = std::move(parser);
82 MPI_Comm comm_world_in)
84 mooseDeprecated(
"Please update your main.C to adapt new main function in MOOSE framework, " 85 "see'test/src/main.C in MOOSE as an example of moose::main()'. ");
93 pre_command_line.
parse();
97 const auto & input_filenames = command_line_params.get<std::vector<std::string>>(
"input_file");
98 auto parser = std::make_unique<Parser>(input_filenames);
99 if (input_filenames.size())
102 std::string app_type = command_line_params.get<std::string>(
"app_to_run");
103 if (app_type.empty())
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;
115 auto command_line = std::make_unique<CommandLine>(argc, argv);
116 command_line->parse();
117 app_params.set<std::shared_ptr<CommandLine>>(
"_command_line") = std::move(command_line);
121 app_params.set<std::shared_ptr<Parser>>(
"_parser") = std::move(parser);
128 const std::string & name,
130 MPI_Comm comm_world_in)
135 mooseError(
"Object '" + app_type +
"' was not registered.");
136 auto & build_info = it->second;
139 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 mooseAssert(command_line->hasParsed(),
"Should have been parsed");
153 command_line->populateCommandLineParams(parameters);
162 build_info->_app_creation_count++;
164 return build_info->build(params);
173 mooseError(
"AppFactory::createdAppCount(): '", app_type,
"' is not a registered app");
175 return it->second->_app_creation_count;
181 const std::size_t next_id =
184 const auto it_inserted_pair =
186 mooseAssert(it_inserted_pair.second,
"Already exists");
187 auto & stored_params = *it_inserted_pair.first->second;
188 stored_params.finalize(
"");
189 return stored_params;
196 mooseError(
"AppFactory::getAppParamsID(): Invalid application parameters (missing " 197 "'_app_params_id')");
198 return params.
get<std::size_t>(
"_app_params_id");
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)
const InputParameters & storeAppParams(InputParameters ¶ms)
Stores the given parameters within _input_parameters for app construction.
static void addInputParam(InputParameters ¶ms)
const InputParameters & getAppParams(const InputParameters ¶ms) const
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.
void clearAppParams(const InputParameters ¶ms, const ClearAppParamsKey)
Clears the stored parameters for the given application parameteres.
AppFactoryBuildInfoMap _name_to_build_info
std::size_t createdAppCount(const std::string &app_type) const
std::map< std::size_t, std::unique_ptr< InputParameters > > _input_parameters
Storage of input parameters used in applications (ID (from getAppParamsID()) -> params) ...
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.
std::size_t getAppParamsID(const InputParameters ¶ms) const
Get the ID for the InputParameters associated with an application, used in storing them in _input_par...
static void addAppParam(InputParameters ¶ms)
Class that is used as a parameter to clearAppParams() that allows only MooseApp to call clearAppParam...
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.