def test_calculus_2d_4(): DIM = 2 domain = Domain('Omega', dim=DIM) V = ScalarFunctionSpace('V', domain, kind=None) u, v = elements_of(V, names='u, v') a = Constant('a', is_real=True) # ... jump operator assert (jump(u + v) == jump(u) + jump(v)) assert (jump(a * u) == a * jump(u)) # ... # ... avg operator assert (avg(u + v) == avg(u) + avg(v)) assert (avg(a * u) == a * avg(u)) # ... # ... Dn operator assert (Dn(u + v) == Dn(u) + Dn(v)) assert (Dn(a * u) == a * Dn(u)) # ... # ... minus operator assert (minus(u + v) == minus(u) + minus(v)) assert (minus(a * u) == a * minus(u)) # ... # ... plus operator assert (plus(u + v) == plus(u) + plus(v)) assert (plus(a * u) == a * plus(u))
def test_interface_2d_1(): # ... def two_patches(): from sympde.topology import InteriorDomain from sympde.topology import Connectivity, Interface A = Square('A') B = Square('B') A = A.interior B = B.interior connectivity = Connectivity() bnd_A_1 = Boundary(r'\Gamma_1', A, axis=0, ext=-1) bnd_A_2 = Boundary(r'\Gamma_2', A, axis=0, ext=1) bnd_A_3 = Boundary(r'\Gamma_3', A, axis=1, ext=-1) bnd_A_4 = Boundary(r'\Gamma_4', A, axis=1, ext=1) bnd_B_1 = Boundary(r'\Gamma_1', B, axis=0, ext=-1) bnd_B_2 = Boundary(r'\Gamma_2', B, axis=0, ext=1) bnd_B_3 = Boundary(r'\Gamma_3', B, axis=1, ext=-1) bnd_B_4 = Boundary(r'\Gamma_4', B, axis=1, ext=1) connectivity['I'] = Interface('I', bnd_A_2, bnd_B_1) Omega = Domain('Omega', interiors=[A, B], boundaries=[ bnd_A_1, bnd_A_2, bnd_A_3, bnd_A_4, bnd_B_1, bnd_B_2, bnd_B_3, bnd_B_4 ], connectivity=connectivity) return Omega # ... # create a domain with an interface domain = two_patches() interfaces = domain.interfaces V = ScalarFunctionSpace('V', domain) u, v = elements_of(V, names='u, v') print(integral(interfaces, u * v)) expr = integral(domain, dot(grad(v), grad(u))) expr += integral(interfaces, -avg(Dn(u)) * jump(v) + avg(Dn(v)) * jump(u)) a = BilinearForm((u, v), expr) print(a)
def test_interface_integral_1(): # ... A = Square('A') B = Square('B') domain = A.join(B, name='domain', bnd_minus=A.get_boundary(axis=0, ext=1), bnd_plus=B.get_boundary(axis=0, ext=-1)) # ... x, y = domain.coordinates V = ScalarFunctionSpace('V', domain, kind=None) assert (V.is_broken) u, v = elements_of(V, names='u, v') # ... I = domain.interfaces # ... # expr = minus(Dn(u)) # print(expr) # import sys; sys.exit(0) # ... bilinear forms # a = BilinearForm((u,v), integral(domain, u*v)) # a = BilinearForm((u,v), integral(domain, dot(grad(u),grad(v)))) # a = BilinearForm((u,v), integral(I, jump(u) * jump(v))) # a = BilinearForm((u,v), integral(I, jump(Dn(u)) * jump(v))) # a = BilinearForm((u,v), integral(domain, dot(grad(u),grad(v))) # + integral(I, jump(u) * jump(v))) # Nitsch kappa = Constant('kappa') expr_I = (-jump(u) * jump(Dn(v)) + kappa * jump(u) * jump(v) + plus(Dn(u)) * minus(v) + minus(Dn(u)) * plus(v)) a = BilinearForm( (u, v), integral(domain, dot(grad(u), grad(v))) + integral(I, expr_I)) # # TODO BUG # bnd_A = A.get_boundary(axis=0, ext=1) # # a = BilinearForm((u,v), integral(domain, dot(grad(u),grad(v))) # + integral(I, jump(u) * jump(v)) # + integral(bnd_A, dx(u)*v)) expr = TerminalExpr(a) print(expr)