]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Ensure that DoFs not touched by VectorTools::interpolate don't get set.
authorWolfgang Bangerth <bangerth@colostate.edu>
Wed, 12 Dec 2018 18:12:24 +0000 (11:12 -0700)
committerWolfgang Bangerth <bangerth@colostate.edu>
Fri, 28 Dec 2018 16:59:55 +0000 (09:59 -0700)
include/deal.II/numerics/vector_tools.templates.h

index 6eac0117ad39d56cc6772e04217db019ee431b54..b9f6b2f47c031c418e644e44b130cc9fd6c9e3e5 100644 (file)
@@ -515,14 +515,21 @@ namespace VectorTools
 
       for (const auto i : interpolation.locally_owned_elements())
         {
-          const auto value =
-            ::dealii::internal::ElementAccess<VectorType>::get(interpolation,
-                                                               i);
           const auto weight =
             ::dealii::internal::ElementAccess<VectorType>::get(weights, i);
-          ::dealii::internal::ElementAccess<VectorType>::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<VectorType>::get(
+                  interpolation, i);
+              ::dealii::internal::ElementAccess<VectorType>::set(value / weight,
+                                                                 i,
+                                                                 vec);
+            }
         }
       vec.compress(VectorOperation::insert);
     }

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.