From 935590db8bac81c61b2e7971c462d31782c9ca45 Mon Sep 17 00:00:00 2001 From: Elias Pipping <elias.pipping@fu-berlin.de> Date: Wed, 5 Feb 2014 11:58:08 +0100 Subject: [PATCH] [Cleanup] Store Dirichlet values --- src/timestepping/backward_euler.cc | 10 +++------- src/timestepping/backward_euler.hh | 1 + src/timestepping/newmark.cc | 10 +++------- src/timestepping/newmark.hh | 1 + 4 files changed, 8 insertions(+), 14 deletions(-) diff --git a/src/timestepping/backward_euler.cc b/src/timestepping/backward_euler.cc index 6e14784a..6d5f6bed 100644 --- a/src/timestepping/backward_euler.cc +++ b/src/timestepping/backward_euler.cc @@ -23,7 +23,7 @@ void BackwardEuler<Vector, Matrix, Function, dim>::setup( Vector const &ell, double _tau, double relativeTime, Vector &rhs, Vector &iterate, Matrix &AM) { postProcessCalled = false; - + dirichletFunction.evaluate(relativeTime, dirichletValue); tau = _tau; /* We start out with the formulation @@ -72,12 +72,8 @@ void BackwardEuler<Vector, Matrix, Function, dim>::setup( for (size_t i = 0; i < dirichletNodes.size(); ++i) for (size_t j = 0; j < dim; ++j) - if (dirichletNodes[i][j]) { - if (j == 0) - dirichletFunction.evaluate(relativeTime, iterate[i][j]); - else - iterate[i][j] = 0; - } + if (dirichletNodes[i][j]) + iterate[i][j] = (j == 0) ? dirichletValue : 0; } template <class Vector, class Matrix, class Function, size_t dim> diff --git a/src/timestepping/backward_euler.hh b/src/timestepping/backward_euler.hh index c598c8ff..a07b878d 100644 --- a/src/timestepping/backward_euler.hh +++ b/src/timestepping/backward_euler.hh @@ -25,6 +25,7 @@ class BackwardEuler : public TimeSteppingScheme<Vector, Matrix, Function, dim> { Vector v; Dune::BitSetVector<dim> const &dirichletNodes; Function const &dirichletFunction; + double dirichletValue; Vector u_o; Vector v_o; diff --git a/src/timestepping/newmark.cc b/src/timestepping/newmark.cc index b6f90e31..6b703135 100644 --- a/src/timestepping/newmark.cc +++ b/src/timestepping/newmark.cc @@ -27,7 +27,7 @@ void Newmark<Vector, Matrix, Function, dim>::setup(Vector const &ell, Vector &rhs, Vector &iterate, Matrix &AM) { postProcessCalled = false; - + dirichletFunction.evaluate(relativeTime, dirichletValue); tau = _tau; /* We start out with the formulation @@ -79,12 +79,8 @@ void Newmark<Vector, Matrix, Function, dim>::setup(Vector const &ell, for (size_t i = 0; i < dirichletNodes.size(); ++i) for (size_t j = 0; j < dim; ++j) - if (dirichletNodes[i][j]) { - if (j == 0) - dirichletFunction.evaluate(relativeTime, iterate[i][j]); - else - iterate[i][j] = 0; - } + if (dirichletNodes[i][j]) + iterate[i][j] = (j == 0) ? dirichletValue : 0; } template <class Vector, class Matrix, class Function, size_t dim> diff --git a/src/timestepping/newmark.hh b/src/timestepping/newmark.hh index 0d5774d6..78f7731a 100644 --- a/src/timestepping/newmark.hh +++ b/src/timestepping/newmark.hh @@ -27,6 +27,7 @@ class Newmark : public TimeSteppingScheme<Vector, Matrix, Function, dim> { Vector a; Dune::BitSetVector<dim> const &dirichletNodes; Function const &dirichletFunction; + double dirichletValue; Vector u_o; Vector v_o; -- GitLab