diff --git a/source/pysph/sph/funcs/arithmetic_funcs.pyx b/source/pysph/sph/funcs/arithmetic_funcs.pyx index 8cf7a4f..d24a0ec 100644 --- a/source/pysph/sph/funcs/arithmetic_funcs.pyx +++ b/source/pysph/sph/funcs/arithmetic_funcs.pyx @@ -13,7 +13,7 @@ cdef class PropertyGet(SPHFunction): dest -- The destination particle array prop_names -- The properties to get (upto 3 particle arrays) """ - self.prop_names = prop_names + self.prop_names = list(prop_names) SPHFunction.__init__(self, source, dest, setup_arrays=True) self.num_outputs = len(prop_names) self.id = 'property_get' @@ -47,7 +47,7 @@ cdef class PropertyAdd(SPHFunction): prop_names -- The properties to get the sum of constant -- a constant value to add to the result """ - self.prop_names = prop_names + self.prop_names = list(prop_names) self.constant = constant SPHFunction.__init__(self, source, dest, setup_arrays=True) self.num_outputs = 1 @@ -83,7 +83,7 @@ cdef class PropertyNeg(SPHFunction): dest -- The destination particle array. prop_names -- The properties to get the inverse of (upto 3) """ - self.prop_names = prop_names + self.prop_names = list(prop_names) SPHFunction.__init__(self, source, dest, setup_arrays=True) self.num_outputs = len(prop_names) self.id = 'property_neg' @@ -117,7 +117,7 @@ cdef class PropertyMul(SPHFunction): prop_names -- The properties to get product of constant -- a constant value to multiply to the result """ - self.prop_names = prop_names + self.prop_names = list(prop_names) self.constant = constant SPHFunction.__init__(self, source, dest, setup_arrays=True) self.num_outputs = 1 @@ -153,7 +153,7 @@ cdef class PropertyInv(SPHFunction): dest -- The destination particle array. prop_names -- The properties to get inverse of (upto 3) """ - self.prop_names = prop_names + self.prop_names = list(prop_names) SPHFunction.__init__(self, source, dest, setup_arrays=True) self.num_outputs = len(prop_names) self.id = 'property_inv' diff --git a/source/pysph/sph/sph_calc.pyx b/source/pysph/sph/sph_calc.pyx index 7de97f3..d1bb79c 100644 --- a/source/pysph/sph/sph_calc.pyx +++ b/source/pysph/sph/sph_calc.pyx @@ -171,10 +171,11 @@ cdef class SPHCalc: msg = 'SPHFunction.source not same as' msg += ' SPHCalc.sources[%d]'%(i) raise ValueError, msg - if funcs[i].num_outputs > len(self.updates): - raise ValueError, ('Number of updates not same as num_outputs' - '; required %d, got %d %s for func %s'%(funcs[i].num_outputs, - len(self.updates), self.updates, funcs[i])) + if funcs[i].num_outputs != len(self.updates): + logger.warn('Number of updates not same as num_outputs; ' + 'required %d, got %d %s for func %s'%( + funcs[i].num_outputs, len(self.updates), + self.updates, funcs[i])) # not valid for SPHFunction #if funcs[i].dest != self.dest: # msg = 'SPHFunction.dest not same as' @@ -216,6 +217,9 @@ cdef class SPHCalc: func = self.funcs[0] + # Add temporary array in case of fewer arguments to sph() + self.dest.add_property(dict(name='_tmp')) + self.src_reads = func.src_reads self.dst_reads = func.dst_reads @@ -223,17 +227,24 @@ cdef class SPHCalc: str output_array3=None, bint exclude_self=False): """ """ - if output_array1 is None: output_array1 = '_tmpx' - if output_array2 is None: output_array2 = '_tmpy' - if output_array3 is None: output_array3 = '_tmpz' - - cdef DoubleArray output1 = self.dest.get_carray(output_array1) - cdef DoubleArray output2 = self.dest.get_carray(output_array2) - cdef DoubleArray output3 = self.dest.get_carray(output_array3) - - if output1 is not None: self.reset_output_array(output1) - if output2 is not None: self.reset_output_array(output2) - if output3 is not None: self.reset_output_array(output3) + cdef DoubleArray output1, output2, output3 + if output_array1 is None: + output1 = self.dest.get_carray('_tmp') + else: + output1 = self.dest.get_carray(output_array1) + self.reset_output_array(output1) + + if output_array2 is None: + output2 = self.dest.get_carray('_tmp') + else: + output2 = self.dest.get_carray(output_array2) + self.reset_output_array(output2) + + if output_array3 is None: + output3 = self.dest.get_carray('_tmp') + else: + output3 = self.dest.get_carray(output_array3) + self.reset_output_array(output3) self.sph_array(output1, output2, output3, exclude_self) diff --git a/source/pysph/sph/tests/test_boundary_funcs.py b/source/pysph/sph/tests/test_boundary_funcs.py index 3d4131a..4c71841 100644 --- a/source/pysph/sph/tests/test_boundary_funcs.py +++ b/source/pysph/sph/tests/test_boundary_funcs.py @@ -55,7 +55,7 @@ def setUp(self): rhof = numpy.ones_like(xf) self.fluid = base.get_particle_array(x=xf, y=yf, h=hf, m=mf, rho=rhof, - cs=cs, tmpx=mf, tmpy=mf, tmpz=mf, + cs=cs, ax=mf, ay=mf, az=mf, name='fluid', type=Fluid) @@ -113,7 +113,7 @@ def test_force(self): self.particles.update() - calc.sph('tmpx', 'tmpy', 'tmpz') + calc.sph('ax', 'ay', 'az') force = fluid.tmpy