From: Wolfgang Bangerth Date: Wed, 12 Dec 2018 18:12:24 +0000 (-0700) Subject: Ensure that DoFs not touched by VectorTools::interpolate don't get set. X-Git-Tag: v9.1.0-rc1~475^2~2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=061d9ba0127dcdf87df160e8eaa696a91a3db555;p=dealii.git Ensure that DoFs not touched by VectorTools::interpolate don't get set. --- diff --git a/include/deal.II/numerics/vector_tools.templates.h b/include/deal.II/numerics/vector_tools.templates.h index 6eac0117ad..b9f6b2f47c 100644 --- a/include/deal.II/numerics/vector_tools.templates.h +++ b/include/deal.II/numerics/vector_tools.templates.h @@ -515,14 +515,21 @@ namespace VectorTools for (const auto i : interpolation.locally_owned_elements()) { - const auto value = - ::dealii::internal::ElementAccess::get(interpolation, - i); const auto weight = ::dealii::internal::ElementAccess::get(weights, i); - ::dealii::internal::ElementAccess::set(value / weight, - i, - vec); + + // See if we touched this DoF at all. If so, set the average + // of the value we computed in the output vector. Otherwise, + // don't touch the value at all. + if (weight != number(0)) + { + const auto value = + ::dealii::internal::ElementAccess::get( + interpolation, i); + ::dealii::internal::ElementAccess::set(value / weight, + i, + vec); + } } vec.compress(VectorOperation::insert); }