def __init__(self, inlet_pa, dest_pa, inletinfo, kernel, dim, active_stages=[1], callback=None, ghost_pa=None): """An API to add/delete particle when moving between inlet-fluid Parameters ---------- inlet_pa : particle_array particle array for inlet dest_pa : particle_array particle_array of the fluid inletinfo : InletInfo instance contains information fo inlet kernel : Kernel instance Kernel to be used for computations dim : int dimension of the problem active_stages : list stages of integrator at which update should be active callback : function callback after the update function ghost_pa : particle_array particle_array of the ghost_inlet """ self.inlet_pa = inlet_pa self.dest_pa = dest_pa self.ghost_pa = ghost_pa self.callback = callback self.dim = dim self.kernel = kernel self.inletinfo = inletinfo self.x = self.y = self.z = 0.0 self.xn = self.yn = self.zn = 0.0 self.length = 0.0 self.dx = 0.0 self.active_stages = active_stages self.io_eval = None self._init = False cfg = get_config() self.gpu = cfg.use_opencl or cfg.use_cuda
def __init__(self, outlet_pa, source_pa, outletinfo, kernel, dim, active_stages=[1], callback=None, ghost_pa=None): """An API to add/delete particle when moving between fluid-outlet Parameters ---------- outlet_pa : particle_array particle array for outlet source_pa : particle_array particle_array of the fluid ghost_pa : particle_array particle_array of the outlet ghost outletinfo : OutletInfo instance contains information fo outlet kernel : Kernel instance Kernel to be used for computations dim : int dimnesion of the problem active_stages : list stages of integrator at which update should be active callback : function callback after the update function """ self.outlet_pa = outlet_pa self.source_pa = source_pa self.ghost_pa = ghost_pa self.dim = dim self.kernel = kernel self.outletinfo = outletinfo self.x = self.y = self.z = 0.0 self.xn = self.yn = self.zn = 0.0 self.length = 0.0 self.callback = callback self.active_stages = active_stages self.io_eval = None self._init = False self.props_to_copy = None cfg = get_config() self.gpu = cfg.use_opencl or cfg.use_cuda
def setup(backend, openmp=False): get_config().use_openmp = openmp e = Elementwise(axpb, backend=backend) return e
"""Shows the use of annotate without any type information. The type information is extracted from the arguments passed and the function is annotated and compiled at runtime. """ from compyle.api import annotate, Elementwise, wrap, get_config, declare import numpy as np from numpy import sin @annotate def axpb(i, x, y, a, b): xi = x[i] y[i] = a * sin(xi) + b x = np.linspace(0, 1, 10000) y = np.zeros_like(x) a = 2.0 b = 3.0 backend = 'opencl' get_config().use_openmp = True x, y = wrap(x, y, backend=backend) e = Elementwise(axpb, backend=backend) e(x, y, a, b)
p.add_argument('-n', action='store', type=int, dest='n', default=512, help='Number of grid points in y.') p.add_argument('--show', action='store_true', dest='show', default=False, help='Show animation (requires mayavi)') p.add_argument('--gif', action='store_true', default=False, help='Make a gif animation (requires imageio)') cfg = get_config() cfg.suppress_warnings = True o = p.parse_args() julia = elementwise(julia) ny = o.n nx = int(4 * ny // 3) x, y = np.mgrid[-2:2:nx * 1j, -1.5:1.5:ny * 1j] x, y = x.ravel(), y.ravel() z = np.zeros_like(x) x, y, z = wrap(x, y, z) timer(x, y, z) if o.show: plot(x, y, z, nx, ny) if o.gif: