Debian Codegraph @

python/test/unit/mesh/test_mesh_markers.py

raw
1 """Unit tests for the class MeshMarkers. These unit test actually test
2 a bit more than that, since they also test marking of meshes and the
3 interaction between Mesh - MeshDomains - MeshMarkers"""
4
5 # Copyright (C) 2011 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: 2011-09-01
23 # Last changed: 2011-09-02
24
25 import pytest
26 from dolfin import *
27
28
29 def test_subdomain_marking():
30 "Test setting markers from subdomains"
31
32 # Define subdomains for 5 of the 6 faces of the unit cube
33 class F0(SubDomain):
34 def inside(self, x, inside):
35 return near(x[0], 0.0)
36
37 class F1(SubDomain):
38 def inside(self, x, inside):
39 return near(x[0], 1.0)
40
41 class F2(SubDomain):
42 def inside(self, x, inside):
43 return near(x[1], 0.0)
44
45 class F3(SubDomain):
46 def inside(self, x, inside):
47 return near(x[1], 1.0)
48
49 class F4(SubDomain):
50 def inside(self, x, inside):
51 return near(x[2], 0.0)
52 f0 = F0()
53 f1 = F1()
54 f2 = F2()
55 f3 = F3()
56 f4 = F4()
57
58 # Apply markers to unit cube
59 mesh = UnitCubeMesh(3, 3, 3)
60 f0.mark_facets(mesh, 0)
61 f1.mark_facets(mesh, 1)
62 f2.mark_facets(mesh, 2)
63 f3.mark_facets(mesh, 3)
64 f4.mark_facets(mesh, 4)
65
66 # FIXME: Add test here
67 assert 0 == 0
68
69
70 def test_domain_markers():
71 mesh = UnitSquareMesh(3, 3)
72 mdoms = mesh.domains()
73 ret = mdoms.set_marker((0, 2), 2)
74 assert ret
75 ret = mdoms.set_marker((0, 3), 2)
76 assert not ret
77
78 assert mdoms.get_marker(0, 2) == 3