Add Lavery splines (#23)#83
Conversation
|
@vincmarks Would it be okay for me to push directly to your fork? I have done some optimization of the 1D implementation and prototyped the 2D version. |
|
Sure, thanks. |
|
The 2D Lavery spline is quite slow for larger data sets. There are likely some easy optimizations that can be done when constructing the JuMP Below are some benchmark numbers for the one dimensional Lavery spline. Note, I changed the default value of Original implementation: julia> @benchmark LaverySpline1D($xDataMedium, $yDataMedium)
BenchmarkTools.Trial: 6 samples with 1 evaluation per sample.
Range (min … max): 901.768 ms … 1.043 s ┊ GC (min … max): 0.00% … 0.00%
Time (median): 928.236 ms ┊ GC (median): 0.00%
Time (mean ± σ): 952.323 ms ± 59.910 ms ┊ GC (mean ± σ): 0.67% ± 1.08%
█ ▁ ▁ ▁ ▁
█▁▁▁▁▁█▁▁▁▁▁▁▁▁▁█▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁█▁▁▁▁▁▁▁▁▁▁▁▁▁█ ▁
902 ms Histogram: frequency by time 1.04 s <
Memory estimate: 35.22 MiB, allocs estimate: 546856.New implementation julia> @benchmark LaverySpline1D($xDataMedium, $yDataMedium; integral_steps=5)
BenchmarkTools.Trial: 227 samples with 1 evaluation per sample.
Range (min … max): 19.462 ms … 55.591 ms ┊ GC (min … max): 0.00% … 42.65%
Time (median): 21.409 ms ┊ GC (median): 0.00%
Time (mean ± σ): 22.023 ms ± 2.971 ms ┊ GC (mean ± σ): 0.47% ± 2.83%
▅█▂ ▁ ▃█▆▂ ▁▂ ▁
▇███▆█▄▆▆███████▅▆▇▆█▅▆▆▄▄▃▄▄▃▃▁▁▅▄▃▄▁▃▃▃▁▁▁▁▄▁▁▁▃▁▃▄▃▁▁▁▁▃ ▄
19.5 ms Histogram: frequency by time 29.1 ms <
Memory estimate: 944.72 KiB, allocs estimate: 16703. |
Pull Request Test Coverage Report for Build 21151938608Details
💛 - Coveralls |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #83 +/- ##
==========================================
- Coverage 96.48% 96.10% -0.39%
==========================================
Files 9 9
Lines 484 488 +4
==========================================
+ Hits 467 469 +2
- Misses 17 19 +2 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
Nice! Does it make sense to put the code in an extension for JuMP and HiGHS because they are not so lightweight and not necessary for every user of TrixiBottomTopography.jl? |
That is probably a better way to add this feature that compartmentalizes the implementation. I am currently looking into improved ways to construct the shape preserving splines. Right now the computational cost of the 2D version makes it not very useful for practitioners. However, I think we can remove some of the optimzation constraints...but I need to read more. |
|
I dug into the literature a bit and implemented a relaxed shape preserving spline in 2D. The relaxation of shape preservation is global versus point-wise. The best comparison I can think of is switching from TVB to TVD for shock capturing. It is much more computationally efficient. For the final example in the thesis from Logan and Oscar (the Seaside, Oregon topography with I also think it is a good idea to have this as a package extension as suggested by @JoshuaLampert . But I want to wait and do that last, once the implementation is cleaned up. |
Co-authored-by: Joshua Lampert <51029046+JoshuaLampert@users.noreply.github.com>
Good point! I thought the docstrings were rendering but need to check this. I opened an issue already that someone (i.e. me) should add some examples that demonstrate how to use your RBF interpolation and the new Lavery splines. |
JoshuaLampert
left a comment
There was a problem hiding this comment.
Thanks! This looks mostly good to me. I only have one question below. I cannot really judge the correctness of the implementation because I am not familiar with Lavery splines, but I assume this is fine.
Co-authored-by: Joshua Lampert <51029046+JoshuaLampert@users.noreply.github.com>
|
Thanks @vincmarks for initiating the implementation! This is a new feature that many will find useful. |
Nice 👍 Did you already open an issue for this? |
I forgot, but can do so. |

Uh oh!
There was an error while loading. Please reload this page.