Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUGFIX] Fix particle selection for corner cases of morton index values #2575

Merged
merged 47 commits into from
Jun 5, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
c3ae3e0
First sketch of a particle selection tester
matthewturk May 4, 2020
0299776
Add in the smoothing length calculations
matthewturk May 4, 2020
073fbf9
Fix particle selection for sub-regions
matthewturk May 4, 2020
f3dd249
Had the logic for is_refined backwards
matthewturk May 5, 2020
7a99703
Updating tests to use particle selection comparison
matthewturk May 5, 2020
df4cf91
Update yt/geometry/particle_oct_container.pyx
matthewturk May 5, 2020
878e018
Update yt/geometry/particle_oct_container.pyx
matthewturk May 5, 2020
cc93f19
Update yt/geometry/particle_oct_container.pyx
matthewturk May 5, 2020
a8ef879
Updating from comments
matthewturk May 5, 2020
d22947e
Refine tests a bit
matthewturk May 7, 2020
934a4eb
Add tests for wrapping on right
matthewturk May 7, 2020
402afa0
Rework periodic smoothing length calculations
matthewturk May 7, 2020
2e39ef1
Rework periodic smoothing length calculations
matthewturk May 7, 2020
0b68faf
We need bounds[i][1] + 1 for inclusive loops
matthewturk May 7, 2020
a5642b6
Merge branch 'fix_select_mi1mi2' of github.com:matthewturk/yt into fi…
matthewturk May 7, 2020
6f6dadc
Merge branch 'test_particle_selections' into fix_select_mi1mi2
matthewturk May 7, 2020
b20c3ed
remove unused import
matthewturk May 8, 2020
8cdf546
First, not-quite-working, pass at refined stuff.
matthewturk May 9, 2020
af135de
Temporary commit, still not working
matthewturk May 13, 2020
0062a98
Merge branch 'fix_select_mi1mi2' of github.com:matthewturk/yt into fi…
matthewturk May 13, 2020
e626e25
another pass
matthewturk May 15, 2020
b1c0d74
try to short circuit, and fix cython bugs
matthewturk May 15, 2020
bc7121c
Use expanded morton for faster BIGMAX selection
matthewturk May 19, 2020
300fc4a
Give up on hiding the C++ in EWAH
matthewturk May 19, 2020
2164393
Intermediate commit on way to working
matthewturk May 21, 2020
e89bd59
Keep a semi-running tally of bool array collections
matthewturk May 21, 2020
09aacb9
Switch to using BoolArray
matthewturk May 22, 2020
c82a015
Switch to word adding for refined EWAH.
matthewturk May 22, 2020
5c30b9a
Fixing a flake8 error
matthewturk May 22, 2020
a66be30
remove unused unordered_set import
matthewturk May 22, 2020
017768b
Fix testing calls; not working yet.
matthewturk May 23, 2020
d99d87f
Missed a logic check
matthewturk May 25, 2020
c5da911
Use bounded_morton_split_dds in coarse indexing
matthewturk May 26, 2020
ac32bb0
Fencepost error
matthewturk May 26, 2020
e8ce92b
Check for None in append()
matthewturk May 26, 2020
588b50e
Changing to uint32_t for Clang
matthewturk May 26, 2020
6488e10
Try to be more careful with uint/int distinctions.
matthewturk May 26, 2020
26a4ed4
Explicitly cast to uword
matthewturk May 26, 2020
e29599d
Update EWAH to 88b25a3345b82353ccd97a7de6064e6c179a7cc2
matthewturk May 27, 2020
9e1f34e
This fixes a compilation error
jzuhone May 29, 2020
bd1fb35
Make this platform-dependent
jzuhone May 29, 2020
25304b3
Update order-of-include and C++11 for particle_oct_container.pyx
matthewturk May 29, 2020
1384a35
Merge branch 'yt-4.0' into fix_select_mi1mi2
matthewturk May 29, 2020
e5847d8
Update to Bionic as per Kacper's suggestion
matthewturk May 29, 2020
3baa1bc
Merge branch 'fix_select_mi1mi2' of github.com:matthewturk/yt into fi…
matthewturk May 29, 2020
c85827e
Fix a handful of lint and style issues
matthewturk Jun 2, 2020
59290f0
Updating to new answer-store rev
matthewturk Jun 3, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
language: python
dist: xenial
dist: bionic
Copy link
Member

Choose a reason for hiding this comment

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

I must have missed the reason for switching dists in travis. What was that for?

Copy link
Contributor

@ax3l ax3l Oct 8, 2020

Choose a reason for hiding this comment

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

Ups, this slipped through and caused a regression: older GCC (<6) need explicit C++11 flags in the build system, otherwise they will fail to build: #2892
It's not clear to me why this is not set though, because setup.py sets extra_compile_args=["-std=c++11"])... 🤔 Does it need to be added to further Extensions that include the same header?

