Example #1
0
 def test_Rectangle_Function_gradient_Simetric(
         self):  #expanded and non-expanded
     ranks = getMPISizeWorld()
     for expanded in [True, False]:
         for order in range(2, 11):
             dom = Rectangle(order, 3, 3 * ranks, d1=ranks)
             x = ContinuousFunction(dom).getX()
             m = -2 * 1j + 4
             b = 3 + 8 * 1j
             f = Vector(0., Solution(dom))
             sample_data = [[
                 0.000000000 + 0.000000000j, 4.000000000 - 2.000000000j
             ], [4.000000000 - 2.000000000j, 8.000000000 - 4.000000000j]]
             sample = Data(sample_data, Function(dom), True)
             sample[0, 0] = 0.000000000 + 0.000000000j
             sample[0, 1] = 4.000000000 - 2.000000000j
             sample[1, 0] = 4.000000000 - 2.000000000j
             sample[1, 1] = 8.000000000 - 4.000000000j
             for i in range(dom.getDim()):
                 for j in range(dom.getDim()):
                     f[i] += m * (i + j) * x[j] + b - i * j
             g = grad(f)
             self.assertLess(
                 Lsup(g - sample), 1e-9,
                 "single component failure, order %d%s, %e >= 1e-10" %
                 (order,
                  (" expanded" if expanded else ""), Lsup(g - sample)))