-1
$\begingroup$

I'm trying to implement mesh in Google colab from gmesh tutorials. I have an error: Exception: Fltk not available

My code is:

try:                     
            import google.colab  # noqa: F401
except ImportError:
    import gmsh
else:
    try:
        import gmsh
    except ImportError:
        !wget "https://fem-on-colab.github.io/releases/gmsh-install.sh" -O "/tmp/gmsh-install.sh" && bash "/tmp/gmsh-install.sh"
        import gmsh`
import gmsh
import sys
 

gmsh.initialize()

gmsh.model.add("t1")
 
lc = 1e-2
gmsh.model.geo.addPoint(0, 0, 0, lc, 1)
 
gmsh.model.geo.addPoint(.1, 0, 0, lc, 2)
gmsh.model.geo.addPoint(.1, .3, 0, lc, 3)
 

p4 = gmsh.model.geo.addPoint(0, .3, 0, lc)
 
gmsh.model.geo.addLine(1, 2, 1)
gmsh.model.geo.addLine(3, 2, 2)
gmsh.model.geo.addLine(3, p4, 3)
gmsh.model.geo.addLine(4, 1, p4)
 
gmsh.model.geo.addCurveLoop([4, 1, -2, 3], 1)
 
gmsh.model.geo.addPlaneSurface([1], 1)
 

gmsh.model.geo.synchronize()


gmsh.model.addPhysicalGroup(1, [1, 2, 4], 5)
gmsh.model.addPhysicalGroup(2, [1], name = "My surface")
 

gmsh.model.mesh.generate(2)
 
# ... and save it to disk
gmsh.write("t1.msh")
 
if '-nopopup' not in sys.argv:
    gmsh.fltk.run()
 
gmsh.finalize()
```c
$\endgroup$
1
  • 2
    $\begingroup$ Welcome to SciComp.SE. I think that this is not the right place for your question since it is related with the use of a particular software. Maybe you should search in Gmsh site or their issue tracker. $\endgroup$
    – nicoguaro
    Commented Dec 5, 2023 at 12:51

1 Answer 1

3
$\begingroup$

The graphical user interface (GUI) of Gmsh was written in FLTK. This is for desktop systems, therefore, the Gmsh GUI will not be embedded in Jupyter notebooks (including Google Colab).

If you run your Gmsh script on a desktop system that has a display, and your Gmsh version was compiled with FLTK support (which is the case if you download the precompiled binaries from the Gmsh website), then the gmsh.fltk.run() command will open a FLTK window.

If you run Gmsh in headless mode (so you have no display, as on HPC clusters) or Gmsh was built without FLTK, then you cannot use the GUI. In such scenarios, export your geometry and your mesh into one of the many supported file formats. For instance, you can export the geometry to a CAD format and the mesh to VTK format to be visualized by ParaView.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.