Example #1
0
                res = objective(s, r)
                mres = np.hypot(res[:, 0], res[:, 1]).max()
            # get the departure points
            xd = bx_interp(s) + nx_interp(s) * r
            yd = by_interp(s) + ny_interp(s) * r
            xd_all[c3] = xd
            yd_all[c3] = yd
        # now interpolate to c
        ch = ebdy.interpolate_to_points(c - dt * scaled_nonlinearity(c),
                                        xd_all, yd_all)
        # set the grid values
        c_new.grid_value[new_ebdyc.phys_not_in_annulus] = ch[:gp.N]
        # set the radial values
        c_new.radial_value_list[0][:] = ch[gp.N:].reshape(ebdy.radial_shape)
        # overwrite under grid under annulus by radial grid
        _ = new_ebdyc.interpolate_radial_to_grid(c_new.radial_value_list,
                                                 c_new.grid_value)

    else:  # the second order method

        bx = ebdy.bdy.x + 0.5 * dt * (3 * ub - ubo_new_parm)
        by = ebdy.bdy.y + 0.5 * dt * (3 * vb - vbo_new_parm)
        bx, by, new_t = arc_length_parameterize(bx, by, return_t=True)
        bu_interp = interp1d(0, 2 * np.pi, bdy.dt, ub, p=True)
        bv_interp = interp1d(0, 2 * np.pi, bdy.dt, vb, p=True)
        # old boundary velocity values have to be in the correct place
        ubo_new_parm = bu_interp(new_t)
        vbo_new_parm = bv_interp(new_t)
        ubo = ub.copy()
        vbo = vb.copy()

        x_tracers.append(bx)
Example #2
0
fes = ebdyc.v2l(fev)
errs = [np.abs(fe - fr).max() for fe, fr in zip(fes, frs)]
err = max(errs)
print('Error in grid --> interface interpolation: {:0.2e}'.format(err))

# Interpolation of a function to the interface (NUFFT)
frs = [test_func(ebdy.interface.x, ebdy.interface.y) for ebdy in ebdys]
fev = ebdyc.interpolate_grid_to_interface(f, order=np.Inf, cutoff=True)
fes = ebdyc.v2l(fev)
errs = [np.abs(fe - fr).max() for fe, fr in zip(fes, frs)]
err = max(errs)
print('Error in grid --> interface interpolation: {:0.2e}'.format(err))

# Interpolation of a function from radial to grid
frs = [test_func(ebdy.radial_x, ebdy.radial_y) for ebdy in ebdys]
fts = ebdyc.interpolate_radial_to_grid(frs)
fes = [test_func(ebdy.grid_ia_x, ebdy.grid_ia_y) for ebdy in ebdys]
errs = [np.abs(fe - ft).max() for fe, ft in zip(fes, fts)]
err = max(errs)
print('Error in radial --> grid interpolation:    {:0.2e}'.format(err))

################################################################################
# Test derivatives

# fourth order accurate gradient on whole domain
dx = lambda x: fd_x_4(x, grid.xh, periodic_fix=True)
dy = lambda x: fd_y_4(x, grid.yh, periodic_fix=True)
fxe, fye, fxres, fyres = ebdyc.gradient(f, frs, dx, dy, cutoff=False)
fxt = test_func_x(grid.xg, grid.yg)
fyt = test_func_y(grid.xg, grid.yg)
err_x = np.abs(fxt - fxe)[ebdyc.phys].max()