Skip to content

Add anisotropic meshing to LearnerND#141

Merged
basnijholt merged 35 commits intomainfrom
74--add-anisotropicity-to-learnerND
Apr 6, 2026
Merged

Add anisotropic meshing to LearnerND#141
basnijholt merged 35 commits intomainfrom
74--add-anisotropicity-to-learnerND

Conversation

@basnijholt
Copy link
Copy Markdown
Member

(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:

  • 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
  • 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
  • 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

jhoofwijk and others added 30 commits July 23, 2018 11:00
taking into account the output dimension of the function
this way you can import them into other files
it prunes some circumcircles faster
it results in:
~20% faster in 2d
~40% faster in 3d
@basnijholt
Copy link
Copy Markdown
Member Author

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
Copy link
Copy Markdown
Member Author

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
Copy link
Copy Markdown
Member Author

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
Copy link
Copy Markdown
Member Author

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
Copy link
Copy Markdown
Member Author

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
Copy link
Copy Markdown
Member Author

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

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

@basnijholt
Copy link
Copy Markdown
Member Author

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

Totally works with the ring:

image

@basnijholt
Copy link
Copy Markdown
Member Author

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
Copy link
Copy Markdown
Member Author

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
Copy link
Copy Markdown
Member Author

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
Copy link
Copy Markdown
Member Author

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 and others added 5 commits April 3, 2026 13:08
…ransform

The per-simplex anisotropic transform (based on local gradient) varies
across the mesh, which can produce disconnected or non-star-shaped
cavities in the Bowyer-Watson algorithm, breaking its volume
conservation invariant.

Fix: use the uniform bounds-scaling matrix for triangulation
maintenance (Bowyer-Watson insertion). The anisotropic transform is
still used for point selection (choose_point_in_simplex in
_ask_best_point), so anisotropic sampling behavior is preserved.

Closes #74.
…y-to-learnerND

# Conflicts:
#	adaptive/learner/learnerND.py
#	adaptive/learner/triangulation.py
#	adaptive/tests/test_learnernd.py
@basnijholt basnijholt changed the title WIP: (feature) add anisotropic meshing to LearnerND Add anisotropic meshing to LearnerND Apr 6, 2026
@basnijholt basnijholt enabled auto-merge (squash) April 6, 2026 00:11
@basnijholt basnijholt disabled auto-merge April 6, 2026 06:22
@basnijholt basnijholt merged commit 1f60c43 into main Apr 6, 2026
17 of 18 checks passed
@basnijholt basnijholt deleted the 74--add-anisotropicity-to-learnerND branch April 6, 2026 06:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants