# Copyright (C) 2007 Murtazo Nazarov.
# Licensed under the GNU GPL Version 2.
#

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


v    = TestFunction(constant_scalar)    # constant scalar test basis function
u    = Function(vector)                 # velocity
rho  = Function(scalar)                 # density
rho0 = Function(scalar)                 # density from previous timestep

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

k  = Constant("tetrahedron")         		# time step

rhobar = 0.5 * (rho + rho0)

# the linear form of the density residual:
L = ((rho-rho0) / k + dot(u, grad(rhobar)) + dot(rhobar, grad(u))) * vol_inv * v * dx
