12#ifndef DUMUX_PARAMETERS_HH
13#define DUMUX_PARAMETERS_HH
18#include <unordered_map>
22#include <dune/common/parametertree.hh>
36 using DefaultParams = std::function<void (Dune::ParameterTree&)>;
37 using Usage = std::function<void (
const char *,
const std::string &)>;
42 static void init(
int argc,
char **argv,
const Usage& usage);
45 static void init(
int argc,
char **argv,
46 std::string parameterFileName,
47 const Usage& usage = [](
const char *,
const std::string &){});
50 static void init(
int argc,
char **argv,
51 const DefaultParams& defaultParams,
70 static void init(
int argc,
char **argv,
71 const DefaultParams& defaultParams = [] (Dune::ParameterTree&) {},
72 std::string parameterFileName =
"",
73 const Usage& usage = [](
const char *,
const std::string &){});
82 static void init(
const DefaultParams& params = [] (Dune::ParameterTree&) {},
83 const DefaultParams& defaultParams = [] (Dune::ParameterTree&) {});
96 static void init(
const std::string& parameterFileName,
97 const DefaultParams& params = [] (Dune::ParameterTree&) {},
98 bool inputFileOverwritesParams =
true,
99 const DefaultParams& defaultParams = [] (Dune::ParameterTree&) {});
116 static Dune::ParameterTree& paramTree_();
119 static Dune::ParameterTree& defaultParamTree_();
123 static void applyGlobalDefaults_(Dune::ParameterTree& params);
126 static void mergeTree_(Dune::ParameterTree& target,
const Dune::ParameterTree& source,
bool overwrite =
true);
129 static void mergeTreeImpl_(Dune::ParameterTree& target,
const Dune::ParameterTree& source,
bool overwrite,
const std::string& group);
138template<
typename T = std::string,
typename... Args>
148template<
typename T = std::string,
typename... Args>
173inline std::vector<std::string>
getParamSubGroups(
const std::string& subGroupName,
const std::string& paramGroup)
A parameter tree that logs which parameters have been used.
Definition: loggingparametertree.hh:31
std::vector< std::string > getSubGroups(const std::string &subGroupName, std::string groupPrefix) const
obtain a vector of all full group names for a specified subgroup name
Definition: loggingparametertree.hh:121
bool hasKeyInGroup(const std::string &key, const std::string &groupPrefix) const
test for key in group
Definition: loggingparametertree.hh:78
bool hasKey(const std::string &key) const
test for key
Definition: loggingparametertree.hh:60
Parameter class managing runtime input parameters.
Definition: parameters.hh:34
static const LoggingParameterTree & getTree()
Get the parameter tree.
Definition: parameters.cc:211
static void print()
prints all used and unused parameters
Definition: parameters.cc:164
static void init(int argc, char **argv, const Usage &usage)
Initialize the parameter tree singletons.
Definition: parameters.cc:33
static Dune::ParameterTree parseCommandLine(int argc, char **argv)
Parse command line arguments into a parameter tree.
Definition: parameters.cc:170
Function printing a default usage message.
std::vector< std::string > getParamSubGroups(const std::string &subGroupName, const std::string ¶mGroup)
Get a list of sub groups from the parameter tree sorted by relevance.
Definition: parameters.hh:173
T getParamFromGroup(Args &&... args)
A free function to get a parameter from the parameter tree singleton with a model group.
Definition: parameters.hh:149
bool hasParamInGroup(const std::string ¶mGroup, const std::string ¶m)
Check whether a key exists in the parameter tree with a model group prefix.
Definition: parameters.hh:165
bool hasParam(const std::string ¶m)
Check whether a key exists in the parameter tree.
Definition: parameters.hh:157
T getParam(Args &&... args)
A free function to get a parameter from the parameter tree singleton.
Definition: parameters.hh:139
A parameter tree that logs which parameters have been used.