Skip to content

Commit 46bec4d

Browse files
tophmatthewszachmprince
authored andcommitted
Do smarter control over header
Closes idaholab#29662
1 parent 01249e3 commit 46bec4d

File tree

7 files changed

+109
-7
lines changed

7 files changed

+109
-7
lines changed

framework/src/base/MooseApp.C

+6-7
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,10 @@ MooseApp::validParams()
247247
"Continue the calculation. Without <file base>, the most recent recovery file will be used");
248248
params.setGlobalCommandLineParam("recover");
249249

250+
params.addCommandLineParam<bool>(
251+
"suppress_header", "--suppress-header", false, "Flag to print the App header");
252+
params.setGlobalCommandLineParam("suppress_header");
253+
250254
params.addCommandLineParam<bool>(
251255
"test_checkpoint_half_transient",
252256
"--test-checkpoint-half-transient",
@@ -730,13 +734,8 @@ MooseApp::setupOptions()
730734
TIME_SECTION("setupOptions", 5, "Setting Up Options");
731735

732736
// Print the header, this is as early as possible
733-
auto hdr = header();
734-
if (hdr.length() != 0)
735-
{
736-
if (multiAppLevel() > 0)
737-
MooseUtils::indentMessage(_name, hdr);
738-
Moose::out << hdr << std::endl;
739-
}
737+
if (header().length() && !getParam<bool>("suppress_header"))
738+
_console << header() << std::endl;
740739

741740
if (getParam<bool>("error_unused"))
742741
setCheckUnusedFlag(true);

test/include/base/MooseTestApp.h

+2
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,6 @@ class MooseTestApp : public MooseApp
2525

2626
static void registerAll(Factory & f, ActionFactory & af, Syntax & s, bool use_test_objs = false);
2727
static void registerApps();
28+
29+
virtual std::string header() const override;
2830
};

test/src/base/MooseTestApp.C

+9
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,9 @@ MooseTestApp::validParams()
5252
"--test-check-legacy-params",
5353
"Check for legacy parameter construction with CheckLegacyParamsAction; for testing");
5454

55+
params.addCommandLineParam<std::string>(
56+
"append_header", "--append-header <header>", "", "String to print at top of console output");
57+
5558
params.set<bool>("automatic_automatic_scaling") = false;
5659
params.set<bool>("use_legacy_material_output") = false;
5760
params.set<bool>("use_legacy_initial_residual_evaluation_behavior") = false;
@@ -141,6 +144,12 @@ MooseTestApp::registerApps()
141144
registerApp(MooseTestApp);
142145
}
143146

147+
std::string
148+
MooseTestApp::header() const
149+
{
150+
return getParam<std::string>("append_header");
151+
}
152+
144153
extern "C" void
145154
MooseTestApp__registerAll(Factory & f, ActionFactory & af, Syntax & s)
146155
{

test/tests/misc/header/parent.i

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
[Mesh]
2+
type = GeneratedMesh
3+
dim = 1
4+
[]
5+
6+
[Problem]
7+
solve = false
8+
[]
9+
10+
[Executioner]
11+
type = Transient
12+
num_steps = 0
13+
[]
14+
15+
[Outputs]
16+
color = false
17+
[]
18+
19+
[MultiApps]
20+
[sub]
21+
type = TransientMultiApp
22+
app_type = MooseTestApp
23+
input_files = sub.i
24+
cli_args = --append-header=sub
25+
[]
26+
[]

test/tests/misc/header/sub.i

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
[Mesh]
2+
type = GeneratedMesh
3+
dim = 1
4+
[]
5+
6+
[Problem]
7+
solve = false
8+
[]
9+
10+
[Executioner]
11+
type = Transient
12+
num_steps = 0
13+
[]
14+
15+
[Outputs]
16+
color = false
17+
[]
18+
19+
[MultiApps]
20+
[sub]
21+
type = TransientMultiApp
22+
app_type = MooseTestApp
23+
input_files = subsub.i
24+
cli_args = --append-header=subsub
25+
[]
26+
[]

test/tests/misc/header/subsub.i

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
[Mesh]
2+
type = GeneratedMesh
3+
dim = 1
4+
[]
5+
6+
[Problem]
7+
solve = false
8+
[]
9+
10+
[Executioner]
11+
type = Transient
12+
num_steps = 0
13+
[]
14+
15+
[Outputs]
16+
color = false
17+
[]

test/tests/misc/header/tests

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
[Tests]
2+
issues = '#1832'
3+
design = 'syntax/MultiApps/index.md'
4+
5+
[g]
6+
requirement = "The system shall be able to print a header for multi-level sub-applications:"
7+
[header_on]
8+
type = 'RunApp'
9+
input = 'parent.i'
10+
expect_out = 'parent\nsub0: sub\nsub0_sub0: subsub'
11+
detail = "custom for each parent and sub-applications;"
12+
cli_args = '--append-header=parent'
13+
[]
14+
[header_off]
15+
type = 'RunApp'
16+
input = 'parent.i'
17+
prereq = g/header_on
18+
cli_args = '--append-header=parent --suppress-header'
19+
absent_out = 'parent\nsub0: sub\nsub0_sub0: subsub'
20+
detail = "and suppress the all parent and sub-applications."
21+
[]
22+
[]
23+
[]

0 commit comments

Comments
 (0)