Skip to content
Snippets Groups Projects
Commit 6c4c1972 authored by Jean-Baptiste Keck's avatar Jean-Baptiste Keck
Browse files

updated introduction notebook

parent ba88fd08
No related branches found
No related tags found
No related merge requests found
......@@ -29,14 +29,14 @@ __FFTW_ENABLED__ = "ON" is "ON"
__SCALES_ENABLED__ = "OFF" is "ON"
__OPTIMIZE__ = not __debug__
__VERBOSE__ = get_env('VERBOSE', False)
__DEBUG__ = get_env('DEBUG', False)
__PROFILE__ = get_env('PROFILE', False)
__VERBOSE__ = get_env('VERBOSE', ("ON" is "ON"))
__DEBUG__ = get_env('DEBUG', ("OFF" is "ON"))
__PROFILE__ = get_env('PROFILE', ("ON" is "ON"))
__KERNEL_DEBUG__ = get_env('KERNEL_DEBUG', False)
__TRACE_CALLS__ = get_env('TRACE_CALLS', False)
__TRACE_WARNINGS__ = get_env('TRACE_WARNINGS', False)
__TRACE_MEMALLOCS__ = get_env('TRACE_MEMALLOCS', False)
__TRACE_MEMALLOCS__ = get_env('TRACE_MEMALLOC', False)
__TRACE_KERNELS__ = get_env('TRACE_KERNELS', False)
__KERNEL_DEBUG__ = get_env('KERNEL_DEBUG', False)
__BACKTRACE_BIG_MEMALLOCS__ = get_env('BACKTRACE_BIG_MEMALLOCS', False)
......@@ -45,8 +45,8 @@ __TEST_ALL_OPENCL_PLATFORMS__ = get_env('TEST_ALL_OPENCL_PLATFORMS', False)
__ENABLE_LONG_TESTS__ = get_env('ENABLE_LONG_TESTS', ("OFF" is "ON"))
# OpenCL
__DEFAULT_PLATFORM_ID__ = 0
__DEFAULT_DEVICE_ID__ = 0
__DEFAULT_PLATFORM_ID__ = 2
__DEFAULT_DEVICE_ID__ = 2
if __MPI_ENABLED__:
......
......@@ -232,6 +232,12 @@ class CartesianDiscreteFieldView(DiscreteFieldView):
def _get_space_step(self):
"""Get the space step of the discretized mesh grid."""
return self.mesh.space_step
def _get_coords(self):
"""Get local mesh physical coordinates in each direction."""
return self.mesh.local_coords
def _get_mesh_coords(self):
"""Get local mesh physical coordinates in each direction."""
return self.mesh.local_mesh_coords
def _get_is_tmp(self):
"""Is this DiscreteField temporary ?"""
return self._dfield.is_tmp
......@@ -432,7 +438,8 @@ CartesianDiscreteFieldView (id={}, tag={})
self.backend.rand(out=self.data[d], **kwds)
def initialize(self, formula, vectorize=False,
only_finite=True, exchange_ghosts=True, **kwds):
only_finite=True, exchange_ghosts=True,
quiet=False, **kwds):
"""
Initialize the field components
......@@ -459,12 +466,14 @@ CartesianDiscreteFieldView (id={}, tag={})
formula = to_tuple(formula)
msg='\n>Initializing discrete field {} from raw array data.'
msg=msg.format(self.name)
vprint(msg)
if not quiet:
vprint(msg)
from_raw_data = True
else:
msg='\n>Initializing discrete field {} with formula {}.'
msg=msg.format(self.name, formula.__name__)
vprint(msg)
if not quiet:
vprint(msg)
from_formula = True
if (backend.kind == Backend.HOST):
......@@ -472,7 +481,8 @@ CartesianDiscreteFieldView (id={}, tag={})
else:
# we are not on host, allocate temporary buffers
msg=' *Allocating temporary buffers on host.'
vprint(msg)
if not quiet:
vprint(msg)
host_backend = self.backend.host_array_backend
data = tuple(host_backend.empty(shape=self.shape, dtype=self.dtype)
for _ in xrange(self.nb_components))
......@@ -524,11 +534,13 @@ CartesianDiscreteFieldView (id={}, tag={})
if (backend.kind != Backend.HOST):
msg=' *Copying temporary buffers to backend {}.'
msg=msg.format(backend.kind)
vprint(msg)
if not quiet:
vprint(msg)
self.data = data
msg=' *Exchanging ghosts on backend {}.'
msg=msg.format(backend.kind)
vprint(msg)
if not quiet:
vprint(msg)
if exchange_ghosts:
evt = self.exchange_ghosts()
......@@ -639,14 +651,16 @@ CartesianDiscreteFieldView (id={}, tag={})
strarr[lg] = inner_ghosts
strarr[rg] = inner_ghosts
if (outer_ghosts is not None):
for lg, rg, _ in self.outer_ghost_slices:
if callable(outer_ghosts):
outer_ghosts = np.vectorize(outer_ghosts)
strarr[lg] = outer_ghosts(strarr[lg])
strarr[rg] = outer_ghosts(strarr[rg])
else:
strarr[lg] = outer_ghosts
strarr[rg] = outer_ghosts
for ndir in self.all_outer_ghost_slices:
for directions in self.all_outer_ghost_slices[ndir]:
for disp, (slc,_) in self.all_outer_ghost_slices[ndir][directions].iteritems():
if (sum(d!=0 for d in disp) == ndir) and ndir:
if callable(outer_ghosts):
outer_ghosts = np.vectorize(outer_ghosts)
strarr[slc] = outer_ghosts(strarr[slc])
else:
strarr[slc] = outer_ghosts
_formatter = {
object: lambda x: '{:^6}'.format(x)[:6],
......@@ -735,6 +749,8 @@ CartesianDiscreteFieldView (id={}, tag={})
boundaries = property(_get_boundaries)
space_step = property(_get_space_step)
is_tmp = property(_get_is_tmp)
coords = property(_get_coords)
mesh_coords = property(_get_mesh_coords)
compute_slices = property(_get_compute_slices)
inner_ghost_slices = property(get_inner_ghost_slices)
......
......@@ -47,7 +47,7 @@ class Simulation(object):
"""
def __init__(self, name=None, start=0.0, end=1.0, nb_iter=None, dt0=None,
max_iter=None, t=None, dt=None, times_of_interest=None,
max_iter=None, t=None, dt=None, times_of_interest=None, quiet=False,
**kwds):
"""
Parameters
......@@ -138,7 +138,7 @@ class Simulation(object):
dt_name = '{}_dt'.format(name) if (name is not None) else 'dt'
if (dt is None):
self.dt = ScalarParameter(name=dt_name, dtype=HYSOP_REAL, min_value=eps,
initial_value=dt0)
initial_value=dt0, quiet=quiet)
else:
dt.value = dt0
self.dt = dt
......@@ -150,7 +150,7 @@ class Simulation(object):
# Starting time for the current iteration
if (t is None):
self.t = ScalarParameter(name='t', dtype=HYSOP_REAL,
initial_value=start)
initial_value=start, quiet=quiet)
else:
self.t = t
assert isinstance(t, ScalarParameter), type(t)
......
Source diff could not be displayed: it is too large. Options to address this: view the blob.
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