1
# Copyright (c) 2005 Johan Hoffman
2
# Licensed under the GNU GPL Version 2
4
# Modified by Anders Logg 2006
7
# Last changed: 2006-03-28
9
# The momentum equation for the incompressible
10
# Navier-Stokes equations using cG(1)cG(1)
12
# Compile this form with FFC: ffc NSEMomentum2D.form.
14
name = "NSEMomentum3D"
15
scalar = FiniteElement("Lagrange", "tetrahedron", 1)
16
vector = VectorElement("Lagrange", "tetrahedron", 1)
17
constant_scalar = FiniteElement("Discontinuous Lagrange", "tetrahedron", 0)
18
constant_vector = VectorElement("Discontinuous Lagrange", "tetrahedron", 0)
20
v = TestFunction(vector) # test basis function
21
U = TrialFunction(vector) # trial basis function
22
#uc = Function(vector) # linearized velocity
23
um = Function(constant_vector) # cell mean linearized velocity
24
u0 = Function(vector) # velocity from previous time step
25
f = Function(vector) # force term
26
p = Function(scalar) # pressure
27
delta1 = Function(constant_scalar) # stabilization parameter
28
delta2 = Function(constant_scalar) # stabilization parameter
30
k = Constant("tetrahedron") # time step
31
nu = Constant("tetrahedron") # viscosity
33
#uc = mean(uc) # cell mean value of linearized velocity
34
#uc = uc # cell mean value of linearized velocity
36
i0 = Index() # index for tensor notation
37
i1 = Index() # index for tensor notation
38
i2 = Index() # index for tensor notation
40
# Galerkin discretization of bilinear form
41
G_a = (dot(v, U) + k*nu*0.5*dot(grad(v), grad(U)) + 0.5*k*v[i0]*um[i1]*U[i0].dx(i1))*dx
42
# Least squares stabilization of bilinear form
43
SD_a = (delta1*k*0.5*um[i1]*v[i0].dx(i1)*um[i2]*U[i0].dx(i2) + delta2*k*0.5*div(v)*div(U))*dx
45
# Galerkin discretization of linear form
46
G_L = (dot(v, u0) + k*dot(v, f) + k*div(v)*p - k*nu*0.5*dot(grad(v), grad(u0)) - 0.5*k*v[i0]*um[i1]*u0[i0].dx(i1))*dx
47
# Least squares stabilization of linear form
48
SD_L = (- delta1*k*0.5*um[i1]*v[i0].dx(i1)*um[i2]*u0[i0].dx(i2) - delta2*k*0.5*div(v)*div(u0))*dx
50
# Bilinear and linear forms