diff --git a/framework/src/base/MooseApp.C b/framework/src/base/MooseApp.C index 40e2c7894bbe..ac8c7bcae56a 100644 --- a/framework/src/base/MooseApp.C +++ b/framework/src/base/MooseApp.C @@ -247,6 +247,10 @@ MooseApp::validParams() "Continue the calculation. Without , the most recent recovery file will be used"); params.setGlobalCommandLineParam("recover"); + params.addCommandLineParam( + "suppress_header", "--suppress-header", false, "Flag to print the App header"); + params.setGlobalCommandLineParam("suppress_header"); + params.addCommandLineParam( "test_checkpoint_half_transient", "--test-checkpoint-half-transient", @@ -730,13 +734,8 @@ MooseApp::setupOptions() TIME_SECTION("setupOptions", 5, "Setting Up Options"); // Print the header, this is as early as possible - auto hdr = header(); - if (hdr.length() != 0) - { - if (multiAppLevel() > 0) - MooseUtils::indentMessage(_name, hdr); - Moose::out << hdr << std::endl; - } + if (header().length() && !getParam("suppress_header")) + _console << header() << std::endl; if (getParam("error_unused")) setCheckUnusedFlag(true); diff --git a/test/include/base/MooseTestApp.h b/test/include/base/MooseTestApp.h index fc5f0fd6a84c..d05c18d13a50 100644 --- a/test/include/base/MooseTestApp.h +++ b/test/include/base/MooseTestApp.h @@ -25,4 +25,6 @@ class MooseTestApp : public MooseApp static void registerAll(Factory & f, ActionFactory & af, Syntax & s, bool use_test_objs = false); static void registerApps(); + + virtual std::string header() const override; }; diff --git a/test/src/base/MooseTestApp.C b/test/src/base/MooseTestApp.C index 0de2faae4892..fd15e6fbd8ca 100644 --- a/test/src/base/MooseTestApp.C +++ b/test/src/base/MooseTestApp.C @@ -52,6 +52,9 @@ MooseTestApp::validParams() "--test-check-legacy-params", "Check for legacy parameter construction with CheckLegacyParamsAction; for testing"); + params.addCommandLineParam( + "append_header", "--append-header
", "", "String to print at top of console output"); + params.set("automatic_automatic_scaling") = false; params.set("use_legacy_material_output") = false; params.set("use_legacy_initial_residual_evaluation_behavior") = false; @@ -141,6 +144,12 @@ MooseTestApp::registerApps() registerApp(MooseTestApp); } +std::string +MooseTestApp::header() const +{ + return getParam("append_header"); +} + extern "C" void MooseTestApp__registerAll(Factory & f, ActionFactory & af, Syntax & s) { diff --git a/test/tests/misc/header/parent.i b/test/tests/misc/header/parent.i new file mode 100644 index 000000000000..5a0aae5df7d2 --- /dev/null +++ b/test/tests/misc/header/parent.i @@ -0,0 +1,26 @@ +[Mesh] + type = GeneratedMesh + dim = 1 +[] + +[Problem] + solve = false +[] + +[Executioner] + type = Transient + num_steps = 0 +[] + +[Outputs] + color = false +[] + +[MultiApps] + [sub] + type = TransientMultiApp + app_type = MooseTestApp + input_files = sub.i + cli_args = --append-header=sub + [] +[] diff --git a/test/tests/misc/header/sub.i b/test/tests/misc/header/sub.i new file mode 100644 index 000000000000..ad66e199e2ff --- /dev/null +++ b/test/tests/misc/header/sub.i @@ -0,0 +1,26 @@ +[Mesh] + type = GeneratedMesh + dim = 1 +[] + +[Problem] + solve = false +[] + +[Executioner] + type = Transient + num_steps = 0 +[] + +[Outputs] + color = false +[] + +[MultiApps] + [sub] + type = TransientMultiApp + app_type = MooseTestApp + input_files = subsub.i + cli_args = --append-header=subsub + [] +[] diff --git a/test/tests/misc/header/subsub.i b/test/tests/misc/header/subsub.i new file mode 100644 index 000000000000..28799b9e2deb --- /dev/null +++ b/test/tests/misc/header/subsub.i @@ -0,0 +1,17 @@ +[Mesh] + type = GeneratedMesh + dim = 1 +[] + +[Problem] + solve = false +[] + +[Executioner] + type = Transient + num_steps = 0 +[] + +[Outputs] + color = false +[] diff --git a/test/tests/misc/header/tests b/test/tests/misc/header/tests new file mode 100644 index 000000000000..a55cccb5767d --- /dev/null +++ b/test/tests/misc/header/tests @@ -0,0 +1,23 @@ +[Tests] + issues = '#1832' + design = 'syntax/MultiApps/index.md' + + [g] + requirement = "The system shall be able to print a header for multi-level sub-applications:" + [header_on] + type = 'RunApp' + input = 'parent.i' + expect_out = 'parent\nsub0: sub\nsub0_sub0: subsub' + detail = "custom for each parent and sub-applications;" + cli_args = '--append-header=parent' + [] + [header_off] + type = 'RunApp' + input = 'parent.i' + prereq = g/header_on + cli_args = '--append-header=parent --suppress-header' + absent_out = 'parent\nsub0: sub\nsub0_sub0: subsub' + detail = "and suppress the all parent and sub-applications." + [] + [] +[]