| 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: 2017-08-23 |
| 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 (avg, Circumradius, Coefficient, dI, dO, dX, dx, FiniteElement, |
| 27 |
dot, grad, FacetNormal, jump, |
| 28 |
tetrahedron, TestFunction, TrialFunction) |
| 29 |
|
| 30 |
# Define element |
| 31 |
simplex = tetrahedron |
| 32 |
element = FiniteElement("Lagrange", simplex, 1) |
| 33 |
|
| 34 |
# Define trial and test functions and right-hand side |
| 35 |
u = TrialFunction(element) |
| 36 |
v = TestFunction(element) |
| 37 |
f = Coefficient(element) |
| 38 |
|
| 39 |
# Define facet normal and mesh size |
| 40 |
n = FacetNormal(simplex) |
| 41 |
h = 2.0*Circumradius(simplex) |
| 42 |
h = (h('+') + h('-')) / 2 |
| 43 |
|
| 44 |
# Parameters |
| 45 |
alpha = 4.0 |
| 46 |
beta = 4.0 |
| 47 |
|
| 48 |
# Define bilinear form |
| 49 |
a = dot(grad(u), grad(v))*dX \ |
| 50 |
- dot(avg(grad(u)), jump(v, n))*dI \ |
| 51 |
- dot(avg(grad(v)), jump(u, n))*dI \ |
| 52 |
+ alpha/h*jump(u)*jump(v)*dI \ |
| 53 |
+ beta*dot(jump(grad(u)), jump(grad(v)))*dO |
| 54 |
|
| 55 |
# Define linear form |
| 56 |
L = f*v*dX |