ddemidov / mba

Scattered data interpolation with multilevel B-Splines
MIT License
73 stars 23 forks source link

grid size #14

Open untereiner opened 3 years ago

untereiner commented 3 years ago

Hi,

The paper gives an example with a change to the resolution for the coarsest control lattice, starting with m0 = n0 = 1 But using grid = {1, 1} gives an error. Are these parameters max values ? How is it possible to select the m0 and n0 values in your project ?

subsidiary question: The values and coordinates have to be normalized for the algorithm to work, isn't it ?

ddemidov commented 3 years ago

It's a long time since I touched the code, but I think the minimal grid size should be at least 2. The grid will grow as required in order to refine the approximation (up to max_levels levels).

The values and coordinates have to be normalized for the algorithm to work, isn't it ?

The coordinates seem to be normalized internally here: https://github.com/ddemidov/mba/blob/master/mba/mba.hpp#L377

and I don't think the normalization of values is necessary.

Controlling grid sizes for separate axes could be a useful tool in your hands. See the layered medium example here: https://github.com/ddemidov/mba/blob/master/python/layered.ipynb

untereiner commented 3 years ago

Thanks for you quick response !

I am for now using the sintef implementation of MBA. There is function with parameters m0,n0 defined as:


 /** Create a B-spline approximation to the scattered data.
   *
   *  \param m0,n0 (>=1): The initial size of the spline space in the hierarchical construction.
   *               If the rectangular domain is a square, m0=n0=1 is recommended.
   *               If the rectangular domain in the y-direction is twice of that
   *               the x-direction, m0=1, n0=2 is recommended.
   *               In general, if the rectangular domain in the y-direction is 
   *               k times the length in the x-direction, m0=1, n0=k is recommended.

I don't understand where I can put these in your code.

ddemidov commented 3 years ago

I would try to do grid = {m0 + 1, n0 + 1}. The difference could be that they are counting grid cells, and I count grid points.

untereiner commented 3 years ago

For now I don't succeed to have the same result with the two implementations. I'll check further

osu1191 commented 2 years ago

acg

Hello Mr. Demidov,

I am trying to interpolate a scattered set of data points in 3D (x, y, z, phi) to a regular rectangular 3D grid in a "smooth" manner, i.e. with derivative continuity. The rectangular grid size is always larger than the scattered grid extent. For this particular example, I am using

mba::point<3> lo = {-15.0, -15.0, -15.0}; // lowest extent in all 3-dimension mba::point<3> hi = { 15.0, 15.0, 15.0}; // highest extent in all 3 dimension mba::index<3> grid = {10, 10, 10};
mba::MBA<3> interp(lo, hi, grid, coo, val); // "coo" is a (3 x N) matrix containing (x,y,z) information; 'val' contains the (phi) information.

For points at the corners (e.g. -14, -14, -14), specially around the edges (lying within lo and hi regions), I am getting '0' or values tending to be '0'. Lowering the grid from (10, 10, 10) to (5, 5, 5) increases this interpolated values. I believe, I am making the grid coarser by doing so.

So, I wanted to ask if there is an ideal value of grid (... , ... , ...) parameters that is recommended?

Secondly, if I had to interpolate too many points (~10^6 rectangular grid points), is there a way I could parallelize this process, to reduce computational time consumption?

Thanks in advance,

Paul

ddemidov commented 2 years ago

Each data point only affects 4 grid points around it. So if you have small (5x5x5) initial grid, then each data point contributes to each grid point on this initial grid and thus the final surface is smoother. On your 10x10x10 grid some grid-points are further than 4 cells from any data point and thus have 0 value. The first figure in this example illustrates this:

https://github.com/ddemidov/mba/blob/master/python/example.ipynb

P.S. You should have opened a new issue for this