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

name = "CNSResEnergy2D"
scalar = FiniteElement("Lagrange", "triangle", 1)
vector = VectorElement("Lagrange", "triangle", 1)
constant_scalar = FiniteElement("Discontinuous Lagrange", "triangle", 0)


v    =  TestFunction(constant_scalar)    # constant scalar test basis function
P    =  Function(scalar)                 # energy from previous timestep
u    =  Function(vector)                 # velocity
e    =  Function(scalar)                 # energy
e0   =  Function(scalar)                 # energy from previous timestep

ebar = 0.5 * (e + e0)

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

k  = Constant("triangle")         		# time step

# the linear form of the energy residual:
L = ((e-e0) / k + dot(u, grad(ebar)) + ebar * div(u) + dot(u, grad(P)) + P * div(u)) * vol_inv * v * dx
