Skip to content

Commit 2884b76

Browse files
committed
Vectorize the particle deposition
Assume that we're depositing vector, and treat scalar fields as a special case of vectors
1 parent fff7e64 commit 2884b76

File tree

6 files changed

+112
-305
lines changed

6 files changed

+112
-305
lines changed

yt/data_objects/index_subobjects/octree_subset.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
from unyt import unyt_array
88

99
import yt.geometry.particle_deposit as particle_deposit
10-
import yt.geometry.particle_deposit_vector as particle_deposit_vector
1110
import yt.geometry.particle_smooth as particle_smooth
1211
from yt.data_objects.selection_objects.data_selection_objects import (
1312
YTSelectionContainer,
@@ -173,10 +172,8 @@ def deposit(
173172
# Here we perform our particle deposition.
174173
if fields is None:
175174
fields = []
176-
if vector_field:
177-
cls = getattr(particle_deposit_vector, f"deposit_{method}", None)
178-
else:
179-
cls = getattr(particle_deposit, f"deposit_{method}", None)
175+
176+
cls = getattr(particle_deposit, f"deposit_{method}", None)
180177
if cls is None:
181178
raise YTParticleDepositionNotImplemented(method)
182179
nz = self.nz

yt/frontends/artio/_artio_caller.pyx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1560,7 +1560,7 @@ cdef class ARTIORootMeshContainer:
15601560
nf = len(fields)
15611561
cdef np.float64_t[::cython.view.indirect, ::1] field_pointers
15621562
if nf > 0: field_pointers = OnceIndirect(fields)
1563-
cdef np.float64_t[:] field_vals = np.empty(nf, dtype="float64")
1563+
cdef np.float64_t[:, :] field_vals = np.empty((nf, 1), dtype="float64")
15641564
cdef np.ndarray[np.uint8_t, ndim=1, cast=True] mask
15651565
mask = self.mask(selector, -1)
15661566
cdef np.ndarray[np.int64_t, ndim=1] domain_ind
@@ -1583,7 +1583,7 @@ cdef class ARTIORootMeshContainer:
15831583
cdef np.int64_t offset
15841584
for i in range(positions.shape[0]):
15851585
for j in range(nf):
1586-
field_vals[j] = field_pointers[j][i]
1586+
field_vals[j,0] = field_pointers[j][i]
15871587
for j in range(3):
15881588
pos[j] = positions[i, j]
15891589
coords[j] = <int>((pos[j] - self.DLE[j])/self.dds[j])
@@ -1598,7 +1598,7 @@ cdef class ARTIORootMeshContainer:
15981598
offset, pos, field_vals, sfc)
15991599
if pdeposit.update_values == 1:
16001600
for j in range(nf):
1601-
field_pointers[j][i] = field_vals[j]
1601+
field_pointers[j][i] = field_vals[j,0]
16021602

16031603
cdef class SFCRangeSelector(SelectorObject):
16041604

yt/geometry/particle_deposit.pxd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,5 +144,5 @@ cdef class ParticleDepositOperation:
144144
cdef public int update_values
145145
cdef int process(self, int dim[3], int ipart, np.float64_t left_edge[3],
146146
np.float64_t dds[3], np.int64_t offset,
147-
np.float64_t ppos[3], np.float64_t[:] fields,
147+
np.float64_t ppos[3], np.float64_t[:, :] fields,
148148
np.int64_t domain_ind) except -1 nogil

0 commit comments

Comments
 (0)