本文整理汇总了Python中mesh.Mesh.discretize方法的典型用法代码示例。如果您正苦于以下问题:Python Mesh.discretize方法的具体用法?Python Mesh.discretize怎么用?Python Mesh.discretize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mesh.Mesh
的用法示例。
在下文中一共展示了Mesh.discretize方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1:
# 需要导入模块: from mesh import Mesh [as 别名]
# 或者: from mesh.Mesh import discretize [as 别名]
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)
示例2:
# 需要导入模块: from mesh import Mesh [as 别名]
# 或者: from mesh.Mesh import discretize [as 别名]
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"
示例3: plotBndFun
# 需要导入模块: from mesh import Mesh [as 别名]
# 或者: from mesh.Mesh import discretize [as 别名]
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]))