Esempio n. 1
0
    def test_polation_interoperator(self):
        pde = CosCosData()
        maxit = 4
        errorType = ['$|u_I - u_h|_{max}$']
        Maxerror = np.zeros((len(errorType), maxit), dtype=np.float)
        NE = np.zeros(maxit, )

        for i in range(maxit):
            start3 = time.time()
            mesh = self.mesh
            isBDEdge = mesh.ds.boundary_edge_flag()
            NE[i] = mesh.number_of_edges()
            h = mesh.hx
            bc = mesh.entity_barycenter('cell')
            ec = mesh.entity_barycenter('edge')

            uI = mesh.polation_interoperator(pde.solution(bc))
            uh = pde.solution(ec)
            Maxerror[0, i] = np.sqrt(np.sum(h**2 * (uh - uI)**2))
            #            Maxerror[0, i] = max(abs(uh - uI))
            end3 = time.time()
            print('time of %d iteration' % i, end3 - start3)

            if i < maxit - 1:
                mesh.uniform_refine()

        showmultirate(plt, 0, NE, Maxerror, errorType)
        print('Maxerror', Maxerror)
        plt.show()
Esempio n. 2
0
 def test_cbar(self):
     dt = 0
     start4 = time.time()
     mesh = self.mesh
     pde = CosCosData()
     bc = mesh.entity_barycenter('cell')
     ch = pde.solution(bc)
     NC = mesh.number_of_cells()
     cellidx = np.arange(NC)
     xbar = bc - dt
     cbar = mesh.cbar_interpolation(ch, cellidx, xbar)
     end4 = time.time()
     print('test_cbar time', end4 - start4)
     print('cbar', sum(cbar - ch))