SyFi  0.3
test_geometry.py
Go to the documentation of this file.
00001 #!/usr/bin/env python
00002 
00003 __authors__ = "Martin Sandve Alnes"
00004 __date__ = "2012-05-16"
00005 
00006 from unittest import TestCase
00007 import swiginac
00008 import SyFi
00009 
00010 class TestGeometry(TestCase):
00011 
00012     def _validate_vertex(self, v, dim):
00013         if len(v) != dim:
00014             print
00015             print v
00016             print
00017         self.assertEqual(len(v), dim)
00018 
00019     def _validate_line(self, cell, dim):
00020         self.assertEqual(cell.no_space_dim(), 1)
00021         #self.assertEqual(cell.no_space_dim(), dim)
00022 
00023         self.assertEqual(cell.no_vertices(), 2)
00024         for i in range(2):
00025             self._validate_vertex(cell.vertex(i), dim)
00026 
00027     def _validate_triangle(self, cell, dim):
00028         self.assertEqual(cell.no_space_dim(), 2)
00029         #self.assertEqual(cell.no_space_dim(), dim)
00030 
00031         self.assertEqual(cell.no_vertices(), 3)
00032         for i in range(3):
00033             self._validate_vertex(cell.vertex(i), dim)
00034         for i in range(3):
00035             self._validate_line(cell.line(i), dim)
00036 
00037     def _validate_tetrahedron(self, cell, dim):
00038         self.assertEqual(cell.no_space_dim(), 3)
00039         #self.assertEqual(cell.no_space_dim(), dim)
00040 
00041         self.assertEqual(cell.no_vertices(), 4)
00042         for i in range(4):
00043             self._validate_vertex(cell.vertex(i), dim)
00044         for i in range(6):
00045             self._validate_line(cell.line(i), dim)
00046         for i in range(4):
00047             self._validate_triangle(cell.triangle(i), dim)
00048 
00049     def _validate_rectangle(self, cell, dim):
00050         self.assertEqual(cell.no_space_dim(), 2)
00051         #self.assertEqual(cell.no_space_dim(), dim)
00052 
00053         self.assertEqual(cell.no_vertices(), 4)
00054         for i in range(4):
00055             self._validate_vertex(cell.vertex(i), dim)
00056         for i in range(4):
00057             self._validate_line(cell.line(i), dim)
00058 
00059     def _validate_box(self, cell, dim):
00060         self.assertEqual(cell.no_space_dim(), 3)
00061         #self.assertEqual(cell.no_space_dim(), dim)
00062 
00063         self.assertEqual(cell.no_vertices(), 8)
00064         for i in range(6):
00065             self._validate_vertex(cell.vertex(i), dim)
00066         for i in range(12):
00067             self._validate_line(cell.line(i), dim)
00068         for i in range(6):
00069             self._validate_rectangle(cell.rectangle(i), dim)
00070 
00071     def test_reference_line_dimensions(self):
00072         d = 1
00073         SyFi.initSyFi(d)
00074         c = SyFi.ReferenceLine()
00075         self._validate_line(c, d)
00076 
00077     def test_reference_triangle_dimensions(self):
00078         d = 2
00079         SyFi.initSyFi(d)
00080         c = SyFi.ReferenceTriangle()
00081         self._validate_triangle(c, d)
00082 
00083     def test_reference_rectangle_dimensions(self):
00084         d = 2
00085         SyFi.initSyFi(d)
00086         c = SyFi.ReferenceRectangle()
00087         self._validate_rectangle(c, d)
00088 
00089     def test_reference_tetrahedron_dimensions(self):
00090         d = 3
00091         SyFi.initSyFi(d)
00092         c = SyFi.ReferenceTetrahedron()
00093         self._validate_tetrahedron(c, d)
00094 
00095     def test_reference_box_dimensions(self):
00096         d = 3
00097         SyFi.initSyFi(d)
00098         c = SyFi.ReferenceBox()
00099         self._validate_box(c, d)
00100 
00101     def test_spacetime_dimensions(self):
00102         l = SyFi.ReferenceLine()
00103         t = SyFi.ReferenceTriangle()
00104         sd = SyFi.SpaceTimeDomain(l, t)
00105         #self.assertEqual(TODO)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator