Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add cmd line arg to suppress header output #29669

Open
wants to merge 1 commit into
base: next
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 6 additions & 7 deletions framework/src/base/MooseApp.C
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,10 @@ MooseApp::validParams()
"Continue the calculation. Without <file base>, the most recent recovery file will be used");
params.setGlobalCommandLineParam("recover");

params.addCommandLineParam<bool>(
"suppress_header", "--suppress-header", false, "Flag to print the App header");
params.setGlobalCommandLineParam("suppress_header");
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ugh, this comment got stuck in "review", sorry it didn't go out...anyways, heres the command line and old comment...

@loganharbour This PR builds on #29663 , so it's a bit convoluted with that update, but here is the cmd line I'm trying to add. I would like to be able to optionally suppress the header being printed. I tried to use CommonOutputAction, similar to #29665, but it's not built at this point (I think?).


params.addCommandLineParam<bool>(
"test_checkpoint_half_transient",
"--test-checkpoint-half-transient",
Expand Down Expand Up @@ -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<bool>("suppress_header"))
_console << header() << std::endl;

if (getParam<bool>("error_unused"))
setCheckUnusedFlag(true);
Expand Down
2 changes: 2 additions & 0 deletions test/include/base/MooseTestApp.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};
9 changes: 9 additions & 0 deletions test/src/base/MooseTestApp.C
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ MooseTestApp::validParams()
"--test-check-legacy-params",
"Check for legacy parameter construction with CheckLegacyParamsAction; for testing");

params.addCommandLineParam<std::string>(
"append_header", "--append-header <header>", "", "String to print at top of console output");

params.set<bool>("automatic_automatic_scaling") = false;
params.set<bool>("use_legacy_material_output") = false;
params.set<bool>("use_legacy_initial_residual_evaluation_behavior") = false;
Expand Down Expand Up @@ -141,6 +144,12 @@ MooseTestApp::registerApps()
registerApp(MooseTestApp);
}

std::string
MooseTestApp::header() const
{
return getParam<std::string>("append_header");
}

extern "C" void
MooseTestApp__registerAll(Factory & f, ActionFactory & af, Syntax & s)
{
Expand Down
26 changes: 26 additions & 0 deletions test/tests/misc/header/parent.i
Original file line number Diff line number Diff line change
@@ -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
[]
[]
26 changes: 26 additions & 0 deletions test/tests/misc/header/sub.i
Original file line number Diff line number Diff line change
@@ -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
[]
[]
17 changes: 17 additions & 0 deletions test/tests/misc/header/subsub.i
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
[Mesh]
type = GeneratedMesh
dim = 1
[]

[Problem]
solve = false
[]

[Executioner]
type = Transient
num_steps = 0
[]

[Outputs]
color = false
[]
23 changes: 23 additions & 0 deletions test/tests/misc/header/tests
Original file line number Diff line number Diff line change
@@ -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."
[]
[]
[]