From: Denis Davydov Date: Tue, 31 Jan 2017 07:43:39 +0000 (+0100) Subject: CSpline: add hessian and laplacian X-Git-Tag: v8.5.0-rc1~180^2~2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7eb2ef301bfc1cb3e3dc7ef30580f621ccc62f32;p=dealii.git CSpline: add hessian and laplacian --- diff --git a/include/deal.II/base/function_cspline.h b/include/deal.II/base/function_cspline.h index 0d324460dc..1653ba0fd2 100644 --- a/include/deal.II/base/function_cspline.h +++ b/include/deal.II/base/function_cspline.h @@ -87,6 +87,12 @@ namespace Functions virtual Tensor<1,dim> gradient (const Point &p, const unsigned int component = 0) const; + virtual SymmetricTensor<2,dim> hessian (const Point &p, + const unsigned int component = 0) const; + + virtual double laplacian(const Point< dim > &p, + const unsigned int component = 0) const; + std::size_t memory_consumption () const; private: diff --git a/source/base/function_cspline.cc b/source/base/function_cspline.cc index f06dc8b562..abb8d87afc 100644 --- a/source/base/function_cspline.cc +++ b/source/base/function_cspline.cc @@ -49,6 +49,8 @@ namespace Functions gsl_spline_init (cspline, &interpolation_points[0], &interpolation_values[0], n); } + + template CSpline::~CSpline() { @@ -59,6 +61,7 @@ namespace Functions } + template double CSpline::value (const Point &p, @@ -72,6 +75,7 @@ namespace Functions } + template Tensor<1,dim> CSpline::gradient (const Point &p, @@ -88,6 +92,33 @@ namespace Functions } + + template + double + CSpline::laplacian (const Point &p, + const unsigned int) const + { + const double &x = p[0]; + Assert (x >= interpolation_points.front() && x <= interpolation_points.back(), + ExcCSplineRange(x,interpolation_points.front(),interpolation_points.back())); + + return gsl_spline_eval_deriv2 (cspline, x, acc); + } + + + + template + SymmetricTensor<2,dim> + CSpline::hessian (const Point &p, + const unsigned int) const + { + Tensor<2,dim> res; + res[0][0] = laplacian(p); + return res; + } + + + template std::size_t CSpline::memory_consumption () const