From 061d9ba0127dcdf87df160e8eaa696a91a3db555 Mon Sep 17 00:00:00 2001 From: Wolfgang Bangerth Date: Wed, 12 Dec 2018 11:12:24 -0700 Subject: [PATCH] Ensure that DoFs not touched by VectorTools::interpolate don't get set. --- .../deal.II/numerics/vector_tools.templates.h | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) 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); } -- 2.39.5