| 1 |
# Copyright (C) 2010 Marie E. Rognes |
| 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: 2010-11-01 |
| 19 |
# Last changed: 2011-06-29 |
| 20 |
# |
| 21 |
# Compile with ffc -e -l dolfin AdaptiveNavierStokes.ufl |
| 22 |
|
| 23 |
from ufl_legacy import (Coefficient, ds, dx, FiniteElement, VectorElement, |
| 24 |
as_vector, FacetNormal, |
| 25 |
div, dot, grad, inner, |
| 26 |
triangle, TestFunctions) |
| 27 |
|
| 28 |
cell = triangle |
| 29 |
V = VectorElement("CG", cell, 2) |
| 30 |
Q = FiniteElement("CG", cell, 1) |
| 31 |
R = FiniteElement("Real", cell, 0) |
| 32 |
W = V * Q |
| 33 |
|
| 34 |
w = Coefficient(W) |
| 35 |
(u, p) = (as_vector((w[0], w[1])), w[2]) |
| 36 |
(v, q) = TestFunctions(W) |
| 37 |
|
| 38 |
# Prescribed pressure |
| 39 |
T = FiniteElement("CG", cell, 1) |
| 40 |
p0 = Coefficient(T) |
| 41 |
|
| 42 |
# Prescribed viscosity |
| 43 |
nu = Coefficient(R) |
| 44 |
|
| 45 |
# Define FacetNormal |
| 46 |
n = FacetNormal(cell) |
| 47 |
|
| 48 |
# Define variational form |
| 49 |
L = (nu*inner(grad(u), grad(v)) - p*div(v) + div(u)*q |
| 50 |
+ inner(v, grad(u)*u))*dx() \ |
| 51 |
+ p0*dot(v, n)*ds() |
| 52 |
|
| 53 |
# Define goal functional |
| 54 |
M = w[0]*ds(0) |
| 55 |
|
| 56 |
# NB: Label the unknown |
| 57 |
unknown = w |