# generate a holding ground for the new c c_new = EmbeddedFunction(new_ebdyc) c_new.zero() # get departure points xd_all = np.zeros(aap.N) yd_all = np.zeros(aap.N) # advect those in the annulus c1, c2, c3 = AEP.get_categories() c1n, c2n, c3n = AEP.get_category_Ns() # category 1 and 2 c1_2 = np.logical_or(c1, c2) c1_2n = c1n + c2n uxh = ebdy.interpolate_to_points(ux, aap.x, aap.y) uyh = ebdy.interpolate_to_points(uy, aap.x, aap.y) vxh = ebdy.interpolate_to_points(vx, aap.x, aap.y) vyh = ebdy.interpolate_to_points(vy, aap.x, aap.y) uh = ebdy.interpolate_to_points(u, aap.x, aap.y) vh = ebdy.interpolate_to_points(v, aap.x, aap.y) SLM = np.zeros([ c1_2n, ] + [2, 2], dtype=float) SLR = np.zeros([ c1_2n, ] + [ 2, ], dtype=float) SLM[:, 0, 0] = 1 + dt * uxh[c1_2] SLM[:, 0, 1] = dt * uyh[c1_2]
(time.time() - st) * 1000)) st = time.time() # now we need to interpolate onto things AEP = ebdy.registered_partitions[ap_key] GEP = ebdy.registered_partitions[gp_key] # generate a holding ground for the new c c_new = EmbeddedFunction(new_ebdyc) c_new.zero() # advect those in the annulus # category 1 c1, c2, c3 = AEP.get_categories() c1n, c2n, c3n = AEP.get_category_Ns() uxh = ebdy.interpolate_to_points(ux, ap.x, ap.y) uyh = ebdy.interpolate_to_points(uy, ap.x, ap.y) vxh = ebdy.interpolate_to_points(vx, ap.x, ap.y) vyh = ebdy.interpolate_to_points(vy, ap.x, ap.y) uh = ebdy.interpolate_to_points(u, ap.x, ap.y) vh = ebdy.interpolate_to_points(v, ap.x, ap.y) SLM = np.zeros([ c1n, ] + [2, 2], dtype=float) SLR = np.zeros([ c1n, ] + [ 2, ], dtype=float) SLM[:, 0, 0] = 1 + dt * uxh[c1] SLM[:, 0, 1] = dt * uyh[c1]
# now solve for sd, rd res = objective(s, r) mres = np.hypot(res[:, 0], res[:, 1]).max() tol = 1e-12 while mres > tol: J = Jac(s, r) d = np.linalg.solve(J, res) s -= d[:, 0] r -= d[:, 1] 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 # now interpolate to c ch3 = ebdy.interpolate_to_points(c - dt * scaled_nonlinearity(c), xd, yd) ch12 = ebdy.interpolate_to_points(ecnew, aap.x[c12], aap.y[c12]) # get the full thing ch = np.empty(aap.N) ch[c12] = ch12 ch[c3] = ch3 # 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) # save this for a moment c_force = c_new.copy()