Exemple #1
0
def apply_bc_from_fnc(mesh, fnc, type):
    """
    Does the same as apply_bc_from_coeffs, but interpolates a function first
    to get the coefficients.
    """
    for e in mesh:
        basis = basis_from_func(e.basis, fnc, e)
        e.bc = BC(type, basis)
Exemple #2
0
def test_basis_from_func():
    msh = simple_line_mesh(1)
    bf = basis_from_degree(1)
    soln = basis_from_func(bf, lambda x, n: x, msh.elements[0])

    value = soln.evaluate(0, 0.0)
    np.testing.assert_almost_equal(value, [-1.0, 0.0])

    value = soln.evaluate(1, 1.0)
    np.testing.assert_almost_equal(value, [1.0, 0.0])