Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initializer list #25341

Merged
merged 1 commit into from
Aug 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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