/usr/lib/python2.7/dist-packages/PySPH-1.0a4.dev0-py2.7-linux-x86_64.egg/pysph/tools/sph_evaluator.py is in python-pysph 0~20160514.git91867dc-4build1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 | """A convenience class that combines an AccelerationEval and an SPHCompiler to
allow a user to specify particle arrays, equations, an optional domain and
kernel to produce an SPH evaluation.
This is handy for post-processing.
"""
from pysph.base.kernels import Gaussian
from pysph.base.nnps import LinkedListNNPS as NNPS
from pysph.sph.acceleration_eval import AccelerationEval
from pysph.sph.sph_compiler import SPHCompiler
class SPHEvaluator(object):
def __init__(self, arrays, equations, dim, kernel=None,
domain_manager=None):
"""Constructor.
Parameters
----------
arrays: list(ParticleArray)
equations: list
dim: int
kernel: kernel instance.
domain_manager: DomainManager
"""
self.arrays = arrays
self.equations = equations
self.domain_manager = domain_manager
self.dim = dim
if kernel is None:
self.kernel = Gaussian(dim=dim)
else:
self.kernel = kernel
self.func_eval = AccelerationEval(arrays, equations, self.kernel)
compiler = SPHCompiler(self.func_eval, None)
compiler.compile()
self._create_nnps(arrays)
def evaluate(self, t=0.0, dt=0.1):
"""Evalute the SPH equations, dummy t and dt values can
be passed.
"""
self.func_eval.compute(t, dt)
def update_particle_arrays(self, arrays):
self._create_nnps(arrays)
self.func_eval.update_particle_arrays(arrays)
#### Private protocol ###################################################
def _create_nnps(self, arrays):
self.nnps = NNPS(dim=self.kernel.dim, particles=arrays,
radius_scale=self.kernel.radius_scale,
domain=self.domain_manager,
cache=True)
self.nnps.update()
self.func_eval.set_nnps(self.nnps)
|