コード例 #1
0
ファイル: generalrobin.py プロジェクト: tbetcke/PyPWDG
def search():
    k = 2
    g = pcb.FourierHankel([-1,-1], [0], k)
    bdytag = "BDY"
    bnddata={bdytag:pcbd.dirichlet(g)}
    
    bounds=np.array([[0,1],[0,1]],dtype='d')
    npoints=np.array([200,200])
    gmresits = []
    params = []
    conds = []

    n = 6
    meshinfo = tum.regularsquaremeshinfo(n, bdytag)
    topology = pmm.Topology(meshinfo)
    partition = pmm.BespokePartition(meshinfo, topology, lambda n: np.arange(meshinfo.nelements).reshape(n, -1))    
    mesh = pmm.MeshView(meshinfo, topology, partition)
    
    mesh = pmo.overlappingPartitions(mesh)
    problem = psp.Problem(mesh,k,bnddata)
    
    npw = 7
    basisrule = pcb.planeWaveBases(2,k,npw)
    
    basisrule = pcbr.ReferenceBasisRule(pcbr.Dubiner(0))
    nquad = 4
           
        #    mesh = pmo.overlappingPartitions(pmo.overlappingPartitions(mesh))
            
           
        #    problem = psp.Problem(mesh, k, bnddata)
    dovolumes = True
           
    compinfo = psc.ComputationInfo(problem, basisrule, nquad)
    computation = psc.Computation(compinfo, pcp.HelmholtzSystem)
    sold = computation.solution(psc.DirectOperator(), psc.DirectSolver(), dovolumes=dovolumes)
    pom.output2dsoln(bounds, sold, npoints, show = False)
    for x in np.arange(-10,10,2):#, 1E-6, 1]:# 1j, -0.1, -0.1j]:
        for y in np.arange(-10,10,2):
            q = x + 1j * y
            perturbation = GeneralRobinPerturbation(compinfo, q)
        
            op = psd.GeneralSchwarzOperator(PerturbedSchwarzWorker(perturbation, mesh))
            callback = psi.ItCounter(100)
            solver = psi.GMRESSolver('ctor', callback)
            sol = computation.solution(op, solver, dovolumes=dovolumes)
            nn = len(op.rhs())
            M = np.hstack([op.multiply(xx).reshape(-1,1) for xx in np.eye(nn)])
            conds.append(np.linalg.cond(M))            
            params.append(q)
            gmresits.append(solver.callback.n)
        print conds
        print params
        print gmresits
コード例 #2
0
ファイル: generalrobin.py プロジェクト: tbetcke/PyPWDG
#    npoints=np.array([200,200])
#    with puf.pushd('../../examples/2D'):
#        mesh = pmm.gmshMesh('squarescatt.msh',dim=2)


    # goes wrong for n=7 with npw = 6 & 7.  
    npw = 5
    basisrule = pcb.planeWaveBases(2,k,npw)
    dovolumes=False
    
#    basisrule = pcbr.ReferenceBasisRule(pcbr.Dubiner(0))
#    dovolumes = True
    nquad = 7
   
#    mesh = pmo.overlappingPartitions(pmo.overlappingPartitions(mesh))
    mesh = pmo.overlappingPartitions(mesh)
    
   
    problem = psp.Problem(mesh, k, bnddata)
    
    compinfo = psc.ComputationInfo(problem, basisrule, nquad)
    computation = psc.Computation(compinfo, pcp.HelmholtzSystem)
    sold = computation.solution(psc.DirectOperator(), psc.DirectSolver(), dovolumes=dovolumes)
    print "direct solution", sold.x
    pom.output2dsoln(bounds, sold, npoints, show = False)
    for p in [1]:#, 1, 1j, -0.1, -0.1j]:
        perturbation = GeneralRobinPerturbation(compinfo, p)
    
        w = PerturbedSchwarzWorker(perturbation, mesh)
        op = psd.GeneralSchwarzOperator(w)
#        op = psd.SchwarzOperator(mesh)