From 0348e56bcd22df71222912ea87b6a0fc86de9cdb Mon Sep 17 00:00:00 2001 From: "kunal.r.puri@gmail.com" Date: Fri, 29 Apr 2011 17:54:37 +0530 Subject: [PATCH] Removing SPHFunctionPoint in favor of a new Probe particle type. --- source/pysph/base/particle_types.py | 1 + source/pysph/base/particles.py | 3 +- source/pysph/sph/funcs/basic_funcs.pyx | 2 +- source/pysph/sph/sph_func.pyx | 95 -------------------------- 4 files changed, 4 insertions(+), 97 deletions(-) diff --git a/source/pysph/base/particle_types.py b/source/pysph/base/particle_types.py index 7a301b4..7326070 100644 --- a/source/pysph/base/particle_types.py +++ b/source/pysph/base/particle_types.py @@ -7,6 +7,7 @@ class ParticleType: Fluid = 0 Solid = 1 DummyFluid = 2 + Probe = 3 def __init__(self): """ diff --git a/source/pysph/base/particles.py b/source/pysph/base/particles.py index 9b7867b..2803569 100644 --- a/source/pysph/base/particles.py +++ b/source/pysph/base/particles.py @@ -5,6 +5,7 @@ Fluid = ParticleType.Fluid Solid = ParticleType.Solid +Probe = ParticleType.Probe # MPI conditional imports HAS_MPI = True @@ -338,7 +339,7 @@ def get_particle_array(cl_precision="double", **props): if props.has_key("type"): particle_type = props["type"] - assert particle_type in [Fluid, Solid], 'Type not understood!' + assert particle_type in [Fluid, Solid, Probe], 'Type not understood!' pa = ParticleArray(name=name, particle_type=particle_type, cl_precision=cl_precision, **prop_dict) diff --git a/source/pysph/sph/funcs/basic_funcs.pyx b/source/pysph/sph/funcs/basic_funcs.pyx index 7d9067b..5aa5036 100644 --- a/source/pysph/sph/funcs/basic_funcs.pyx +++ b/source/pysph/sph/funcs/basic_funcs.pyx @@ -30,7 +30,7 @@ cdef class SPH(CSPHFunctionParticle): CSPHFunctionParticle.__init__(self, source, dest, setup_arrays = True) self.id = 'sph' - self.cl_kernel_src_file = "basic_funcs.cl" + self.cl_kernel_src_file = "basic_funcs.clt" self.cl_kernel_function_name = "SPH" cpdef setup_arrays(self): diff --git a/source/pysph/sph/sph_func.pyx b/source/pysph/sph/sph_func.pyx index 3cf47d3..87a376b 100755 --- a/source/pysph/sph/sph_func.pyx +++ b/source/pysph/sph/sph_func.pyx @@ -461,98 +461,3 @@ cdef class CSPHFunctionParticle(SPHFunctionParticle): by the kernel sum of all the neighboring particles """ raise NotImplementedError, 'CSPHFunctionParticle.evaleval_nbr_csph()' - -################################################################################ -# `SPHFunctionPoint` class. -################################################################################ -cdef class SPHFunctionPoint: - """ - Base class to compute the contribution of an SPH particle, on a point in - space. - - The class is designed on similar lines to the SPHFunctionParticle class, - except that destination point, can be any random point. Thus no dest - particle array is necessary here. The eval interfaces in the derived classes - also have a different signature than that of the eval interfaces of classes - derived from SPHFunctionParticle. - - """ - def __init__(self, ParticleArray array, bint setup_arrays=True, - *args, **kwargs): - - self.source = array - - #Default properties - self.m = 'm' - self.rho = 'rho' - self.h = 'h' - self.p = 'p' - self.e = 'e' - self.x = 'x' - self.y = 'y' - self.z = 'z' - self.u = 'u' - self.v = 'v' - self.w = 'w' - - if setup_arrays: - self.setup_arrays() - - cpdef setup_arrays(self): - """ - """ - self.s_x = self.source.get_carray(self.x) - self.s_y = self.source.get_carray(self.y) - self.s_z = self.source.get_carray(self.z) - self.s_u = self.source.get_carray(self.u) - self.s_v = self.source.get_carray(self.v) - self.s_w = self.source.get_carray(self.w) - self.s_h = self.source.get_carray(self.h) - self.s_m = self.source.get_carray(self.m) - self.s_rho = self.source.get_carray(self.rho) - self.s_p = self.source.get_carray(self.p) - self.s_e = self.source.get_carray(self.e) - - cdef void eval(self, cPoint pnt, int dest_pid, - KernelBase kernel, double * nr, double * dnr): - """ Computes the contribution of particle at source_pid on point pnt - - **Parameters** - - - pnt - the point at which some quantity is to be interpolated. - - source_pid - the neighbor whose contribution is to be computed. - - kernel - the kernel to be used. - - nr - memory location to store the numerator of the result. - - dnr - memory location to store the denominator of the result. - - """ - raise NotImplementedError, 'SPHFunctionPoint::eval' - - cpdef py_eval(self, Point pnt, int dest_pid, - KernelBase kernel, numpy.ndarray - nr, numpy.ndarray dnr): - """ Python wrapper for the eval function, to be used in tests """ - cdef double * _nr - cdef double * _dnr - cdef int i - - _nr = < double *> malloc(sizeof(double) * self.output_fields()) - _dnr = < double *> malloc(sizeof(double) * self.output_fields()) - - self.eval(pnt.data, dest_pid, kernel, _nr, _dnr) - - for i in range(self.output_fields()): - nr[i] += _nr[i] - dnr[i] += _dnr[i] - - free(< void *> _nr) - free(< void *> _dnr) - - cpdef int output_fields(self) except - 1: - """ - Returns the number of output fields, this SPHFunctionPoint will write - to. This does not depend on the dimension of the simulation, it just - indicates, the size of the arrays, dnr and nr that need to be passed to - the eval function. - """ - raise NotImplementedError, 'SPHFunctionPoint::output_fields'