Skip to content

Commit

Permalink
Add option for specifying specific application for input run
Browse files Browse the repository at this point in the history
  • Loading branch information
lindsayad committed Jan 17, 2022
1 parent 18c73d2 commit 0a13b20
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 4 deletions.
2 changes: 1 addition & 1 deletion framework/include/base/AppFactory.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class AppFactory
/**
* Helper function for creating a MooseApp from command-line arguments.
*/
static MooseAppPtr createAppShared(const std::string & app_type,
static MooseAppPtr createAppShared(const std::string & default_app_type,
int argc,
char ** argv,
MPI_Comm comm_word = MPI_COMM_WORLD);
Expand Down
2 changes: 2 additions & 0 deletions framework/include/base/MooseApp.h
Original file line number Diff line number Diff line change
Expand Up @@ -918,6 +918,8 @@ class MooseApp : public ConsoleStreamInterface,
template <class T>
const std::vector<T *> & getInterfaceObjects() const;

static void addAppParam(InputParameters & params);

protected:
/**
* Whether or not this MooseApp has cached a Backup to use for restart / recovery
Expand Down
10 changes: 9 additions & 1 deletion framework/src/base/AppFactory.C
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include "AppFactory.h"
#include "CommandLine.h"
#include "InputParameters.h"
#include "MooseApp.h"

AppFactory AppFactory::_instance = AppFactory();

Expand All @@ -32,12 +33,19 @@ AppFactory::getValidParams(const std::string & name)
}

MooseAppPtr
AppFactory::createAppShared(const std::string & app_type,
AppFactory::createAppShared(const std::string & default_app_type,
int argc,
char ** argv,
MPI_Comm comm_world_in)
{
auto command_line = std::make_shared<CommandLine>(argc, argv);
auto which_app_param = emptyInputParameters();
MooseApp::addAppParam(which_app_param);
command_line->addCommandLineOptionsFromParams(which_app_param);
std::string app_type;
if (!command_line->search("app_to_run", app_type))
app_type = default_app_type;

auto app_params = AppFactory::instance().getValidParams(app_type);

app_params.set<int>("_argc") = argc;
Expand Down
13 changes: 13 additions & 0 deletions framework/src/base/MooseApp.C
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,17 @@

defineLegacyParams(MooseApp);

void
MooseApp::addAppParam(InputParameters & params)
{
params.addCommandLineParam<std::string>(
"app_to_run",
"--app <AppName>",
"Specify the application that should be used to run the input file. This must match an "
"application name registered to the application factory. Note that this option is "
"case-sensitive.");
}

InputParameters
MooseApp::validParams()
{
Expand Down Expand Up @@ -303,6 +314,8 @@ MooseApp::validParams()
true,
"Set false to allow material properties to be output on INITIAL, not just TIMESTEP_END.");

MooseApp::addAppParam(params);

return params;
}

Expand Down
1 change: 1 addition & 0 deletions test/tests/kernels/simple_diffusion/gold/app.e
13 changes: 11 additions & 2 deletions test/tests/kernels/simple_diffusion/tests
Original file line number Diff line number Diff line change
@@ -1,11 +1,20 @@
[Tests]
[./test]
[test]
type = 'Exodiff'
input = 'simple_diffusion.i'
exodiff = 'simple_diffusion_out.e'

issues = '#1493'
design = 'kernels/Diffusion.md'
requirement = 'The system shall run a simple 2D linear diffusion problem with Dirichlet boundary conditions on a regular mesh.'
[../]
[]
[specified_app]
type = 'Exodiff'
input = 'simple_diffusion.i'
exodiff = 'app.e'
issues = '#20062'
design = 'MooseApp.md'
cli_args = "Outputs/file_base='app' --app MooseTestApp"
requirement = 'The system shall be able to run a specific application by passing a command line option.'
[]
[]

0 comments on commit 0a13b20

Please sign in to comment.