# 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: 2014-06-10 # Last changed: 2015-11-17 # # The bilinear form a(u, v) and linear form L(v) for a multimesh # formulation of the Stokes equations. # # Compile this form with FFC: ffc -l dolfin MultiMeshStokes.ufl. from ufl_legacy import (Circumradius, Coefficient, dC, dI, dO, dX, FiniteElement, VectorElement, avg, div, FacetNormal, inner, grad, jump, outer, triangle, TestFunctions, TrialFunctions) # Define element P2 = VectorElement("Lagrange", triangle, 2) P1 = FiniteElement("Lagrange", triangle, 1) TH = P2 * P1 # Define trial and test functions and right-hand side (u, p) = TrialFunctions(TH) (v, q) = TestFunctions(TH) f = Coefficient(P2) # Define facet normal and mesh size n = FacetNormal(triangle) h = 2.0*Circumradius(triangle) # Parameters alpha = 20.0 beta = 5 def tensor_jump(v, n): return outer(v('+'), n('+')) + outer(v('-'), n('-')) def a_h(v, w): return inner(grad(v), grad(w))*dX \ - inner(avg(grad(v)), tensor_jump(w, n))*dI \ - inner(avg(grad(w)), tensor_jump(v, n))*dI \ + alpha/avg(h) * inner(jump(v), jump(w))*dI def b_h(v, q): return -div(v)*q*dX + jump(v, n)*avg(q)*dI def l_h(v, q, f): return inner(f, v)*dX def s_O(v, q, w, r): return (beta/avg(h)**2) * inner(jump(v), jump(w))*dO \ + beta * inner(jump(q), jump(r))*dO def s_C(v, q, w, r): return h*h*inner(-div(grad(v)) + grad(q), -div(grad(w)) - grad(r))*dC def l_C(v, q, f): return h*h*inner(f, -div(grad(v)) - grad(q))*dC # Define bilinear form a = a_h(u, v) + b_h(v, p) + b_h(u, q) + s_O(u, p, v, q) + s_C(u, p, v, q) # Define linear form L = l_h(v, q, f) + l_C(v, q, f)