[yt-svn] commit/yt-3.0: MatthewTurk: Adding a few count functions, and also a flat indexing method for octs.
Bitbucket
commits-noreply at bitbucket.org
Sat Aug 18 06:42:48 PDT 2012
1 new commit in yt-3.0:
https://bitbucket.org/yt_analysis/yt-3.0/changeset/90d723c1c52f/
changeset: 90d723c1c52f
branch: yt-3.0
user: MatthewTurk
date: 2012-08-18 15:42:39
summary: Adding a few count functions, and also a flat indexing method for octs.
affected #: 2 files
diff -r b5e577214c438bea26414a2cc558dc742b55fc5e -r 90d723c1c52f6252684ca346d94d1ccd1994b51c yt/geometry/oct_container.pxd
--- a/yt/geometry/oct_container.pxd
+++ b/yt/geometry/oct_container.pxd
@@ -58,6 +58,8 @@
cdef OctAllocationContainer **domains
cdef struct ParticleArrays:
+ Oct *oct
+ ParticleArrays *next
np.float64_t **pos
np.int64_t *domain_id
np.int64_t np
diff -r b5e577214c438bea26414a2cc558dc742b55fc5e -r 90d723c1c52f6252684ca346d94d1ccd1994b51c yt/geometry/oct_container.pyx
--- a/yt/geometry/oct_container.pyx
+++ b/yt/geometry/oct_container.pyx
@@ -418,6 +418,8 @@
return local_filled
cdef class ParticleOctreeContainer(OctreeContainer):
+ cdef ParticleArrays *first_sd
+ cdef ParticleArrays *last_sd
def __dealloc__(self):
cdef i, j, k
@@ -426,7 +428,7 @@
for k in range(self.nn[2]):
self.visit_free(self.root_mesh[i][j][k])
- cdef visit_free(self, Oct *o):
+ cdef void visit_free(self, Oct *o):
cdef int i, j, k
for i in range(2):
for j in range(2):
@@ -444,11 +446,13 @@
cdef int count, i
cdef Oct* allocate_oct(self):
+ self.nocts += 1
cdef Oct *my_oct = <Oct*> malloc(sizeof(Oct))
cdef ParticleArrays *sd = <ParticleArrays*> \
malloc(sizeof(ParticleArrays))
cdef int i, j, k
- my_oct.ind = my_oct.local_ind = my_oct.domain = -1
+ my_oct.local_ind = my_oct.domain = -1
+ my_oct.ind = self.nocts - 1
my_oct.pos[0] = my_oct.pos[1] = my_oct.pos[2] = -1
my_oct.level = -1
my_oct.sd = sd
@@ -457,14 +461,32 @@
for k in range(2):
my_oct.children[i][j][k] = NULL
my_oct.parent = NULL
+ if self.first_sd == NULL:
+ self.first_sd = sd
+ if self.last_sd != NULL:
+ self.last_sd.next = sd
+ self.last_sd = sd
+ sd.oct = my_oct
+ sd.next = NULL
sd.pos = <np.float64_t **> malloc(sizeof(np.float64_t*) * 3)
sd.pos[0] = <np.float64_t *> malloc(sizeof(np.float64_t) * 32)
sd.pos[1] = <np.float64_t *> malloc(sizeof(np.float64_t) * 32)
sd.pos[2] = <np.float64_t *> malloc(sizeof(np.float64_t) * 32)
sd.domain_id = <np.int64_t *> malloc(sizeof(np.int64_t) * 32)
+ for i in range(32):
+ sd.pos[0][i] = sd.pos[1][i] = sd.pos[2][i] = 0.0
+ sd.domain_id[i] = -1
sd.np = 0
return my_oct
+ def linearly_count(self):
+ cdef np.int64_t total = 0
+ cdef ParticleArrays *c = self.first_sd
+ while c != NULL:
+ total += 1
+ c = c.next
+ return total
+
def add(self, np.ndarray[np.float64_t, ndim=2] pos, np.int64_t domain_id):
cdef int no = pos.shape[0]
cdef int p, i, level
@@ -505,7 +527,7 @@
cur.sd.domain_id[pi] = domain_id
cur.sd.np += 1
- cdef refine_oct(self, Oct *o, np.float64_t pos[3]):
+ cdef void refine_oct(self, Oct *o, np.float64_t pos[3]):
cdef int i, j, k, m, ind[3]
cdef Oct *noct
for i in range(2):
Repository URL: https://bitbucket.org/yt_analysis/yt-3.0/
--
This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.
More information about the yt-svn
mailing list