diff --git a/framework/doc/content/source/parser/Parser.md b/framework/doc/content/source/parser/Parser.md index 4a6fdffc7da7..ac777da49479 100644 --- a/framework/doc/content/source/parser/Parser.md +++ b/framework/doc/content/source/parser/Parser.md @@ -1,14 +1,15 @@ # Parser -The MOOSE Parser object is responsible for interacting with the HIT input file parser -and constructing the necessary [Actions](Action.md) that ultimately execute to build -up the objects which compose a complete MOOSE based simulation. It is important to note -that +this+ object is not responsible for the raw file-base I/O. The underlying -structure of the MOOSE input file is dictated by HIT and information on the format -can be found [here](/application_usage/input_syntax.md optional=True). The parser abstraction expects -information to be organized into a hierarchy of blocks with zero or more children -at each level. All of the name/value pairs at each level are used to construct -one or more complete objects. +The MOOSE Parser object is responsible for interacting with the HIT input file +parser and constructing the necessary [Actions](Action.md) that ultimately +execute to build up the objects which compose a complete MOOSE based simulation. +It is important to note that +this+ object is not responsible for the raw +file-base I/O. The underlying structure of the MOOSE input file is dictated by +HIT and information on the format can be found +[here](/application_usage/input_syntax.md optional=True). The parser abstraction +expects information to be organized into a hierarchy of blocks with zero or more +children at each level. All of the name/value pairs at each level are used to +construct one or more complete objects. ## Associating parser blocks @@ -30,4 +31,12 @@ See [Brace Expressions](input_syntax.md optional=True) The Parser supports the ability to selectively activate or deactivate individual blocks without the use of block comment characters through the use of the special "active" and "inactive" parameter blocks. Either of these parameters (but not both) can be added -to any block (including the top level) to selectively turn individual blocks on/off. \ No newline at end of file +to any block (including the top level) to selectively turn individual blocks on/off. + +## Multiple inputs + +When multiple inputs are supplied to a MOOSE application, the parser will read +them in successively and add merge them into a single block hierarchy. Later +inputs add to and override parameters to previous inputs. This permits the user +to factor out common parts of a set of inputs and reuse them in multiple +simulations. diff --git a/test/tests/parser/multiple_inputs/diffusion1a.i b/test/tests/parser/multiple_inputs/diffusion1a.i new file mode 100644 index 000000000000..38e21bda091f --- /dev/null +++ b/test/tests/parser/multiple_inputs/diffusion1a.i @@ -0,0 +1,24 @@ +[Mesh] + type = GeneratedMesh + dim = 2 + nx = 10 + ny = 10 +[] + +[BCs] + [left] + type = DirichletBC + variable = u + boundary = left + value = 0 + [] +[] + +[Executioner] + type = Steady + solve_type = 'PJFNK' +[] + +[Outputs] + exodus = true +[] diff --git a/test/tests/parser/multiple_inputs/diffusion1b.i b/test/tests/parser/multiple_inputs/diffusion1b.i new file mode 100644 index 000000000000..687fb60fe091 --- /dev/null +++ b/test/tests/parser/multiple_inputs/diffusion1b.i @@ -0,0 +1,5 @@ +[BCs] + [right] + value = 2 + [] +[] diff --git a/test/tests/parser/multiple_inputs/diffusion1c.i b/test/tests/parser/multiple_inputs/diffusion1c.i new file mode 100644 index 000000000000..9ebb5e6a704a --- /dev/null +++ b/test/tests/parser/multiple_inputs/diffusion1c.i @@ -0,0 +1,25 @@ +[Variables] + [u] + [] +[] + +[Kernels] + [diff] + type = Diffusion + variable = u + [] +[] + +[BCs] + [right] + type = DirichletBC + variable = u + boundary = right + value = 1 + [] +[] + +[Executioner] + petsc_options_iname = '-pc_type -pc_hypre_type' + petsc_options_value = 'hypre boomeramg' +[] diff --git a/test/tests/parser/multiple_inputs/diffusion1d.i b/test/tests/parser/multiple_inputs/diffusion1d.i new file mode 100644 index 000000000000..c3032c9fd0c6 --- /dev/null +++ b/test/tests/parser/multiple_inputs/diffusion1d.i @@ -0,0 +1,5 @@ +[BCs] + [right] + invalid_param = 'invalid_value' + [] +[] diff --git a/test/tests/parser/multiple_inputs/gold/diffusion1a_out.e b/test/tests/parser/multiple_inputs/gold/diffusion1a_out.e new file mode 120000 index 000000000000..835f6e5ad5d5 --- /dev/null +++ b/test/tests/parser/multiple_inputs/gold/diffusion1a_out.e @@ -0,0 +1 @@ +../../../kernels/simple_diffusion/gold/simple_diffusion_out.e \ No newline at end of file diff --git a/test/tests/parser/multiple_inputs/tests b/test/tests/parser/multiple_inputs/tests new file mode 100644 index 000000000000..783c43a803c5 --- /dev/null +++ b/test/tests/parser/multiple_inputs/tests @@ -0,0 +1,26 @@ +[Tests] + design = 'Parser.md' + issues = '#17989' + requirement = 'The system shall support for multiple input files, which are merged into one input specification for a simulation' + + [./two_inputs] + type = 'Exodiff' + input = 'diffusion1a.i diffusion1c.i' + exodiff = 'diffusion1a_out.e' + detail = 'where no parameters overlap' + [../] + + [./three_inputs_override] + type = 'Exodiff' + input = 'diffusion1a.i diffusion1b.i diffusion1c.i' + exodiff = 'diffusion1a_out.e' + detail = 'where input files may override parameters in previous inputs' + [../] + + [./three_inputs_error] + type = 'RunException' + input = 'diffusion1a.i diffusion1c.i diffusion1d.i' + expect_err = 'moose/test/tests/parser/multiple_inputs/diffusion1d.i:3: unused parameter \'BCs/right/invalid_param\'' + detail = 'while locating input errors in the correct file' + [../] +[]