Example #1
0
def test_extract_transport_coefficients():
    u = Variable('u', rank=0)
    a, b, d = Coefficients('a b d', rank=0)
    b, e = Coefficients('b e', rank=1)
    c, = Coefficients('c', rank=2)

    eqn = Dt(a*u) + div(b*u + c*grad(u)) + d*u + dot(e, grad(u))
    strong_form = StrongForm(eqn)

    coeffs = {'diffusion': c,
              'reaction': d*u,
              'hamiltonian': dot(e, grad(u)),
              'potential': u,
              'mass': Dt(a*u),
              'advection': b*u,
              }
    sf_coeffs = strong_form.extract_transport_coefficients()
    assert(coeffs == sf_coeffs)
    eqn =  d*u + dot(e, grad(u)) + Dt(a*u) + div(b*u) + div(c*grad(u))
    strong_form = StrongForm(eqn)
    sf_coeffs = strong_form.extract_transport_coefficients()
    assert(coeffs == sf_coeffs)