From e136bdcab507fa7328afd936e4d699468fb1432c 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/AddNodalNormalsAction.C | 5 +++-- framework/src/actions/SetupMeshAction.C | 10 ++++++---- 3 files changed, 20 insertions(+), 6 deletions(-) diff --git a/framework/include/utils/InputParameters.h b/framework/include/utils/InputParameters.h index 0ff05c709b55..5baf3b620fd1 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/AddNodalNormalsAction.C b/framework/src/actions/AddNodalNormalsAction.C index b0db35a59465..ec603380241a 100644 --- a/framework/src/actions/AddNodalNormalsAction.C +++ b/framework/src/actions/AddNodalNormalsAction.C @@ -28,9 +28,10 @@ AddNodalNormalsAction::validParams() "facing normal from a node."); // Initialize the 'boundary' input option to default to any boundary - std::vector everywhere(1, "ANY_BOUNDARY_ID"); params.addParam>( - "boundary", everywhere, "The boundary ID or name where the normals will be computed"); + "boundary", + {"ANY_BOUNDARY_ID"}, + "The boundary ID or name where the normals will be computed"); params.addParam("corner_boundary", "boundary ID or name with nodes at 'corners'"); MooseEnum orders("FIRST SECOND", "FIRST"); params.addParam("order", diff --git a/framework/src/actions/SetupMeshAction.C b/framework/src/actions/SetupMeshAction.C index 28f72db61780..3194e153021a 100644 --- a/framework/src/actions/SetupMeshAction.C +++ b/framework/src/actions/SetupMeshAction.C @@ -50,9 +50,11 @@ SetupMeshAction::validParams() params.addParam>( "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, @@ -72,8 +74,8 @@ 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 "