Skip to content

Add some factory functions for (Tensor)B-splines#881

Draft
hverhelst wants to merge 6 commits into
devfrom
feature/spline_factories
Draft

Add some factory functions for (Tensor)B-splines#881
hverhelst wants to merge 6 commits into
devfrom
feature/spline_factories

Conversation

@hverhelst

@hverhelst hverhelst commented May 5, 2026

Copy link
Copy Markdown
Member

Provided a spline $S(\xi,\eta,\dots)$, this PR provides methods to obtain $S^2(\xi,\eta,\dots)$, $S^3(\xi,\eta,\dots)$, $\nabla S(\xi,\eta,\dots)$, $\nabla \cdot S(\xi,\eta,\dots)$, $\nabla^2 S(\xi,\eta,\dots)$.
The PR also adds the knot removal algorithm which is used to go from a Bezier representation of a spline to a higher-continuous representation.

I have added an example, which compares the spline factories w.r.t. interpolateAtAnchors, $L2$ projection and Quasi-Interpolation. There is no clear winner between the interpolateAtAnchors and the spline factories. See the table here:

$ ./bin/splineFactories_example 

Spline c: degree=3, dofs=121 (11×11)

  Quantity  Method                L2 coef err   Linf coef err Time (s)
--------------------------------------------------------------------------------
  toBezier  Factory (ref)         (func check)  1.387e-15     7.949e-05  (func err at 100 pts)
  squared   Factory (ref)         (exact)       (exact)       3.519e-03
  squared   L2 projection         2.291e-10     2.968e-11     3.265e-02
  squared   Quasi-interp          5.780e-12     1.360e-12     8.192e-02
  squared   InterpAtAnchors       5.060e-13     1.085e-13     1.009e-03
  cubed     Factory (ref)         (exact)       (exact)       8.208e-03
  cubed     L2 projection         6.010e-07     1.029e-07     1.626e-01
  cubed     Quasi-interp          1.367e-10     2.379e-11     6.665e-01
  cubed     InterpAtAnchors       2.830e-10     4.142e-11     2.434e-03
  grad_x    Factory (ref)         (exact)       (exact)       2.718e-06
  grad_x    L2 projection         6.357e-14     1.865e-14     2.580e-03
  grad_x    Quasi-interp          1.516e-13     7.505e-14     1.573e-03
  grad_x    InterpAtAnchors       6.549e-15     2.220e-15     4.566e-04
  grad_y    Factory (ref)         (exact)       (exact)       2.446e-05
  grad_y    L2 projection         1.151e-13     2.975e-14     3.531e-03
  grad_y    Quasi-interp          1.504e-13     7.949e-14     1.553e-03
  grad_y    InterpAtAnchors       8.510e-15     2.665e-15     1.051e-04
  lapl      Factory (ref)         (exact)       (exact)       7.615e-05
  lapl      L2 projection         5.049e-12     7.780e-13     4.501e-03
  lapl      Quasi-interp          1.551e-12     2.700e-13     1.295e-02
  lapl      InterpAtAnchors       9.086e-13     2.096e-13     6.003e-04

NEW:
Add knot removal algorithm to gsBoehm (based on Piegl & Tiller)
Add knot removal to gsBSpline and gsTensorBSpline(Basis)
Add factory functions to gsTensorBSpline for Bezier, Squared spline, Cubed spline, Gradient(s) of a spline, Divergence of a spline, Laplacian and Hessian of a spline


Please consider the following checklist before issuing a pull
request:

  • Have you added an explanation of what your changes do and why
    you'd like us to include them?
  • Have you documented any new codes using Doxygen comments?
  • Have you written new tests or examples for your changes?

hverhelst added 6 commits May 5, 2026 16:03
- gsBasis::uniformRefine/Coarsen_withTransfer
- gsConstantFunction
- gsField
- gsFunctionExpr::set_u
- trampoline for gsFunctionSet and gsFunction
- Extra functions (refinement, degree elevation etc) for gsMultiBasis
- Improvements of templated basis bindings (gsHTensorBasis, gsTHBSpline)
- gsOptionList: add function that writes to python dict
- Improve argument names and default args of gsWriteParaview bindings
- SparseMatrix Major template exposure to Pybind (for transfer matrix)
- SparseMatrix cast to CSC Python structure
- System, matrix and rhs independent assembly code for gsL2Projection
- Exposure of quasi interpolation
- Add knot removal to gsBSpline and gsTensorBSpline(Basis)
- Add factory functions to gsTensorBSpline for:
* Bezier
* Squared spline
* Cubed spline
* Gradient(s) of a spline
* Divergence of a spline
* Laplacian and Hessian of a spline
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant