| 1 |
# Copyright (C) 2007 Marie Rognes |
| 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 bilinear form a(u, v) and linear form L(v) for the Hodge Laplace |
| 19 |
# problem using 0- and 1-forms. Intended to demonstrate use of N1curl |
| 20 |
# elements. |
| 21 |
|
| 22 |
# Compile this form with FFC: ffc VectorLaplaceGradCurl.ufl |
| 23 |
|
| 24 |
def HodgeLaplaceGradCurl(element, felement): |
| 25 |
"""This is a formulation of the Hodge Laplacian using k=1 and n=3, |
| 26 |
i.e 0-forms and 1-forms in 3D. |
| 27 |
|
| 28 |
Appropriate elements are |
| 29 |
|
| 30 |
GRAD \times CURL = |
| 31 |
Lagrange_r \ times Ned^1_{r} |
| 32 |
Lagrange_{r+1} \ times Ned^2_{r} |
| 33 |
""" |
| 34 |
|
| 35 |
(sigma, u) = TrialFunctions(element) |
| 36 |
(tau, v) = TestFunctions(element) |
| 37 |
f = Coefficient(felement) |
| 38 |
a = (inner(sigma, tau) - inner(grad(tau), u) + |
| 39 |
inner(grad(sigma), v) + inner(curl(u), curl(v)))*dx |
| 40 |
L = inner(f, v)*dx |
| 41 |
return [a, L] |
| 42 |
|
| 43 |
shape = tetrahedron |
| 44 |
order = 1 |
| 45 |
|
| 46 |
GRAD = FiniteElement("Lagrange", shape, order) |
| 47 |
CURL = FiniteElement("N1curl", shape, order) |
| 48 |
VectorLagrange = VectorElement("Lagrange", shape, order+1) |
| 49 |
|
| 50 |
[a, L] = HodgeLaplaceGradCurl(GRAD * CURL, VectorLagrange) |