BEMpp Grid: TypeError: list indices must be integers or slices, not str

32 views
Skip to first unread message

george...@gmail.com

unread,
Jul 21, 2020, 2:12:37 AM7/21/20
to bempp

Hello,


I’m new to BEMpp and I’m trying to run the first Laplace problem in Jupyter Notebook (Python 3.7) on the “Solving your first problem” page in the documentation. The import statement works, but the following line


grid = bempp.api.shapes.sphere(h=0.1)


returns a TypeError.


Could someone advise me on how to solve this issue? I’ve included the full error statement below.


When I modify my code from sphere to other shapes that also rely on line 390 in shapes.py, and therefore line 22 in io.py, I get the same error. On the other hand, calling regular_sphere (which doesn’t rely on the generate_grid_from_geo_string method) instead of sphere runs without a problem, and I’m able to proceed with the solved Laplace problem together with the visualization.


Thank you!

George


P.S.

---------------------------------------------------------------------------

TypeError                                 Traceback (most recent call last)

<ipython-input-4-8ea91180c722> in <module>

----> 1 grid = bempp.api.shapes.sphere(h=0.1)

      2 grid.plot()


/opt/anaconda3/lib/python3.7/site-packages/bempp/api/shapes/shapes.py in sphere(r, origin, h)

    404 

    405     """

--> 406     return ellipsoid(r1=r, r2=r, r3=r, origin=origin, h=h)

    407 

    408 


/opt/anaconda3/lib/python3.7/site-packages/bempp/api/shapes/shapes.py in ellipsoid(r1, r2, r3, origin, h)

    388         "cl = " + str(h) + ";\n" + stub)

    389 

--> 390     return __generate_grid_from_geo_string(geometry)

    391 

    392 def sphere(r=1, origin=(0, 0, 0), h=0.1):


/opt/anaconda3/lib/python3.7/site-packages/bempp/api/shapes/shapes.py in __generate_grid_from_geo_string(geo_string)

     72 

     73     msh_name = msh_from_string(geo_string)

---> 74     grid = bempp.api.import_grid(msh_name)

     75     os.remove(msh_name)

     76     return grid


/opt/anaconda3/lib/python3.7/site-packages/bempp/api/grid/io.py in import_grid(filename)

     20 

     21     vertices = mesh.points.T

---> 22     elements = mesh.cells["triangle"].T.astype("uint32")

     23 

     24     try:


TypeError: list indices must be integers or slices, not str


Timo Betcke

unread,
Jul 22, 2020, 5:43:53 PM7/22/20
to bempp
Hi. The meshio library on which Bempp-cl depends has recently been updated with some API changes.
You could either try to downgrade the library (maybe easiest) or use our development version in the staging branch (however, some features are still stabilising there).

Best wishes

Timo

george...@gmail.com

unread,
Jul 25, 2020, 10:21:42 PM7/25/20
to bempp
Thank you very much, Timo! I followed your advice and downgraded meshio, and the simulation successfully ran. It seems like starting from update 4.0.0, meshio does not work with Bempp-cl.
Reply all
Reply to author
Forward
0 new messages