From: kanschat Date: Thu, 20 Sep 2007 21:58:33 +0000 (+0000) Subject: add additional Hessians X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=82b6ca409a24871eee3a3a95957f85eb14b361b9;p=dealii-svn.git add additional Hessians git-svn-id: https://svn.dealii.org/trunk@15226 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/deal.II/include/fe/fe_values.h b/deal.II/deal.II/include/fe/fe_values.h index 4162fdd2c0..ed0281f0e8 100644 --- a/deal.II/deal.II/include/fe/fe_values.h +++ b/deal.II/deal.II/include/fe/fe_values.h @@ -1080,6 +1080,31 @@ class FEValuesBase : protected FEValuesData, std::vector > > &hessians, bool quadrature_points_fastest = false) const; + /** + * Function gradient access with + * more flexibility. see + * get_function_values() with + * corresponding arguments. + */ + template + void get_function_hessians ( + const InputVector& fe_function, + const VectorSlice >& indices, + std::vector >& result) const; + + /** + * Function gradient access with + * more flexibility. see + * get_function_values() with + * corresponding arguments. + */ + template + void get_function_hessians ( + const InputVector& fe_function, + const VectorSlice >& indices, + std::vector > >& result, + bool quadrature_points_fastest = false) const; + /** * @deprecated Wrapper for get_function_hessians() */ @@ -1097,6 +1122,7 @@ class FEValuesBase : protected FEValuesData, std::vector > >&, bool = false) const; + //@} /** diff --git a/deal.II/deal.II/source/fe/fe_values.cc b/deal.II/deal.II/source/fe/fe_values.cc index a87b8d0be8..20ce6c9488 100644 --- a/deal.II/deal.II/source/fe/fe_values.cc +++ b/deal.II/deal.II/source/fe/fe_values.cc @@ -662,9 +662,9 @@ void FEValuesBase::get_function_values ( template template void -FEValuesBase:: -get_function_gradients (const InputVector &fe_function, - std::vector > &gradients) const +FEValuesBase::get_function_gradients ( + const InputVector &fe_function, + std::vector > &gradients) const { Assert (this->update_flags & update_gradients, ExcAccessToUninitializedField()); @@ -744,9 +744,9 @@ void FEValuesBase::get_function_gradients ( template template void -FEValuesBase:: -get_function_gradients (const InputVector &fe_function, - std::vector > > &gradients) const +FEValuesBase::get_function_gradients ( + const InputVector &fe_function, + std::vector > > &gradients) const { Assert (gradients.size() == n_quadrature_points, ExcDimensionMismatch(gradients.size(), n_quadrature_points)); @@ -932,6 +932,44 @@ get_function_hessians (const InputVector &fe_function, +template +template +void FEValuesBase::get_function_hessians ( + const InputVector& fe_function, + const VectorSlice >& indices, + std::vector > &values) const +{ + Assert (this->update_flags & update_second_derivatives, ExcAccessToUninitializedField()); + // This function fills a single + // component only + Assert (fe->n_components() == 1, + ExcDimensionMismatch(fe->n_components(), 1)); + // One index for each dof + Assert (indices.size() == dofs_per_cell, + ExcDimensionMismatch(indices.size(), dofs_per_cell)); + // This vector has one entry for + // each quadrature point + Assert (values.size() == n_quadrature_points, + ExcDimensionMismatch(values.size(), n_quadrature_points)); + + // initialize with zero + std::fill_n (values.begin(), n_quadrature_points, Tensor<2,dim>()); + + // add up contributions of trial + // functions. note that here we + // deal with scalar finite + // elements, so no need to check + // for non-primitivity of shape + // functions + for (unsigned int point=0; pointshape_hessian(shape_func, point)); +} + + + + template template void @@ -1004,6 +1042,97 @@ get_function_hessians (const InputVector &fe_function, +template +template +void FEValuesBase::get_function_hessians ( + const InputVector& fe_function, + const VectorSlice >& indices, + std::vector > >& values, + bool quadrature_points_fastest) const +{ + Assert (this->update_flags & update_second_derivatives, ExcAccessToUninitializedField()); + + const unsigned int n_components = fe->n_components(); + + // 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, + ExcNotMultiple(indices.size(), dofs_per_cell)); + + // The number of components of the + // result may be a multiple of the + // number of components of the + // finite element + const unsigned int result_components = indices.size() * n_components / dofs_per_cell; + + // Check if the value argument is + // initialized to the correct sizes + if (quadrature_points_fastest) + { + Assert (values.size() == result_components, + ExcDimensionMismatch(values.size(), result_components)); + for (unsigned i=0;i()); + + // add up contributions of trial + // functions. now check whether the + // shape function is primitive or + // not. if it is, then set its only + // non-zero component, otherwise + // loop over components + if (quadrature_points_fastest) + for (unsigned int mc = 0; mc < component_multiple; ++mc) + for (unsigned int point=0; pointis_primitive(shape_func)) + values[fe->system_to_component_index(shape_func).first + +mc * n_components][point] + += fe_function(indices[shape_func+mc*dofs_per_cell]) + * shape_hessian(shape_func, point); + else + for (unsigned int c=0; cis_primitive(shape_func)) + values[point][fe->system_to_component_index(shape_func).first + +mc * n_components] + += fe_function(indices[shape_func+mc*dofs_per_cell]) + * shape_hessian(shape_func, point); + else + for (unsigned int c=0; c unsigned int FEValuesBase::memory_consumption () const diff --git a/deal.II/deal.II/source/fe/fe_values.instance.h b/deal.II/deal.II/source/fe/fe_values.instance.h index 94f3f68484..d6ce461798 100644 --- a/deal.II/deal.II/source/fe/fe_values.instance.h +++ b/deal.II/deal.II/source/fe/fe_values.instance.h @@ -74,9 +74,17 @@ void FEValuesBase::get_function_gradients template void FEValuesBase::get_function_hessians (const IN&, std::vector > &) const; +template +void FEValuesBase::get_function_hessians +(const IN&, const VectorSlice >&, + std::vector > &) const; template void FEValuesBase::get_function_hessians (const IN&, std::vector > > &, bool) const; +template +void FEValuesBase::get_function_hessians +(const IN&, const VectorSlice >&, + std::vector > > &, bool) const; DEAL_II_NAMESPACE_CLOSE