# Copyright (C) 2014 Anders Logg # # This file is part of FFC. # # FFC 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. # # FFC 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 FFC. If not, see . # # First added: 2014-03-04 # Last changed: 2014-06-10 # # This demo illustrates the use of custom integrals with vector elements. # # Compile this form with FFC: ffc CustomVectorIntegral.ufl # Define element element = VectorElement("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 # Define custom measures (FIXME: prettify this) dc0 = dc(0, metadata={"num_cells": 1}) dc1 = dc(1, metadata={"num_cells": 2}) dc2 = dc(2, metadata={"num_cells": 2}) # Define measures for integration dx = dx + dc0 # domain integral di = dc1 # interface integral do = dc2 # overlap integral # Parameters alpha = 4.0 def tensor_jump(v, n): return outer(v('+'), n('+')) + outer(v('-'), n('-')) # Bilinear form a = inner(grad(u), grad(v))*dx \ - inner(avg(grad(u)), tensor_jump(v, n))*di \ - inner(avg(grad(v)), tensor_jump(u, n))*di \ + alpha/h*dot(jump(u), jump(v))*di \ + inner(jump(grad(u)), jump(grad(v)))*do # Linear form L = dot(f, v)*dx