From 54669342bead30987d16bd1646bd169a2c05fa0a Mon Sep 17 00:00:00 2001 From: Daniel Schwen Date: Tue, 29 Aug 2023 15:54:17 -0600 Subject: [PATCH] Enable initializer lists as defaults (#24455) --- framework/include/utils/InputParameters.h | 11 +++++++++++ framework/src/actions/SetupMeshAction.C | 16 ++++++++++------ 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/framework/include/utils/InputParameters.h b/framework/include/utils/InputParameters.h index 52e8765ad43e..acf25d312dd8 100644 --- a/framework/include/utils/InputParameters.h +++ b/framework/include/utils/InputParameters.h @@ -160,6 +160,17 @@ class InputParameters : public Parameters void addParam(const std::string & name, const std::string & doc_string); ///@} + /** + * Enable support for initializer lists as default arguments for container type. + */ + template + void addParam(const std::string & name, + const std::initializer_list & value, + const std::string & doc_string) + { + addParam(name, T{value}, doc_string); + } + ///@{ // BEGIN RANGE CHECKED PARAMETER METHODS /** diff --git a/framework/src/actions/SetupMeshAction.C b/framework/src/actions/SetupMeshAction.C index 28f72db61780..d54e72bdc15c 100644 --- a/framework/src/actions/SetupMeshAction.C +++ b/framework/src/actions/SetupMeshAction.C @@ -46,13 +46,15 @@ SetupMeshAction::validParams() "mesh. Note: This is NOT needed if you are reading " "an actual first order mesh."); - params.addParam>("block_id", "IDs of the block id/name pairs"); + params.addParam>("block_id", {}, "IDs of the block id/name pairs"); params.addParam>( - "block_name", "Names of the block id/name pairs (must correspond with \"block_id\""); + "block_name", {}, "Names of the block id/name pairs (must correspond with \"block_id\""); - params.addParam>("boundary_id", "IDs of the boundary id/name pairs"); + params.addParam>("boundary_id", {}, "IDs of the boundary id/name pairs"); params.addParam>( - "boundary_name", "Names of the boundary id/name pairs (must correspond with \"boundary_id\""); + "boundary_name", + {}, + "Names of the boundary id/name pairs (must correspond with \"boundary_id\""); params.addParam("construct_side_list_from_node_list", false, @@ -62,6 +64,7 @@ SetupMeshAction::validParams() params.addParam>( "displacements", + {}, "The variables corresponding to the x y z displacements of the mesh. If " "this is provided then the displacements will be taken into account during " "the computation. Creation of the displaced mesh can be suppressed even if " @@ -72,9 +75,10 @@ SetupMeshAction::validParams() "Create the displaced mesh if the 'displacements' " "parameter is set. If this is 'false', a displaced mesh will not be created, " "regardless of whether 'displacements' is set."); - params.addParam>("ghosted_boundaries", - "Boundaries to be ghosted if using Nemesis"); + params.addParam>( + "ghosted_boundaries", {}, "Boundaries to be ghosted if using Nemesis"); params.addParam>("ghosted_boundaries_inflation", + {}, "If you are using ghosted boundaries you will want to set " "this value to a vector of amounts to inflate the bounding " "boxes by. ie if you are running a 3D problem you might set "