]> https://gitweb.dealii.org/ - dealii.git/commitdiff
fixed a bug in FEFieldFunction::vector_gradient() introduced in 0dc4d47 2235/head
authorDenis Davydov <davydden@gmail.com>
Tue, 23 Feb 2016 13:33:12 +0000 (14:33 +0100)
committerDenis Davydov <davydden@gmail.com>
Tue, 23 Feb 2016 15:31:51 +0000 (16:31 +0100)
include/deal.II/numerics/fe_field_function.templates.h

index 025d9cf59f55eee89171750ac8e073629a69cdde..aea385d4b639a0b469b25a8f2883317d647bb4ed 100644 (file)
@@ -114,6 +114,7 @@ namespace Functions
   vector_gradient (const Point<dim>            &p,
                    std::vector<Tensor<1,dim,typename VectorType::value_type> > &gradients) const
   {
+    typedef typename VectorType::value_type number;
     Assert (gradients.size() == n_components,
             ExcDimensionMismatch(gradients.size(), n_components));
     typename DoFHandlerType::active_cell_iterator cell = cell_hint.get();
@@ -140,7 +141,25 @@ namespace Functions
     FEValues<dim> fe_v(mapping, cell->get_fe(), quad,
                        update_gradients);
     fe_v.reinit(cell);
-    fe_v.get_function_gradients(data_vector, gradients);
+
+    if (n_components == 1)
+      {
+        // the size of the @p gradients coincidentally coincides
+        // with the number of quadrature points we evaluate the function at.
+        fe_v.get_function_gradients(data_vector, gradients);
+      }
+    else
+      {
+        // Unfortunately we still need a temporary argument as we want to
+        // evaluate a gradient of a (generally) multicomponent function at
+        // a single quadrature point. Note that the first std::vector<> is related
+        // to the number of quadrature points (always one here), whereas the second
+        // to the number of components.
+        std::vector< std::vector<Tensor<1,dim,number> > > vgrads
+        (1,  std::vector<Tensor<1,dim,number> >(n_components) );
+        fe_v.get_function_gradients(data_vector, vgrads);
+        gradients = vgrads[0];
+      }
   }
 
 

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.