Skip to content

Commit

Permalink
Merge pull request #25341 from dschwen/initializer_list
Browse files Browse the repository at this point in the history
Initializer list
  • Loading branch information
dschwen authored Aug 30, 2023
2 parents f11ac02 + e136bdc commit f338799
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 6 deletions.
11 changes: 11 additions & 0 deletions framework/include/utils/InputParameters.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 <typename T>
void addParam(const std::string & name,
const std::initializer_list<typename T::value_type> & value,
const std::string & doc_string)
{
addParam<T>(name, T{value}, doc_string);
}

///@{
// BEGIN RANGE CHECKED PARAMETER METHODS
/**
Expand Down
5 changes: 3 additions & 2 deletions framework/src/actions/AddNodalNormalsAction.C
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,10 @@ AddNodalNormalsAction::validParams()
"facing normal from a node.");

// Initialize the 'boundary' input option to default to any boundary
std::vector<BoundaryName> everywhere(1, "ANY_BOUNDARY_ID");
params.addParam<std::vector<BoundaryName>>(
"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<BoundaryName>("corner_boundary", "boundary ID or name with nodes at 'corners'");
MooseEnum orders("FIRST SECOND", "FIRST");
params.addParam<MooseEnum>("order",
Expand Down
10 changes: 6 additions & 4 deletions framework/src/actions/SetupMeshAction.C
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,11 @@ SetupMeshAction::validParams()
params.addParam<std::vector<SubdomainName>>(
"block_name", "Names of the block id/name pairs (must correspond with \"block_id\"");

params.addParam<std::vector<BoundaryID>>("boundary_id", "IDs of the boundary id/name pairs");
params.addParam<std::vector<BoundaryID>>("boundary_id", {}, "IDs of the boundary id/name pairs");
params.addParam<std::vector<BoundaryName>>(
"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<bool>("construct_side_list_from_node_list",
false,
Expand All @@ -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<std::vector<BoundaryName>>("ghosted_boundaries",
"Boundaries to be ghosted if using Nemesis");
params.addParam<std::vector<BoundaryName>>(
"ghosted_boundaries", {}, "Boundaries to be ghosted if using Nemesis");
params.addParam<std::vector<Real>>("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 "
Expand Down

0 comments on commit f338799

Please sign in to comment.