deal.II version GIT relicensing-6834-g5b78e6bcdf 2026-10-01 11:20:01+00:00
\(\newcommand{\dealvcentcolon}{\mathrel{\mathop{:}}}\) \(\newcommand{\dealcoloneq}{\dealvcentcolon\mathrel{\mkern-1.2mu}=}\) \(\newcommand{\jump}[1]{\left[\!\left[ #1 \right]\!\right]}\) \(\newcommand{\average}[1]{\left\{\!\left\{ #1 \right\}\!\right\}}\)
Loading...
Searching...
No Matches
function_cspline.h
Go to the documentation of this file.
1// -----------------------------------------------------------------------------
2//
3// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception OR LGPL-2.1-or-later
4// Copyright (C) 2016 - 2026 by the deal.II authors
5//
6// This file is part of the deal.II library.
7//
8// Detailed license information governing the source code and contributions
9// can be found in LICENSE.md and CONTRIBUTING.md at the top level directory.
10//
11// -----------------------------------------------------------------------------
12
13#ifndef dealii_function_cspline_h
14#define dealii_function_cspline_h
15
16#include <deal.II/base/config.h>
17
20#include <deal.II/base/tensor.h>
21
22#include <cstddef>
23#include <ostream>
24#include <vector>
25
26#ifdef DEAL_II_WITH_GSL
28# include <deal.II/base/mutex.h>
29# include <deal.II/base/point.h>
30
31# include <gsl/gsl_interp.h>
32# include <gsl/gsl_spline.h>
33
34# include <memory>
35
36#endif
37
39
40#ifdef DEAL_II_WITH_GSL
41namespace Functions
42{
44 int,
45 << "Interpolation points vector size can not be <" << arg1
46 << ">.");
47
49 int,
50 int,
51 << "The size of interpolation points <" << arg1
52 << "> is different from the size of interpolation values <"
53 << arg2 << ">.");
54
55
57 int,
58 double,
59 double,
60 << "The input interpolation points are not strictly ordered : "
61 << std::endl
62 << "x[" << arg1 << "] = " << arg2 << " >= x[" << (arg1 + 1)
63 << "] = " << arg3 << '.');
64
67 double,
68 double,
69 double,
70 << "Spline function can not be evaluated outside of the interpolation range: "
71 << std::endl
72 << arg1 << " is not in [" << arg2 << ';' << arg3 << "].");
73
84 template <int dim>
85 class CSpline : public Function<dim>
86 {
87 public:
93 CSpline(const std::vector<double> &interpolation_points,
94 const std::vector<double> &interpolation_values);
95
96 virtual double
97 value(const Point<dim> &point,
98 const unsigned int component = 0) const override;
99
100 virtual Tensor<1, dim>
101 gradient(const Point<dim> &p,
102 const unsigned int component = 0) const override;
103
105 hessian(const Point<dim> &p,
106 const unsigned int component = 0) const override;
107
108 virtual double
109 laplacian(const Point<dim> &p,
110 const unsigned int component = 0) const override;
111
115 virtual std::size_t
116 memory_consumption() const override;
117
118 private:
122 const std::vector<double> interpolation_points;
123
127 const std::vector<double> interpolation_values;
128
132 std::unique_ptr<gsl_interp_accel, void (*)(gsl_interp_accel *)> acc;
133
137 std::unique_ptr<gsl_spline, void (*)(gsl_spline *)> cspline;
138
143 };
144} // namespace Functions
145
146#endif
147
149
150#endif
virtual SymmetricTensor< 2, dim > hessian(const Point< dim > &p, const unsigned int component=0) const override
Threads::Mutex acc_mutex
virtual double value(const Point< dim > &point, const unsigned int component=0) const override
virtual std::size_t memory_consumption() const override
std::unique_ptr< gsl_interp_accel, void(*)(gsl_interp_accel *)> acc
const std::vector< double > interpolation_points
virtual double laplacian(const Point< dim > &p, const unsigned int component=0) const override
const std::vector< double > interpolation_values
std::unique_ptr< gsl_spline, void(*)(gsl_spline *)> cspline
virtual Tensor< 1, dim > gradient(const Point< dim > &p, const unsigned int component=0) const override
Definition point.h:111
#define DEAL_II_NAMESPACE_OPEN
Definition config.h:38
#define DEAL_II_NAMESPACE_CLOSE
Definition config.h:39
static ::ExceptionBase & ExcCSplineSizeMismatch(int arg1, int arg2)
#define DeclException2(Exception2, type1, type2, outsequence)
static ::ExceptionBase & ExcCSplineRange(double arg1, double arg2, double arg3)
#define DeclException3(Exception3, type1, type2, type3, outsequence)
static ::ExceptionBase & ExcCSplineOrder(int arg1, double arg2, double arg3)
static ::ExceptionBase & ExcCSplineEmpty(int arg1)
#define DeclException1(Exception1, type1, outsequence)