Debian Codegraph @

demo/QuadratureElement.ufl

raw
1 # Copyright (C) 2008-2016 Kristian B. Oelgaard
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 # The linearised bilinear form a(u, v) and linear form L(v) for
19 # the nonlinear equation -div (1 + u) grad u = f (nonlinear Poisson)
20 #
21 # Compile this form with FFC: ffc QuadratureElement.ufl
22
23 # Configure measure with specific quadrature rule
24 scheme = "default"
25 degree = 3
26 dx = Measure("dx")
27 dx = dx(degree=degree, scheme=scheme)
28
29 # Configure quadrature elements with compatible rule
30 element = FiniteElement("Lagrange", triangle, 2)
31 QE = FiniteElement("Quadrature", triangle, degree, quad_scheme=scheme)
32 sig = VectorElement("Quadrature", triangle, degree, quad_scheme=scheme)
33
34 u = TrialFunction(element)
35 v = TestFunction(element)
36 u0 = Coefficient(element)
37 C = Coefficient(QE)
38 sig0 = Coefficient(sig)
39 f = Coefficient(element)
40
41 a = C*u.dx(i)*v.dx(i)*dx + 2*u0*u0.dx(i)*u*v.dx(i)*dx
42 L = f*v*dx - inner(sig0, grad(v))*dx