From 2ed3a742e702b10dc5441136f6119cc3a1d3aee4 Mon Sep 17 00:00:00 2001 From: Elias Pipping <elias.pipping@fu-berlin.de> Date: Fri, 11 Nov 2011 18:14:51 +0100 Subject: [PATCH] Use parametertree --- src/one-body-sample.cc | 30 ++++++++++++++++++------------ src/one-body-sample.parset | 16 ++++++++++++++++ 2 files changed, 34 insertions(+), 12 deletions(-) create mode 100644 src/one-body-sample.parset diff --git a/src/one-body-sample.cc b/src/one-body-sample.cc index 30fbeb28..73d5237a 100644 --- a/src/one-body-sample.cc +++ b/src/one-body-sample.cc @@ -13,6 +13,8 @@ #include <dune/common/exceptions.hh> #include <dune/common/fmatrix.hh> #include <dune/common/fvector.hh> +#include <dune/common/parametertree.hh> +#include <dune/common/parametertreeparser.hh> #include <dune/common/shared_ptr.hh> #include <dune/common/stdstreams.hh> #include <dune/grid/common/mcmgmapper.hh> @@ -126,21 +128,26 @@ void assemble_frictional( true); // whether to resize the output vector and zero all of its entries } -int main() { +int main(int argc, char *argv[]) { try { + Dune::ParameterTree parset; + Dune::ParameterTreeParser::readINITree("../../src/one-body-sample.parset", + parset); + Dune::ParameterTreeParser::readOptions(argc, argv, parset); + typedef Dune::FieldVector<double, dim> SmallVector; typedef Dune::FieldMatrix<double, dim, dim> SmallMatrix; typedef Dune::BCRSMatrix<SmallMatrix> OperatorType; typedef Dune::BlockVector<SmallVector> VectorType; typedef Dune::BlockVector<Dune::FieldVector<double, 1>> CellVectorType; - // FIXME: Random values - size_t const runs = 1000; - double const E = 1e4; - double const nu = 0.3; - int const refinements = 5; - size_t const solver_maxIterations = 100000; - double const solver_tolerance = 1e-6; + auto const runs = parset.get<size_t>("timesteps"); + auto const E = parset.get<double>("body.E"); + auto const nu = parset.get<double>("body.nu"); + auto const refinements = parset.get<int>("grid.refinements"); + auto const solver_maxIterations = + parset.get<size_t>("solver.maxiterations"); + auto const solver_tolerance = parset.get<double>("solver.tolerance"); // {{{ Set up grid typedef Dune::YaspGrid<dim> GridType; @@ -211,16 +218,15 @@ int main() { stiffnessMatrix.umv(u3, b3); // {{{ Assemble terms for the nonlinearity - // TODO: Random value std::vector<double> normalStress; normalStress.resize(grid.size(grid.maxLevel(), dim)); - std::fill(normalStress.begin(), normalStress.end(), 0.1); + std::fill(normalStress.begin(), normalStress.end(), + parset.get<double>("boundary.normalstress")); - // TODO: Random value std::vector<double> coefficientOfFriction; coefficientOfFriction.resize(grid.size(grid.maxLevel(), dim)); std::fill(coefficientOfFriction.begin(), coefficientOfFriction.end(), - 0.75); + parset.get<double>("boundary.mu")); Dune::GlobalNonlinearity<dim, Dune::LinearFunction> myGlobalNonlinearity( coefficientOfFriction, normalStress, nodalIntegrals); diff --git a/src/one-body-sample.parset b/src/one-body-sample.parset new file mode 100644 index 00000000..ef20f2b1 --- /dev/null +++ b/src/one-body-sample.parset @@ -0,0 +1,16 @@ +timesteps = 1000 + +[grid] +refinements = 5 + +[body] +E = 1e4 +nu = 0.3 + +[solver] +maxiterations = 100000 +tolerance = 1e-6 + +[boundary] +normalstress = 0.1 +mu = 0.75 -- GitLab