Skip to content

Commit

Permalink
Enable initializer lists as defaults (idaholab#24455)
Browse files Browse the repository at this point in the history
  • Loading branch information
dschwen committed Aug 29, 2023
1 parent 9b9bf58 commit 5466934
Show file tree
Hide file tree
Showing 2 changed files with 21 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
16 changes: 10 additions & 6 deletions framework/src/actions/SetupMeshAction.C
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,15 @@ SetupMeshAction::validParams()
"mesh. Note: This is NOT needed if you are reading "
"an actual first order mesh.");

params.addParam<std::vector<SubdomainID>>("block_id", "IDs of the block id/name pairs");
params.addParam<std::vector<SubdomainID>>("block_id", {}, "IDs of the block id/name pairs");
params.addParam<std::vector<SubdomainName>>(
"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<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 @@ -62,6 +64,7 @@ SetupMeshAction::validParams()

params.addParam<std::vector<std::string>>(
"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 "
Expand All @@ -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<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 "
"boxes by. ie if you are running a 3D problem you might set "
Expand Down

0 comments on commit 5466934

Please sign in to comment.