Skip to content
Snippets Groups Projects
Commit 82b6ab50 authored by Elias Pipping's avatar Elias Pipping
Browse files

[Cleanup] Improve handling of ignored DOFs

parent 3df2a133
No related branches found
No related tags found
No related merge requests found
......@@ -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;
}
};
}
......
......@@ -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);
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment