import tensiga.utils.varmeshes as varmeshes from tensiga.quadrature.glnint import glnint from tensiga.fredholm.HilbertSchmidtKern import expkernop as cov from tensiga.fredholm.assembly.ApproxGalerkin import ApproxGalerkin # init geometry domain = varmeshes.QuarterAnnulus2D(1., 0.6) idomain = varmeshes.QuarterAnnulus2D(1., 0.6) # refine the spline object for k in range(domain.dim): domain.href(np.linspace(0, 1, 30)[1:-1], k) idomain.href(np.linspace(0, 1, 30)[1:-1], k) # compute global quadrature rule quadrature = glnint(domain.kv, domain.deg + np.array([1, 1])) # define data struct for covariance kernel (:sig:, :b:, :L:) cov_data = np.array([1., .5, 1.]) # initialize method method = ApproxGalerkin(domain, idomain, quadrature, cov, cov_data) # formation and assembly A, B = method.direct() # solution neigs = 3 lambda_h, f_h = eigsh(A, neigs, B) # ordered smallest to highest method.normalize_ev(f_h)
ctrlpts = [ np.array([[1.0, 0.6], [1.0, 0.6], [0.0, 0.0]]), # x np.array([[0.0, 0.0], [1.0, 0.6], [1.0, 0.6]]) ] # z # init primitive spline object spline = Bspline(dim, codim, kv, deg, ctrlpts) # refine the spline object u = np.linspace(0, 1, 20)[1:-1] v = np.linspace(0, 1, 6)[1:-1] spline.href(u, 0) spline.href(v, 1) # get the integration rule quadrature = glnint(spline.kv, spline.deg + np.array([1, 1])) xip = spline.eval(quadrature.ip, 0) yip = spline.eval(quadrature.ip, 1) # compute jacobian J = spline.jacobian(quadrature.ip) # compute geometry ep = spline.kv x = spline.eval(ep, 0) y = spline.eval(ep, 1) # plot plt.pcolor(x, y, np.sqrt(x**2 + y**2), edgecolor='black') plt.plot(xip, yip, 'ko', markersize=1) plt.show()
ep = [np.unique(kv) for kv in domain.kv] x, y, z = [domain.eval(ep, k) for k in range(domain.dim)] ''' # plot mesh plotter = pv.Plotter() mesh = pv.StructuredGrid(x, y, z) plotter.add_mesh(mesh, show_edges=False) plotter.show_axes() plotter.view_xy() plotter.show() ''' print(domain.nelem()) # compute global quadrature rule quadrature = glnint(domain.kv, domain.deg + np.array([2, 2, 2])) # define data struct for covariance kernel (:sig:, :b:, :L:) cov_data = np.array([1., 0.5, 10.]) # initialize method method = Galerkin(domain, quadrature, cov, cov_data) # formation and assembly A, B = method._nurbs_direct_elementwise() Aref, Bref = method._bspline_direct_elementwise() # solution neigs = 10 lambda_h, f_h = eigsh(A, neigs, B) # ordered smallest to highest