]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Make things work for std::complex data types. 5388/head
authorWolfgang Bangerth <bangerth@colostate.edu>
Tue, 31 Oct 2017 21:49:14 +0000 (15:49 -0600)
committerWolfgang Bangerth <bangerth@colostate.edu>
Fri, 3 Nov 2017 16:53:44 +0000 (10:53 -0600)
include/deal.II/numerics/vector_tools.templates.h

index dc42b5bfab5740eea991b4d2bdaa63af189e5eeb..850e3ff34ec0d7ca3d0ee6d647488a1b78d8df36 100644 (file)
@@ -133,17 +133,19 @@ namespace VectorTools
               const auto &jacobians =
                 fe_values_jacobians.get_present_fe_values().get_jacobians();
 
-              auto shifted_view = boost::make_iterator_range(
-                                    std::begin(function_values[i]) + offset,
-                                    std::begin(function_values[i]) + offset + dim);
-              std::array<typename T3::value_type::value_type,dim> old_value;
-              std::copy(std::begin(shifted_view),
-                        std::end(shifted_view),
-                        std::begin(old_value));
+              const ArrayView<typename T3::value_type::value_type>
+              source (&function_values[i][0] + offset, dim);
+
+              Tensor<1,dim,typename ProductType<typename T3::value_type::value_type,double>::type>
+              destination;
 
               // value[m] <- sum jacobian_transpose[m][n] * old_value[n]:
               TensorAccessors::contract<1, 2, 1, dim>(
-                shifted_view, jacobians[i].transpose(), old_value);
+                destination, jacobians[i].transpose(), source);
+
+              // now copy things back into the input=output vector
+              for (unsigned int d=0; d<dim; ++d)
+                source[d] = destination[d];
             }
           break;
 
@@ -161,20 +163,20 @@ namespace VectorTools
                 fe_values_jacobians.get_present_fe_values()
                 .get_inverse_jacobians();
 
-              auto shifted_view = boost::make_iterator_range(
-                                    std::begin(function_values[i]) + offset,
-                                    std::begin(function_values[i]) + offset + dim);
-              std::array<typename T3::value_type::value_type,dim> old_value;
-              std::copy(std::begin(shifted_view),
-                        std::end(shifted_view),
-                        std::begin(old_value));
+              const ArrayView<typename T3::value_type::value_type>
+              source (&function_values[i][0] + offset, dim);
+
+              Tensor<1,dim,typename ProductType<typename T3::value_type::value_type,double>::type>
+              destination;
 
               // value[m] <- sum inverse_jacobians[m][n] * old_value[n]:
               TensorAccessors::contract<1, 2, 1, dim>(
-                shifted_view, inverse_jacobians[i], old_value);
+                destination, inverse_jacobians[i], source);
+              destination *= jacobians[i].determinant();
 
-              for (unsigned int j = 0; j < dim; ++j)
-                shifted_view[j] *= jacobians[i].determinant();
+              // now copy things back into the input=output vector
+              for (unsigned int d=0; d<dim; ++d)
+                source[d] = destination[d];
             }
           break;
 

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.