- dlPotInt.evaluateAtPoints(uInt, points[:,inside], evalOptions)) # Combine the results obtained for points inside and outside the scatterer # in a single array vals = np.empty(nPointsX * nPointsY, dtype=complex) np.place(vals, outside, valsExt.ravel()) np.place(vals, inside, valsInt.ravel()) # Display the field plot from bempp import visualization2 as vis tvtkU = vis.tvtkStructuredGridData( points, vals, (nPointsX, nPointsY)) tvtkGrid = vis.tvtkGrid(grid) vis.plotScalarData(tvtkGrid, None, tvtkU) # Export the results into a VTK file from tvtk.api import write_data write_data(tvtkU, "u.vts") # PART 6: Evaluate the far-field pattern of the scattered field ################ # Create the necessary potential operators slFfPot = lib.createHelmholtz3dFarFieldSingleLayerPotentialOperator(context, kExt) dlFfPot = lib.createHelmholtz3dFarFieldDoubleLayerPotentialOperator(context, kExt) # Define a set of points on the unit sphere and evaluate the potentials
slPotOp = createLaplace3dSingleLayerPotentialOperator(context) dlPotOp = createLaplace3dDoubleLayerPotentialOperator(context) # Define points at which the solution should be evaluated rCount = 51; thetaCount = 361; r, theta, z = np.mgrid[1:2:rCount*1j, 0:2*np.pi:thetaCount*1j, 0:0:1j] x = r * np.cos(theta) y = r * np.sin(theta) # put the x, y and z coordinates in successive rows of a matrix evaluationPoints = np.vstack((x.ravel(), y.ravel(), z.ravel())) # Use the Green's representation formula to evaluate the solution evaluationOptions = createEvaluationOptions() field = (-slPotOp.evaluateAtPoints(solFun, evaluationPoints, evaluationOptions) + dlPotOp.evaluateAtPoints(dirichletData, evaluationPoints, evaluationOptions)) # Plot data from bempp import visualization2 as vis annulus = vis.tvtkStructuredGridData( evaluationPoints, field, (rCount, thetaCount)) sphere = vis.tvtkGridFunction(dirichletData) vis.plotScalarData(tvtkGridFunctions=sphere, tvtkStructuredGridData=annulus)