Debian Codegraph @

demo/PoissonDG.ufl

raw
1 # Copyright (C) 2006-2007 Kristian B. Oelgaard and Anders Logg
2 #
3 # This file is part of FFC.
4 #
5 # FFC 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 # FFC 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 FFC. If not, see <http://www.gnu.org/licenses/>.
17 #
18 # First added: 2006-12-05
19 # Last changed: 2011-03-08
20 #
21 # The bilinear form a(u, v) and linear form L(v) for
22 # Poisson's equation in a discontinuous Galerkin (DG)
23 # formulation.
24 #
25 # Compile this form with FFC: ffc PoissonDG.ufl
26
27 # Elements
28 element = FiniteElement("Discontinuous Lagrange", triangle, 1)
29
30 # Trial and test functions
31 u = TrialFunction(element)
32 v = TestFunction(element)
33
34 # Facet normal, mesh size and right-hand side
35 n = FacetNormal(triangle)
36 h = 2.0*Circumradius(triangle)
37 f = Coefficient(element)
38
39 # Compute average of mesh size
40 h_avg = (h('+') + h('-'))/2.0
41
42 # Neumann boundary conditions
43 gN = Coefficient(element)
44
45 # Parameters
46 alpha = 4.0
47 gamma = 8.0
48
49 # Bilinear form
50 a = inner(grad(u), grad(v))*dx \
51 - inner(jump(u, n), avg(grad(v)))*dS \
52 - inner(avg(grad(u)), jump(v, n))*dS \
53 + alpha/h_avg*inner(jump(u, n), jump(v, n))*dS \
54 - inner(u*n, grad(v))*ds \
55 - inner(grad(u), v*n)*ds \
56 + gamma/h*u*v*ds
57
58 # Linear form
59 L = f*v*dx + gN*v*ds