| 1 |
"Unit tests for the mesh library" |
| 2 |
|
| 3 |
# Copyright (C) 2012 Anders Logg |
| 4 |
# |
| 5 |
# This file is part of DOLFIN. |
| 6 |
# |
| 7 |
# DOLFIN is free software: you can redistribute it and/or modify |
| 8 |
# it under the terms of the GNU Lesser General Public License as published by |
| 9 |
# the Free Software Foundation, either version 3 of the License, or |
| 10 |
# (at your option) any later version. |
| 11 |
# |
| 12 |
# DOLFIN is distributed in the hope that it will be useful, |
| 13 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 |
# GNU Lesser General Public License for more details. |
| 16 |
# |
| 17 |
# You should have received a copy of the GNU Lesser General Public License |
| 18 |
# along with DOLFIN. If not, see <http://www.gnu.org/licenses/>. |
| 19 |
|
| 20 |
from dolfin import * |
| 21 |
|
| 22 |
|
| 23 |
def test_translate_2d(): |
| 24 |
mesh = UnitSquareMesh(8, 8) |
| 25 |
p = Point(1, 2) |
| 26 |
mesh.translate(p) |
| 27 |
|
| 28 |
|
| 29 |
def test_translate_3d(): |
| 30 |
mesh = UnitCubeMesh(8, 8, 8) |
| 31 |
p = Point(1, 2, 3) |
| 32 |
mesh.translate(p) |
| 33 |
|
| 34 |
|
| 35 |
def test_rotate_2d(): |
| 36 |
mesh = UnitSquareMesh(8, 8) |
| 37 |
p = Point(1, 2) |
| 38 |
mesh.rotate(10) |
| 39 |
mesh.rotate(10, 2) |
| 40 |
mesh.rotate(10, 2, p) |
| 41 |
|
| 42 |
|
| 43 |
def test_rotate_3d(): |
| 44 |
mesh = UnitCubeMesh(8, 8, 8) |
| 45 |
p = Point(1, 2, 3) |
| 46 |
mesh.rotate(30, 0) |
| 47 |
mesh.rotate(30, 1) |
| 48 |
mesh.rotate(30, 2) |
| 49 |
mesh.rotate(30, 0, p) |
| 50 |
|
| 51 |
|
| 52 |
def test_rescale_2d(): |
| 53 |
mesh = UnitSquareMesh(8, 8) |
| 54 |
p = Point(4, 4) |
| 55 |
s = 1.5 |
| 56 |
MeshTransformation.rescale(mesh, s, p) |
| 57 |
comm = mesh.mpi_comm() |
| 58 |
assert MPI.sum(comm, sum(c.volume() for c in cells(mesh))) == s*s |
| 59 |
|
| 60 |
|
| 61 |
def test_rescale_3d(): |
| 62 |
mesh = UnitCubeMesh(8, 8, 8) |
| 63 |
p = Point(4, 4, 4) |
| 64 |
s = 1.5 |
| 65 |
MeshTransformation.rescale(mesh, s, p) |
| 66 |
comm = mesh.mpi_comm() |
| 67 |
assert MPI.sum(comm, sum(c.volume() for c in cells(mesh))) == s*s*s |