コード例 #1
0
ファイル: testwavefront.py プロジェクト: tbetcke/PyPWDG
 def testRaytraceMesh(self):
     c = 0.5
     for (Nmesh, Nrt) in [(10,10), (20,4), (4, 20)]:
         mesh = ptum.regularsquaremesh(Nmesh, "BDY")
         x0 = np.vstack((np.linspace(-0.2,1.2,Nrt), np.ones(Nrt)*(-0.2))).transpose()
         p0 = np.vstack((np.zeros(Nrt), np.ones(Nrt))).transpose()
         slowness = lambda x: np.ones(len(x))/c
         gradslowness = lambda x: np.zeros_like(x)
         
         wfs, fidxs = prw.wavefront(x0, p0, slowness, gradslowness, 1/(c * Nrt), 1.4 / c, 1/(c * Nrt))
         phases = prw.nodesToPhases(wfs, fidxs, mesh, ["BDY"])
         self.assertEqual(len(phases), (Nmesh+1)**2)
         for vp in phases:
             self.assertGreaterEqual(len(vp), 1)
             for p in vp:
                 np.testing.assert_array_almost_equal(p, [0,1/c])
コード例 #2
0
ファイル: wavefrontbasis.py プロジェクト: tbetcke/PyPWDG
prodpw = pcb.ProductBasisRule(pw, poly)

# Product basis:
#basisrule = pcb.ProductBasisRule(pcb.planeWaveBases(2,k,npw), pcbr.ReferenceBasisRule(pcbr.Dubiner(1)))

#basisrule=pcb.ProductBasisRule(pw,pcbr.ReferenceBasisRule(pcbr.Dubiner(0)))
#basisrule = pcbred.SVDBasisReduceRule(puq.trianglequadrature(quadpoints), basisrule)


#mesh = pmm.gmshMesh('../../examples/2D/square.msh',dim=2)
for n in [16]:
    bdytag = "BDY"
    volentity = 5 # 6
    mesh = ptum.regularrectmesh(bounds[0], bounds[1], n, n)
    print mesh.nelements
    vtods = prw.nodesToPhases(wavefronts, forwardidxs, mesh, [2])
    rt = prb.RaytracedBasisRule(vtods)
    prodrt = pcb.ProductBasisRule(rt, poly)
    basisrule = prodrt
#    basisrule = pcbred.SVDBasisReduceRule(puq.trianglequadrature(quadpoints), basisrule)
    entityton = {volentity:slow}

    bnddata = {1:zerobd,2:impbd,3:zerobd,4:zerobd}
    problem = psp.VariableNProblem(entityton, mesh, k, bnddata)
#    problem = psp.Problem(mesh, k, bnddata)
    
    alpha = pdeg ^2 * n  / k
    beta = k / (pdeg * n) 
    
    computation = psc.Computation(problem, basisrule, pcp.HelmholtzSystem, quadpoints, alpha = alpha, beta = beta)
    solution = computation.solution(psc.DirectSolver().solve, dovolumes=True)