Debian Codegraph @

demo/documented/navier-stokes/cpp/PressureUpdate.ufl

raw
1 # Copyright (C) 2010 Anders Logg
2 #
3 # This file is part of DOLFIN.
4 #
5 # DOLFIN is free software: you can redistribute it and/or modify
6 # it under the terms of the GNU Lesser General Public License as published by
7 # the Free Software Foundation, either version 3 of the License, or
8 # (at your option) any later version.
9 #
10 # DOLFIN is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU Lesser General Public License for more details.
14 #
15 # You should have received a copy of the GNU Lesser General Public License
16 # along with DOLFIN. If not, see <http://www.gnu.org/licenses/>.
17 #
18 # First added: 2010-08-30
19 # Last changed: 2010-09-01
20 #
21 # The bilinear form a(u, v) and linear form L(v) for the pressure
22 # update step in Chorin's method for the incompressible Navier-Stokes
23 # equations.
24 #
25 # Compile this form with FFC: ffc -l dolfin PressureUpdate.ufl.
26
27 from ufl_legacy import (Coefficient, dx, FiniteElement, VectorElement,
28 div, grad, inner,
29 triangle, TestFunction, TrialFunction)
30
31 # Define function spaces (P2-P1)
32 V = VectorElement("Lagrange", triangle, 2)
33 Q = FiniteElement("Lagrange", triangle, 1)
34 R = FiniteElement("Real", triangle, 0)
35
36 # Define trial and test functions
37 p = TrialFunction(Q)
38 q = TestFunction(Q)
39
40 # Define coefficients
41 k = Coefficient(R)
42 u1 = Coefficient(V)
43
44 # Define bilinear and linear forms
45 a = inner(grad(p), grad(q))*dx
46 L = -(1/k)*div(u1)*q*dx