Skip to content
Snippets Groups Projects
Commit ece71cee authored by Andreas Lauser's avatar Andreas Lauser
Browse files

add a function which prints which parameters came from where

just call Dumux::Parameters::print<TypeTag>() after the end of the
simulation and you will get a full report.

git-svn-id: svn://svn.iws.uni-stuttgart.de/DUMUX/dumux/trunk@6484 2fb0f335-1f38-0410-981e-8018bf24f1b0
parent b043ccc9
No related branches found
No related tags found
No related merge requests found
......@@ -86,36 +86,24 @@ SET_PROP(NumericModel, ParameterTree)
static Dune::ParameterTree &tree()
{
if (initFinished_) {
DUNE_THROW(Dune::InvalidStateException,
"The ParameterTree cannot be accessed after "
"the initialization phase of the simulation!");
}
return parameterTree_;
static Dune::ParameterTree obj_;
return obj_;
};
static void initFinished()
{ initFinished_ = true; }
static Dune::ParameterTree &compileTimeParams()
{
static Dune::ParameterTree obj_;
return obj_;
};
private:
static Dune::ParameterTree parameterTree_;
static bool initFinished_;
static Dune::ParameterTree &runTimeParams()
{
static Dune::ParameterTree obj_;
return obj_;
};
};
// allocate space for the static parameter tree object
template<class TypeTag>
Dune::ParameterTree
Property<TypeTag,
TTAG(NumericModel),
PTAG(ParameterTree)>::parameterTree_;
template<class TypeTag>
bool Property<TypeTag,
TTAG(NumericModel),
PTAG(ParameterTree)>::initFinished_ = false;
// use the global group as default for the model's parameter group
SET_PROP(NumericModel, ModelParameterGroup)
{ static const char *value() { return ""; }; };
......
......@@ -27,11 +27,12 @@
#ifndef DUMUX_PARAMETERS_HH
#define DUMUX_PARAMETERS_HH
#include "propertysystem.hh"
#include <dune/common/parametertree.hh>
#include <sstream>
#include "propertysystem.hh"
#include <list>
/*!
* \brief Retrieve a runtime parameter which _does_ have a default value taken from
......@@ -69,6 +70,47 @@ NEW_PROP_TAG(ModelParameterGroup);
} // namespace Properties
namespace Parameters {
template <class TypeTag>
void print(std::ostream &os = std::cout)
{
typedef typename GET_PROP(TypeTag, PTAG(ParameterTree)) Params;
const Dune::ParameterTree &tree = Params::tree();
const Dune::ParameterTree &rt = Params::runTimeParams();
const Dune::ParameterTree &ct = Params::compileTimeParams();
os << "###############################\n";
os << "# Run-time parameters:\n";
os << "###############################\n";
rt.report(os);
os << "###############################\n";
os << "# Compile-time parameters:\n";
os << "###############################\n";
ct.report(os);
std::list<std::string> unusedParams;
int n = 0;
const Dune::ParameterTree::KeyVector &keys =
Params::tree().getValueKeys();
for (int i = 0; i < keys.size(); ++i) {
// check wheter the key was accessed
if (rt.hasKey(keys[i]))
continue;
++n;
unusedParams.push_back(keys[i]);
}
if (unusedParams.size() > 0) {
os << "###############################\n";
os << "# UNUSED PARAMETERS:\n";
os << "###############################\n";
std::list<std::string>::const_iterator it = unusedParams.begin();
for (; it != unusedParams.end(); ++it) {
os << *it << " = \"" << tree.get(*it, "") << "\"\n";
};
}
};
const char *getString_(const char *foo = 0)
{ return foo; }
......@@ -154,8 +196,8 @@ private:
// remember whether the parameter was taken from the parameter
// tree or the default from the property system was taken.
Dune::ParameterTree &rt = Params::tree().sub("RunTimeParams");
Dune::ParameterTree &ct = Params::tree().sub("DefaultParams");
Dune::ParameterTree &rt = Params::runTimeParams();
Dune::ParameterTree &ct = Params::compileTimeParams();
if (Params::tree().hasKey(finalName)) {
rt[finalName] = Params::tree()[finalName];
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment