| 1 |
# Copyright (C) 2014-2015 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: 2013-06-26 |
| 19 |
# Last changed: 2015-11-28 |
| 20 |
# |
| 21 |
# The bilinear form a(u, v) and linear form L(v) for a multimesh |
| 22 |
# formulation of Poisson's equation. |
| 23 |
# |
| 24 |
# Compile this form with FFC: ffc -l dolfin MultiMeshPoisson.ufl. |
| 25 |
|
| 26 |
from ufl_legacy import (Circumradius, Coefficient, dI, dO, dX, dx, FiniteElement, |
| 27 |
avg, dot, FacetNormal, grad, jump, |
| 28 |
triangle, TestFunction, TrialFunction) |
| 29 |
|
| 30 |
# Define element |
| 31 |
element = FiniteElement("Lagrange", triangle, 1) |
| 32 |
|
| 33 |
# Define trial and test functions and right-hand side |
| 34 |
u = TrialFunction(element) |
| 35 |
v = TestFunction(element) |
| 36 |
f = Coefficient(element) |
| 37 |
|
| 38 |
# Define facet normal and mesh size |
| 39 |
n = FacetNormal(triangle) |
| 40 |
h = 2.0*Circumradius(triangle) |
| 41 |
h = (h('+') + h('-')) / 2 |
| 42 |
|
| 43 |
# Parameters |
| 44 |
alpha = 10.0 |
| 45 |
beta = 1.0 |
| 46 |
|
| 47 |
# Define bilinear form |
| 48 |
a = dot(grad(u), grad(v))*dX \ |
| 49 |
- dot(avg(grad(u)), jump(v, n))*dI \ |
| 50 |
- dot(avg(grad(v)), jump(u, n))*dI \ |
| 51 |
+ alpha/h * jump(u)*jump(v)*dI \ |
| 52 |
+ beta/h**2 * dot(jump(u), jump(v))*dO |
| 53 |
|
| 54 |
# Define linear form |
| 55 |
L = f*v*dX |