PETSc.Sys.Print('ExtensionMat built') band.initialu(initialu) PETSc.Sys.Print('Initial') nextt = 0.1 PETSc.Sys.Print('Begin to solve') t = 0 for t in sp.arange(0,1,dt): L.multAdd(gv,gv,wv) M.mult(wv,gv) if t > nextt: nextt += 0.1 PETSc.Sys.Print('time is {0}'.format(t)) mv = band.createExtensionMatForLoop(cp=points[vstart:vstart+vAssigned]) cv = mv.getVecLeft() mv.mult(gv,cv) cv = band.toZeroStatic(cv) if comm.rank == 0: cv = cv.getArray() exu = sp.exp(-t)*exactu ee = norm(cv-exu, sp.inf) error.append(ee) dx.append( band.dx ) PETSc.Sys.Print('==================================') if comm.rank == 0: print('maximal is {0}'.format(ee))
#surface = MeshWrapper('eight_refined.ply') except IOError: surface = MeshWrapper('cp/tests/data/eight.ply') #surface = MeshWrapper('cp/tests/data/eight_refined.ply') comm = MPI.COMM_WORLD band = Band(surface,comm,opt) la,lv,gv,wv = band.createGLVectors() v = band.getCoordinates() centers = band.BlockInd2CenterCarWithoutBand(band.gindBlockWBand.getArray()) dt = 0.1*band.dx**2 vv = sp.array([[0,0,0],[1,0,0],[-1,0,0],[0,1,0],[0,-1,0],[0,0,1],[0,0,-1]]) weights = sp.array([-6,1,1,1,1,1,1])*(dt/band.dx**2) L = band.createAnyMat(vv, weights, (7,3)) PETSc.Sys.Print('Laplacian') M = band.createExtensionMatForLoop() band.initialu(initialu) PETSc.Sys.Print('Initial') plot3d_total(v,gv) nextt = 0.01 PETSc.Sys.Print('Begin to solve.\n dt is {0}'.format(dt)) for t in sp.arange(0,0.2,dt): L.multAdd(gv,gv,wv) M.mult(wv,gv) if t > nextt: nextt += 0.01 PETSc.Sys.Print('time is {0}'.format(t)) PETSc.Sys.Print('End to solve.') v = surface.v
M = band.createExtensionMat() PETSc.Sys.Print('ExtensionMat built') band.initialu(initialu) PETSc.Sys.Print('Initial') nextt = 0.1 PETSc.Sys.Print('Begin to solve') t = 0 for t in sp.arange(0, 1, dt): L.multAdd(gv, gv, wv) M.mult(wv, gv) if t > nextt: nextt += 0.1 PETSc.Sys.Print('time is {0}'.format(t)) mv = band.createExtensionMatForLoop(cp=points[vstart:vstart + vAssigned]) cv = mv.getVecLeft() mv.mult(gv, cv) cv = band.toZeroStatic(cv) if comm.rank == 0: cv = cv.getArray() exu = sp.exp(-t) * exactu ee = norm(cv - exu, sp.inf) error.append(ee) dx.append(band.dx) PETSc.Sys.Print('==================================') if comm.rank == 0: print('maximal is {0}'.format(ee)) PETSc.Sys.Print('==================================') del band, v, mv, cv
opacity=0.5) comm = MPI.COMM_WORLD band = Band(surface, comm, opt) la, lv, gv, wv = band.createGLVectors() v = band.getCoordinates() centers = band.BlockInd2CenterCarWithoutBand( band.gindBlockWBand.getArray()) pl.points3d(centers[:, 0], centers[:, 1], centers[:, 2], mode='point') dt = 0.1 * band.dx**2 vv = sp.array([[0, 0, 0], [1, 0, 0], [-1, 0, 0], [0, 1, 0], [0, -1, 0], [0, 0, 1], [0, 0, -1]]) weights = sp.array([-6, 1, 1, 1, 1, 1, 1]) * (dt / band.dx**2) L = band.createAnyMat(vv, weights, (7, 3)) PETSc.Sys.Print('Laplacian') M = band.createExtensionMatForLoop() band.initialu(initialu) PETSc.Sys.Print('Initial') plot3d_total(v, gv) nextt = 0.05 PETSc.Sys.Print('Begin to solve.\n dt is {0}'.format(dt)) for t in sp.arange(0, 1, dt): L.multAdd(gv, gv, wv) M.mult(wv, gv) if t > nextt: nextt += 0.05 PETSc.Sys.Print('time is {0}'.format(t)) PETSc.Sys.Print('End to solve.')