Skip to content
Snippets Groups Projects
Commit 60138fc9 authored by Jean-Matthieu Etancelin's avatar Jean-Matthieu Etancelin
Browse files

New multiphase examples + fix 2 bugs

parent a8886b79
No related branches found
No related tags found
No related merge requests found
This diff is collapsed.
This diff is collapsed.
import os
import numpy as np
from hysop.constants import HYSOP_REAL, ORDER
def random_init(shape, mpi_comm):
# Create a folder to store all random arrays
d = 'rand_init'
if mpi_comm.Get_rank() == 0:
if not os.path.exists(d):
os.makedirs(d)
mpi_comm.Barrier()
file_name = "{0}_{1}_{2}".format(*shape)
file_name += "_{0}p_{1}.dat".format(mpi_comm.Get_size(),
mpi_comm.Get_rank())
try:
randX = np.asarray(
np.reshape(np.fromfile(os.path.join(d, 'randX_' + file_name),
dtype=HYSOP_REAL), shape),
dtype=HYSOP_REAL, order=ORDER)
randY = np.asarray(
np.reshape(np.fromfile(os.path.join(d, 'randY_' + file_name),
dtype=HYSOP_REAL), shape),
dtype=HYSOP_REAL, order=ORDER)
randZ = np.asarray(
np.reshape(np.fromfile(os.path.join(d, 'randZ_' + file_name),
dtype=HYSOP_REAL), shape),
dtype=HYSOP_REAL, order=ORDER)
except IOError:
randX = np.asarray(np.random.random(shape),
dtype=HYSOP_REAL, order=ORDER) - 0.5
randY = np.asarray(np.random.random(shape),
dtype=HYSOP_REAL, order=ORDER) - 0.5
randZ = np.asarray(np.random.random(shape),
dtype=HYSOP_REAL, order=ORDER) - 0.5
randX.tofile(os.path.join(d, 'randX_' + file_name))
randY.tofile(os.path.join(d, 'randY_' + file_name))
randZ.tofile(os.path.join(d, 'randZ_' + file_name))
return randX, randY, randZ
......@@ -2,10 +2,9 @@
@file gpu_kernel.py
"""
from hysop.constants import debug, S_DIR
#from hysop import __VERBOSE__
from hysop import __VERBOSE__
from hysop.gpu import cl, CL_PROFILE
from hysop.tools.profiler import FProfiler
__VERBOSE__ = True
class KernelListLauncher(object):
"""
......
......@@ -126,16 +126,16 @@ class MultiGPUParticleAdvection(GPUParticleAdvection):
self.max_cfl_s = int(max_cfl * scale_factor) + 1
self.max_cfl_v = int(max_cfl) + 1
else:
try:
self.max_cfl_s = int(max_velocity[self.direction] * max_dt /
self._space_step[self.direction]) + 1
self.max_cfl_v = int(max_velocity[self.direction] * max_dt /
self._v_space_step[self.direction]) + 1
except TypeError:
self.max_cfl_s = int(max_velocity * max_dt /
self._space_step[self.direction]) + 1
self.max_cfl_v = int(max_velocity * max_dt /
self._v_space_step[self.direction]) + 1
try:
self.max_cfl_s = int(max_velocity[self.direction] * max_dt /
self._space_step[self.direction]) + 1
self.max_cfl_v = int(max_velocity[self.direction] * max_dt /
self._v_space_step[self.direction]) + 1
except TypeError:
self.max_cfl_s = int(max_velocity * max_dt /
self._space_step[self.direction]) + 1
self.max_cfl_v = int(max_velocity * max_dt /
self._v_space_step[self.direction]) + 1
# Slice
self._sl_dim = slice(self.dim, 2 * self.dim)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment