Example #1
0

xe, ye, ze = radpl*np.cos(angl), radpl*np.sin(angl), hwwing+endpl/2;
print "Error on airplane body = ", np.abs(slPot.evaluateAtPoints(sol, [[xe],[ye],[ze]], evalOptions) + uIncData([xe,ye,ze]))

#quit()

nPointsX = 301
nPointsY = 301
#xx, yy, zz = np.mgrid[-22.5:22.5:nPointsX*1j, -8.45:17:nPointsY*1j, -0.7:-0.7:1j]
#xx, yy, zz = np.mgrid[-2.1:2.1:nPointsX*1j, 0.0:0.0:1j,  -4.5:4.5:nPointsY*1j]
xx, yy, zz = np.mgrid[-1.75:1.75:nPointsX*1j, 0.0:0.0:1j,  -1.2:1.2:nPointsY*1j]

if True:
	from bempp import visualization as vis
	points = np.vstack((xx.ravel(), yy.ravel(), zz.ravel()))
	#uActor = vis.scalarDataOnRegularGridActor(points, vals, (233,26), transformation="abs")
	#vals = (- slPot.evaluateAtPoints(sol, points, evalOptions) + incident(points) )
	vals = (slPot.evaluateAtPoints(sol, points, evalOptions) + incident(points) )
	#vals = slPot.evaluateAtPoints(sol, points, evalOptions)
	uActor = vis.scalarDataOnRegularGridActor(points, vals, (nPointsX, nPointsY), transformation="abs")
	legendActor = vis.legendActor(uActor)
	gridActor = vis.gridActor(grid)
	vis.plotTvtkActors([uActor, gridActor, legendActor])
	#from tvtk.api import tvtk as tva
	#line = tva.LineSource(point1=(0, 0, 0), point2=(4, 0, 0))
	#line_mapper = tva.PolyDataMapper(input=line.output)
	#line_actor = tva.Actor(mapper=line_mapper)
	#vis.plotTvtkActors([uActor, gridActor, legendActor,line_actor])

# 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 visualization as vis
annulusActor = vis.scalarDataOnRegularGridActor(
    evaluationPoints, field, (rCount, thetaCount))
sphereActor = vis.gridFunctionActor(dirichletData)
# make colour scales on the sphere and the annulus equal
sphereActor.mapper.scalar_range = [-1.3, 1.3]
annulusActor.mapper.scalar_range = [-1.3, 1.3]
legendActor = vis.legendActor(sphereActor)
vis.plotTvtkActors([annulusActor, sphereActor, legendActor])
Example #3
0
                  valsInt[2].real**2 + valsInt[2].imag**2)

# 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 visualization as vis
uActor = vis.scalarDataOnRegularGridActor(points, vals, (nPointsX, nPointsY))
legendActor = vis.legendActor(uActor)
gridActor = vis.gridActor(grid)
vis.plotTvtkActors([uActor, gridActor, legendActor])

# Export the results into a VTK file

from tvtk.api import write_data
write_data(uActor.mapper.input_as_data_set, "u.vts")

# # Create potential operators

# slPotOpExt = createMaxwell3dSingleLayerPotentialOperator(context, kExt)
# dlPotOpExt = createMaxwell3dDoubleLayerPotentialOperator(context, kExt)
# slPotOpInt = createMaxwell3dSingleLayerPotentialOperator(context, kInt)
# dlPotOpInt = createMaxwell3dDoubleLayerPotentialOperator(context, kInt)

# # Define points at which the solution should be evaluated in the exterior
Example #4
0
# 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 visualization as vis
annulusActor = vis.scalarDataOnRegularGridActor(
    evaluationPoints, field, (rCount, thetaCount))
sphereActor = vis.gridFunctionActor(dirichletData)
# make colour scales on the sphere and the annulus equal
sphereActor.mapper.scalar_range = [-1.3, 1.3]
annulusActor.mapper.scalar_range = [-1.3, 1.3]
legendActor = vis.legendActor(sphereActor)
vis.plotTvtkActors([annulusActor, sphereActor, legendActor])