SyFi
0.3
|
Public Member Functions | |
def | assertAlmostEqualNumpy |
def | assertAssembledAlmostEqual |
def | test_constant_interval |
def | test_constant_triangle |
def | test_constant_tetrahedron |
def | test_volume_interval |
def | test_volume_triangle |
def | test_volume_tetrahedron |
def | xtest_volume_quadrilateral |
def | xtest_volume_hexahedron |
def | test_coordinates_interval |
def | test_coordinates_triangle |
def | test_coordinates_tetrahedron |
def | xtest_coordinates_quadrilateral |
def | xtest_coordinates_hexahedron |
Private Member Functions | |
def | _test_constant |
def | _test_volume |
def | _test_coordinates |
Definition at line 113 of file test_geometry_code.py.
def test_sfc.test_geometry_code.GeometryTestMixin._test_constant | ( | self, | |
cell | |||
) | [private] |
Test that the integral of 1.0 over a unit cell equals the length/area/volume of the unit cell.
Definition at line 132 of file test_geometry_code.py.
References test_sfc.test_geometry_code.GeometryTestMixin.assertAssembledAlmostEqual(), and test_sfc.test_form_argument_code.FormArgumentTestMixin.assertAssembledAlmostEqual().
Referenced by test_sfc.test_geometry_code.GeometryTestMixin.test_constant_interval(), test_sfc.test_geometry_code.GeometryTestMixin.test_constant_tetrahedron(), and test_sfc.test_geometry_code.GeometryTestMixin.test_constant_triangle().
00132 00133 def _test_constant(self, cell): 00134 """Test that the integral of 1.0 over a unit cell 00135 equals the length/area/volume of the unit cell.""" 00136 D = cell2volume[cell] 00137 c = Constant(cell) 00138 a = c*dx 00139 coeffs = [1.2] 00140 expected = 1.2 * D 00141 self.assertAssembledAlmostEqual(a, cell, coeffs, expected)
def test_sfc.test_geometry_code.GeometryTestMixin._test_coordinates | ( | self, | |
cell, | |||
expected | |||
) | [private] |
Definition at line 169 of file test_geometry_code.py.
References test_sfc.test_geometry_code.GeometryTestMixin.assertAssembledAlmostEqual(), and test_sfc.test_form_argument_code.FormArgumentTestMixin.assertAssembledAlmostEqual().
Referenced by test_sfc.test_geometry_code.GeometryTestMixin.test_coordinates_interval(), test_sfc.test_geometry_code.GeometryTestMixin.test_coordinates_tetrahedron(), test_sfc.test_geometry_code.GeometryTestMixin.test_coordinates_triangle(), test_sfc.test_geometry_code.GeometryTestMixin.xtest_coordinates_hexahedron(), and test_sfc.test_geometry_code.GeometryTestMixin.xtest_coordinates_quadrilateral().
00169 00170 def _test_coordinates(self, cell, expected): 00171 x = cell.x 00172 if cell.d == 1: 00173 a = (x**2)*dx 00174 if cell.d == 2: 00175 a = (x[0]**2+x[1]**2)*dx 00176 if cell.d == 3: 00177 a = (x[0]**2+x[1]**2+x[2]**2)*dx 00178 coeffs = [] 00179 self.assertAssembledAlmostEqual(a, cell, coeffs, expected)
def test_sfc.test_geometry_code.GeometryTestMixin._test_volume | ( | self, | |
cell | |||
) | [private] |
Definition at line 149 of file test_geometry_code.py.
References test_sfc.test_geometry_code.GeometryTestMixin.assertAssembledAlmostEqual(), and test_sfc.test_form_argument_code.FormArgumentTestMixin.assertAssembledAlmostEqual().
Referenced by test_sfc.test_geometry_code.GeometryTestMixin.test_volume_interval(), test_sfc.test_geometry_code.GeometryTestMixin.test_volume_tetrahedron(), test_sfc.test_geometry_code.GeometryTestMixin.test_volume_triangle(), test_sfc.test_geometry_code.GeometryTestMixin.xtest_volume_hexahedron(), and test_sfc.test_geometry_code.GeometryTestMixin.xtest_volume_quadrilateral().
00149 00150 def _test_volume(self, cell): 00151 D = cell2volume[cell] 00152 c = cell.volume 00153 a = c*dx 00154 coeffs = [] 00155 expected = D * D 00156 self.assertAssembledAlmostEqual(a, cell, coeffs, expected)
def test_sfc.test_geometry_code.GeometryTestMixin.assertAlmostEqualNumpy | ( | self, | |
actual, | |||
expected, | |||
eps = 1e-8 |
|||
) |
Definition at line 115 of file test_geometry_code.py.
Referenced by test_sfc.test_geometry_code.GeometryTestMixin.assertAssembledAlmostEqual().
00115 00116 def assertAlmostEqualNumpy(self, actual, expected, eps=1e-8): 00117 self.assertEqual(actual.shape, expected.shape) 00118 mdiff = expected - actual 00119 vdiff = mdiff.reshape((product(mdiff.shape),)) 00120 sdiff = numpy.dot(vdiff,vdiff) 00121 self.assertAlmostEqual(sdiff, 0.0, eps)
def test_sfc.test_geometry_code.GeometryTestMixin.assertAssembledAlmostEqual | ( | self, | |
ufl_form, | |||
ufl_cell, | |||
coeffs, | |||
expected | |||
) |
Test that the integral of 1.0 over a unit cell equals the length/area/volume of the unit cell.
Definition at line 122 of file test_geometry_code.py.
References test_sfc::cell_assembly.assemble_on_cell(), test_sfc.test_geometry_code.GeometryTestMixin.assertAlmostEqualNumpy(), test_sfc.test_form_argument_code.FormArgumentTestMixin.assertAlmostEqualNumpy(), and test_sfc.test_tempdir_base.TempDirTestBase.options.
Referenced by test_sfc.test_geometry_code.GeometryTestMixin._test_constant(), test_sfc.test_geometry_code.GeometryTestMixin._test_coordinates(), and test_sfc.test_geometry_code.GeometryTestMixin._test_volume().
00122 00123 def assertAssembledAlmostEqual(self, ufl_form, ufl_cell, coeffs, expected): 00124 """Test that the integral of 1.0 over a unit cell 00125 equals the length/area/volume of the unit cell.""" 00126 ufc_form, module, formdata, prefix = sfc.jit(ufl_form, parameters=self.options) 00127 assembled = assemble_on_cell(ufc_form, ufl_cell, coeffs=coeffs) 00128 if isinstance(assembled, float): 00129 self.assertAlmostEqual(assembled, expected) 00130 else: 00131 self.assertAlmostEqualNumpy(assembled, expected)
Definition at line 142 of file test_geometry_code.py.
References test_sfc.test_geometry_code.GeometryTestMixin._test_constant(), and test_sfc.test_form_argument_code.FormArgumentTestMixin._test_constant().
00142 00143 def test_constant_interval(self): self._test_constant(ufl.interval)
Definition at line 146 of file test_geometry_code.py.
References test_sfc.test_geometry_code.GeometryTestMixin._test_constant(), and test_sfc.test_form_argument_code.FormArgumentTestMixin._test_constant().
00146 00147 def test_constant_tetrahedron(self): 00148 self._test_constant(ufl.tetrahedron)
Definition at line 144 of file test_geometry_code.py.
References test_sfc.test_geometry_code.GeometryTestMixin._test_constant(), and test_sfc.test_form_argument_code.FormArgumentTestMixin._test_constant().
00144 00145 def test_constant_triangle(self): self._test_constant(ufl.triangle)
Definition at line 180 of file test_geometry_code.py.
References test_sfc.test_geometry_code.GeometryTestMixin._test_coordinates().
00180 00181 def test_coordinates_interval(self): self._test_coordinates(ufl.interval, 1.0/3.0)
Definition at line 184 of file test_geometry_code.py.
References test_sfc.test_geometry_code.GeometryTestMixin._test_coordinates().
00184 00185 def test_coordinates_tetrahedron(self): 00186 self._test_coordinates(ufl.tetrahedron, 1.0/20.0)
Definition at line 182 of file test_geometry_code.py.
References test_sfc.test_geometry_code.GeometryTestMixin._test_coordinates().
00182 00183 def test_coordinates_triangle(self): self._test_coordinates(ufl.triangle, 1.0/6.0)
Definition at line 157 of file test_geometry_code.py.
References test_sfc.test_geometry_code.GeometryTestMixin._test_volume().
00157 00158 def test_volume_interval(self): self._test_volume(ufl.interval)
Definition at line 161 of file test_geometry_code.py.
References test_sfc.test_geometry_code.GeometryTestMixin._test_volume().
00161 00162 def test_volume_tetrahedron(self): 00163 self._test_volume(ufl.tetrahedron)
Definition at line 159 of file test_geometry_code.py.
References test_sfc.test_geometry_code.GeometryTestMixin._test_volume().
00159 00160 def test_volume_triangle(self): self._test_volume(ufl.triangle)
Definition at line 189 of file test_geometry_code.py.
References test_sfc.test_geometry_code.GeometryTestMixin._test_coordinates().
00189 00190 def xtest_coordinates_hexahedron(self): # TODO: Not supported by dolfin yet 00191 self._test_coordinates(ufl.hexahedron, 3.0/3.0) # FIXME
Definition at line 187 of file test_geometry_code.py.
References test_sfc.test_geometry_code.GeometryTestMixin._test_coordinates().
00187 00188 def xtest_coordinates_quadrilateral(self): # TODO: Not supported by dolfin yet self._test_coordinates(ufl.quadrilateral, 2.0/3.0) # FIXME
Definition at line 166 of file test_geometry_code.py.
References test_sfc.test_geometry_code.GeometryTestMixin._test_volume().
00166 00167 def xtest_volume_hexahedron(self): # TODO: Not supported by dolfin yet 00168 self._test_volume(ufl.hexahedron)
Definition at line 164 of file test_geometry_code.py.
References test_sfc.test_geometry_code.GeometryTestMixin._test_volume().
00164 00165 def xtest_volume_quadrilateral(self): # TODO: Not supported by dolfin yet self._test_volume(ufl.quadrilateral)