Skip to content
Snippets Groups Projects
Commit 8f72fa94 authored by Elias Pipping's avatar Elias Pipping Committed by Elias Pipping
Browse files

Introduce enum for scheme; Give each a constructor

parent 445acbcb
No related branches found
No related tags found
No related merge requests found
#include <dune/common/exceptions.hh>
template <> struct StringToEnum<Config::scheme> {
static Config::scheme convert(std::string const &s) {
if (s == "implicitTwoStep")
return Config::ImplicitTwoStep;
if (s == "implicitEuler")
return Config::ImplicitEuler;
DUNE_THROW(Dune::Exception, "failed to parse enum");
}
};
...@@ -10,5 +10,9 @@ struct Config { ...@@ -10,5 +10,9 @@ struct Config {
Dieterich, Dieterich,
Ruina Ruina
}; };
enum scheme {
ImplicitTwoStep,
ImplicitEuler
};
}; };
#endif #endif
...@@ -71,6 +71,7 @@ ...@@ -71,6 +71,7 @@
#include "enums.hh" #include "enums.hh"
#include "enum_parser.cc" #include "enum_parser.cc"
#include "enum_state_model.cc" #include "enum_state_model.cc"
#include "enum_scheme.cc"
#include "timestepping.cc" #include "timestepping.cc"
...@@ -259,22 +260,31 @@ int main(int argc, char *argv[]) { ...@@ -259,22 +260,31 @@ int main(int argc, char *argv[]) {
VectorType *u_old_old_ptr = (run == 1) ? nullptr : &u_old_old; VectorType *u_old_old_ptr = (run == 1) ? nullptr : &u_old_old;
typedef TimeSteppingScheme<VectorType, MatrixType, typedef TimeSteppingScheme<VectorType, MatrixType,
decltype(dirichletFunction), dim> TS; decltype(dirichletFunction),
dim> TimeSteppingSchemeType;
Dune::shared_ptr<TimeSteppingSchemeType> timeSteppingScheme;
{
typedef ImplicitEuler<VectorType, MatrixType, typedef ImplicitEuler<VectorType, MatrixType,
decltype(dirichletFunction), dim> IE; decltype(dirichletFunction), dim> IE;
typedef ImplicitTwoStep<VectorType, MatrixType, typedef ImplicitTwoStep<VectorType, MatrixType,
decltype(dirichletFunction), dim> ITS; decltype(dirichletFunction), dim> ITS;
Dune::shared_ptr<TS> timeSteppingScheme; switch (parset.get<Config::scheme>("timeSteppingScheme")) {
if (run == 1 || !parset.get<bool>("implicitTwoStep")) case Config::ImplicitTwoStep:
timeSteppingScheme = if (run != 1) {
Dune::make_shared<IE>(ell, stiffnessMatrix, u_old, u_old_old_ptr, timeSteppingScheme = Dune::make_shared<ITS>(
ignoreNodes, dirichletFunction, time, tau); ell, stiffnessMatrix, u_old, u_old_old_ptr, ignoreNodes,
else dirichletFunction, time, tau);
timeSteppingScheme = break;
Dune::make_shared<ITS>(ell, stiffnessMatrix, u_old, u_old_old_ptr, }
ignoreNodes, dirichletFunction, time, tau); // Fall through
case Config::ImplicitEuler:
timeSteppingScheme = Dune::make_shared<IE>(
ell, stiffnessMatrix, u_old, u_old_old_ptr, ignoreNodes,
dirichletFunction, time, tau);
break;
}
}
timeSteppingScheme->setup(problem_rhs, problem_iterate, problem_A); timeSteppingScheme->setup(problem_rhs, problem_iterate, problem_A);
VectorType u_saved = u_old; VectorType u_saved = u_old;
......
...@@ -13,7 +13,7 @@ printVelocitySteppingComparison = false ...@@ -13,7 +13,7 @@ printVelocitySteppingComparison = false
enable_timer = false enable_timer = false
implicitTwoStep = false timeSteppingScheme = implicitEuler
[grid] [grid]
refinements = 4 refinements = 4
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment