19#ifdef DEAL_II_WITH_GSL
28 const std::vector<double> &y_)
29 : interpolation_points(x_)
30 , interpolation_values(y_)
31 , acc(gsl_interp_accel_alloc(),
32 [](gsl_interp_accel *p) { gsl_interp_accel_free(p); })
33 , cspline(gsl_spline_alloc(gsl_interp_cspline, interpolation_points.size()),
34 [](gsl_spline *p) { gsl_spline_free(p); })
36 Assert(interpolation_points.size() > 0,
39 Assert(interpolation_points.size() == interpolation_values.size(),
41 interpolation_values.size()));
44 for (
unsigned int i = 0; i < interpolation_points.size() - 1; ++i)
45 AssertThrow(interpolation_points[i] < interpolation_points[i + 1],
47 interpolation_points[i],
48 interpolation_points[i + 1]));
50 const unsigned int n = interpolation_points.size();
52 gsl_spline_init(cspline.get(),
53 interpolation_points.data(),
54 interpolation_values.data(),
67 std::lock_guard<std::mutex> lock(acc_mutex);
69 const double x = p[0];
70 Assert(x >= interpolation_points.front() &&
71 x <= interpolation_points.back(),
73 interpolation_points.front(),
74 interpolation_points.back()));
76 return gsl_spline_eval(cspline.get(), x, acc.get());
88 std::lock_guard<std::mutex> lock(acc_mutex);
90 const double x = p[0];
91 Assert(x >= interpolation_points.front() &&
92 x <= interpolation_points.back(),
94 interpolation_points.front(),
95 interpolation_points.back()));
97 const double deriv = gsl_spline_eval_deriv(cspline.get(), x, acc.get());
112 std::lock_guard<std::mutex> lock(acc_mutex);
114 const double x = p[0];
115 Assert(x >= interpolation_points.front() &&
116 x <= interpolation_points.back(),
118 interpolation_points.front(),
119 interpolation_points.back()));
121 return gsl_spline_eval_deriv2(cspline.get(), x, acc.get());
131 res[0][0] = laplacian(p);
143 return sizeof(*this) + 2 *
sizeof(double) * interpolation_values.size();
virtual SymmetricTensor< 2, dim > hessian(const Point< dim > &p, const unsigned int component=0) const override
virtual double value(const Point< dim > &point, const unsigned int component=0) const override
CSpline(const std::vector< double > &interpolation_points, const std::vector< double > &interpolation_values)
virtual std::size_t memory_consumption() const override
virtual double laplacian(const Point< dim > &p, const unsigned int component=0) const override
virtual Tensor< 1, dim > gradient(const Point< dim > &p, const unsigned int component=0) const override
#define DEAL_II_NAMESPACE_OPEN
#define DEAL_II_NAMESPACE_CLOSE
static ::ExceptionBase & ExcCSplineSizeMismatch(int arg1, int arg2)
#define Assert(cond, exc)
static ::ExceptionBase & ExcCSplineRange(double arg1, double arg2, double arg3)
static ::ExceptionBase & ExcCSplineOrder(int arg1, double arg2, double arg3)
static ::ExceptionBase & ExcCSplineEmpty(int arg1)
#define AssertThrow(cond, exc)