コード例 #1
0
 def test_Brick_Function_gradient_Simetric(
         self):  #expanded and non-expanded
     ranks = getMPISizeWorld()
     for expanded in [True, False]:
         for order in range(2, 11):
             dom = Brick(order, 3, 3 * ranks, 3, 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,
                 8.000000000 - 4.000000000j
             ],
                            [
                                4.000000000 - 2.000000000j,
                                8.000000000 - 4.000000000j,
                                12.000000000 - 6.000000000j
                            ],
                            [
                                8.000000000 - 4.000000000j,
                                12.000000000 - 6.000000000j,
                                16.000000000 - 8.000000000j
                            ]]
             sample = Data(sample_data, Function(dom), True)
             sample[0, 0] = 0.000000000 + 0.000000000j
             sample[0, 1] = 4.000000000 - 2.000000000j
             sample[0, 2] = 8.000000000 - 4.000000000j
             sample[1, 0] = 4.000000000 - 2.000000000j
             sample[1, 1] = 8.000000000 - 4.000000000j
             sample[1, 2] = 12.000000000 - 6.000000000j
             sample[2, 0] = 8.000000000 - 4.000000000j
             sample[2, 1] = 12.000000000 - 6.000000000j
             sample[2, 2] = 16.000000000 - 8.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)))