From: Denis Davydov Date: Sat, 28 Feb 2015 18:41:31 +0000 (+0100) Subject: made FEValuesBase::get_function_xxx to store results in containers of consistent... X-Git-Tag: v8.3.0-rc1~184^2~27 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4752501994177d28280a22382357bacdaa9e4fba;p=dealii.git made FEValuesBase::get_function_xxx to store results in containers of consistent type with the input vector --- diff --git a/include/deal.II/fe/fe_values.h b/include/deal.II/fe/fe_values.h index fd06bafda7..f3c0d421b4 100644 --- a/include/deal.II/fe/fe_values.h +++ b/include/deal.II/fe/fe_values.h @@ -1687,9 +1687,9 @@ public: * * @dealiiRequiresUpdateFlags{update_values} */ - template + template void get_function_values (const InputVector &fe_function, - std::vector &values) const; + std::vector &values) const; /** * This function does the same as the other get_function_values(), but @@ -1704,9 +1704,9 @@ public: * * @dealiiRequiresUpdateFlags{update_values} */ - template + template void get_function_values (const InputVector &fe_function, - std::vector > &values) const; + std::vector > &values) const; /** * Generate function values from an arbitrary vector. @@ -1726,10 +1726,10 @@ public: * * @dealiiRequiresUpdateFlags{update_values} */ - template + template void get_function_values (const InputVector &fe_function, const VectorSlice > &indices, - std::vector &values) const; + std::vector &values) const; /** * Generate vector function values from an arbitrary vector. @@ -1752,10 +1752,10 @@ public: * * @dealiiRequiresUpdateFlags{update_values} */ - template + template void get_function_values (const InputVector &fe_function, const VectorSlice > &indices, - std::vector > &values) const; + std::vector > &values) const; /** @@ -1791,7 +1791,7 @@ public: template void get_function_values (const InputVector &fe_function, const VectorSlice > &indices, - VectorSlice > > values, + VectorSlice > > values, const bool quadrature_points_fastest) const; //@} @@ -1834,7 +1834,7 @@ public: */ template void get_function_gradients (const InputVector &fe_function, - std::vector > &gradients) const; + std::vector > &gradients) const; /** * This function does the same as the other get_function_gradients(), but @@ -1854,7 +1854,7 @@ public: */ template void get_function_gradients (const InputVector &fe_function, - std::vector > > &gradients) const; + std::vector > > &gradients) const; /** * Function gradient access with more flexibility. See get_function_values() @@ -1865,7 +1865,7 @@ public: template void get_function_gradients (const InputVector &fe_function, const VectorSlice > &indices, - std::vector > &gradients) const; + std::vector > &gradients) const; /** * Function gradient access with more flexibility. See get_function_values() @@ -1876,7 +1876,7 @@ public: template void get_function_gradients (const InputVector &fe_function, const VectorSlice > &indices, - VectorSlice > > > gradients, + VectorSlice > > > gradients, bool quadrature_points_fastest = false) const; //@} @@ -1921,7 +1921,7 @@ public: template void get_function_hessians (const InputVector &fe_function, - std::vector > &hessians) const; + std::vector > &hessians) const; /** * This function does the same as the other get_function_hessians(), but @@ -1943,7 +1943,7 @@ public: template void get_function_hessians (const InputVector &fe_function, - std::vector > > &hessians, + std::vector > > &hessians, bool quadrature_points_fastest = false) const; /** @@ -1954,7 +1954,7 @@ public: void get_function_hessians ( const InputVector &fe_function, const VectorSlice > &indices, - std::vector > &hessians) const; + std::vector > &hessians) const; /** * Access to the second derivatives of a function with more flexibility. See @@ -1966,7 +1966,7 @@ public: void get_function_hessians ( const InputVector &fe_function, const VectorSlice > &indices, - VectorSlice > > > hessians, + VectorSlice > > > hessians, bool quadrature_points_fastest = false) const; /** @@ -2008,10 +2008,10 @@ public: * * @dealiiRequiresUpdateFlags{update_hessians} */ - template + template void get_function_laplacians (const InputVector &fe_function, - std::vector &laplacians) const; + std::vector &laplacians) const; /** * This function does the same as the other get_function_laplacians(), but @@ -2032,10 +2032,10 @@ public: * * @dealiiRequiresUpdateFlags{update_hessians} */ - template + template void get_function_laplacians (const InputVector &fe_function, - std::vector > &laplacians) const; + std::vector > &laplacians) const; /** * Access to the second derivatives of a function with more flexibility. See @@ -2043,11 +2043,11 @@ public: * * @dealiiRequiresUpdateFlags{update_hessians} */ - template + template void get_function_laplacians ( const InputVector &fe_function, const VectorSlice > &indices, - std::vector &laplacians) const; + std::vector &laplacians) const; /** * Access to the second derivatives of a function with more flexibility. See @@ -2055,11 +2055,11 @@ public: * * @dealiiRequiresUpdateFlags{update_hessians} */ - template + template void get_function_laplacians ( const InputVector &fe_function, const VectorSlice > &indices, - std::vector > &laplacians) const; + std::vector > &laplacians) const; /** * Access to the second derivatives of a function with more flexibility. See @@ -2067,11 +2067,11 @@ public: * * @dealiiRequiresUpdateFlags{update_hessians} */ - template + template void get_function_laplacians ( const InputVector &fe_function, const VectorSlice > &indices, - std::vector > &laplacians, + std::vector > &laplacians, bool quadrature_points_fastest = false) const; //@} diff --git a/source/fe/fe_values.cc b/source/fe/fe_values.cc index d606db71a7..94550ad6fa 100644 --- a/source/fe/fe_values.cc +++ b/source/fe/fe_values.cc @@ -2588,11 +2588,12 @@ namespace internal template -template +template void FEValuesBase::get_function_values ( const InputVector &fe_function, - std::vector &values) const + std::vector &values) const { + typedef typename InputVector::value_type Number; Assert (this->update_flags & update_values, ExcAccessToUninitializedField("update_values")); AssertDimension (fe->n_components(), 1); @@ -2602,7 +2603,7 @@ void FEValuesBase::get_function_values ( present_cell->n_dofs_for_dof_handler()); // get function values of dofs on this cell - Vector dof_values (dofs_per_cell); + Vector dof_values (dofs_per_cell); present_cell->get_interpolated_dof_values(fe_function, dof_values); internal::do_function_values (dof_values.begin(), this->shape_values, values); @@ -2611,12 +2612,13 @@ void FEValuesBase::get_function_values ( template -template +template void FEValuesBase::get_function_values ( const InputVector &fe_function, const VectorSlice > &indices, - std::vector &values) const + std::vector &values) const { + typedef typename InputVector::value_type Number; Assert (this->update_flags & update_values, ExcAccessToUninitializedField("update_values")); AssertDimension (fe->n_components(), 1); @@ -2625,14 +2627,14 @@ void FEValuesBase::get_function_values ( // avoid allocation when the local size is small enough if (dofs_per_cell <= 100) { - double dof_values[100]; + Number dof_values[100]; for (unsigned int i=0; ishape_values, values); } else { - Vector dof_values(dofs_per_cell); + Vector dof_values(dofs_per_cell); for (unsigned int i=0; ishape_values, @@ -2643,11 +2645,12 @@ void FEValuesBase::get_function_values ( template -template +template void FEValuesBase::get_function_values ( const InputVector &fe_function, - std::vector > &values) const + std::vector > &values) const { + typedef typename InputVector::value_type Number; Assert (present_cell.get() != 0, ExcMessage ("FEValues object is not reinit'ed to any cell")); @@ -2656,7 +2659,7 @@ void FEValuesBase::get_function_values ( AssertDimension (fe_function.size(), present_cell->n_dofs_for_dof_handler()); // get function values of dofs on this cell - Vector dof_values (dofs_per_cell); + Vector dof_values (dofs_per_cell); present_cell->get_interpolated_dof_values(fe_function, dof_values); VectorSlice > > val(values); internal::do_function_values(dof_values.begin(), this->shape_values, *fe, @@ -2666,12 +2669,13 @@ void FEValuesBase::get_function_values ( template -template +template void FEValuesBase::get_function_values ( const InputVector &fe_function, const VectorSlice > &indices, - std::vector > &values) const + std::vector > &values) const { + typedef typename InputVector::value_type Number; // Size of indices must be a multiple of dofs_per_cell such that an integer // number of function values is generated in each point. Assert (indices.size() % dofs_per_cell == 0, @@ -2682,7 +2686,7 @@ void FEValuesBase::get_function_values ( VectorSlice > > val(values); if (indices.size() <= 100) { - double dof_values[100]; + Number dof_values[100]; for (unsigned int i=0; ishape_values, *fe, @@ -2691,7 +2695,7 @@ void FEValuesBase::get_function_values ( } else { - Vector dof_values(100); + Vector dof_values(100); for (unsigned int i=0; ishape_values, *fe, @@ -2707,9 +2711,10 @@ template void FEValuesBase::get_function_values ( const InputVector &fe_function, const VectorSlice > &indices, - VectorSlice > > values, + VectorSlice > > values, bool quadrature_points_fastest) const { + typedef typename InputVector::value_type Number; Assert (this->update_flags & update_values, ExcAccessToUninitializedField("update_values")); @@ -2720,7 +2725,7 @@ void FEValuesBase::get_function_values ( if (indices.size() <= 100) { - double dof_values[100]; + Number dof_values[100]; for (unsigned int i=0; ishape_values, *fe, @@ -2730,7 +2735,7 @@ void FEValuesBase::get_function_values ( } else { - Vector dof_values(indices.size()); + Vector dof_values(indices.size()); for (unsigned int i=0; ishape_values, *fe, @@ -2747,8 +2752,9 @@ template void FEValuesBase::get_function_gradients ( const InputVector &fe_function, - std::vector > &gradients) const + std::vector > &gradients) const { + typedef typename InputVector::value_type Number; Assert (this->update_flags & update_gradients, ExcAccessToUninitializedField("update_gradients")); AssertDimension (fe->n_components(), 1); @@ -2757,7 +2763,7 @@ FEValuesBase::get_function_gradients ( AssertDimension (fe_function.size(), present_cell->n_dofs_for_dof_handler()); // get function values of dofs on this cell - Vector dof_values (dofs_per_cell); + Vector dof_values (dofs_per_cell); present_cell->get_interpolated_dof_values(fe_function, dof_values); internal::do_function_derivatives(dof_values.begin(), this->shape_gradients, gradients); @@ -2770,15 +2776,16 @@ template void FEValuesBase::get_function_gradients ( const InputVector &fe_function, const VectorSlice > &indices, - std::vector > &gradients) const + std::vector > &gradients) const { + typedef typename InputVector::value_type Number; Assert (this->update_flags & update_gradients, ExcAccessToUninitializedField("update_gradients")); AssertDimension (fe->n_components(), 1); AssertDimension (indices.size(), dofs_per_cell); if (dofs_per_cell <= 100) { - double dof_values[100]; + Number dof_values[100]; for (unsigned int i=0; ishape_gradients, @@ -2786,7 +2793,7 @@ void FEValuesBase::get_function_gradients ( } else { - Vector dof_values(dofs_per_cell); + Vector dof_values(dofs_per_cell); for (unsigned int i=0; ishape_gradients, @@ -2802,8 +2809,9 @@ template void FEValuesBase::get_function_gradients ( const InputVector &fe_function, - std::vector > > &gradients) const + std::vector > > &gradients) const { + typedef typename InputVector::value_type Number; Assert (this->update_flags & update_gradients, ExcAccessToUninitializedField("update_gradients")); Assert (present_cell.get() != 0, @@ -2811,9 +2819,9 @@ FEValuesBase::get_function_gradients ( AssertDimension (fe_function.size(), present_cell->n_dofs_for_dof_handler()); // get function values of dofs on this cell - Vector dof_values (dofs_per_cell); + Vector dof_values (dofs_per_cell); present_cell->get_interpolated_dof_values(fe_function, dof_values); - VectorSlice > > > grads(gradients); + VectorSlice > > > grads(gradients); internal::do_function_derivatives(dof_values.begin(), this->shape_gradients, *fe, this->shape_function_to_row_table, grads); @@ -2826,9 +2834,10 @@ template void FEValuesBase::get_function_gradients ( const InputVector &fe_function, const VectorSlice > &indices, - VectorSlice > > > gradients, + VectorSlice > > > gradients, bool quadrature_points_fastest) const { + typedef typename InputVector::value_type Number; // Size of indices must be a multiple of dofs_per_cell such that an integer // number of function values is generated in each point. Assert (indices.size() % dofs_per_cell == 0, @@ -2838,7 +2847,7 @@ void FEValuesBase::get_function_gradients ( if (indices.size() <= 100) { - double dof_values[100]; + Number dof_values[100]; for (unsigned int i=0; ishape_gradients, @@ -2848,7 +2857,7 @@ void FEValuesBase::get_function_gradients ( } else { - Vector dof_values(indices.size()); + Vector dof_values(indices.size()); for (unsigned int i=0; ishape_gradients, @@ -2865,8 +2874,9 @@ template void FEValuesBase:: get_function_hessians (const InputVector &fe_function, - std::vector > &hessians) const + std::vector > &hessians) const { + typedef typename InputVector::value_type Number; AssertDimension (fe->n_components(), 1); Assert (this->update_flags & update_hessians, ExcAccessToUninitializedField("update_hessians")); @@ -2875,7 +2885,7 @@ get_function_hessians (const InputVector &fe_function, AssertDimension (fe_function.size(), present_cell->n_dofs_for_dof_handler()); // get function values of dofs on this cell - Vector dof_values (dofs_per_cell); + Vector dof_values (dofs_per_cell); present_cell->get_interpolated_dof_values(fe_function, dof_values); internal::do_function_derivatives(dof_values.begin(), this->shape_hessians, hessians); @@ -2888,15 +2898,16 @@ template void FEValuesBase::get_function_hessians ( const InputVector &fe_function, const VectorSlice > &indices, - std::vector > &hessians) const + std::vector > &hessians) const { + typedef typename InputVector::value_type Number; Assert (this->update_flags & update_hessians, ExcAccessToUninitializedField("update_hessians")); AssertDimension (fe_function.size(), present_cell->n_dofs_for_dof_handler()); AssertDimension (indices.size(), dofs_per_cell); if (dofs_per_cell <= 100) { - double dof_values[100]; + Number dof_values[100]; for (unsigned int i=0; ishape_hessians, @@ -2904,7 +2915,7 @@ void FEValuesBase::get_function_hessians ( } else { - Vector dof_values(dofs_per_cell); + Vector dof_values(dofs_per_cell); for (unsigned int i=0; ishape_hessians, @@ -2920,9 +2931,10 @@ template void FEValuesBase:: get_function_hessians (const InputVector &fe_function, - std::vector > > &hessians, + std::vector > > &hessians, bool quadrature_points_fastest) const { + typedef typename InputVector::value_type Number; Assert (this->update_flags & update_hessians, ExcAccessToUninitializedField("update_hessians")); Assert (present_cell.get() != 0, @@ -2930,9 +2942,9 @@ get_function_hessians (const InputVector &fe_function, AssertDimension (fe_function.size(), present_cell->n_dofs_for_dof_handler()); // get function values of dofs on this cell - Vector dof_values (dofs_per_cell); + Vector dof_values (dofs_per_cell); present_cell->get_interpolated_dof_values(fe_function, dof_values); - VectorSlice > > > hes(hessians); + VectorSlice > > > hes(hessians); internal::do_function_derivatives(dof_values.begin(), this->shape_hessians, *fe, this->shape_function_to_row_table, hes, quadrature_points_fastest); @@ -2945,16 +2957,17 @@ template void FEValuesBase::get_function_hessians ( const InputVector &fe_function, const VectorSlice > &indices, - VectorSlice > > > hessians, + VectorSlice > > > hessians, bool quadrature_points_fastest) const { + typedef typename InputVector::value_type Number; Assert (this->update_flags & update_hessians, ExcAccessToUninitializedField("update_hessians")); Assert (indices.size() % dofs_per_cell == 0, ExcNotMultiple(indices.size(), dofs_per_cell)); if (indices.size() <= 100) { - double dof_values[100]; + Number dof_values[100]; for (unsigned int i=0; ishape_hessians, @@ -2964,7 +2977,7 @@ void FEValuesBase::get_function_hessians ( } else { - Vector dof_values(indices.size()); + Vector dof_values(indices.size()); for (unsigned int i=0; ishape_hessians, @@ -2977,11 +2990,12 @@ void FEValuesBase::get_function_hessians ( template -template +template void FEValuesBase::get_function_laplacians ( const InputVector &fe_function, - std::vector &laplacians) const + std::vector &laplacians) const { + typedef typename InputVector::value_type Number; Assert (this->update_flags & update_hessians, ExcAccessToUninitializedField("update_hessians")); AssertDimension (fe->n_components(), 1); @@ -2990,7 +3004,7 @@ void FEValuesBase::get_function_laplacians ( AssertDimension (fe_function.size(), present_cell->n_dofs_for_dof_handler()); // get function values of dofs on this cell - Vector dof_values (dofs_per_cell); + Vector dof_values (dofs_per_cell); present_cell->get_interpolated_dof_values(fe_function, dof_values); internal::do_function_laplacians(dof_values.begin(), this->shape_hessians, laplacians); @@ -2999,19 +3013,20 @@ void FEValuesBase::get_function_laplacians ( template -template +template void FEValuesBase::get_function_laplacians ( const InputVector &fe_function, const VectorSlice > &indices, - std::vector &laplacians) const + std::vector &laplacians) const { + typedef typename InputVector::value_type Number; Assert (this->update_flags & update_hessians, ExcAccessToUninitializedField("update_hessians")); AssertDimension (fe->n_components(), 1); AssertDimension (indices.size(), dofs_per_cell); if (dofs_per_cell <= 100) { - double dof_values[100]; + Number dof_values[100]; for (unsigned int i=0; ishape_hessians, @@ -3019,7 +3034,7 @@ void FEValuesBase::get_function_laplacians ( } else { - Vector dof_values(dofs_per_cell); + Vector dof_values(dofs_per_cell); for (unsigned int i=0; ishape_hessians, @@ -3030,11 +3045,12 @@ void FEValuesBase::get_function_laplacians ( template -template +template void FEValuesBase::get_function_laplacians ( const InputVector &fe_function, - std::vector > &laplacians) const + std::vector > &laplacians) const { + typedef typename InputVector::value_type Number; Assert (present_cell.get() != 0, ExcMessage ("FEValues object is not reinit'ed to any cell")); Assert (this->update_flags & update_hessians, @@ -3042,7 +3058,7 @@ void FEValuesBase::get_function_laplacians ( AssertDimension (fe_function.size(), present_cell->n_dofs_for_dof_handler()); // get function values of dofs on this cell - Vector dof_values (dofs_per_cell); + Vector dof_values (dofs_per_cell); present_cell->get_interpolated_dof_values(fe_function, dof_values); internal::do_function_laplacians(dof_values.begin(), this->shape_hessians, *fe, this->shape_function_to_row_table, @@ -3052,12 +3068,13 @@ void FEValuesBase::get_function_laplacians ( template -template +template void FEValuesBase::get_function_laplacians ( const InputVector &fe_function, const VectorSlice > &indices, - std::vector > &laplacians) const + std::vector > &laplacians) const { + typedef typename InputVector::value_type Number; // Size of indices must be a multiple of dofs_per_cell such that an integer // number of function values is generated in each point. Assert (indices.size() % dofs_per_cell == 0, @@ -3066,7 +3083,7 @@ void FEValuesBase::get_function_laplacians ( ExcAccessToUninitializedField("update_hessians")); if (indices.size() <= 100) { - double dof_values[100]; + Number dof_values[100]; for (unsigned int i=0; ishape_hessians, @@ -3076,7 +3093,7 @@ void FEValuesBase::get_function_laplacians ( } else { - Vector dof_values(indices.size()); + Vector dof_values(indices.size()); for (unsigned int i=0; ishape_hessians, @@ -3089,20 +3106,21 @@ void FEValuesBase::get_function_laplacians ( template -template +template void FEValuesBase::get_function_laplacians ( const InputVector &fe_function, const VectorSlice > &indices, - std::vector > &laplacians, + std::vector > &laplacians, bool quadrature_points_fastest) const { + typedef typename InputVector::value_type number; Assert (indices.size() % dofs_per_cell == 0, ExcNotMultiple(indices.size(), dofs_per_cell)); Assert (this->update_flags & update_hessians, ExcAccessToUninitializedField("update_hessians")); if (indices.size() <= 100) { - double dof_values[100]; + Number dof_values[100]; for (unsigned int i=0; ishape_hessians, @@ -3112,7 +3130,7 @@ void FEValuesBase::get_function_laplacians ( } else { - Vector dof_values(indices.size()); + Vector dof_values(indices.size()); for (unsigned int i=0; ishape_hessians,