Skip to content

Commit

Permalink
Merge pull request idaholab#25927 from GiudGiud/PR_misc
Browse files Browse the repository at this point in the history
Miscellaneous items from the Physics PR
  • Loading branch information
GiudGiud authored Nov 9, 2023
2 parents b0a428c + 31f6151 commit 81c558a
Show file tree
Hide file tree
Showing 7 changed files with 47 additions and 2 deletions.
5 changes: 5 additions & 0 deletions framework/include/utils/InputParameters.h
Original file line number Diff line number Diff line change
Expand Up @@ -788,6 +788,11 @@ class InputParameters : public Parameters
std::vector<R2>>::type>
std::vector<std::pair<R1, R2>> get(const std::string & param1, const std::string & param2) const;

/**
* @returns list of all parameters
*/
std::set<std::string> getParametersList() const;

/**
* Return list of controllable parameters
*/
Expand Down
1 change: 1 addition & 0 deletions framework/include/utils/MultiMooseEnum.h
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ class MultiMooseEnum : public MooseEnumBase
void push_back(const std::string & names);
void push_back(const std::vector<std::string> & names);
void push_back(const std::set<std::string> & names);
void push_back(const MultiMooseEnum & other_enum);
///@}

/**
Expand Down
9 changes: 9 additions & 0 deletions framework/src/utils/InputParameters.C
Original file line number Diff line number Diff line change
Expand Up @@ -1251,6 +1251,15 @@ InputParameters::getGroupParameters(const std::string & group) const
return names;
}

std::set<std::string>
InputParameters::getParametersList() const
{
std::set<std::string> param_set;
for (auto it = _params.begin(); it != _params.end(); ++it)
param_set.emplace(it->first);
return param_set;
}

std::set<std::string>
InputParameters::getControllableParameters() const
{
Expand Down
6 changes: 6 additions & 0 deletions framework/src/utils/MultiMooseEnum.C
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,12 @@ MultiMooseEnum::push_back(const std::set<std::string> & names)
assign(names.begin(), names.end(), true);
}

void
MultiMooseEnum::push_back(const MultiMooseEnum & other_enum)
{
assign(other_enum.begin(), other_enum.end(), true);
}

const std::string &
MultiMooseEnum::operator[](unsigned int i) const
{
Expand Down
6 changes: 4 additions & 2 deletions framework/src/variables/MooseVariableFE.C
Original file line number Diff line number Diff line change
Expand Up @@ -966,7 +966,8 @@ MooseVariableFE<OutputType>::evaluateOnElement(const ElemQpArg & elem_qp,
const bool cache_eligible) const
{
mooseAssert(this->hasBlocks(elem_qp.elem->subdomain_id()),
"This variable doesn't exist in the requested block!");
"Variable " + this->name() + " doesn't exist on block " +
std::to_string(elem_qp.elem->subdomain_id()));

const Elem * const elem = elem_qp.elem;
if (!cache_eligible || (elem != _current_elem_qp_functor_elem))
Expand Down Expand Up @@ -1167,7 +1168,8 @@ MooseVariableFE<OutputType>::evaluateOnElementSide(const ElemSideQpArg & elem_si
const bool cache_eligible) const
{
mooseAssert(this->hasBlocks(elem_side_qp.elem->subdomain_id()),
"This variable doesn't exist in the requested block!");
"Variable " + this->name() + " doesn't exist on block " +
std::to_string(elem_side_qp.elem->subdomain_id()));

const Elem * const elem = elem_side_qp.elem;
const auto side = elem_side_qp.side;
Expand Down
12 changes: 12 additions & 0 deletions unit/src/InputParametersTest.C
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,18 @@ TEST(InputParameters, getControllablePairs)
}
}

TEST(InputParameters, getParamList)
{
std::vector<std::string> num_words{"zero", "one", "two", "three"};

InputParameters p = emptyInputParameters();
p.addParam<std::vector<std::string>>("first", num_words, "");
p.addParam<std::vector<int>>("second", std::vector<int>{0, 1, 2, 3}, "");

std::set<std::string> param_list({"first", "second"});
EXPECT_EQ(p.getParametersList(), param_list);
}

TEST(InputParameters, transferParameters)
{
// Add parameters of various types to p1
Expand Down
10 changes: 10 additions & 0 deletions unit/src/MooseEnumTest.C
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,16 @@ TEST(MooseEnum, multiTestOne)
EXPECT_EQ(mme.contains("three"), true);
EXPECT_EQ(mme.contains("four"), false);

// Insert another valid multi-enum
mme.clear();
mme = "one four";
MultiMooseEnum mme2("one two three four", "three");
mme.push_back(mme2);
EXPECT_EQ(mme.contains("one"), true);
EXPECT_EQ(mme.contains("two"), false);
EXPECT_EQ(mme.contains("three"), true);
EXPECT_EQ(mme.contains("four"), true);

mme.clear();
mme = "one four";
EXPECT_EQ(mme.contains("one"), true);
Expand Down

0 comments on commit 81c558a

Please sign in to comment.