| 1 |
#!/usr/bin/env python |
| 2 |
|
| 3 |
"""This script provides a benchmark for interpolation between meshes""" |
| 4 |
|
| 5 |
# Copyright (C) 2013 Anders Logg |
| 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: 2013-06-17 |
| 23 |
# Last changed: 2013-06-21 |
| 24 |
|
| 25 |
from dolfin import * |
| 26 |
from time import time |
| 27 |
|
| 28 |
SIZE_0 = 21 #71 |
| 29 |
SIZE_1 = 23 #73 |
| 30 |
|
| 31 |
info("Extrapolation from P1 on UnitCubeMesh(%d, %d, %d) to " |
| 32 |
"P1 on UnitCubeMesh(%d, %d, %d)" |
| 33 |
% (SIZE_0, SIZE_0, SIZE_0, SIZE_1, SIZE_1, SIZE_1)) |
| 34 |
|
| 35 |
parameters["allow_extrapolation"] = True |
| 36 |
|
| 37 |
mesh_0 = UnitCubeMesh(SIZE_0, SIZE_0, SIZE_0) |
| 38 |
mesh_1 = UnitCubeMesh(SIZE_1, SIZE_1, SIZE_1) |
| 39 |
|
| 40 |
V0 = FunctionSpace(mesh_0, "CG", 1) |
| 41 |
V1 = FunctionSpace(mesh_1, "CG", 1) |
| 42 |
|
| 43 |
v0 = interpolate(Expression("sin(5*x[0])*cos(7*x[1])"), V0) |
| 44 |
|
| 45 |
tic = time() |
| 46 |
v1 = interpolate(v0, V1) |
| 47 |
t = time() - tic |
| 48 |
|
| 49 |
print "BENCH: ", t |