From 9128001f7bbeecf5f9ef2b54c219c485015f198c Mon Sep 17 00:00:00 2001 From: Lukas Riedel Date: Wed, 14 Feb 2018 17:48:42 +0100 Subject: [PATCH] Add CMake option to control DG method with the config file - add CMake option 'EXPERIMENTAL_DG_FEATURES' - add cpp definition EXPERIMENTAL_DG_FEATURES - add optional config keys 'dg.method' and 'dg.upwinding' --- CMakeLists.txt | 8 ++++++ dune/dorie/interface/simulation.cc | 7 ++++++ dune/dorie/interface/simulation.hh | 40 ++++++++++++++++++++++++++++++ 3 files changed, 55 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8fd854b7..087d9bad 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -12,6 +12,14 @@ if(CMAKE_BUILD_TYPE_UPPER MATCHES DEBUG) endif() set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Wall -Werror") +# option to change DG scheme via config file +option(EXPERIMENTAL_DG_FEATURES + "Set DG method and upwinding scheme in config file" + OFF) +if(EXPERIMENTAL_DG_FEATURES) + add_definitions(-DEXPERIMENTAL_DG_FEATURES) +endif() + # if(NOT (dune-common_DIR OR dune-common_ROOT OR "${CMAKE_PREFIX_PATH}" MATCHES ".*dune-common.*")) diff --git a/dune/dorie/interface/simulation.cc b/dune/dorie/interface/simulation.cc index d207c8e0..f98dad44 100644 --- a/dune/dorie/interface/simulation.cc +++ b/dune/dorie/interface/simulation.cc @@ -31,7 +31,14 @@ Simulation::Simulation (Dune::MPIHelper& _helper, std::shared_ptr finitial = std::make_unique(inifile,*param,gv); // --- Local Operators --- +#ifdef EXPERIMENTAL_DG_FEATURES + const auto settings = read_experimental_operator_settings(inifile); + slop = std::make_unique(inifile, *param, gv, *fboundary, *fsource, + settings.first, settings.second); +#else slop = std::make_unique(inifile,*param,gv,*fboundary,*fsource); +#endif // EXPERIMENTAL_DG_FEATURES + tlop = std::make_unique(inifile,*param,gv); controller = std::make_unique(inifile,*fboundary,helper); diff --git a/dune/dorie/interface/simulation.hh b/dune/dorie/interface/simulation.hh index 6683164d..11b6f313 100644 --- a/dune/dorie/interface/simulation.hh +++ b/dune/dorie/interface/simulation.hh @@ -127,6 +127,46 @@ protected: const int verbose; +private: + + /// Read experimental operator settings from a parameter file + /* \return Pair of RichardsDGMethod and RichardsDGUpwinding + * to be inserted into the local operator constructor. + */ + auto read_experimental_operator_settings (const Dune::ParameterTree& inifile) + -> std::pair + { + using namespace Operator; + RichardsDGMethod::Type method; + RichardsDGUpwinding::Type upwinding; + + const auto method_str = inifile.get("dg.method"); + if (method_str == "SIPG") + method = RichardsDGMethod::SIPG; + else if (method_str == "NIPG") + method = RichardsDGMethod::NIPG; + else if (method_str == "OOB") + method = RichardsDGMethod::OOB; + else if (method_str == "IIP") + method = RichardsDGMethod::IIP; + else + DUNE_THROW(Dune::IOError, "Unknown DG method '" + method_str + "'!"); + + const auto upwinding_str = inifile.get("dg.upwinding"); + if (upwinding_str == "none") + upwinding = RichardsDGUpwinding::none; + else if (upwinding_str == "semiUpwind") + upwinding = RichardsDGUpwinding::semiUpwind; + else if (upwinding_str == "fullUpwind") + upwinding = RichardsDGUpwinding::fullUpwind; + else + DUNE_THROW(Dune::IOError, "Unknown upwdinding '" + upwinding_str + "'!"); + + return std::make_pair(method, upwinding); + } + + public: /// Execute the simulation until tEnd is reached. -- GitLab