]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Added Scalar::get_function_values_from_local_dof_values
authorLuca Heltai <luca.heltai@sissa.it>
Wed, 9 Aug 2017 00:36:17 +0000 (18:36 -0600)
committerJean-Paul Pelteret <jppelteret@gmail.com>
Sat, 12 Aug 2017 17:09:26 +0000 (11:09 -0600)
include/deal.II/fe/fe_values.h
source/fe/fe_values.cc
source/fe/fe_values.inst.in

index d49cf35727b70835da5a4af1125a503c1a60d694..3e747687d22725bf89279e4dcf654fa401d008da 100644 (file)
@@ -165,6 +165,44 @@ namespace FEValuesViews
      */
     typedef dealii::Tensor<3,spacedim> third_derivative_type;
 
+    /**
+     * A struct that provides the output type for the product of the value
+     * and derivatives of basis functions of the Scalar view and any @p Number type.
+     */
+    template <typename Number>
+    struct OutputType
+    {
+      /**
+       * A typedef for the data type of the product of a @p Number and the
+       * values of the view the Scalar class.
+       */
+      typedef typename ProductType<typename std::remove_cv<Number>::type, typename Scalar<dim,spacedim>::value_type>::type value_type;
+
+      /**
+       * A typedef for the data type of the product of a @p Number and the
+       * gradients of the view the Scalar class.
+       */
+      typedef typename ProductType<typename std::remove_cv<Number>::type, typename Scalar<dim,spacedim>::gradient_type>::type gradient_type;
+
+      /**
+       * A typedef for the data type of the product of a @p Number and the
+       * laplacians of the view the Scalar class.
+       */
+      typedef typename ProductType<typename std::remove_cv<Number>::type, typename Scalar<dim,spacedim>::value_type>::type laplacian_type;
+
+      /**
+       * A typedef for the data type of the product of a @p Number and the
+       * hessians of the view the Scalar class.
+       */
+      typedef typename ProductType<typename std::remove_cv<Number>::type, typename Scalar<dim,spacedim>::hessian_type>::type hessian_type;
+
+      /**
+       * A typedef for the data type of the product of a @p Number and the
+       * third derivatives of the view the Scalar class.
+       */
+      typedef typename ProductType<typename std::remove_cv<Number>::type, typename Scalar<dim,spacedim>::third_derivative_type>::type third_derivative_type;
+    };
+
     /**
      * A structure where for each shape function we pre-compute a bunch of
      * data that will make later accesses much cheaper.
@@ -291,6 +329,30 @@ namespace FEValuesViews
     void get_function_values (const InputVector &fe_function,
                               std::vector<typename ProductType<value_type,typename InputVector::value_type>::type> &values) const;
 
+    /**
+     * Same as above, but using a vector of local degree-of-freedom values.
+     *
+     * The @p dof_values vector must have a length equal to number of DoFs on
+     * a cell, and  each entry @p dof_values[i] is the value of the local DoF
+     * @p i. The fundamental prerequisite for the @p InputVector is that it must
+     * be possible to create an ArrayView from it; this is satisfied by the
+     * @p std::vector class.
+     *
+     * The DoF values typically would be obtained in the following way:
+     * @code
+     * Vector<double> local_dof_values(cell->get_fe().dofs_per_cell);
+     * cell->get_dof_values(solution, local_dof_values);
+     * @endcode
+     * or, for a generic @p Number type,
+     * @code
+     * std::vector<Number> local_dof_values(cell->get_fe().dofs_per_cell);
+     * cell->get_dof_values(solution, local_dof_values.begin(), local_dof_values.end());
+     * @endcode
+     */
+    template <class InputVector>
+    void get_function_values_from_local_dof_values (const InputVector &dof_values,
+                                                    std::vector<typename OutputType<typename InputVector::value_type>::value_type> &values) const;
+
     /**
      * Return the gradients of the selected scalar component of the finite
      * element function characterized by <tt>fe_function</tt> at the
index 2d1ab1755f96d10ff75caebc1028fc15a9348d71..039a7cec749a726a6c5d03437ad76c837b5fb219 100644 (file)
@@ -39,6 +39,8 @@
 #include <iomanip>
 #include <memory>
 
+#include <deal.II/base/sacado_product_type.h>
+
 DEAL_II_NAMESPACE_OPEN
 
 
@@ -459,7 +461,7 @@ namespace FEValuesViews
     do_function_values (const ArrayView<Number> &dof_values,
                         const Table<2,double> &shape_values,
                         const std::vector<typename Scalar<dim,spacedim>::ShapeFunctionData> &shape_function_data,
-                        std::vector<typename ProductType<Number,double>::type>            &values)
+                        std::vector<typename ProductType<typename std::remove_cv<Number>::type,double>::type>            &values)
     {
       const unsigned int dofs_per_cell = dof_values.size();
       const unsigned int n_quadrature_points = dofs_per_cell > 0 ?
@@ -1286,6 +1288,24 @@ namespace FEValuesViews
      fe_values->finite_element_output.shape_values, shape_function_data, values);
   }
 
+  template <int dim, int spacedim>
+  template <class InputVector>
+  void
+  Scalar<dim,spacedim>::
+  get_function_values_from_local_dof_values (const InputVector &dof_values,
+                                             std::vector<typename OutputType<typename InputVector::value_type>::value_type> &values) const
+  {
+    Assert (fe_values->update_flags & update_values,
+            (typename FEValuesBase<dim,spacedim>::ExcAccessToUninitializedField("update_values")));
+    Assert (fe_values->present_cell.get() != nullptr,
+            ExcMessage ("FEValues object is not reinit'ed to any cell"));
+    AssertDimension (dof_values.size(), fe_values->dofs_per_cell);
+
+    internal::do_function_values<dim,spacedim>
+    (make_array_view(dof_values.begin(), dof_values.end()),
+     fe_values->finite_element_output.shape_values, shape_function_data, values);
+  }
+
 
 
   template <int dim, int spacedim>
index 45265919974356e22e2ff33b8a62704cc25b8340..90f24d926af6000f93c1cee67a197cf6a2ef9649 100644 (file)
@@ -139,6 +139,19 @@ for (VEC : SERIAL_VECTORS; deal_II_dimension : DIMENSIONS; deal_II_space_dimensi
 }
 
 
+for (VEC : GENERAL_CONTAINER_TYPES;
+        Number : ALL_SCALAR_TYPES;
+        deal_II_dimension : DIMENSIONS;
+        deal_II_space_dimension :  SPACE_DIMENSIONS)
+{
+#if deal_II_dimension <= deal_II_space_dimension
+    template
+    void FEValuesViews::Scalar<deal_II_dimension, deal_II_space_dimension>
+    ::get_function_values_from_local_dof_values<VEC<Number>>
+            (const VEC<Number>&, std::vector<typename OutputType<Number>::value_type>&) const;
+#endif
+}
+
 
 for (VEC : SERIAL_VECTORS; deal_II_dimension : DIMENSIONS; deal_II_space_dimension :  SPACE_DIMENSIONS)
 {

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.