Ejemplo n.º 1
0
def test_ldc_bnd():
    nx = 4
    ny = nx
    nz = nx
    dim = 3
    dof = 4
    parameters = {'Reynolds Number': 100}
    n = nx * ny * nz * dof

    discretization = Discretization(parameters, nx, ny, nz, dim, dof)
    atom = discretization.linear_part()
    discretization.boundaries(atom)
    A = discretization.assemble_jacobian(atom)

    B = read_matrix('ldc_bnd_%sx%sx%s.txt' % (nx, ny, nz))

    for i in range(n):
        print(i)

        print('Expected:')
        print(B.jcoA[B.begA[i]:B.begA[i + 1]])
        print(B.coA[B.begA[i]:B.begA[i + 1]])

        print('Got:')
        print(A.jcoA[A.begA[i]:A.begA[i + 1]])
        print(A.coA[A.begA[i]:A.begA[i + 1]])

        assert B.begA[i + 1] - B.begA[i] == A.begA[i + 1] - A.begA[i]
        for j in range(B.begA[i], B.begA[i + 1]):
            assert B.jcoA[j] == A.jcoA[j]
            assert B.coA[j] == A.coA[j]
Ejemplo n.º 2
0
def test_bous_bnd():
    nx = 4
    ny = nx
    nz = nx
    dim = 3
    dof = 5
    parameters = {
        'Reynolds Number': 1,
        'Rayleigh Number': 100,
        'Prandtl Number': 100,
        'Problem Type': 'Rayleigh-Benard'
    }
    n = nx * ny * nz * dof

    discretization = Discretization(parameters, nx, ny, nz, dim, dof)
    atom = discretization.linear_part()
    discretization.boundaries(atom)
    A = discretization.assemble_jacobian(atom)

    B = read_bous_matrix('bous_bnd_%sx%sx%s.txt' % (nx, ny, nz))

    pytest.skip('The Prandtl number is currently applied in a different place')

    for i in range(n):
        print(i)

        print('Expected:')
        print(B.jcoA[B.begA[i]:B.begA[i + 1]])
        print(B.coA[B.begA[i]:B.begA[i + 1]])

        print('Got:')
        print(A.jcoA[A.begA[i]:A.begA[i + 1]])
        print(A.coA[A.begA[i]:A.begA[i + 1]])

        assert B.begA[i + 1] - B.begA[i] == A.begA[i + 1] - A.begA[i]
        for j in range(B.begA[i], B.begA[i + 1]):
            assert B.jcoA[j] == A.jcoA[j]
            assert B.coA[j] == pytest.approx(A.coA[j])