Exemplo n.º 1
0
def test_funspace_4():
    '''Test of FunctionSpace.int_phi_phi made up of linear elements, Laplace
    matrix multiply

    '''
    ox, dx, nx = 0., 1., 10
    mesh = Mesh(type='uniform', lx=dx, nx=nx, block='B1')
    V = FunctionSpace(mesh, {'B1': Element(type='link2')})
    C = V.int_phi_phi(derivative=(True, True))

    sol = np.ones(V.num_dof)
    b = np.dot(C, sol)
    assert norm(b) < 1.e-12
Exemplo n.º 2
0
def test_funspace_9():
    '''Testing of FunctionSpace.int_phi_phi, mixed integration MMS'''
    ox, dx, nx = 0., 10., 10
    mesh = Mesh(type='uniform', lx=dx, nx=nx, block='B1')
    V = FunctionSpace(mesh, {'B1': Element(type='link2')})

    D = V.int_phi_phi(derivative=(False,True))
    sol = np.ones(V.num_dof)
    b = np.dot(D, sol)
    # Norm check (rhs d/dx + Neumann, const soln)
    assert norm(b) < 1.e-12

    D[0, 0] = 1.0
    D[0, 1:] = 0.0
    D[-1, -1] = 1.0
    D[-1, 0:-1] = 0.0
    sol = V.X
    b = np.dot(D, sol)
    rhs = V.int_phi(lambda x: 1)
    rhs[0] = sol[0]
    rhs[-1] = sol[-1]
    # norm check (d/dx+Dirichlet sol=x)
    assert norm(rhs - b) < 1.e-12
Exemplo n.º 3
0
def test_funspace_6():
    '''Test of FunctionSpace.int_phi_phi made up of linear elements, Laplace
    norm check.  Solution = x^2

    '''
    ox, dx, nx = 0., 1., 10
    mesh = Mesh(type='uniform', lx=dx, nx=nx, block='B1')
    V = FunctionSpace(mesh, {'B1': Element(type='link2')})
    C = V.int_phi_phi(derivative=(True, True))

    sol = V.X ** 2
    b = np.dot(C, sol)
    rhs = V.int_phi(lambda x: 2.)
    # natural b.c. not satisfied on right, don't check it
    rhs[-1] = -b[-1]
    assert norm(rhs + b) < 1.e-12