class ParticleField(object): def __init__(self): self._group = Syncgroup() self._varnames = [] # keep varnames as list to preserve order def __setattr__(self, name, value): if isinstance(value, CLVar): if not(name in self._varnames): self._group.add(value) self._varnames.append(name) object.__setattr__(self, name, value) else: raise NameError('Name already exists.') else: object.__setattr__(self, name, value) def setup_vec(self, *args): for arg in args: self.__setattr__(arg, CLReal4()) def setup_scal(self, *args): for arg in args: self.__setattr__(arg, CLReal()) def setup_int(self, *args): for arg in args: self.__setattr__(arg, CLInt()) def set_length(self, value): self._group._vars[0].shape = (value,) + self._group._vars[0].shape[1:]
def __init__(self): self._group = Syncgroup() self._varnames = [] # keep varnames as list to preserve order