From 81a5415c9cbfc75c6297e75f58310e2095cd99d1 Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Keck <Jean-Baptiste.Keck@imag.fr> Date: Sun, 2 Dec 2018 20:10:37 +0100 Subject: [PATCH] fixed all examples --- .../particles_above_salt/particles_above_salt_periodic.py | 3 +-- .../particles_above_salt_symmetrized.py | 4 +++- hysop/operator/base/spectral_operator.py | 6 ++++-- test_examples.sh | 1 + 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/examples/particles_above_salt/particles_above_salt_periodic.py b/examples/particles_above_salt/particles_above_salt_periodic.py index 26c9625ae..e90f8a67b 100644 --- a/examples/particles_above_salt/particles_above_salt_periodic.py +++ b/examples/particles_above_salt/particles_above_salt_periodic.py @@ -76,8 +76,7 @@ def compute(args): # Constants l0 = 1.5 #initial thickness of the profile - (Sc, tau, Vp, Rs, Xo, Xn, N) = (0.70, 25, 0.04, 2.0, (-600,0), (600,750), (1537, 487)) - #(Sc, tau, Vp, Rs, Xo, Xn, N) = (7.00, 25, 0.04, 2.0, (-110,0,0), (65,100,100), (1537, 512, 512)) + (Sc, tau, Vp, Rs, Xo, Xn, N) = (0.70, 25, 0.04, 2.0, (-600,0), (600,750), (1536, 512)) nu_S = 1.0/Sc nu_C = 1.0/(tau*Sc) diff --git a/examples/particles_above_salt/particles_above_salt_symmetrized.py b/examples/particles_above_salt/particles_above_salt_symmetrized.py index af63fdc06..d48a421ee 100644 --- a/examples/particles_above_salt/particles_above_salt_symmetrized.py +++ b/examples/particles_above_salt/particles_above_salt_symmetrized.py @@ -71,7 +71,7 @@ def compute(args): # Constants l0 = 1.5 #initial thickness of the profile - (Sc, tau, Vp, Rs, Xo, Xn, N) = (0.70, 25, 0.04, 2.0, (-600,0), (600,750), (1537, 487)) + (Sc, tau, Vp, Rs, Xo, Xn, N) = (0.70, 25, 0.04, 2.0, (-600,0), (600,750), (1537, 512)) #(Sc, tau, Vp, Rs, Xo, Xn, N) = (7.00, 25, 0.04, 2.0, (-110,0,0), (65,100,100), (1537, 512, 512)) nu_S = ScalarParameter(name='nu_S', dtype=args.dtype, const=True, initial_value=1.0/Sc) @@ -103,6 +103,8 @@ def compute(args): cl_env = get_or_create_opencl_env(mpi_params=mpi_params, platform_id=args.cl_platform_id, device_id=args.cl_device_id) + + tg = cl_env.build_typegen(args.dtype, 'dec', False, False) # Configure OpenCL kernel generation and tuning (already done by HysopArgParser) from hysop.methods import OpenClKernelConfig diff --git a/hysop/operator/base/spectral_operator.py b/hysop/operator/base/spectral_operator.py index 347403136..b79db00b6 100644 --- a/hysop/operator/base/spectral_operator.py +++ b/hysop/operator/base/spectral_operator.py @@ -1225,7 +1225,8 @@ class PlannedSpectralTransform(object): buf_nbytes = compute_nbytes(buf.shape, buf.dtype) input_nbytes = compute_nbytes(input_shape, input_dtype) assert buf_nbytes >= input_nbytes, (buf_nbytes, input_nbytes) - buf = buf.view(dtype=np.int8)[:input_nbytes].view(dtype=input_dtype).reshape(input_shape) + if (buf.shape!=input_shape) or (buf.dtype!=input_dtype): + buf = buf.view(dtype=np.int8)[:input_nbytes].view(dtype=input_dtype).reshape(input_shape) if isinstance(buf, Array): buf = buf.handle input_buffer = buf[self.input_slices] @@ -1242,7 +1243,8 @@ class PlannedSpectralTransform(object): buf_nbytes = compute_nbytes(buf.shape, buf.dtype) output_nbytes = compute_nbytes(output_shape, output_dtype) assert buf_nbytes >= output_nbytes, (buf_nbytes, output_nbytes) - buf = buf.view(dtype=np.int8)[:output_nbytes].view(dtype=output_dtype).reshape(output_shape) + if (buf.shape!=output_shape) or (buf.dtype!=output_dtype): + buf = buf.view(dtype=np.int8)[:output_nbytes].view(dtype=output_dtype).reshape(output_shape) if isinstance(buf, Array): buf = buf.handle output_buffer = buf[self.output_slices] diff --git a/test_examples.sh b/test_examples.sh index c4abfbb60..4af3534c4 100755 --- a/test_examples.sh +++ b/test_examples.sh @@ -28,5 +28,6 @@ python "$EXAMPLE_DIR/bubble/periodic_bubble_levelset_penalization.py" $EXAMPLE_O python "$EXAMPLE_DIR/bubble/periodic_jet_levelset.py" $EXAMPLE_OPTIONS python "$EXAMPLE_DIR/particles_above_salt/particles_above_salt_periodic.py" $EXAMPLE_OPTIONS python "$EXAMPLE_DIR/particles_above_salt/particles_above_salt_symmetrized.py" $EXAMPLE_OPTIONS +python "$EXAMPLE_DIR/particles_above_salt/particles_above_salt_bc.py" $EXAMPLE_OPTIONS exit 0 -- GitLab