import bempp.apiimport numpy as np bempp.api.global_parameters.hmat.eps = 1e-3 # 1.5*1e-2gmres_tolerance = 1e-2
f = 300 # frequencyc = 343 # speed of soundrho = 1.2 # air densityk = 2 * np.pi * f / c # wave number
admittance_1 = 1e-10admittance_2 = 0.5
grid = bempp.api.import_grid("GMSH/glatte_platte_segmente.msh")
physical_group_1 = [1]physical_group_2 = [2]
space_general = bempp.api.function_space(grid, "P", 1)space_1 = bempp.api.function_space(grid, "P", 1, domains=physical_group_1,element_on_segment=True, closed=True)space_2 = bempp.api.function_space(grid, "P", 1, domains=physical_group_2,element_on_segment=True, closed=False)
identity_general = bempp.api.operators.boundary.sparse.identity(space_general, space_general, space_general)identity_1 = bempp.api.operators.boundary.sparse.identity(space_general, space_1, space_1,)identity_2 = bempp.api.operators.boundary.sparse.identity(space_general, space_2, space_2,)
dlp_general = bempp.api.operators.boundary.helmholtz.double_layer(space_general, space_general, space_general, k)dlp_1 = bempp.api.operators.boundary.helmholtz.double_layer(space_general, space_1, space_1, k)dlp_2 = bempp.api.operators.boundary.helmholtz.double_layer(space_general, space_2, space_2, k)
slp_general = bempp.api.operators.boundary.helmholtz.single_layer(space_general, space_general, space_general, k)slp_1 = bempp.api.operators.boundary.helmholtz.single_layer(space_general, space_1, space_1, k)slp_2 = bempp.api.operators.boundary.helmholtz.single_layer(space_general, space_2, space_2, k)
# left hands side of equations system, A
blocked = bempp.api.BlockedOperator(2, 1)
blocked[0,0] = 0.5 * identity_1 - dlp_1 - 1j * k * admittance_1 * slp_1blocked[1,0] = 0.5 * identity_2 - dlp_2 - 1j * k * admittance_2 * slp_2
lhs = blocked.weak_form() # right hands side of equations system, b theta = np.radians( 90 ) # polar angle in degreesphi = np.radians( 0 ) # azimuth angle in degreesa = [ np.sin(theta)*np.cos(phi) , np.sin(theta)*np.sin(phi) , np.cos(theta) ] # plane wave directional vector def combined_data(x, n, domain_index, result): result[0] = np.exp(1*1j * k * np.dot(x,a))
grid_fun_general = bempp.api.GridFunction(space_general, fun=combined_data)
rhs = grid_fun_general
# solving
from bempp.api.linalg import gmressurface_pressures, info = gmres(lhs, rhs,tol=gmres_tolerance)
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-56-4ece98f228cc> in <module>()
59
60 from bempp.api.linalg import gmres
---> 61 surface_pressures, info = gmres(lhs, rhs,tol=gmres_tolerance)
/usr/lib/python2.7/dist-packages/bempp/api/linalg/iterative_solvers.py in gmres(A, b, tol, restart, maxiter, use_strong_form, return_residuals, return_iteration_count)
64 return _gmres_block_op_imp(
65 A, b, tol, restart, maxiter, use_strong_form, return_residuals,
---> 66 return_iteration_count)
67
68 raise ValueError(
/usr/lib/python2.7/dist-packages/bempp/api/linalg/iterative_solvers.py in _gmres_block_op_imp(A, b, tol, restart, maxiter, use_strong_form, return_residuals, return_iteration_count)
199 A_op = A.weak_form()
200 b_vec = projections_of_grid_function_list(
--> 201 b, A.dual_to_range_spaces)
202
203 callback = _it_counter(return_residuals)
/usr/lib/python2.7/dist-packages/bempp/api/assembly/blocked_operator.py in projections_of_grid_function_list(grid_funs, projection_spaces)
912 """
913 projections = []
--> 914 for item, proj_space in zip(grid_funs, projection_spaces):
915 projections.append(item.projections(proj_space))
916 vec_len = 0
TypeError: zip argument #1 must support iteration
grid_fun_1 = bempp.api.GridFunction(space_1, fun=combined_data) grid_fun_2 = bempp.api.GridFunction(space_2, fun=combined_data)
rhs = grid_fun_1,grid_fun_2
from scipy.sparse.linalg import LinearOperator
admittance_operator = scipy.sparse.linalg.aslinearoperator(scipy.sparse.diags( admittance_vector ,0))
lhs_weak = 0.5 * i_wf - dlp_wf - 1j*k*(slp_wf * admittance_operator)
suface_pressures_admittance = bempp.api.GridFunction(space, coefficients=np.multiply(surface_pressures.coefficients,admittance[domain_indices]))
pressure_field = u_inc(points_grid) + dlp_pot.evaluate(surface_pressures + 1j*k*slp_pot.evaluate(suface_pressures_admittance)
--
You received this message because you are subscribed to the Google Groups "bempp" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bempp+un...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/bempp/5c31a707-b0e8-4a3f-ad54-6ffe7b3ccd3f%40googlegroups.com.
Hi Luiz,I would not yet recommend to use Bempp-cl. We are in the last steps of preparing the first release of it and are currently porting over all the tutorials. By doing so we have already found and fixed a number of bugs, but not yet merged into the master branch.Best wishesTimo
To unsubscribe from this group and stop receiving emails from it, send an email to be...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/bempp/5c31a707-b0e8-4a3f-ad54-6ffe7b3ccd3f%40googlegroups.com.
--
Timo BetckeProfessor of Computational MathematicsUniversity College LondonDepartment of Mathematics
E-Mail: t.b...@ucl.ac.ukTel.: +44 (0) 20-3108-4068