From 82b6ab5008a1e1f32495d6887cee917d1fbf13b5 Mon Sep 17 00:00:00 2001 From: Elias Pipping <elias.pipping@fu-berlin.de> Date: Fri, 13 Dec 2013 01:23:10 +0100 Subject: [PATCH] [Cleanup] Improve handling of ignored DOFs --- dune/tectonic/ellipticenergy.hh | 10 ++++++---- dune/tectonic/myblockproblem.hh | 18 +----------------- 2 files changed, 7 insertions(+), 21 deletions(-) diff --git a/dune/tectonic/ellipticenergy.hh b/dune/tectonic/ellipticenergy.hh index ce755278..36826483 100644 --- a/dune/tectonic/ellipticenergy.hh +++ b/dune/tectonic/ellipticenergy.hh @@ -19,7 +19,8 @@ template <size_t dim> class EllipticEnergy { using Nonlinearity = LocalFriction<dim>; EllipticEnergy(SmallMatrix const &A, SmallVector const &b, - shared_ptr<Nonlinearity const> phi, size_t ignore = dim) + shared_ptr<Nonlinearity const> phi, + typename Dune::BitSetVector<dim>::const_reference ignore) : A(A), b(b), phi(phi), ignore(ignore) {} double operator()(SmallVector const &v) const { @@ -31,15 +32,16 @@ template <size_t dim> class EllipticEnergy { shared_ptr<Nonlinearity const> const phi; /* Dimension that should be ignored; goes from 0 to dim-1; the special value dim means that no dimension should be ignored */ - size_t const ignore; + typename Dune::BitSetVector<dim>::const_reference const ignore; void gradient(SmallVector const &x, SmallVector &y) const { A.mv(x, y); y -= b; phi->addGradient(x, y); - if (ignore != dim) - y[ignore] = 0; + for (size_t i = 0; i < dim; ++i) + if (ignore[i]) + y[i] = 0; } }; } diff --git a/dune/tectonic/myblockproblem.hh b/dune/tectonic/myblockproblem.hh index 8d5a112e..4601c7c2 100644 --- a/dune/tectonic/myblockproblem.hh +++ b/dune/tectonic/myblockproblem.hh @@ -239,22 +239,6 @@ class MyBlockProblem<ConvexProblem>::IterateObject { LocalVector &ui, size_t m, typename Dune::BitSetVector<block_size>::const_reference ignore) { { - size_t ic = - block_size; // Special value that indicates nothing should be ignored - switch (ignore.count()) { - case 0: // Full problem - break; - case 1: - for (ic = 0; ic < block_size; ++ic) - if (ignore[ic]) - break; - break; - case block_size: // Ignore the whole node - return; - default: - assert(false); - } - LocalMatrix const *localA = nullptr; LocalVector localb(problem.f[m]); @@ -269,7 +253,7 @@ class MyBlockProblem<ConvexProblem>::IterateObject { assert(localA != nullptr); auto const phi = problem.phi.restriction(m); - Dune::EllipticEnergy<block_size> localJ(*localA, localb, phi, ic); + Dune::EllipticEnergy<block_size> localJ(*localA, localb, phi, ignore); Dune::minimise(localJ, ui, localsteps, bisection); } } -- GitLab