| 1 |
"Unit tests for BoundaryMesh library" |
| 2 |
|
| 3 |
# Copyright (C) 2012 Garth N. Wells |
| 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 |
# Modified by Oeyvind Evju 2013 |
| 21 |
# |
| 22 |
# First added: 2011-10-09 |
| 23 |
# Last changed: 2013-10-11 |
| 24 |
|
| 25 |
import pytest |
| 26 |
import numpy |
| 27 |
from dolfin import * |
| 28 |
|
| 29 |
|
| 30 |
def test_1D_mesh(): |
| 31 |
mesh = UnitIntervalMesh(32) |
| 32 |
|
| 33 |
# Create global boundary mesh |
| 34 |
bmesh1 = BoundaryMesh(mesh, "exterior") |
| 35 |
assert MPI.sum(mesh.mpi_comm(), bmesh1.num_cells()) == 2 |
| 36 |
assert bmesh1.num_entities_global(0) == 2 |
| 37 |
assert bmesh1.topology().dim() == 0 |
| 38 |
|
| 39 |
|
| 40 |
def test_2D_mesh(): |
| 41 |
mesh = UnitSquareMesh(8, 8) |
| 42 |
|
| 43 |
# Create global boundary mesh |
| 44 |
bmesh1 = BoundaryMesh(mesh, "exterior") |
| 45 |
assert MPI.sum(mesh.mpi_comm(), bmesh1.num_cells()) == 4*8 |
| 46 |
assert bmesh1.num_entities_global(1) == 4*8 |
| 47 |
assert bmesh1.topology().dim() == 1 |
| 48 |
|
| 49 |
|
| 50 |
def test_3D_mesh(): |
| 51 |
mesh = UnitCubeMesh(8, 8, 8) |
| 52 |
|
| 53 |
# Create global boundary mesh |
| 54 |
bmesh1 = BoundaryMesh(mesh, "exterior") |
| 55 |
assert MPI.sum(mesh.mpi_comm(), bmesh1.num_cells()) == 6*8*8*2 |
| 56 |
assert bmesh1.num_entities_global(2) == 6*8*8*2 |
| 57 |
assert bmesh1.topology().dim() == 2 |