Skip to content

Commit

Permalink
GRParmParse: Add default values to the ParmParse table
Browse files Browse the repository at this point in the history
When a GRParmParse::load() overload is called and a default value is
used as the parameter is not present in the ParmParse table, this
default value will now be added to the ParmParse table.
  • Loading branch information
mirenradia committed Jul 18, 2024
1 parent 4efe7ce commit 1fad2da
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions Source/utils/GRParmParse.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,7 @@ class GRParmParse : public amrex::ParmParse
/// Loads a value from the parameter file, if the value isn't defined it
/// sets to the supplied default
template <class data_t>
void load(const char *name, data_t &parameter,
const data_t default_value) const
void load(const char *name, data_t &parameter, const data_t default_value)
{
if (contains(name))
{
Expand All @@ -95,6 +94,8 @@ class GRParmParse : public amrex::ParmParse
else
{
parameter = default_value;
// Add the default value to the ParmParse table
this->queryAdd(name, parameter);
default_message(name, default_value);
}
}
Expand All @@ -103,7 +104,7 @@ class GRParmParse : public amrex::ParmParse
/// vector isn't defined, it is set to the supplied default
template <class data_t>
void load(const char *name, std::vector<data_t> &vector, const int num_comp,
const std::vector<data_t> &default_vector) const
const std::vector<data_t> &default_vector)
{
if (contains(name))
{
Expand All @@ -112,6 +113,8 @@ class GRParmParse : public amrex::ParmParse
else
{
vector = default_vector;
// Add the default value to the ParmParse table
this->queryAdd(name, vector);
default_message(name, default_vector);
}
}
Expand All @@ -120,7 +123,7 @@ class GRParmParse : public amrex::ParmParse
/// vector isn't defined it sets all components to the supplied default
template <class data_t>
void load(const char *name, std::vector<data_t> &vector, const int num_comp,
const data_t default_value) const
const data_t default_value)
{
load(name, vector, num_comp,
std::vector<data_t>(num_comp, default_value));
Expand Down

0 comments on commit 1fad2da

Please sign in to comment.