| 1 |
#!/usr/bin/env python |
| 2 |
|
| 3 |
"""This script provides a benchmark for Extrapolation""" |
| 4 |
|
| 5 |
# Copyright (C) 2010 Marie E. Rognes |
| 6 |
# |
| 7 |
# This file is part of DOLFIN. |
| 8 |
# |
| 9 |
# DOLFIN is free software: you can redistribute it and/or modify |
| 10 |
# it under the terms of the GNU Lesser General Public License as published by |
| 11 |
# the Free Software Foundation, either version 3 of the License, or |
| 12 |
# (at your option) any later version. |
| 13 |
# |
| 14 |
# DOLFIN is distributed in the hope that it will be useful, |
| 15 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 16 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 17 |
# GNU Lesser General Public License for more details. |
| 18 |
# |
| 19 |
# You should have received a copy of the GNU Lesser General Public License |
| 20 |
# along with DOLFIN. If not, see <http://www.gnu.org/licenses/>. |
| 21 |
# |
| 22 |
# First added: 2010-06-07 |
| 23 |
# Last changed: 2013-06-17 |
| 24 |
|
| 25 |
from dolfin import * |
| 26 |
from time import time |
| 27 |
|
| 28 |
SIZE = 4 |
| 29 |
|
| 30 |
info("Extrapolation from P2*dP1 to P3*dP2 on UnitCubeMesh(%d, %d, %d)" |
| 31 |
% (SIZE, SIZE, SIZE)) |
| 32 |
|
| 33 |
mesh = UnitCubeMesh(SIZE, SIZE, SIZE) |
| 34 |
cell = mesh.ufl_cell() |
| 35 |
|
| 36 |
V = FunctionSpace(mesh, VectorElement("CG", cell, 2) * FiniteElement("DG", cell, 1)) |
| 37 |
W = FunctionSpace(mesh, VectorElement("CG", cell, 3) * FiniteElement("DG", cell, 2)) |
| 38 |
|
| 39 |
u = Expression(("sin(x[0])", "1.0", "x[0]*x[1]", "0.0"), degree=3) |
| 40 |
u = interpolate(u, V) |
| 41 |
|
| 42 |
w = Function(W) |
| 43 |
|
| 44 |
tic = time() |
| 45 |
w.extrapolate(u) |
| 46 |
t = time() - tic |
| 47 |
|
| 48 |
print "BENCH: ", t |