From e2bd4c30b80867c74a0e24cf4794eb3b67d16783 Mon Sep 17 00:00:00 2001 From: wolf Date: Fri, 26 Mar 1999 18:46:56 +0000 Subject: [PATCH] Change the data type of one argument. Add get_function_grads for vector valued finite elements. git-svn-id: https://svn.dealii.org/trunk@1059 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/deal.II/include/fe/fe_values.h | 36 +++++++++++++++++++------- deal.II/deal.II/source/fe/fe_values.cc | 36 ++++++++++++++++++++++++-- 2 files changed, 61 insertions(+), 11 deletions(-) diff --git a/deal.II/deal.II/include/fe/fe_values.h b/deal.II/deal.II/include/fe/fe_values.h index 301451e1d0..72a0f6393b 100644 --- a/deal.II/deal.II/include/fe/fe_values.h +++ b/deal.II/deal.II/include/fe/fe_values.h @@ -296,16 +296,16 @@ class FEValuesBase { void get_function_values (const Vector &fe_function, vector &values) const; - /** - * Access to vector valued finite element functions. - * - * This function does the same as - * the other #get_function_values#, - * but applied to multi-component - * elements. - */ + /** + * Access to vector valued finite element functions. + * + * This function does the same as + * the other #get_function_values#, + * but applied to multi-component + * elements. + */ void get_function_values (const Vector &fe_function, - vector > &values) const; + vector > &values) const; /** * Return the gradient of the #i#th shape @@ -345,6 +345,24 @@ class FEValuesBase { void get_function_grads (const Vector &fe_function, vector > &gradients) const; + /** + * Return the gradients of the finite + * element function characterized + * by #fe_function# restricted to + * #cell# at the quadrature points. + * + * The function assumes that the + * #gradients# object already has the + * right size. + * + * This function does the same as + * the other #get_function_values#, + * but applied to multi-component + * elements. + */ + void get_function_grads (const Vector &fe_function, + vector > > &gradients) const; + /** * Return the 2nd derivatives of * the #i#th shape function at diff --git a/deal.II/deal.II/source/fe/fe_values.cc b/deal.II/deal.II/source/fe/fe_values.cc index 158dd8043d..41f4dec039 100644 --- a/deal.II/deal.II/source/fe/fe_values.cc +++ b/deal.II/deal.II/source/fe/fe_values.cc @@ -90,7 +90,7 @@ void FEValuesBase::get_function_values (const Vector &fe_function, template void FEValuesBase::get_function_values (const Vector &fe_function, - vector< Vector > &values) const + vector< vector > &values) const { Assert (n_quadrature_points == values.size(), ExcWrongNoOfComponents()); @@ -113,7 +113,7 @@ void FEValuesBase::get_function_values (const Vector &fe_functi // functions for (unsigned int point=0; pointsystem_to_component_index(shape_func).first) + values[point][fe->system_to_component_index(shape_func).first] += (dof_values(shape_func) * shape_values[selected_dataset](shape_func, point)); }; @@ -160,6 +160,38 @@ void FEValuesBase::get_function_grads (const Vector &fe_function, }; }; +template +void FEValuesBase::get_function_grads (const Vector &fe_function, + vector > > &gradients) const +{ + Assert (n_quadrature_points == gradients.size(), + ExcWrongNoOfComponents()); + Assert (selected_datasetn_components, + ExcWrongVectorSize(gradients.size(), n_quadrature_points)); + + // get function values of dofs + // on this cell + Vector dof_values (total_dofs); + present_cell->get_dof_values (fe_function, dof_values); + + // initialize with zero + for (unsigned i=0;i()); + + // add up contributions of trial + // functions + for (unsigned int point=0; point tmp(shape_gradients[shape_func][point]); + tmp *= dof_values(shape_func); + gradients[point][fe->system_to_component_index(shape_func).first] + += tmp; + }; +}; template -- 2.39.5