diff --git a/pysph/base/tests/test_kernel.py b/pysph/base/tests/test_kernel.py index 865443228..7cfd580cd 100644 --- a/pysph/base/tests/test_kernel.py +++ b/pysph/base/tests/test_kernel.py @@ -342,6 +342,16 @@ class TestQuinticSpline1D(TestCubicSpline1D): def test_simple(self): self.check_kernel_at_origin(0.55) + def test_normalization(self): + """" Added in response to issue #421. """ + kh = self.wrapper.radius_scale + # Full domain [-3h, 3h] must integrate to 1.0 + r = self.check_kernel_moment_1d(-kh, kh, 1.0, 0, xj=0) + self.assertAlmostEqual(r, 1.0, 8) + # Non-unit h + r = self.check_kernel_moment_1d(-kh, kh, 0.5, 0, xj=0) + self.assertAlmostEqual(r, 1.0, 8) + class TestQuinticSpline2D(TestCubicSpline2D): kernel_factory = staticmethod(lambda: QuinticSpline(dim=2)) diff --git a/pysph/examples/gas_dynamics/riemann_2d.py b/pysph/examples/gas_dynamics/riemann_2d.py index c8346583e..a5c1f40db 100644 --- a/pysph/examples/gas_dynamics/riemann_2d.py +++ b/pysph/examples/gas_dynamics/riemann_2d.py @@ -17,11 +17,8 @@ from pysph.sph.gas_dynamics.magma2 import MAGMA2Scheme from pysph.examples.gas_dynamics.riemann_2d_config import R2DConfig -# current case from the al possible unique cases -case = 3 - # config for current case -config = R2DConfig(case) +config = None gamma = 1.4 gamma1 = gamma - 1 kernel_factor = 1.5 @@ -31,11 +28,15 @@ class Riemann2D(Application): def initialize(self): - # square domain self.dt = dt - self.tf = config.endtime def add_user_options(self, group): + group.add_argument( + "--case", action="store", type=int, + dest="case", default=3, + choices=[2, 3, 4, 5, 6, 8, 12], + help="Riemann 2D case number, one of 2, 3, 4, 5, 6, 8, 12" + ) group.add_argument( "--dscheme", choices=["constant_mass", "constant_volume"], dest="dscheme", default="constant_volume", @@ -48,6 +49,9 @@ def add_user_options(self, group): ) def consume_user_options(self): + global config + config = R2DConfig(self.options.case) + self.tf = config.endtime self.nx = self.options.nparticles self.ny = self.nx self.dx = (config.xmax - config.xmin) / self.nx