diff --git a/CMakeLists.txt b/CMakeLists.txt index 4a9b06b7e9f6a39355ba0fc8b3b8305f63c2da8c..bf322b4996de11fecb44641d1a99177cae4298d7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -35,7 +35,7 @@ option(USE_MPI "Compile and link HySoP with mpi when this mode is enable. Defaul option(WITH_TESTS "Enable testing. Default = OFF" ON) option(BUILD_SHARED_LIBS "Enable dynamic library build, default = ON." ON) option(USE_CXX "Expand hysop with some new functions from a generated c++ to python interface, wrapped into hysop.cpp2hysop module. Default = ON." ON) -option(WITH_SCALES "compile/create scales lib and link it with HySoP. Default = ON." OFF) +option(WITH_SCALES "compile/create scales lib and link it with HySoP. Default = ON." ON) option(WITH_FFTW "Link with fftw library (required for some HySoP solvers), default = ON" ON) option(WITH_EXTRAS "Link with some extra fortran libraries (like arnoldi solver), default = OFF" OFF) option(WITH_GPU "Use of GPU (required for some HySoP solvers), default = ON" ON) diff --git a/hysop/fields/cartesian_discrete_field.py b/hysop/fields/cartesian_discrete_field.py index 78167bedbf7cd4d22d0673f2a10c13c77b7e49b9..e0cd4ec2f7db943258506fa5cdf56f676804ac57 100644 --- a/hysop/fields/cartesian_discrete_field.py +++ b/hysop/fields/cartesian_discrete_field.py @@ -131,9 +131,10 @@ class CartesianDiscreteScalarFieldViewContainerI(object): elif from_raw_data: # initialize from raw data assert len(formula) == len(data) - src_slices = kwds.pop('src_slices', Ellipsis) - dst_slices = kwds.pop('dst_slices', Ellipsis) - for (dsrc, ddst) in zip(formula, data): + all_src_slices = kwds.get('src_slices', (Ellipsis,)*len(formula)) + for i, (dsrc, ddst) in enumerate(zip(formula, data)): + src_slices = all_src_slices[i] + dst_slices = kwds.get('dst_slices', self.discrete_fields()[i].compute_slices) check_instance(dsrc, (np.ndarray, HostArray)) check_instance(ddst, (np.ndarray, HostArray)) src_shape = dsrc[src_slices].shape diff --git a/hysop/operator/tests/test_derivative.py b/hysop/operator/tests/test_derivative.py index 33cc3d8ac222488977f749d631e093e140819c42..b153ee3ba6d07dcfbbf4d4b7709c8e77e779cdef 100644 --- a/hysop/operator/tests/test_derivative.py +++ b/hysop/operator/tests/test_derivative.py @@ -27,8 +27,8 @@ class TestGradient(object): IO.set_default_path('/tmp/hysop_tests/test_gradient') - cls.size_min = 57 - cls.size_max = 97 + cls.size_min = 23 + cls.size_max = 35 cls.enable_extra_tests = enable_extra_tests cls.enable_debug_mode = enable_debug_mode @@ -222,7 +222,7 @@ class TestGradient(object): eps = npw.finfo(fout.dtype).eps dist = npw.abs(fout-fref) dL1 = npw.nansum(dist) / dist.size - if (dL1 < 1e-2): + if (dL1 < 1e-1): print '{}, '.format(dL1), continue has_nan = npw.any(npw.isnan(fout)) diff --git a/hysop/operator/tests/test_directional_stretching.py b/hysop/operator/tests/test_directional_stretching.py index adbaef83059c9cf366440b48f8811a6394dd1de2..aeff082c28e03f1f73674ff121e9c0a92f30d783 100644 --- a/hysop/operator/tests/test_directional_stretching.py +++ b/hysop/operator/tests/test_directional_stretching.py @@ -163,9 +163,6 @@ class TestDirectionalStretchingOperator(object): dwin = split.get_input_discrete_field(win) dwout = split.get_output_discrete_field(wout) - W_view = dwin.compute_slices - V_view = dvin.compute_slices - sys.stdout.write('.') sys.stdout.flush() try: @@ -173,10 +170,10 @@ class TestDirectionalStretchingOperator(object): dwin.initialize(self.__random_init) dvin.initialize(self.__random_init) - V_input = tuple(dvin.data[i].get().handle.copy() - for i in xrange(dvin.nb_components)) - W_input = tuple(dwin.data[i].get().handle.copy() - for i in xrange(dwin.nb_components)) + V_input = tuple(df.data[0].get()[df.compute_slices].handle.copy() + for df in dvin) + W_input = tuple(df.data[0].get()[df.compute_slices].handle.copy() + for df in dwin) V0 = dvin.integrate() W0 = dwin.integrate() @@ -198,8 +195,8 @@ class TestDirectionalStretchingOperator(object): split.apply(dt=dt) - W_output = tuple(dwout.data[i].get().handle.copy() - for i in xrange(dwout.nb_components)) + W_output = tuple(df.data[0].get()[df.compute_slices].handle.copy() + for df in dwout) V1 = dvin.integrate() W1 = dwin.integrate() @@ -219,7 +216,7 @@ class TestDirectionalStretchingOperator(object): msg='W_output shape {} differs from the W_reference one {}.' msg=msg.format(W_output[i].shape, W_reference[i].shape) raise RuntimeError(msg) - mask = npw.isfinite(W_output[i][dwout.compute_slices]) + mask = npw.isfinite(W_output[i][dwout[i].compute_slices]) if not mask.all(): msg='\nFATAL ERROR: W_output is not finite on axis {}.\n'.format(i) npw.fancy_print(W_output[i], @@ -273,26 +270,13 @@ class TestDirectionalStretchingOperator(object): directions = range(dim) + range(dim)[::-1] dt_coeffs = (0.5,)*(2*dim) - W_view = dwin.compute_slices - V_view = dvin.compute_slices - wis = tuple('W{}'.format(i) for i in xrange(3)) Xin = dict(zip(wis, Win)) views = { 'W{}'.format(i): Wi.compute_slices for (i,Wi) in enumerate(dwin) } - print - for i in xrange(3): - print 'V{}: {}'.format(i, Vin[i].shape) - for i in xrange(3): - print 'W{}: {}'.format(i, Win[i].shape) - for i in wis: - print '{}_view: {}'.format(i, views[i]) - print - ghost_exchanger = dwin.build_ghost_exchanger(data=Win) for (j, dt_coeff) in zip(directions, dt_coeffs): - print 'DIRECTION {}'.format(j) ndir = (dim-j-1) V = Vin D1_V = tuple(D1(a=Vi, out=None, axis=ndir, \ @@ -305,22 +289,19 @@ class TestDirectionalStretchingOperator(object): dW_dt = tuple(out[wi] for wi in wis) if (formulation is StretchingFormulation.CONSERVATIVE): D1_VW = () - for Vi in V: + for (i,Vi) in enumerate(V): ghosts = [0,]*3 ghosts[2-j] = dvin.ghosts[-1] - view = dvin.local_slices(ghosts) - a=Vi[view]*W[j] - print 'A.shape: {}'.format(a.shape) + a=Vi*W[j] d1_vw = D1(a=a, axis=ndir, symbols={D1.dx:dwin.space_step[ndir]}) - print 'dA.shape: {}'.format(d1_vw.shape) D1_VW += (d1_vw,) assert (A is None), A for i in xrange(3): ghosts = [0,]*3 - if (i==j): - ghosts[2-j] = dwin[j].ghosts[j] + #if (i==j): + #ghosts[2-j] = dwin[j].ghosts[j] view = dwin[j].local_slices(ghosts) - dW_dt[i][view] = C[i] * D1_VW[i] + dW_dt[i][...] = C[i] * D1_VW[i] elif (formulation is StretchingFormulation.GRAD_UW): assert (A is None), A for i in xrange(3): @@ -351,9 +332,10 @@ class TestDirectionalStretchingOperator(object): out = time_integrator(Xin=Xin, RHS=rhs, views=views, dt=(dt_coeff*dt)) for i in xrange(3): - Win[i][...] = out[wis[i]] + Win[i][views[wis[i]]] = out[wis[i]] ghost_exchanger.exchange_ghosts() - out = tuple(f for f in Win) + views = dvin.get_attributes('compute_slices') + out = tuple(f[v] for (v,f) in zip(views,Win)) return out def test_stretching_3D_inplace_conservative(self):