This file is indexed.

/usr/lib/python2.7/dist-packages/PySPH-1.0a4.dev0-py2.7-linux-x86_64.egg/pysph/tools/tests/test_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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
import unittest

import numpy as np

from pysph.base.utils import get_particle_array
from pysph.base.nnps import DomainManager
from pysph.sph.basic_equations import SummationDensity
from pysph.tools.sph_evaluator import SPHEvaluator


class TestSPHEvaluator(unittest.TestCase):
    def setUp(self):
        x = np.linspace(0, 1, 10)
        dx = x[1] - x[0]
        self.dx = dx
        m = np.ones_like(x)
        h = np.ones_like(x)*dx
        self.src = get_particle_array(name='src', x=x, m=m, h=h)
        self.equations = [SummationDensity(dest='dest', sources=['src'])]

    def test_evaluation(self):
        # Given
        xd = [0.5]
        hd = self.src.h[:1]
        dest = get_particle_array(name='dest', x=xd, h=hd)
        sph_eval = SPHEvaluator(
            arrays=[dest, self.src], equations=self.equations, dim=1
        )

        # When.
        sph_eval.evaluate()

        # Then.
        self.assertAlmostEqual(dest.rho[0], 9.0, places=2)

    def test_evaluation_with_domain_manager(self):
        # Given
        xd = [0.0]
        hd = self.src.h[:1]
        dest = get_particle_array(name='dest', x=xd, h=hd)
        dx = self.dx
        dm = DomainManager(xmin=-dx/2, xmax=1.0+dx/2, periodic_in_x=True)
        sph_eval = SPHEvaluator(
            arrays=[dest, self.src], equations=self.equations, dim=1,
            domain_manager=dm
        )

        # When.
        sph_eval.evaluate()

        # Then.
        self.assertAlmostEqual(dest.rho[0], 9.0, places=2)

    def test_updating_particle_arrays(self):
        # Given
        xd = [0.5]
        hd = self.src.h[:1]
        dest = get_particle_array(name='dest', x=xd, h=hd)
        sph_eval = SPHEvaluator(
            [dest, self.src], equations=self.equations, dim=1
        )
        sph_eval.evaluate()
        rho0 = dest.rho[0]

        # When.
        dest.x[0] = 0.0
        sph_eval.update_particle_arrays([dest, self.src])
        sph_eval.evaluate()

        # Then.
        self.assertNotEqual(rho0, dest.rho[0])
        self.assertAlmostEqual(dest.rho[0], 7.0, places=1)


if __name__ == '__main__':
    unittest.main()