def reduce(self, dst, t, dt): xs_dash = declare('object') ys_dash = declare('object') fx = declare('object') fy = declare('object') torque = declare('object') force = declare('object') body_id = declare('object') i = declare('int') bid = declare('int') torque = dst.torque force = dst.force xs_dash = dst.xs_dash ys_dash = dst.ys_dash fx = dst.fx fy = dst.fy body_id = dst.body_id for i in range(len(fx)): bid = body_id[i] bid2 = bid * 2 force[bid2] += fx[i] force[bid2 + 1] += fy[i] torque[bid] += xs_dash[i] * fy[i] - ys_dash[i] * fx[i]
def initialize(self, d_idx, d_pos_cm, d_pos_cm0, d_vel_cm, d_vel_cm0, d_theta0, d_theta, d_force, d_torque, d_omega, d_omega0, d_num_body): _i = declare('int') _j = declare('int') if d_idx == 0: for _i in range(d_num_body[0]): d_theta0[_i] = d_theta[_i] d_omega0[_i] = d_omega[_i] d_torque[_i] = 0. for _j in range(2): d_force[2 * _i + _j] = 0. d_pos_cm0[2 * _i + _j] = d_pos_cm[2 * _i + _j] d_vel_cm0[2 * _i + _j] = d_vel_cm[2 * _i + _j]
def stage2(self, d_idx, d_indices, d_xb_dash, d_yb_dash, d_xs_dash, d_ys_dash, d_x, d_y, d_u, d_v, d_vel_cm, d_pos_cm, d_omega, d_theta, d_body_id): i2 = declare('int') bid = declare('int') bid = d_body_id[d_idx] i2 = 2 * bid d_xs_dash[d_idx] = (d_xb_dash[d_idx] * cos(d_theta[bid]) - d_yb_dash[d_idx] * sin(d_theta[bid])) d_ys_dash[d_idx] = (d_xb_dash[d_idx] * sin(d_theta[bid]) + d_yb_dash[d_idx] * cos(d_theta[bid])) d_x[d_idx] = d_pos_cm[i2] + d_xs_dash[d_idx] d_y[d_idx] = d_pos_cm[i2 + 1] + d_ys_dash[d_idx] d_u[d_idx] = d_vel_cm[i2] - d_omega[bid] * d_ys_dash[d_idx] d_v[d_idx] = d_vel_cm[i2 + 1] + d_omega[bid] * d_xs_dash[d_idx]
def py3_f(x: int_) -> int_: y = declare('int') y = x + 1 return x * y