Exemple #1
0
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
Exemple #2
0
        print gmresits
        #sol = computation.solution(op, psi.BrutalSolver(np.complex))       

if __name__=="__main__":
#    search()
#    exit()
    k = 5
    n = 4
    g = pcb.FourierHankel([-1,-1], [0], k)
    bdytag = "BDY"
    bnddata={bdytag:pcbd.generic_boundary_data([-1j*k,1],[-1j*k,1], g)}
    
    bounds=np.array([[0,1],[0,1]],dtype='d')
    npoints=np.array([200,200])
#    mesh = tum.regularsquaremesh(n, bdytag)    
    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)
    
#    direction=np.array([[1.0,1.0]])/math.sqrt(2)
#    g = pcb.PlaneWaves(direction, k)
#    
#    bnddata={11:pcbd.zero_dirichlet(),
#             10:pcbd.generic_boundary_data([-1j*k,1],[-1j*k,1],g=g)}
#    
#    bounds=np.array([[-2,2],[-2,2]],dtype='d')
#    npoints=np.array([200,200])
#    with puf.pushd('../../examples/2D'):
#        mesh = pmm.gmshMesh('squarescatt.msh',dim=2)