Commit 45888d7d authored by Santiago Ospina's avatar Santiago Ospina

Create a function that configures the ini file according to the simulation.

Signed-off-by: Santiago Ospina De Los Ríos's avatarSantiago Ospina <santiago.ospina@iup.uni-heidelberg.de>
parent 402041e4
......@@ -30,4 +30,18 @@ endif()
scrape_parameters(${PROJECT_SOURCE_DIR}/dune/dorie ${CMAKE_CURRENT_SOURCE_DIR}/richards-parameters.xml ${CMAKE_CURRENT_SOURCE_DIR}/parameters.css "richards-config.ini;richards-parameters.html;richards-parameters.rst" PARSCRAPE_RETURN)
if (NOT ${PARSCRAPE_RETURN} EQUAL 0)
message(FATAL_ERROR "Parameter scraper failed. DORiE can not be built.")
endif()
\ No newline at end of file
endif()
# Gather different configuration files
file(WRITE config.ini.in "####### Common parameters #######\n\n")
file(READ ${CMAKE_CURRENT_BINARY_DIR}/common-config.ini CONTENTS)
file(APPEND config.ini.in "${CONTENTS}\n\n")
file(APPEND config.ini.in "####### Richards parameters #######\n\n")
file(READ ${CMAKE_CURRENT_BINARY_DIR}/richards-config.ini CONTENTS)
file(APPEND config.ini.in "${CONTENTS}")
configure_file(config.ini.in ${CMAKE_CURRENT_BINARY_DIR}/config.ini COPYONLY)
......@@ -87,6 +87,13 @@ adding an empty line, make text **bold** or ``monospaced``.
<suggestion> false </suggestion>
</parameter>
<parameter name="policy">
<definition> Defines the target policy to do adaptive grid refinement (h-adaptivity).
Only one policy available at the moment. </definition>
<values> waterFlux </values>
<suggestion> waterFlux </suggestion>
</parameter>
<parameter name="maxLevel">
<definition> The maximum refinement level kept in the grid. This is a useful
tool to prevent over-refinement. If this value is high, the grid can
......
......@@ -105,10 +105,8 @@ int main(int argc, char** argv)
sleep(5);
}
// move grid extensions into richards category (needed for reading parameters)
inifile["richards.grid.extensions"] = inifile["grid.extensions"];
// configure a global verbose level
inifile["output.verbose"] = inifile["richards.output.verbose"];
Dune::Dorie::Setup::inifile(inifile);
// extract richards configuration
Dune::ParameterTree richards_config = inifile.sub("richards");
......
......@@ -7,6 +7,7 @@
#include <dune/common/fvector.hh>
#include <dune/common/fmatrix.hh>
#include <dune/common/parametertree.hh>
#include <dune/geometry/type.hh>
......@@ -229,6 +230,33 @@ struct BaseTraits
};
/**
* @brief Helper object to configurate input files
*/
struct Setup
{
/*------------------------------------------------------------------------*//**
* @brief Set up the configuration keys for the simulations
*
* @param ini The inifile
*/
static void inifile(Dune::ParameterTree& ini)
{
// move grid extensions into richards category (needed for reading parameters)
ini["richards.grid.extensions"] = ini["grid.extensions"];
// configure a global verbose level
ini["output.verbose"] = ini["richards.output.verbose"];
if (ini.get<std::string>("adaptivity.policy") == "waterFlux")
// copy adaptivity keywords into richards category
ini.sub("richards.adaptivity") = ini.sub("adaptivity");
else
DUNE_THROW(NotImplemented, "Not known adaptativity policy ("
<< ini.get<std::string>("adaptivity.policy") << ")!");
}
};
}
}
......
......@@ -56,6 +56,12 @@ int main (int argc, char** argv)
Dune::ParameterTreeParser ptreeparser;
ptreeparser.readINITree(inifilename,inifile);
Dune::Dorie::Setup::inifile(inifile);
// extract richards configuration
Dune::ParameterTree richards_config = inifile.sub("richards");
// run test
// double result {0.0};
const auto adaptive = inifile.get<bool>("adaptivity.useAdaptivity");
......@@ -64,14 +70,14 @@ int main (int argc, char** argv)
if (adaptive) {
using TestSim = Dune::Dorie::ParameterizationTest<CubeAdaptive<2, 1>>;
auto grid = Dune::Dorie::build_grid_cube<Dune::UGGrid<2>>(inifile, helper);
TestSim sim(helper, grid, inifile);
TestSim sim(helper, grid, richards_config);
sim.test_new_parameters();
sim.test_parameter_manipulation();
}
else {
using TestSim = Dune::Dorie::ParameterizationTest<Cube<2, 1>>;
auto grid = Dune::Dorie::build_grid_cube<Dune::YaspGrid<2>>(inifile, helper);
TestSim sim(helper, grid, inifile);
TestSim sim(helper, grid, richards_config);
sim.test_new_parameters();
sim.test_parameter_manipulation();
}
......
......@@ -50,6 +50,10 @@ int main (int argc, char** argv)
Dune::ParameterTreeParser ptreeparser;
ptreeparser.readINITree(inifilename,inifile);
Dune::Dorie::Setup::inifile(inifile);
// extract richards configuration
Dune::ParameterTree richards_config = inifile.sub("richards");
const double limit = inifile.get<double>("limit");
// run test
......@@ -60,13 +64,13 @@ int main (int argc, char** argv)
if (grid_type == "rectangular") {
using TestSim = Dune::Dorie::TestSimulation<CubeAdaptive<2, 1>>;
auto grid = Dune::Dorie::build_grid_cube<Dune::UGGrid<2>>(inifile, helper);
TestSim sim(helper, grid, inifile);
TestSim sim(helper, grid, richards_config);
result = sim.run_test();
}
else if (grid_type == "simplex") {
using TestSim = Dune::Dorie::TestSimulation<SimplexAdaptive<2, 1>>;
auto grid = Dune::Dorie::build_grid_gmsh<Dune::UGGrid<2>>(inifile, helper);
TestSim sim(helper, grid, inifile);
TestSim sim(helper, grid, richards_config);
result = sim.run_test();
}
}
......@@ -74,13 +78,13 @@ int main (int argc, char** argv)
if (grid_type == "rectangular") {
using TestSim = Dune::Dorie::TestSimulation<Cube<2, 1>>;
auto grid = Dune::Dorie::build_grid_cube<Dune::YaspGrid<2>>(inifile, helper);
TestSim sim(helper, grid, inifile);
TestSim sim(helper, grid, richards_config);
result = sim.run_test();
}
else if (grid_type == "simplex") {
using TestSim = Dune::Dorie::TestSimulation<Simplex<2, 1>>;
auto grid = Dune::Dorie::build_grid_gmsh<Dune::UGGrid<2>>(inifile, helper);
TestSim sim(helper, grid, inifile);
TestSim sim(helper, grid, richards_config);
result = sim.run_test();
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment