]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Extend convert_generalized_support_point_values_to_dof_values for complex-valued...
authorDaniel Arndt <daniel.arndt@iwr.uni-heidelberg.de>
Mon, 2 Oct 2017 14:12:44 +0000 (16:12 +0200)
committerDaniel Arndt <daniel.arndt@iwr.uni-heidelberg.de>
Mon, 2 Oct 2017 14:12:44 +0000 (16:12 +0200)
include/deal.II/fe/fe_tools.templates.h
source/fe/fe_tools.inst.in

index ac7b14fa98fcc3330ad3b51538348338a2a0f229..8dd5e9cf4c4ce0ddf368ccc0fcc3ba203c042cf4 100644 (file)
@@ -2947,6 +2947,60 @@ namespace FETools
     }
 
 
+    template <int dim, int spacedim, typename number>
+    static void convert_helper(
+      const FiniteElement<dim, spacedim> &finite_element,
+      const std::vector<Vector<std::complex<number> > > &support_point_values,
+      std::vector<std::complex<number> >                &dof_values)
+    {
+      static Threads::ThreadLocalStorage<std::vector<Vector<double> > >
+      double_support_point_values_real;
+      static Threads::ThreadLocalStorage<std::vector<double> >
+      double_dof_values_real;
+      static Threads::ThreadLocalStorage<std::vector<Vector<double> > >
+      double_support_point_values_imag;
+      static Threads::ThreadLocalStorage<std::vector<double> >
+      double_dof_values_imag;
+
+      double_support_point_values_real.get().resize(support_point_values.size());
+      double_dof_values_real.get().resize(dof_values.size());
+      double_support_point_values_imag.get().resize(support_point_values.size());
+      double_dof_values_imag.get().resize(dof_values.size());
+
+      for (unsigned int i = 0; i < support_point_values.size(); ++i)
+        {
+          double_support_point_values_real.get()[i].reinit(
+            finite_element.n_components(), false);
+          double_support_point_values_imag.get()[i].reinit(
+            finite_element.n_components(), false);
+
+          std::transform
+          (std::begin(support_point_values[i]),
+           std::end(support_point_values[i]),
+           std::begin(double_support_point_values_real.get()[i]),
+           [](std::complex<number> c) -> double {return c.real();});
+
+          std::transform
+          (std::begin(support_point_values[i]),
+           std::end(support_point_values[i]),
+           std::begin(double_support_point_values_imag.get()[i]),
+           [](std::complex<number> c) -> double {return c.imag();});
+        }
+
+      finite_element.convert_generalized_support_point_values_to_dof_values(
+        double_support_point_values_real.get(), double_dof_values_real.get());
+      finite_element.convert_generalized_support_point_values_to_dof_values(
+        double_support_point_values_imag.get(), double_dof_values_imag.get());
+
+      std::transform
+      (std::begin(double_dof_values_real.get()),
+       std::end(double_dof_values_real.get()),
+       std::begin(double_dof_values_imag.get()),
+       std::begin(dof_values),
+       [](number real, number imag) -> std::complex<number> {return {real, imag};});
+    }
+
+
     template <int dim, int spacedim>
     static void convert_helper(
       const FiniteElement<dim, spacedim> &finite_element,
index 53b7632fec7dcac664d11515fd526ac9985f5e9b..d122f11ae0dfbb79b4ffd6d884ac4e7fc077a144 100644 (file)
@@ -276,3 +276,20 @@ for (deal_II_dimension : DIMENSIONS; deal_II_space_dimension : SPACE_DIMENSIONS;
     \}
 #endif
 }
+
+for (deal_II_dimension : DIMENSIONS; deal_II_space_dimension : SPACE_DIMENSIONS; number : COMPLEX_SCALARS)
+{
+#if deal_II_dimension <= deal_II_space_dimension
+    namespace FETools
+    \{
+
+    template
+    void
+    convert_generalized_support_point_values_to_dof_values<deal_II_dimension, deal_II_space_dimension, number> (
+        const FiniteElement<deal_II_dimension, deal_II_space_dimension> &,
+        const std::vector<Vector<number> > &,
+        std::vector<number>                &);
+
+    \}
+#endif
+}

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.