Exemplo n.º 1
0
der_funcs = [ux_function, uy_function, vx_function, vy_function]
traction_funcs = [txx_function, txy_function, tyy_function]
all_funcs = main_funcs + der_funcs + traction_funcs
u, v, p, ux, uy, vx, vy, txx, txy, tyy = multi_eval(eval_on_grid, all_funcs)
ru, rv, rp, rux, ruy, rvx, rvy, rtxx, rtxy, rtyy = multi_eval(
    eval_on_radial, all_funcs)
bu, bv, bp, bux, buy, bvx, bvy, btxx, btxy, btyy = multi_eval(
    eval_on_bdy, all_funcs)
iu, iv, ip, iux, iuy, ivx, ivy, itxx, itxy, ityy = multi_eval(
    eval_on_interface, all_funcs)
# calcuate traction on interace
itx = itxx * ebdy.interface.normal_x + itxy * ebdy.interface.normal_y
ity = itxy * ebdy.interface.normal_x + ityy * ebdy.interface.normal_y

# interpolate stress to the interface to get the traction
etxx = ebdy.interpolate_grid_to_interface(txx, order=np.Inf)
etxy = ebdy.interpolate_grid_to_interface(txy, order=np.Inf)
etyy = ebdy.interpolate_grid_to_interface(tyy, order=np.Inf)
etx = etxx * ebdy.interface.normal_x + etxy * ebdy.interface.normal_y
ety = etxy * ebdy.interface.normal_x + etyy * ebdy.interface.normal_y
# get error in this computation
e1 = np.abs(etx - itx).max()
e2 = np.abs(ety - ity).max()
err = max(e1, e2)
print('Error is: {:0.2e}'.format(err))

# now do this with radial coords using helper functions
solver = VectorHelper(ebdy)
etx, ety = solver.get_interface_traction_uvp(ru, rv, rp)
# get error in this computation
e1 = np.abs(etx - itx).max()
Exemplo n.º 2
0
k = 2*np.pi/3
test_func = lambda x, y: np.exp(np.sin(k*x))*np.sin(k*y)
test_func_x = lambda x, y: k*np.exp(np.sin(k*x))*np.cos(k*x)*np.sin(k*y)
test_func_y = lambda x, y: k*np.exp(np.sin(k*x))*np.cos(k*y)

# Interpolation of a globally smooth function on grid to radial
f = test_func(grid.xg, grid.yg)
fr = test_func(ebdy.radial_x, ebdy.radial_y)
fe = ebdy.interpolate_grid_to_radial(f, order=5)
err = np.abs(fe-fr).max()
print('Error in grid --> radial interpolation:    {:0.2e}'.format(err))

# Interpolation of a function to the interface
fr = test_func(ebdy.interface.x, ebdy.interface.y)
fe = ebdy.interpolate_grid_to_interface(f, order=5)
err = np.abs(fe-fr).max()
print('Error in grid --> interface interpolation: {:0.2e}'.format(err))

# Interpolation of a function from radial to grid
fr = test_func(ebdy.radial_x, ebdy.radial_y)
ft = ebdy.interpolate_radial_to_grid(fr)
fe = test_func(ebdy.grid_ia_x, ebdy.grid_ia_y)
err = np.abs(fe-ft).max()
print('Error in radial --> grid interpolation:    {:0.2e}'.format(err))

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

# radial gradient
frxe, frye = ebdy.radial_grid_derivatives(fr)