Ejemplo n.º 1
0
def test_topology_1():
    # ... create a domain with 2 subdomains A and B
    A = InteriorDomain('A', dim=2)
    B = InteriorDomain('B', dim=2)

    connectivity = Connectivity()

    bnd_A_1 = Boundary('Gamma_1', A)
    bnd_A_2 = Boundary('Gamma_2', A)
    bnd_A_3 = Boundary('Gamma_3', A)

    bnd_B_1 = Boundary('Gamma_1', B)
    bnd_B_2 = Boundary('Gamma_2', B)
    bnd_B_3 = Boundary('Gamma_3', B)

    connectivity['I'] = (bnd_A_1, bnd_B_2)

    Omega = Domain('Omega',
                   interiors=[A, B],
                   boundaries=[bnd_A_2, bnd_A_3, bnd_B_1, bnd_B_3],
                   connectivity=connectivity)

    interfaces = Omega.interfaces
    assert(isinstance(interfaces, Interface))

    # export
    Omega.export('omega.h5')
    # ...

    # read it again and check that it has the same description as Omega
    D = Domain.from_file('omega.h5')
    assert( D.todict() == Omega.todict() )
Ejemplo n.º 2
0
def test_domain_1():
    Omega_1 = InteriorDomain('Omega_1', dim=2)
    Omega_2 = InteriorDomain('Omega_2', dim=2)

    Gamma_1 = Boundary('Gamma_1', Omega_1)
    Gamma_2 = Boundary('Gamma_2', Omega_2)
    Gamma_3 = Boundary('Gamma_3', Omega_2)

    Omega = Domain('Omega',
                   interiors=[Omega_1, Omega_2],
                   boundaries=[Gamma_1, Gamma_2, Gamma_3])

    assert( Omega.dim == 2 )
    assert( len(Omega.interior) == 2 )
    assert( len(Omega.boundary) == 3 )
Ejemplo n.º 3
0
def test_element():
    D1 = InteriorDomain('D1', dim=2)
    D2 = InteriorDomain('D2', dim=2)

    D = Union(D1, D2)

    e1 = ElementDomain()

    a = Area(e1)
    print(a)

    a = Area(D1)
    print(a)

    assert(Area(D) ==  Area(D1) + Area(D2))
Ejemplo n.º 4
0
def test_boundary_2d_2():
    Omega_1 = InteriorDomain('Omega_1', dim=2)

    B1 = Boundary('B1', Omega_1)
    B2 = Boundary('B2', Omega_1)
    B3 = Boundary('B3', Omega_1)

    domain = Domain('Omega', interiors=[Omega_1], boundaries=[B1, B2, B3])

    V = FunctionSpace('V', domain)
    v = TestFunction(V, name='v')
    u = TestFunction(V, name='u')

    x, y = V.coordinates

    alpha = Constant('alpha')

    # ...
    print('==== l0 ====')
    l0 = LinearForm(v, x * y * v, name='l0')

    print(evaluate(l0, verbose=VERBOSE))
    print('')
    # ...

    # ...
    print('==== l1 ====')
    g = Tuple(x**2, y**2)
    l1 = LinearForm(v, v * trace_1(g, domain.boundary))

    print(evaluate(l1, verbose=VERBOSE))
    print('')
    # ...

    # ...
    print('==== l2 ====')
    B_neumann = Union(B1, B2)
    g = Tuple(x**2, y**2)
    l2 = LinearForm(v, v * trace_1(g, B_neumann), name='l2')

    print(evaluate(l2, verbose=VERBOSE))
    print('')
    # ...

    # ...
    print('==== l3 ====')
    l3 = LinearForm(v, l2(v))

    assert (l3(v).__str__ == l2(v).__str__)

    print(evaluate(l3, verbose=VERBOSE))
    print('')
    # ...

    # ...
    print('==== l4 ====')
    l4 = LinearForm(v, l0(v) + l2(v))

    print(evaluate(l4, verbose=VERBOSE))
    print('')
Ejemplo n.º 5
0
def test_boundary_3():
    Omega_1 = InteriorDomain('Omega_1', dim=2)

    Gamma_1 = Boundary(r'\Gamma_1', Omega_1, axis=0, ext=-1)
    Gamma_4 = Boundary(r'\Gamma_4', Omega_1, axis=1, ext=1)

    Omega = Domain('Omega',
                   interiors=[Omega_1],
                   boundaries=[Gamma_1, Gamma_4])

    assert(Omega.get_boundary(axis=0, ext=-1) == Gamma_1)
    assert(Omega.get_boundary(axis=1, ext=1) == Gamma_4)
Ejemplo n.º 6
0
def test_boundary_1():
    Omega_1 = InteriorDomain('Omega_1', dim=2)

    Gamma_1 = Boundary('Gamma_1', Omega_1)
    Gamma_2 = Boundary('Gamma_2', Omega_1)

    Omega = Domain('Omega',
                   interiors=[Omega_1],
                   boundaries=[Gamma_1, Gamma_2])

    assert(Omega.boundary == Union(Gamma_1, Gamma_2))
    assert(Omega.boundary.complement(Gamma_1) == Gamma_2)
    assert(Omega.boundary - Gamma_1 == Gamma_2)
Ejemplo n.º 7
0
def test_terminal_expr_linear_2d_4():

    D1 = InteriorDomain('D1', dim=2)
    D2 = InteriorDomain('D2', dim=2)
    domain = Union(D1, D2)

    x, y = domain.coordinates

    kappa = Constant('kappa', is_real=True)
    mu = Constant('mu', is_real=True)

    V = ScalarFunctionSpace('V', domain)

    u, u1, u2 = [element_of(V, name=i) for i in ['u', 'u1', 'u2']]
    v, v1, v2 = [element_of(V, name=i) for i in ['v', 'v1', 'v2']]

    # ...
    int_0 = lambda expr: integral(domain, expr)

    l = LinearForm(v, int_0(x * y * v))
    print(TerminalExpr(l))
    print('')
Ejemplo n.º 8
0
def test_interior_domain():
    D1 = InteriorDomain('D1', dim=2)
    D2 = InteriorDomain('D2', dim=2)

    assert( D1.todict() == OrderedDict([('name', 'D1')]) )
    assert( D2.todict() == OrderedDict([('name', 'D2')]) )

    assert( Union(D2, D1) == Union(D1, D2) )

    D = Union(D1, D2)

    assert(D.dim == 2)
    assert(len(D) == 2)
    assert( D.todict() == [OrderedDict([('name', 'D1')]),
                           OrderedDict([('name', 'D2')])] )
Ejemplo n.º 9
0
def test_interior_domain():
    D1 = InteriorDomain('D1', dim=2)
    D2 = InteriorDomain('D2', dim=2)

    assert( D1.todict() == {'name': 'D1'} )
    assert( D2.todict() == {'name': 'D2'} )

    assert( Union(D2, D1) == Union(D1, D2) )

    D = Union(D1, D2)

    assert(D.dim == 2)
    assert(len(D) == 2)
    assert( D.todict() == [{'name': 'D1'},
                           {'name': 'D2'}] )