cache:
pip: true
directories:
Expand Down
2 changes: 1 addition & 1 deletion answer-store
3 changes: 2 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,8 @@ def _compile(
include_dirs=["yt/utilities/lib/",
"yt/utilities/lib/ewahboolarray"],
language="c++",
libraries=std_libs),
libraries=std_libs,
extra_compile_args=["-std=c++11"]),
Extension("yt.geometry.selection_routines",
["yt/geometry/selection_routines.pyx"],
include_dirs=["yt/utilities/lib/"],
Expand Down
70 changes: 69 additions & 1 deletion yt/frontends/gadget/tests/test_outputs.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
import tempfile

import yt
from yt.testing import requires_file
from yt.testing import requires_file, \
ParticleSelectionComparison
from yt.utilities.answer_testing.framework import \
data_dir_load, \
requires_ds, \
Expand Down Expand Up @@ -107,6 +108,73 @@ def test_multifile_read():
assert isinstance(data_dir_load(snap_33), GadgetDataset)
assert isinstance(data_dir_load(snap_33_dir), GadgetDataset)

@requires_file(snap_33)
def test_particle_subselection():
#This checks that we correctly subselect from a dataset, first by making
#sure we get all the particles, then by comparing manual selections against
#them.
ds = data_dir_load(snap_33)
psc = ParticleSelectionComparison(ds)

sp1 = ds.sphere("c", (0.1, "unitary"))
psc.compare_dobj_selection(sp1)

sp2 = ds.sphere("c", (0.2, "unitary"))
psc.compare_dobj_selection(sp2)

# Test wrapping around each axis individually: x
sp3_x = ds.sphere((1.0, 12.5, 12.5), (2.0, "code_length"))
psc.compare_dobj_selection(sp3_x)

# Test wrapping around each axis individually: y
sp3_y = ds.sphere((12.5, 1.0, 12.5), (2.0, "code_length"))
psc.compare_dobj_selection(sp3_y)

# Test wrapping around each axis individually: z
sp3_z = ds.sphere((12.5, 12.5, 1.0), (2.0, "code_length"))
psc.compare_dobj_selection(sp3_z)

# Test wrapping around all three axes simultaneously on left
sp3_all = ds.sphere((1.0, 1.0, 1.0), (2.0, "code_length"))
psc.compare_dobj_selection(sp3_all)

# Test wrapping around each axis individually on right: x
sp4_x = ds.sphere((24.0, 12.5, 12.5), (2.0, "code_length"))
psc.compare_dobj_selection(sp4_x)

# Test wrapping around each axis individually on right: y
sp4_y = ds.sphere((12.5, 24.0, 12.5), (2.0, "code_length"))
psc.compare_dobj_selection(sp4_y)

# Test wrapping around each axis individually on right: z
sp4_z = ds.sphere((12.5, 12.5, 24.0), (2.0, "code_length"))
psc.compare_dobj_selection(sp4_z)

# Test wrapping around all three axes simultaneously on right
sp4_all = ds.sphere((24.0, 24.0, 24.0), (2.0, "code_length"))
psc.compare_dobj_selection(sp4_all)

sp5 = ds.sphere("c", (0.5, "unitary"))
psc.compare_dobj_selection(sp5)

dd = ds.all_data()
psc.compare_dobj_selection(dd)

reg1 = ds.r[ (0.1, 'unitary'):(0.9, 'unitary'),
(0.1, 'unitary'):(0.9, 'unitary'),
(0.1, 'unitary'):(0.9, 'unitary')]
psc.compare_dobj_selection(reg1)

reg2 = ds.r[ (0.8, 'unitary'):(0.85, 'unitary'),
(0.8, 'unitary'):(0.85, 'unitary'),
(0.8, 'unitary'):(0.85, 'unitary')]
psc.compare_dobj_selection(reg2)

reg3 = ds.r[ (0.3, 'unitary'):(0.6, 'unitary'),
(0.2, 'unitary'):(0.8, 'unitary'),
(0.0, 'unitary'):(0.1, 'unitary')]
psc.compare_dobj_selection(reg3)

@requires_ds(BE_Gadget)
def test_bigendian_field_access():
ds = data_dir_load(BE_Gadget)
Expand Down
21 changes: 15 additions & 6 deletions yt/geometry/particle_geometry_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,21 +167,30 @@ def _initialize_refined_index(self):
sub_mi1 = np.zeros(max_npart, "uint64")
sub_mi2 = np.zeros(max_npart, "uint64")
pb = get_pbar("Initializing refined index", len(self.data_files))
mask_threshold = getattr(self, '_index_mask_threshold', 2)
count_threshold = getattr(self, '_index_count_threshold', 256)
mylog.debug("Using estimated thresholds of %s and %s for refinement", mask_threshold, count_threshold)
total_refined = 0
total_coarse_refined = ((mask >= 2) & (self.regions.particle_counts > count_threshold)).sum()
mylog.debug("This should produce roughly %s zones, for %s of the domain",
total_coarse_refined, 100 * total_coarse_refined / mask.size)
for i, data_file in enumerate(self.data_files):
coll = None
pb.update(i)
nsub_mi = 0
for ptype, pos in self.io._yield_coordinates(data_file):
if pos.size == 0: continue
if hasattr(self.ds, '_sph_ptypes') and ptype == self.ds._sph_ptypes[0]:
hsml = self.io._get_smoothing_length(
data_file, pos.dtype, pos.shape)
else:
hsml = None
nsub_mi = self.regions._refined_index_data_file(
pos, hsml, mask, sub_mi1, sub_mi2,
data_file.file_id, nsub_mi)
self.regions._set_refined_index_data_file(
sub_mi1, sub_mi2,
data_file.file_id, nsub_mi)
nsub_mi, coll = self.regions._refined_index_data_file(
coll, pos, hsml, mask, sub_mi1, sub_mi2,
data_file.file_id, nsub_mi, count_threshold = count_threshold,
mask_threshold = mask_threshold)
total_refined += nsub_mi
self.regions.bitmasks.append(data_file.file_id, coll)
pb.finish()
self.regions.find_collisions_refined()

Expand Down
Loading