# PART 4: Discretize and solve the equations ################################### solver = lib.createDefaultIterativeSolver(lhsOp) params = lib.defaultGmresParameterList(1e-8) solver.initializeSolver(params) # Solve the equation solution = solver.solve(rhs) print solution.solverMessage() # PART 5: Extract the solution ################################################# sol = solution.gridFunction() print "************** k = ", k, " **********************" slPot = lib.createHelmholtz3dSingleLayerPotentialOperator(context, k) dlPot = lib.createHelmholtz3dDoubleLayerPotentialOperator(context, k) evalOptions = lib.createEvaluationOptions() endpl = 0.5; radpl = 0.1; hwwing = 0.05; angl = 0.3; wings = 0.3; xe = radpl*np.cos(angl)+wings; ye = 0.0; #radpl*Sin(angl); ze = 0.0; # : Middle of wing plane potRes = slPot.evaluateAtPoints(sol, [[xe],[ye],[ze]], evalOptions) negInci = -uIncData([xe,ye,ze]) print [[xe],[ye],[ze]], negInci, " = pt and neg of inc wave, approx and potential =", potRes, ", error = ", np.abs(potRes-negInci)
rhs = -uInc # PART 4: Discretize and solve the equations ################################### solver = lib.createDefaultIterativeSolver(lhsOp) params = lib.defaultGmresParameterList(1e-8) solver.initializeSolver(params) # Solve the equation solution = solver.solve(rhs) print solution.solverMessage() # PART 5: Extract the solution ################################################# sol = solution.gridFunction() print "************** k = ", k, " **********************" slPot = lib.createHelmholtz3dSingleLayerPotentialOperator(context, k) dlPot = lib.createHelmholtz3dDoubleLayerPotentialOperator(context, k) evalOptions = lib.createEvaluationOptions() endpl = 0.5 radpl = 0.1 hwwing = 0.05 angl = 0.3 wings = 0.3 xe = radpl * np.cos(angl) + wings ye = 0.0 #radpl*Sin(angl); ze = 0.0 # : Middle of wing plane potRes = slPot.evaluateAtPoints(sol, [[xe], [ye], [ze]], evalOptions) negInci = -uIncData([xe, ye, ze])
# Combine them with the incident wave to yield the traces of the scattered field # (uSc) and the field transmitted into the object (uInt) uSc = uExt - uInc uScDeriv = uExtDeriv - uIncDeriv uInt = uExt uIntDeriv = rhoInt / rhoExt * uExtDeriv # PART 6: Evaluate the total field on part of the xy plane ##################### # Create the potential operators entering the Green's representation formula slPotInt = lib.createHelmholtz3dSingleLayerPotentialOperator(context, kInt) dlPotInt = lib.createHelmholtz3dDoubleLayerPotentialOperator(context, kInt) slPotExt = lib.createHelmholtz3dSingleLayerPotentialOperator(context, kExt) dlPotExt = lib.createHelmholtz3dDoubleLayerPotentialOperator(context, kExt) # Create a grid of points nPointsX = 201 nPointsY = 201 x, y, z = np.mgrid[-5:5:nPointsX*1j, -5:5:nPointsY*1j, 0:0:1j] points = np.vstack((x.ravel(), y.ravel(), z.ravel())) # Split the points into those located inside and outside the scatterer inside = lib.areInside(grid, points) outside = np.logical_not(inside)
# Combine them with the incident wave to yield the traces of the scattered field # (uSc) and the field transmitted into the object (uInt) uSc = uExt - uInc uScDeriv = uExtDeriv - uIncDeriv uInt = uExt uIntDeriv = rhoInt / rhoExt * uExtDeriv # PART 6: Evaluate the total field on part of the xy plane ##################### # Create the potential operators entering the Green's representation formula slPotInt = lib.createHelmholtz3dSingleLayerPotentialOperator(context, kInt) dlPotInt = lib.createHelmholtz3dDoubleLayerPotentialOperator(context, kInt) slPotExt = lib.createHelmholtz3dSingleLayerPotentialOperator(context, kExt) dlPotExt = lib.createHelmholtz3dDoubleLayerPotentialOperator(context, kExt) # Create a grid of points nPointsX = 201 nPointsY = 201 x, y, z = np.mgrid[-5:5:nPointsX*1j, -5:5:nPointsY*1j, 0:0:1j] points = np.vstack((x.ravel(), y.ravel(), z.ravel())) # Split the points into those located inside and outside the scatterer inside = lib.areInside(grid, points) outside = np.logical_not(inside)