Skip to content

Commit

Permalink
Removing SPHFunctionPoint in favor of a new Probe particle type.
Browse files Browse the repository at this point in the history
  • Loading branch information
kunal-puri committed Apr 29, 2011
1 parent 00c5849 commit 0348e56
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 97 deletions.
1 change: 1 addition & 0 deletions source/pysph/base/particle_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ class ParticleType:
Fluid = 0
Solid = 1
DummyFluid = 2
Probe = 3

def __init__(self):
"""
Expand Down
3 changes: 2 additions & 1 deletion source/pysph/base/particles.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

Fluid = ParticleType.Fluid
Solid = ParticleType.Solid
Probe = ParticleType.Probe

# MPI conditional imports
HAS_MPI = True
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion source/pysph/sph/funcs/basic_funcs.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
95 changes: 0 additions & 95 deletions source/pysph/sph/sph_func.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -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'

0 comments on commit 0348e56

Please sign in to comment.