From: Jean-Paul Pelteret Date: Thu, 10 Aug 2017 22:56:03 +0000 (-0600) Subject: Added Vector::get_function_values_from_local_dof_values X-Git-Tag: v9.0.0-rc1~1291^2~13 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8bbb00714920e76107f22b1c4405c1e671324547;p=dealii.git Added Vector::get_function_values_from_local_dof_values --- diff --git a/include/deal.II/fe/fe_values.h b/include/deal.II/fe/fe_values.h index e4f5b920e7..c6fe38f0d0 100644 --- a/include/deal.II/fe/fe_values.h +++ b/include/deal.II/fe/fe_values.h @@ -582,6 +582,62 @@ namespace FEValuesViews */ typedef dealii::Tensor<4,spacedim> third_derivative_type; + /** + * A struct that provides the output type for the product of the value + * and derivatives of basis functions of the Vector view and any @p Number type. + */ + template + struct OutputType + { + /** + * A typedef for the data type of the product of a @p Number and the + * values of the view the Vector class. + */ + typedef typename ProductType::type, typename Vector::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 Vector class. + */ + typedef typename ProductType::type, typename Vector::gradient_type>::type gradient_type; + + /** + * A typedef for the data type of the product of a @p Number and the + * symmetric gradients of the view the Vector class. + */ + typedef typename ProductType::type, typename Vector::symmetric_gradient_type>::type symmetric_gradient_type; + + /** + * A typedef for the data type of the product of a @p Number and the + * divergences of the view the Vector class. + */ + typedef typename ProductType::type, typename Vector::divergence_type>::type divergence_type; + + /** + * A typedef for the data type of the product of a @p Number and the + * laplacians of the view the Vector class. + */ + typedef typename ProductType::type, typename Vector::value_type>::type laplacian_type; + + /** + * A typedef for the data type of the product of a @p Number and the + * curls of the view the Vector class. + */ + typedef typename ProductType::type, typename Vector::curl_type>::type curl_type; + + /** + * A typedef for the data type of the product of a @p Number and the + * hessians of the view the Vector class. + */ + typedef typename ProductType::type, typename Vector::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 Vector class. + */ + typedef typename ProductType::type, typename Vector::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. @@ -786,6 +842,30 @@ namespace FEValuesViews void get_function_values (const InputVector &fe_function, std::vector::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 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 local_dof_values(cell->get_fe().dofs_per_cell); + * cell->get_dof_values(solution, local_dof_values.begin(), local_dof_values.end()); + * @endcode + */ + template + void get_function_values_from_local_dof_values (const InputVector &dof_values, + std::vector::value_type> &values) const; + /** * Return the gradients of the selected vector components of the finite * element function characterized by fe_function at the diff --git a/source/fe/fe_values.cc b/source/fe/fe_values.cc index c26294d7ba..3dc2a33af1 100644 --- a/source/fe/fe_values.cc +++ b/source/fe/fe_values.cc @@ -1509,6 +1509,25 @@ namespace FEValuesViews + template + template + void + Vector:: + get_function_values_from_local_dof_values (const InputVector &dof_values, + std::vector::value_type> &values) const + { + Assert (fe_values->update_flags & update_values, + (typename FEValuesBase::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 + (make_array_view(dof_values.begin(), dof_values.end()), + fe_values->finite_element_output.shape_values, shape_function_data, values); + } + + template template diff --git a/source/fe/fe_values.inst.in b/source/fe/fe_values.inst.in index 69c7931298..f0b789a19c 100644 --- a/source/fe/fe_values.inst.in +++ b/source/fe/fe_values.inst.in @@ -169,6 +169,13 @@ for (VEC : GENERAL_CONTAINER_TYPES; void FEValuesViews::Scalar ::get_function_third_derivatives_from_local_dof_values> (const VEC&, std::vector::third_derivative_type>&) const; + + + + template + void FEValuesViews::Vector + ::get_function_values_from_local_dof_values> + (const VEC&, std::vector::value_type>&) const; #endif }