Skip to content

Tree build refactor 1 - #35

Merged
inducer merged 116 commits into
inducer:mainfrom
xywei:tree-build-refactor
Nov 18, 2022
Merged

Tree build refactor 1#35
inducer merged 116 commits into
inducer:mainfrom
xywei:tree-build-refactor

Conversation

@xywei

@xywei xywei commented Apr 20, 2021

Copy link
Copy Markdown
Contributor

This is the first of several PRs to refactor the tree build. This PR adds the very basic classes and methods to enable generation of uniform box mesh for volumential (thus dropping its dependency on another custom fork of boxtree).

Generating a uniform mesh can be done as follows:

import numpy as np
import boxtree as bt
import modepy as mp

tree = bt.tree_build._make_tob_root(2, [[-1, -1], [1, 1]])

n_levels = 3
for lev in range(n_levels):
    tree = tree.uniformly_refined()

quad = mp.LegendreGaussQuadrature(1)
x, q = bt.tree_build.distribute_quadrature_rule(tree, quad)

print(x)
assert np.isclose(sum(q), 4)

@inducer

inducer commented Sep 20, 2022

Copy link
Copy Markdown
Owner

@xywei There are some CI failures here that I believe might be on the end of the new code. Could you take a look?

_ test_uniform_tree_of_boxes_convergence[<context factory for <pyopencl.Device 'pthread-Intel(R) Xeon(R) Platinum 8272CL CPU @ 2.60GHz' on 'Portable Computing Language'>>-4-3] _
[gw1] linux -- Python 3.10.6 /home/runner/work/boxtree/boxtree/.miniforge3/envs/testing/bin/python3
Traceback (most recent call last):
  File "/home/runner/work/boxtree/boxtree/test/test_tree_of_boxes.py", line 156, in test_uniform_tree_of_boxes_convergence
    assert eoc_rec.order_estimate() >= 2*order + 2 - eps
AssertionError: assert 6.59328736537206 >= (((2 * 4) + 2) - 0.01)
 +  where 6.59328736537206 = <bound method EOCRecorder.order_estimate of <pytools.convergence.EOCRecorder object at 0x7f581a3e82e0>>()
 +    where <bound method EOCRecorder.order_estimate of <pytools.convergence.EOCRecorder object at 0x7f581a3e82e0>> = <pytools.convergence.EOCRecorder object at 0x7f581a3e82e0>.order_estimate
_ test_uniform_tree_of_boxes_convergence[<context factory for <pyopencl.Device 'pthread-Intel(R) Xeon(R) Platinum 8272CL CPU @ 2.60GHz' on 'Portable Computing Language'>>-4-2] _
[gw2] linux -- Python 3.10.6 /home/runner/work/boxtree/boxtree/.miniforge3/envs/testing/bin/python3
Traceback (most recent call last):
  File "/home/runner/work/boxtree/boxtree/test/test_tree_of_boxes.py", line 156, in test_uniform_tree_of_boxes_convergence
    assert eoc_rec.order_estimate() >= 2*order + 2 - eps
AssertionError: assert 1.9475325801058603 >= (((2 * 4) + 2) - 0.01)
 +  where 1.9475325801058603 = <bound method EOCRecorder.order_estimate of <pytools.convergence.EOCRecorder object at 0x7faee4da2a40>>()
 +    where <bound method EOCRecorder.order_estimate of <pytools.convergence.EOCRecorder object at 0x7faee4da2a40>> = <pytools.convergence.EOCRecorder object at 0x7faee4da2a40>.order_estimate
_ test_uniform_tree_of_boxes_convergence[<context factory for <pyopencl.Device 'pthread-Intel(R) Xeon(R) Platinum 8272CL CPU @ 2.60GHz' on 'Portable Computing Language'>>-3-2] _
[gw3] linux -- Python 3.10.6 /home/runner/work/boxtree/boxtree/.miniforge3/envs/testing/bin/python3
Traceback (most recent call last):
  File "/home/runner/work/boxtree/boxtree/test/test_tree_of_boxes.py", line 156, in test_uniform_tree_of_boxes_convergence
    assert eoc_rec.order_estimate() >= 2*order + 2 - eps
AssertionError: assert 7.9662860043822175 >= (((2 * 3) + 2) - 0.01)
 +  where 7.9662860043822175 = <bound method EOCRecorder.order_estimate of <pytools.convergence.EOCRecorder object at 0x7fc2d49ebaf0>>()
 +    where <bound method EOCRecorder.order_estimate of <pytools.convergence.EOCRecorder object at 0x7fc2d49ebaf0>> = <pytools.convergence.EOCRecorder object at 0x7fc2d49ebaf0>.order_estimate

Comment thread boxtree/tree.py
Comment thread boxtree/tree.py Outdated
Comment thread boxtree/tree.py Outdated
Comment thread boxtree/tree.py Outdated
Comment thread boxtree/tree.py Outdated
Comment thread boxtree/tree.py
Comment thread boxtree/tree_build.py Outdated
Comment thread test/test_tree_of_boxes.py Outdated

@inducer inducer left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for addressing the previous set of concerns. Looked again, found some more, including a potentially significant one about box number ordering.

Comment thread boxtree/tree.py Outdated
Comment thread boxtree/tree.py Outdated
Comment thread boxtree/tree.py Outdated
Comment thread boxtree/tree_build.py Outdated
Comment thread boxtree/tree_build.py Outdated
Comment thread boxtree/tree_build.py Outdated
Comment thread boxtree/tree_build.py Outdated
Comment thread boxtree/tree_build.py Outdated
Comment thread boxtree/tree_build.py Outdated
Comment thread boxtree/tree_build.py Outdated
@inducer

inducer commented Oct 23, 2022

Copy link
Copy Markdown
Owner

Unsubscribing... @-mention or request review once it's ready for a look or needs attention.

Comment thread boxtree/tree_build.py Outdated
@inducer
inducer force-pushed the tree-build-refactor branch from fa29266 to db957d4 Compare November 18, 2022 00:13
@inducer
inducer enabled auto-merge (squash) November 18, 2022 00:55
@inducer
inducer merged commit 1e4123c into inducer:main Nov 18, 2022
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.

2 participants