if __name__ == "__main__": from bases import ElementToBasis,Legendre from segments import Line,Arc from quadrules import GaussQuadrature from kernels import Identity,AcousticDoubleLayer from mesh import Domain,Mesh from assembly import assembleIdentity, assembleMatrix, projRhs, assembleElement k=10 circle=Arc(0,0,0,2*numpy.pi,.5) circle2=Arc(2,0,0,2*numpy.pi,.5) d=Domain([circle]) d2=Domain([circle2]) mesh=Mesh([d]) mesh.discretize(3) quadrule=GaussQuadrature(5,3,0.15) mToB=Legendre.legendreBasis(mesh,2) kernel=AcousticDoubleLayer(k) matrix=assembleMatrix(mToB,kernel,quadRule=quadrule) identity=assembleIdentity(mToB,quadrule) rhs=projRhs(mToB,[lambda t,x,normals: -numpy.exp(1j*k*x[1])],quadrule) coeffs=numpy.linalg.solve(.5*identity+matrix,rhs) gx,gy=numpy.mgrid[-2:4:200j,-2:2:200j] points=numpy.array([gx.ravel(),gy.ravel()]) res=evaluate(points,mToB,kernel,quadrule,coeffs)
return vec if __name__ == "__main__": from bases import ElementToBasis,Legendre from segments import Line,Arc from quadrules import GaussQuadrature from kernels import Identity,AcousticDoubleLayer, AcousticSingleLayer from mesh import Domain,Mesh circle=Arc(0,0,0,2*numpy.pi,1) d=Domain([circle]) mesh=Mesh([d]) mesh.discretize(100) quadrule=GaussQuadrature(4,2,0.15) mToB=Legendre.legendreBasis(mesh,0) kernel=AcousticSingleLayer(1) matrix=assembleMatrix(mToB,kernel,quadRule=quadrule) identity=assembleIdentity(mToB,quadrule) res=projRhs(mToB,[lambda t,x,normals: numpy.sin(x[0])],quadrule) #fig=plt.plot(numpy.abs(numpy.diag(identity))) print "Finished"
from bases import ElementToBasis,Legendre,NodalLin from segments import Line,Arc from quadrules import GaussQuadrature from kernels import Identity,AcousticDoubleLayer from mesh import Domain,Mesh from assembly import Assembly, nodalProjector from evaluation import Evaluator k=10 circle=Arc(0,0,0,2*numpy.pi,.5) circle2=Arc(2,0,0,2*numpy.pi,.5) d=Domain([circle]) d2=Domain([circle2]) mesh=Mesh([d,d2]) mesh.discretize(50) quadrule=GaussQuadrature(5,3,0.15) #mToB=Legendre.legendreBasis(mesh,0) mToB=NodalLin.nodalLinBasis(mesh) kernel=AcousticDoubleLayer(k) assembly=Assembly(mToB,quadrule) mKernel=assembly.getKernel(kernel) mIdentity=assembly.getIdentity() op=mIdentity+2*mKernel rhs=assembly.projFun([lambda t,x,normals: -numpy.exp(1j*k*x[0])]) coeffs=numpy.linalg.solve(.5*mIdentity+mKernel,rhs) plotBndFun(mToB,coeffs[:,0]) ev=Evaluator(mToB,kernel,quadrule) v=Visualizer(ev,[-1.5,3.5,-1,3],100,100,incWave=lambda x: numpy.exp(1j*k*x[0]))