예제 #1
0
def substep():
    ti.no_activate(x)
    for i in x:
        r = x[i] - sun
        r_sq_inverse = r / r.norm(1e-3)**3
        acceleration = (pressure * inv_m[i] - gravity) * r_sq_inverse
        v[i] += acceleration * dt
        x[i] += v[i] * dt
        color[i] *= ti.exp(-dt * color_decay)

        if not all(-0.1 <= x[i] <= 1.1):
            ti.deactivate(x.snode.parent(), [i])
예제 #2
0
def substep():
    ti.no_activate(x)
    for i in x:
        r = x[i] - sun
        ir = r / r.norm(1e-3)**3
        acci = pressure * ir * inv_m[i]
        acci += -gravity * ir
        v[i] += acci * dt

        x[i] += v[i] * dt
        color[i] *= ti.exp(-dt * colordeg)

        if not all(-0.1 <= x[i] <= 1.1):
            ti.deactivate(x.snode.parent(), [i])
예제 #3
0
def sparse_api_demo():
    ti.activate(block1, [0, 1])
    ti.activate(block2, [1, 2])

    for i, j in x:
        print('field x[{}, {}] = {}'.format(i, j, x[i, j]))
    # outputs:
    # field x[2, 4] = 0
    # field x[2, 5] = 0
    # field x[3, 4] = 0
    # field x[3, 5] = 0

    for i, j in block2:
        print('Active block2: [{}, {}]'.format(i, j))
    # output: Active block2: [1, 2]

    for i, j in block1:
        print('Active block1: [{}, {}]'.format(i, j))
    # output: Active block1: [0, 1]

    for j in range(4):
        print('Activity of block2[2, {}] = {}'.format(
            j, ti.is_active(block2, [1, j])))

    ti.deactivate(block2, [1, 2])

    for i, j in block2:
        print('Active block2: [{}, {}]'.format(i, j))
    # output: nothing

    for i, j in block1:
        print('Active block1: [{}, {}]'.format(i, j))
    # output: Active block1: [0, 1]

    print(ti.rescale_index(x, block1, ti.Vector([9, 17])))
    # output = [2, 4]

    # Note: ti.Vector is optional in ti.rescale_index.
    print(ti.rescale_index(x, block1, [9, 17]))
    # output = [2, 4]

    ti.activate(block2, [1, 2])
 def clear():
     for i in ptr:
         ti.deactivate(ptr, i)
 def deactivate():
     ti.deactivate(ptr, 4)
 def clear():
     for i in range(n):
         ti.deactivate(lst, [i])
예제 #7
0
 def clear():
     for i, j in a.parent():
         ti.deactivate(a.parent().parent(), [i, j])
예제 #8
0
파일: meta.py 프로젝트: xyuan/taichi
def snode_deactivate(b: ti.template()):
    for I in ti.grouped(ti.SNode(b.ptr.get_ch(0))):
        ti.deactivate(b, I)
예제 #9
0
def snode_deactivate_dynamic(b: ti.template()):
    for I in ti.grouped(b.parent()):
        ti.deactivate(b, I)
예제 #10
0
 def clear():
     for i in range(n):
         ti.deactivate(x.parent(), i)
예제 #11
0
 def clear_temp():
     for i, j in x_temp.parent().parent():
         ti.deactivate(x_temp.parent().parent(), [i, j])
예제 #12
0
 def clear_particles(self):
     self.n_particles[None] = 0
     ti.deactivate(self.x.loop_range().parent().snode(), [])
예제 #13
0
def deact():
    ti.deactivate(cell, [5, 10])
예제 #14
0
def deact():
    for i, j in block2:
        print(i, j)
        if i % 32 == 0:
            ti.deactivate(block2, [i, j])
예제 #15
0
 def deactivate_y():
     for i in x:
         ti.deactivate(y_parent, i)
예제 #16
0
파일: utils.py 프로젝트: taichi-dev/taichi
 def deactivate_pointer_fields():
     ti.deactivate(p, [1])
     ti.deactivate(p, [4])
예제 #17
0
 def deactivate():
     ti.deactivate(x.parent().parent(), 4)
예제 #18
0
 def deactivate():
     ti.deactivate(a_a, [0])
예제 #19
0
 def clear():
     for i in x.parent().parent():
         ti.deactivate(x.parent().parent(), i)
예제 #20
0
 def clear():
     for i, j in ptr1:
         ti.deactivate(ptr1, [i, j])
예제 #21
0
 def clear_temp():
     for i, j in ptr2:
         ti.deactivate(ptr2, [i, j])
예제 #22
0
def snode_deactivate(b: ti.template()):
  for I in ti.grouped(b):
    ti.deactivate(b, I)
예제 #23
0
def clear_pid():
    for i, j, k in voxel_has_particle:
        voxel_has_particle[i, j, k] = 0
    for i, j, k in ti.ndrange(particle_grid_res * 4, particle_grid_res * 4,
                              particle_grid_res * 4):
        ti.deactivate(pid.parent(), [i, j, k])