~njansson/dolfin/hpc

« back to all changes in this revision

Viewing changes to bench/fem/assembly/NSEMomentum3D.form

  • Committer: Anders Logg
  • Date: 2008-06-12 20:00:04 UTC
  • mfrom: (2668.1.54 trunk)
  • Revision ID: logg@simula.no-20080612200004-3t5tw0tes2zdaqb4
Merge

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# Copyright (c) 2005 Johan Hoffman 
 
2
# Licensed under the GNU GPL Version 2
 
3
#
 
4
# Modified by Anders Logg 2006
 
5
#
 
6
# First added:  2005
 
7
# Last changed: 2006-03-28
 
8
#
 
9
# The momentum equation for the incompressible 
 
10
# Navier-Stokes equations using cG(1)cG(1)
 
11
#
 
12
# Compile this form with FFC: ffc NSEMomentum2D.form.
 
13
 
 
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)
 
19
 
 
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
 
29
 
 
30
k  = Constant("tetrahedron") # time step
 
31
nu = Constant("tetrahedron") # viscosity
 
32
 
 
33
#uc = mean(uc)   # cell mean value of linearized velocity
 
34
#uc = uc   # cell mean value of linearized velocity
 
35
 
 
36
i0 = Index()    # index for tensor notation
 
37
i1 = Index()    # index for tensor notation
 
38
i2 = Index()    # index for tensor notation
 
39
 
 
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
 
44
 
 
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
 
49
 
 
50
# Bilinear and linear forms
 
51
a = G_a + SD_a
 
52
L = G_L + SD_L
 
53