From 01f7b958bbf618e9c5134b500f44d35e3ce69bec Mon Sep 17 00:00:00 2001 From: Paul Young Date: Mon, 25 Jun 2018 13:43:48 -0500 Subject: [PATCH] guard operator() --- src/QMCFiniteSize/NaturalSpline3D.cpp | 10 ++++++++++ src/QMCFiniteSize/NaturalSpline3D.h | 1 + 2 files changed, 11 insertions(+) diff --git a/src/QMCFiniteSize/NaturalSpline3D.cpp b/src/QMCFiniteSize/NaturalSpline3D.cpp index 1ed165f660..615cfc141b 100644 --- a/src/QMCFiniteSize/NaturalSpline3D.cpp +++ b/src/QMCFiniteSize/NaturalSpline3D.cpp @@ -25,8 +25,18 @@ BCtype_d NaturalSpline3D::natural_boundary() bc.rVal = 1.0; return bc; } +bool NaturalSpline3D::in_convex_hull(double x, double y, double z) +{ + bool inx, iny, inz; + inx = iny = inz = true; + if (xgrid3d_.x.end) inx = false; + if (ygrid3d_.y.end) iny = false; + if (zgrid3d_.z.end) inz = false; + return (inx & iny & inz); +} double NaturalSpline3D::operator()(double x, double y, double z) { + if (not in_convex_hull(x, y, z)) return NAN; double val; eval_UBspline_3d_d(spline3d_, x, y, z, &val); return val; diff --git a/src/QMCFiniteSize/NaturalSpline3D.h b/src/QMCFiniteSize/NaturalSpline3D.h index 8e0631b9d1..c185e1d651 100644 --- a/src/QMCFiniteSize/NaturalSpline3D.h +++ b/src/QMCFiniteSize/NaturalSpline3D.h @@ -17,6 +17,7 @@ class NaturalSpline3D NaturalSpline3D(const Ugrid3D grid3d, double* vals); ~NaturalSpline3D(); BCtype_d natural_boundary(); + bool in_convex_hull(double x, double y, double z); // goal in life: evaluate Bspline at a point in 3D space double operator()(double x, double y, double z);