Esempio n. 1
0
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))
Esempio n. 2
0
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)