Example #1
0
def createproblem(k, direction=array([[1,1]])/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)}
    with(puf.pushd("../../examples/2D")):
        mesh = pmm.gmshMesh('squarescatt.msh',dim=2)
    return psp.Problem(mesh, k, bnddata)
Example #2
0
import pypwdg.core.bases as pcb
import pypwdg.mesh.mesh as pmm
import pypwdg.core.boundary_data as pcbd
import pypwdg.adaptivity.adaptivity2 as paa
import pypwdg.core.physics as pcp
import pypwdg.output.solution as pos
import pypwdg.raytrace.control as prc
import pypwdg.parallel.main

from numpy import array,sqrt

k = 45
direction=array([[1.0,1.0]])/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=array([[-2,2],[-2,2]],dtype='d')
npoints=array([200,200])

mesh = pmm.gmshMesh('squarescatt.msh',dim=2)

quadpoints = 15

problem=psp.Problem(mesh,k, bnddata)
etods = prc.tracemesh(problem, {10:lambda x:direction})
controller = paa.BasisController(mesh, quadpoints, etods, k, nfb=5)
computation = paa.AdaptiveComputation(problem, controller, pcp.HelmholtzSystem, quadpoints)
computation.solve(psc.DirectSolver().solve, 6, pos.AdaptiveOutput1(computation, quadpoints, bounds, npoints, "squarescatt").output)
Example #3
0
import pypwdg.setup as ps
import pypwdg.core.bases as pcb
import pypwdg.mesh.mesh as pmm
import pypwdg.core.boundary_data as pcbd

from numpy import array

k = 20 
direction=array([[1.0,0,0]])
def g(x):
    return pcb.PlaneWaves(direction, k).values(x)
def gn(x,n):
    return pcb.PlaneWaves(direction, k).derivs(x,n)



bnddata={59:pcbd.zero_dirichlet(),
         58:pcbd.generic_boundary_data([-1j*k,1],[-1j*k,1],g=g,dg=gn),
         60:pcbd.generic_boundary_data([-1j*k,1],[-1j*k,1],g=g,dg=gn),
         61:pcbd.zero_dirichlet()}

bounds=array([[0,4],[0,1],[0,.3]],dtype='d')
npoints=array([100,20,20])

comp=ps.setup(pmm.gmshMesh('hole_extrusion.msh',dim=3),k=k,nquadpoints=10,nplanewaves=4,bnddata=bnddata,usecache=False)
comp.solve()
comp.writeSolution(bounds,npoints,fname='hole_extrusion.vti')
comp.writeMesh(fname='hole_extrusion.vtu',scalars=comp.combinedError())
Example #4
0
import pypwdg.setup as ps
import pypwdg.core.bases as pcb
import pypwdg.mesh.mesh as pmm
import pypwdg.core.boundary_data as pcbd
import pypwdg.parallel.main

from numpy import array

k = 10
direction = array([[1.0, 0]])
g = pcb.PlaneWaves(direction, k)

bnddata = {
    21: pcbd.zero_dirichlet(),
    18: pcbd.generic_boundary_data([-1j * k, 1], [-1j * k, 1], g),
    20: pcbd.generic_boundary_data([-1j * k, 1], [-1j * k, 1], g),
    19: pcbd.zero_dirichlet(),
}

bounds = array([[0, 5], [0, 1]], dtype="d")
npoints = array([501, 101])

mesh = pmm.gmshMesh("2dhole.msh", dim=2)
bases = pcb.planeWaveBases(mesh, k, nplanewaves=15)


problem = ps.Problem(mesh, k, 20, bnddata)
solution = ps.Computation(problem, bases).solve()
solution.writeSolution(bounds, npoints, fname="2dhole.vti")
problem.writeMesh(fname="2dhole.vtu", scalars=solution.combinedError())