adaptive icon indicating copy to clipboard operation
adaptive copied to clipboard

WIP: (feature) add anisotropic meshing to LearnerND

Open basnijholt opened this issue 6 years ago • 11 comments

(original merge request on GitLab)

opened by Jorn Hoofwijk (@Jorn) at 2018-07-25T11:37:55.550Z

Closes gitlab:#74

Depends on gitlab:!86 and gitlab:#80 and therefore it has the corresponding branches included as well

Still has a few to-do's:

  • [x] let LearnerND.ip() make use of our triangulation rather than building a new one
  • [ ] make it work in arbitrary dimensions
  • [ ] verify that it is beneficial
  • ~~let the user configure the parameters (maximum stretch factor and number of points to take into account)~~ Use one simplex and it's neighbours
  • [x] make test pass
    • ~~add rtree as install requirement~~ No more RTree anymore :)
    • ~~raise exception if anistropic=True and rtree not installed, pass if anisotropic=False~~
  • [x] refactor code to be human-readable
  • ~~let's make it fast :)~~ gitlab:#80

As it seems it doesn't work that well with the ring, since this ring has a relative low average gradient and very high second derivative. So maybe this second derivative might be a more useful property to determine the

Sneak peek: anisotropic

basnijholt avatar Dec 19 '18 19:12 basnijholt

originally posted by Anton Akhmerov (@anton-akhmerov) at 2018-07-25T11:56:16.294Z on GitLab

I notice that you aren't using transform when adding a point to the subtriangulations; could that be of relevance?

basnijholt avatar Dec 19 '18 19:12 basnijholt

originally posted by Anton Akhmerov (@anton-akhmerov) at 2018-07-25T12:00:43.335Z on GitLab

Shouldn't we rather get all neighbors from the triangulation?

basnijholt avatar Dec 19 '18 19:12 basnijholt

originally posted by Anton Akhmerov (@anton-akhmerov) at 2018-07-25T12:05:07.599Z on GitLab

In my trial runs the triangulation stays isotropic in the ring, regardless of the resolution. It doesn't look like this is working as expected.

basnijholt avatar Dec 19 '18 19:12 basnijholt

originally posted by Anton Akhmerov (@anton-akhmerov) at 2018-07-25T12:11:59.837Z on GitLab

I think the scale matrix should be applied first to the point coordinates instead; isn't that right?

basnijholt avatar Dec 19 '18 19:12 basnijholt

originally posted by Anton Akhmerov (@anton-akhmerov) at 2018-07-25T12:18:22.404Z on GitLab

Um, are you sure that you want to normalize the gradient? That sounds like it could be the explanation for the weird behavior with the circle.

basnijholt avatar Dec 19 '18 19:12 basnijholt

originally posted by Anton Akhmerov (@anton-akhmerov) at 2018-07-25T12:36:18.536Z on GitLab

...But this line I don't understand.

basnijholt avatar Dec 19 '18 19:12 basnijholt

originally posted by Anton Akhmerov (@anton-akhmerov) at 2018-07-25T13:11:11.040Z on GitLab

Totally works with the ring:

image

basnijholt avatar Dec 19 '18 19:12 basnijholt

originally posted by Jorn Hoofwijk (@Jorn) at 2018-08-03T16:00:05.473Z on GitLab

In hindsight, I do have a hard time to produce an example where the anisotropic learner does not produce good results.

basnijholt avatar Dec 19 '18 19:12 basnijholt

originally posted by Jorn Hoofwijk (@Jorn) at 2018-08-20T12:13:33.135Z on GitLab

let LearnerND.ip() make use of our triangulation rather than building a new one

This point is going to be a lot harder than I thought. Scipy does not support this and I couldn't find a lib that does. Also when I would just use Triangulation.locate_point(p) it would be an O(N) operation per requested point.

basnijholt avatar Dec 19 '18 19:12 basnijholt

originally posted by Anton Akhmerov (@anton-akhmerov) at 2018-08-20T12:40:11.106Z on GitLab

For plotting you could consider this approach:

  • precompute an array of values at each pixel
  • loop over all triangles, updating every pixel belonging to a triangle.

Otherwise you'd need an rtree and searching over point's neighbors.

basnijholt avatar Dec 19 '18 19:12 basnijholt

originally posted by Jorn Hoofwijk (@Jorn) at 2018-09-21T11:07:18.805Z on GitLab

actually, @basnijholt pointed out yesterday that I was mistaken and that scipy does allow you to provide a triangulation to the linearNDinterpolator. However, I am not completely sure as to what methods must be implemented on the provided triangulation. Depending on what it is, we can either do it efficiently or it may be pretty inefficient.

basnijholt avatar Dec 19 '18 19:12 basnijholt