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])
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])
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])
def clear(): for i, j in a.parent(): ti.deactivate(a.parent().parent(), [i, j])
def snode_deactivate(b: ti.template()): for I in ti.grouped(ti.SNode(b.ptr.get_ch(0))): ti.deactivate(b, I)
def snode_deactivate_dynamic(b: ti.template()): for I in ti.grouped(b.parent()): ti.deactivate(b, I)
def clear(): for i in range(n): ti.deactivate(x.parent(), i)
def clear_temp(): for i, j in x_temp.parent().parent(): ti.deactivate(x_temp.parent().parent(), [i, j])
def clear_particles(self): self.n_particles[None] = 0 ti.deactivate(self.x.loop_range().parent().snode(), [])
def deact(): ti.deactivate(cell, [5, 10])
def deact(): for i, j in block2: print(i, j) if i % 32 == 0: ti.deactivate(block2, [i, j])
def deactivate_y(): for i in x: ti.deactivate(y_parent, i)
def deactivate_pointer_fields(): ti.deactivate(p, [1]) ti.deactivate(p, [4])
def deactivate(): ti.deactivate(x.parent().parent(), 4)
def deactivate(): ti.deactivate(a_a, [0])
def clear(): for i in x.parent().parent(): ti.deactivate(x.parent().parent(), i)
def clear(): for i, j in ptr1: ti.deactivate(ptr1, [i, j])
def clear_temp(): for i, j in ptr2: ti.deactivate(ptr2, [i, j])
def snode_deactivate(b: ti.template()): for I in ti.grouped(b): ti.deactivate(b, I)
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])