diff --git a/src/assemblers.cc b/src/assemblers.cc index f8485a49c7e98338f0625d676451230c168d7944..972c5512491b2e00e34efcdc283bead6def13e46 100644 --- a/src/assemblers.cc +++ b/src/assemblers.cc @@ -12,6 +12,10 @@ #include "assemblers.hh" +#include "enums.hh" +#include "enum_parser.cc" +#include "enum_model.cc" + // Assembles Neumann boundary term in f template <class GridType, class GridView, class LocalVectorType, class FEBasis> void assemble_neumann(GridView const &gridView, FEBasis const &feBasis, @@ -67,34 +71,32 @@ assemble_nonlinearity( auto normalStress = Dune::make_shared<SingletonVectorType>(size); *normalStress = parset.get<double>("normalstress"); - std::string const friction_model = parset.get<std::string>("model"); - if (friction_model == std::string("Ruina")) { - auto a = Dune::make_shared<SingletonVectorType>(size); - *a = parset.get<double>("ruina.a"); - - auto eta = Dune::make_shared<SingletonVectorType>(size); - *eta = parset.get<double>("eta"); - - auto b = Dune::make_shared<SingletonVectorType>(size); - *b = parset.get<double>("ruina.b"); - - auto L = Dune::make_shared<SingletonVectorType>(size); - *L = parset.get<double>("ruina.L"); - - return Dune::make_shared< - Dune::GlobalRuinaNonlinearity<VectorType, MatrixType> const>( - nodalIntegrals, a, mu, eta, normalStress, b, state, L, h); - } else if (friction_model == std::string("Laursen")) { - return - // TODO: take state and h into account - // FIXME: We should be using a quadratic rather than a linear function - // here! - Dune::make_shared< - Dune::GlobalLaursenNonlinearity<Dune::LinearFunction, VectorType, - MatrixType> const>(mu, normalStress, - nodalIntegrals); - } else { - assert(false); + switch (parset.get<Config::model>("model")) { + case Config::Exponential: { + auto a = Dune::make_shared<SingletonVectorType>(size); + *a = parset.get<double>("ruina.a"); + + auto eta = Dune::make_shared<SingletonVectorType>(size); + *eta = parset.get<double>("eta"); + + auto b = Dune::make_shared<SingletonVectorType>(size); + *b = parset.get<double>("ruina.b"); + + auto L = Dune::make_shared<SingletonVectorType>(size); + *L = parset.get<double>("ruina.L"); + + return Dune::make_shared< + Dune::GlobalRuinaNonlinearity<VectorType, MatrixType> const>( + nodalIntegrals, a, mu, eta, normalStress, b, state, L, h); + } + case Config::Laursen: + return + // TODO: take state and h into account + // FIXME: We should be using a quadratic rather than a linear function + // here! + Dune::make_shared<Dune::GlobalLaursenNonlinearity< + Dune::LinearFunction, VectorType, + MatrixType> const>(mu, normalStress, nodalIntegrals); } } diff --git a/src/enum_model.cc b/src/enum_model.cc new file mode 100644 index 0000000000000000000000000000000000000000..1fd1bc1d525bc6ef678823c00487dfb66a2968bf --- /dev/null +++ b/src/enum_model.cc @@ -0,0 +1,13 @@ +#include <dune/common/exceptions.hh> + +template <> struct StringToEnum<Config::model> { + static Config::model convert(std::string const &s) { + if (s == "Laursen") + return Config::Laursen; + + if (s == "Exponential") + return Config::Exponential; + + DUNE_THROW(Dune::Exception, "failed to parse enum"); + } +}; diff --git a/src/enums.hh b/src/enums.hh index ce43a1f05d5575f2041c770b911c35373fa862ec..d182db67c7c5e6433fa61dbe741192747b31fdd4 100644 --- a/src/enums.hh +++ b/src/enums.hh @@ -1,4 +1,8 @@ struct Config { + enum model { + Laursen, + Exponential + }; enum state_model { Dieterich, Ruina diff --git a/src/one-body-sample.parset b/src/one-body-sample.parset index 58fa7b7968e0fbe8053b492eca340e172e5447c7..1e89999d0b571c28d8d9418228fce2e6c32fb4cb 100644 --- a/src/one-body-sample.parset +++ b/src/one-body-sample.parset @@ -68,7 +68,7 @@ normalstress = 0.1 # laursen depends a lot more on this # http://earthquake.usgs.gov/research/physics/lab/prediction.pdf mu = 0.5 eta = 1 -model = Ruina +model = Exponential [boundary.friction.state] evolve = true