SyFi
0.3
|
Inherits TempDirTestBase.
Public Member Functions | |
def | __init__ |
def | setUp |
def | tearDown |
def | xtest_setup |
def | assertAlmostEqualRelative |
def | xtest_coeff_with_element_sweep |
def | xtest_algebra |
def | xtest_trig |
def | xtest_tensor_algebra |
def | xtest_index_notation |
Private Member Functions | |
def | _test_piecewise_constant_assembly_on_cell_single |
def | _test_piecewise_constant_assembly_on_cell_sweep |
def | _test_piecewise_constant_assembly_on_cell |
Definition at line 21 of file test_jit_functionals.py.
def test_sfc.test_jit_functionals.TestJitFunctionals.__init__ | ( | self, | |
args, | |||
kwargs | |||
) |
Definition at line 22 of file test_jit_functionals.py.
def test_sfc.test_jit_functionals.TestJitFunctionals._test_piecewise_constant_assembly_on_cell | ( | self, | |
function, | |||
vector = False |
|||
) | [private] |
Definition at line 84 of file test_jit_functionals.py.
References test_sfc.test_jit_functionals.TestJitFunctionals._test_piecewise_constant_assembly_on_cell_single().
Referenced by test_sfc.test_jit_functionals.TestJitFunctionals.xtest_algebra(), test_sfc.test_jit_functionals.TestJitFunctionals.xtest_index_notation(), test_sfc.test_jit_functionals.TestJitFunctionals.xtest_tensor_algebra(), and test_sfc.test_jit_functionals.TestJitFunctionals.xtest_trig().
00084 00085 def _test_piecewise_constant_assembly_on_cell(self, function, vector=False): 00086 self._test_piecewise_constant_assembly_on_cell_single(function, tetrahedron, "CG", 1, vector)
def test_sfc.test_jit_functionals.TestJitFunctionals._test_piecewise_constant_assembly_on_cell_single | ( | self, | |
function, | |||
cell, | |||
family, | |||
degree, | |||
vector | |||
) | [private] |
Definition at line 45 of file test_jit_functionals.py.
References test_sfc::cell_assembly.assemble_on_cell(), test_sfc.test_jit_functionals.TestJitFunctionals.assertAlmostEqualRelative(), and test_sfc.test_tempdir_base.TempDirTestBase.options.
Referenced by test_sfc.test_jit_functionals.TestJitFunctionals._test_piecewise_constant_assembly_on_cell(), and test_sfc.test_jit_functionals.TestJitFunctionals._test_piecewise_constant_assembly_on_cell_sweep().
00045 00046 def _test_piecewise_constant_assembly_on_cell_single(self, function, cell, family, degree, vector): 00047 eps = 1e-7 00048 detG = cell2volume[cell.domain()] 00049 00050 if vector: 00051 element = VectorElement(family, cell, degree) 00052 else: 00053 element = FiniteElement(family, cell, degree) 00054 00055 u = Coefficient(element) 00056 M = function(u)*dx 00057 00058 if vector: 00059 u = (3.14, 4.56, 7.89)[:element.value_shape()[0]] 00060 coeffs = [u] 00061 expected = float(function(as_vector(u)))*detG 00062 else: 00063 u = 3.14 00064 coeffs = [u] 00065 expected = float(function(u))*detG 00066 00067 form, module, formdata, prefix = sfc.jit(M, parameters=self.options) 00068 00069 if cell in all_simplices: # Quads not supported by dolfin assembler 00070 assembled = assemble_on_cell(form, cell.domain(), coeffs=coeffs, elements=[]) 00071 self.assertAlmostEqualRelative(assembled, expected, eps)
def test_sfc.test_jit_functionals.TestJitFunctionals._test_piecewise_constant_assembly_on_cell_sweep | ( | self, | |
function, | |||
vector | |||
) | [private] |
Definition at line 72 of file test_jit_functionals.py.
References test_sfc.test_jit_functionals.TestJitFunctionals._test_piecewise_constant_assembly_on_cell_single().
Referenced by test_sfc.test_jit_functionals.TestJitFunctionals.xtest_coeff_with_element_sweep().
00072 00073 def _test_piecewise_constant_assembly_on_cell_sweep(self, function, vector): 00074 families = ("CG", "DG", "R") 00075 degrees = { "CG": (1,2), 00076 "DG": (0,3), 00077 "R": (None,), 00078 } 00079 for cell in all_cells: 00080 for family in families: 00081 for degree in degrees[family]: 00082 self._test_piecewise_constant_assembly_on_cell_single(function, cell, 00083 family, degree, vector)
def test_sfc.test_jit_functionals.TestJitFunctionals.assertAlmostEqualRelative | ( | self, | |
val1, | |||
val2, | |||
eps | |||
) |
Definition at line 37 of file test_jit_functionals.py.
Referenced by test_sfc.test_jit_functionals.TestJitFunctionals._test_piecewise_constant_assembly_on_cell_single().
00037 00038 def assertAlmostEqualRelative(self, val1, val2, eps): 00039 reldiff = ((val1 - val2)**2 / max(val1**2, val2**2))**0.5 00040 if not reldiff < eps: 00041 print "Values are not almost equal:" 00042 print "val1:", val1 00043 print "val2:", val2 00044 self.assertLess(reldiff, eps)
Definition at line 25 of file test_jit_functionals.py.
References test_sfc.test_tempdir_base.TempDirTestBase.options.
Definition at line 30 of file test_jit_functionals.py.
Definition at line 91 of file test_jit_functionals.py.
References test_sfc.test_jit_functionals.TestJitFunctionals._test_piecewise_constant_assembly_on_cell().
00091 00092 def xtest_algebra(self): # FIXME: Failing! 00093 self._test_piecewise_constant_assembly_on_cell(lambda u: (u+2)**2*(u-1.1)**1.5/7.2)
Definition at line 87 of file test_jit_functionals.py.
References test_sfc.test_jit_functionals.TestJitFunctionals._test_piecewise_constant_assembly_on_cell_sweep().
00087 00088 def xtest_coeff_with_element_sweep(self): # This is too slow, too many jits 00089 self._test_piecewise_constant_assembly_on_cell_sweep(lambda u: u, False) 00090 self._test_piecewise_constant_assembly_on_cell_sweep(lambda u: u[0], True)
Definition at line 118 of file test_jit_functionals.py.
References test_sfc.test_jit_functionals.TestJitFunctionals._test_piecewise_constant_assembly_on_cell(), and run_tests.f.
00118 00119 def xtest_index_notation(self): # FIXME: Failing! 00120 i,j = indices(2) 00121 00122 def f(v): 00123 return v[i]*v[i] 00124 self._test_piecewise_constant_assembly_on_cell(f, True) 00125 00126 def f(v): 00127 return outer(v,v)[i,j]*(2*v)[i]*(v/4.5)[j] 00128 self._test_piecewise_constant_assembly_on_cell(f, True) 00129
Definition at line 33 of file test_jit_functionals.py.
00033 00034 def xtest_setup(self): 00035 "Just see that setUp and tearDown works." 00036 self.assertTrue("Did not crash in setUp.")
Definition at line 100 of file test_jit_functionals.py.
References test_sfc.test_jit_functionals.TestJitFunctionals._test_piecewise_constant_assembly_on_cell(), run_tests.f, SyFi.inner(), and test_syfi::debug.v.
00100 00101 def xtest_tensor_algebra(self): # FIXME: Failing! 00102 def v(u): 00103 return as_vector((u, 2*u)) 00104 def w(u): 00105 return as_matrix(((u, 2*u, u+3, u**2), 00106 (7, ln(u), u/5., exp(u)),)) 00107 00108 def f(u): 00109 return dot(v(u),v(u)) 00110 self._test_piecewise_constant_assembly_on_cell(f) 00111 def f(u): 00112 return inner(w(u),w(u)) 00113 self._test_piecewise_constant_assembly_on_cell(f) 00114 def f(u): 00115 z = dot(w(u).T, v(u)) 00116 return dot(z,z) 00117 self._test_piecewise_constant_assembly_on_cell(f)
Definition at line 94 of file test_jit_functionals.py.
References test_sfc.test_jit_functionals.TestJitFunctionals._test_piecewise_constant_assembly_on_cell().
00094 00095 def xtest_trig(self): # FIXME: Failing! 00096 self._test_piecewise_constant_assembly_on_cell(lambda u: (exp(3*u)*ln(u) + 00097 acos(sin(2*u)) + 00098 asin(cos(2*u)) + 00099 atan(tan(2*u))))