How to import a CAD or GMSH files

I tried to import a .msh file with no success.
I used grid = bempp.api.import_grid(‘my_grid.msh’) it does not work for me.

It does not recognise .imprt_grid. How can I solve this problem?

Kind regards,

Bempp-cl supports importing GMSH files. You can find the documentation here: Grids — The Bempp Book
Make sure that the grid file is in the same directory as your code, or specify the entire path of the file.
In case you receive an error message, please post a minimum working example and the full error message.

This is the error message I have
“”"
—> 1 grid=bempp.api.import_grid(‘smallcube.msh’)

~/Downloads/yes/lib/python3.9/site-packages/bempp/api/grid/io.py in import_grid(filename)
21
22 vertices = mesh.points.T
—> 23 elements = mesh.cells_dict[“triangle”].T.astype(“uint32”)
24
25 try:

KeyError: ‘triangle’ “”"

The library can read your grid file but cannot find information about triangles in the mesh.

There might be an issue with how you generated the mesh externally. Bempp always uses a mesh with flat triangular surface elements. When no triangles are present in the mesh, for example, if the mesh has quadrilaterals or tetrahedrons, this type of error will be thrown.

Please check the type of mesh in your mesh file. You can perform the following diagnostics:

import meshio
mesh = meshio.read("smallcube.msh")
print(mesh)
print(mesh.cells_dict.keys())

You expect to see “triangle” as cell type. If you see another cell type, your grid was not generated correctly.

First, I want to thank you greatly for your last response. It really helped me. I am trying to convert the 2 dielectric Bistatic RCS sphere tutorial, to address a 1 PEC sphere such that I can compare my results to standard ones. I have some results now. But I am really not sure about their accuracy. I will appreciate any help to address the case for PEC Material.