# Copyright (c) 2005 Johan Hoffman (hoffman@cims.nyu.edu)
# Licensed under the GNU GPL Version 2

name = "NSEResMomentum2D"
scalar = FiniteElement("Lagrange", "tetrahedron", 1)
vector = VectorElement("Lagrange", "tetrahedron", 1)
constant_scalar = FiniteElement("Discontinuous Lagrange", "tetrahedron", 0)
constant_vector = VectorElement("Discontinuous Lagrange", "tetrahedron", 0)


v    =  TestFunction(constant_vector)   # constant scalar test basis function
P    =  Function(scalar)                # pressure
u    =  Function(vector)                # momentum
u0   =  Function(vector)                # momentum from previous timestep


vol_inv = Function(constant_scalar)     # the inverse of volume of the element

k  = Constant("tetrahedron")         		# time step
#nu = Constant()         		# time step

# the linear form of the momentum residual:

L = mult( 1/k * dot(u-u0, v) +
          0.5 * (u[0] *  u[0].dx(0) * v[0] + u[1] *  u[0].dx(1) * v[0]) +
          0.5 * (u[0] *  u[1].dx(0) * v[1] + u[1] *  u[1].dx(1) * v[1]) +
          0.5 * (u[0] * u0[0].dx(0) * v[0] + u[1] * u0[0].dx(1) * v[0]) +
          0.5 * (u[0] * u0[1].dx(0) * v[1] + u[1] * u0[1].dx(1) * v[1]) +
          dot(grad(P), v), vol_inv) * dx     
