Debian Codegraph @

demo/documented/navier-stokes/cpp/VelocityUpdate.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 velocity
22 # update step in Chorin's method for the incompressible Navier-Stokes
23 # equations.
24 #
25 # Compile this form with FFC: ffc -l dolfin TentativeVelocity.ufl.
26
27 from ufl_legacy import (Coefficient, dx, FiniteElement, VectorElement,
28 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 u = TrialFunction(V)
38 v = TestFunction(V)
39
40 # Define coefficients
41 k = Coefficient(R)
42 u1 = Coefficient(V)
43 p1 = Coefficient(Q)
44
45 # Define bilinear and linear forms
46 a = inner(u, v)*dx
47 L = inner(u1, v)*dx - k*inner(grad(p1), v)*dx