#ifdef DEAL_II_WITH_GSL
#include <deal.II/base/function.h>
#include <deal.II/base/point.h>
+#include <deal.II/base/thread_management.h>
#include <gsl/gsl_spline.h>
DEAL_II_NAMESPACE_OPEN
* GSL cubic spline interpolator
*/
gsl_spline *cspline;
+
+ /**
+ * A mutex for accelerator object.
+ */
+ mutable Threads::Mutex acc_mutex;
};
}
CSpline<dim>::value (const Point<dim> &p,
const unsigned int) const
{
+ // GSL functions may modify gsl_interp_accel *acc object (last argument).
+ // This can only work in multithreaded applications if we lock the data
+ // structures via a mutex.
+ Threads::Mutex::ScopedLock lock (acc_mutex);
+
const double &x = p[0];
Assert (x >= interpolation_points.front() && x <= interpolation_points.back(),
ExcCSplineRange(x,interpolation_points.front(),interpolation_points.back()));
CSpline<dim>::gradient (const Point<dim> &p,
const unsigned int) const
{
+ // GSL functions may modify gsl_interp_accel *acc object (last argument).
+ // This can only work in multithreaded applications if we lock the data
+ // structures via a mutex.
+ Threads::Mutex::ScopedLock lock (acc_mutex);
+
const double &x = p[0];
Assert (x >= interpolation_points.front() && x <= interpolation_points.back(),
ExcCSplineRange(x,interpolation_points.front(),interpolation_points.back()));
CSpline<dim>::laplacian (const Point<dim> &p,
const unsigned int) const
{
+ // GSL functions may modify gsl_interp_accel *acc object (last argument).
+ // This can only work in multithreaded applications if we lock the data
+ // structures via a mutex.
+ Threads::Mutex::ScopedLock lock (acc_mutex);
+
const double &x = p[0];
Assert (x >= interpolation_points.front() && x <= interpolation_points.back(),
ExcCSplineRange(x,interpolation_points.front(),interpolation_points.back()));