def __add__(self, other): #if len(self.vector) != len(self.unwrap(other)): #print len(self.vector), len(self.unwrap(other)), type(other) #print self.signaller, other.signaller #print other in other.signaller.subscribers #print "---------------------------------------------" return NumberShiftableVector(self.vector + self.unwrap(other), self.signaller)
def __call__(self, t, fields_f, state_f): state = state_f() velocities = self.method.velocities(state) from pyrticle.tools import NumberShiftableVector from hedge.tools import make_obj_array result = make_obj_array([ NumberShiftableVector( velocities, signaller=state.particle_number_shift_signaller), 0, self.method.depositor.rhs(state) ]) return result
def rhs(self, state): from pyrticle.tools import NumberShiftableVector sub_timer = self.advective_rhs_timer.start_sub_timer() result = NumberShiftableVector( self.backend.get_advective_particle_rhs( state.depositor_state, state.particle_state, self.method.velocities(state)), signaller=state.depositor_state.rho_dof_shift_listener) sub_timer.stop() self.element_activation_counter.transfer( state.depositor_state.element_activation_counter) self.element_kill_counter.transfer( state.depositor_state.element_kill_counter) return result
def __call__(self, t, fields_f, state_f): from pyrticle._internal import ZeroVector fields = fields_f() state = state_f() e, h = self.maxwell_op.split_eh(fields) # assemble field_args of the form [ex,ey,ez] and [bx,by,bz], # inserting ZeroVectors where necessary. idx = 0 e_arg = [] for use_component in self.maxwell_op.get_eh_subset()[0:3]: if use_component: e_arg.append(e[idx]) idx += 1 else: e_arg.append(ZeroVector()) idx = 0 b_arg = [] for use_component in self.maxwell_op.get_eh_subset()[3:6]: if use_component: b_arg.append(self.maxwell_op.mu * h[idx]) idx += 1 else: b_arg.append(ZeroVector()) field_args = tuple(e_arg) + tuple(b_arg) velocities = self.method.velocities(state) # compute forces forces = self.method.pusher.forces(state, velocities, *field_args) from pyrticle.tools import NumberShiftableVector from hedge.tools import make_obj_array result = make_obj_array([ 0, NumberShiftableVector( forces, signaller=state.particle_number_shift_signaller), 0 ]) return result
def store_particle_vis_vector(self, name, vec): from pyrticle.tools import NumberShiftableVector self.particle_vis_map[name] = NumberShiftableVector( vec, signaller=self.particle_number_shift_signaller)
def __mul__(self, other): result = NumberShiftableVector(self.vector * self.unwrap(other), self.signaller) return result