# Copyright (C) 2014-2015 Anders Logg # # This file is part of DOLFIN. # # DOLFIN is free software: you can redistribute it and/or modify # it under the terms of the GNU Lesser General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # DOLFIN is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public License # along with DOLFIN. If not, see . # # First added: 2013-06-26 # Last changed: 2015-11-28 # # The bilinear form a(u, v) and linear form L(v) for a multimesh # formulation of Poisson's equation. # # Compile this form with FFC: ffc -l dolfin MultiMeshPoisson.ufl. from ufl_legacy import (Circumradius, Coefficient, dI, dO, dX, dx, FiniteElement, avg, dot, FacetNormal, grad, jump, triangle, TestFunction, TrialFunction) # Define element element = FiniteElement("Lagrange", triangle, 1) # Define trial and test functions and right-hand side u = TrialFunction(element) v = TestFunction(element) f = Coefficient(element) # Define facet normal and mesh size n = FacetNormal(triangle) h = 2.0*Circumradius(triangle) h = (h('+') + h('-')) / 2 # Parameters alpha = 10.0 beta = 1.0 # Define bilinear form a = dot(grad(u), grad(v))*dX \ - dot(avg(grad(u)), jump(v, n))*dI \ - dot(avg(grad(v)), jump(u, n))*dI \ + alpha/h * jump(u)*jump(v)*dI \ + beta/h**2 * dot(jump(u), jump(v))*dO # Define linear form L = f*v*dX