def calcPoissonError (solname, outputdir, exactsol): # get aproximated solution at each node sol = Solution(solname, outdir=outputdir) uh = sol.getPhie()[0,:] # compute exact solution at each node ue = np.zeros((np.shape(uh)[0]),dtype='float32') # exact u lM = sol.getLumpedMassMatrixE() # lumped Mass mesh = sol.getNodes() X = mesh[:,0] Y = mesh[:,1] Z = mesh[:,2] ue = evalExactSolution(exactsol, X, Y, Z) # compute nodal error err = ue - uh # compute the L2 norm of the error normeu = sol.calcL2NormError(err, lM) return normeu
def viewLaplaceSolution (solname): lasol = Solution(solname) lphie = lasol.getPhie() # no time steps lphie = lphie[0,:] peshp = np.shape(lphie)[0] # view structured square mesh only numNodesX = int( sqrt(peshp) ) numNodesY = int( sqrt(peshp) ) # reshape for visualization phie = np.reshape(lphie, (numNodesX,numNodesY)) ax = subplot(111) im = imshow(phie,cmap=cm.jet) im.set_interpolation('bilinear') title('Solution of the Laplace problem') colorbar() show()
E2t = np.zeros(m) E2q = np.zeros(m) E2i = np.zeros(m) EM = np.zeros(m) DOF = np.zeros(m) # reference solutions triRef = Solution('/data/sim/simulacao_3/tri_10um/tri_10um') quaRef = Solution('/data/sim/simulacao_3/qua_10um/qua_10um') quaisoRef = Solution('/data/sim/simulacao_3/qua_iso_10um/qua_iso_10um') # convergence for triangle for t in xrange(len(time)): for i in xrange(m): solname = os.path.join(dataPrefix + tr_name[i], tr_name[i]) triSol = Solution(solname) E2t[i] = triSol.getL2NormError(triRef, time[t]) DOF[i] = triSol.getNumberOfNodes() print 'Tr ', E2t # convergence for quadrangle (hybrid approach) for t in xrange(len(time)): for i in xrange(m): solname = os.path.join(dataPrefix + qd_name[i], qd_name[i]) quaSol = Solution(solname) E2q[i] = quaSol.getL2NormError(quaRef, time[t]) DOF[i] = quaSol.getNumberOfNodes() print 'Qd ', E2q