Generate UnitIntervalMesh dolfin-legacy

Hi,

I am not able to generate interval mesh in dolfin-legacy. However, I found this command was working previously and can be seen in previous posts. The dolfin-version is: 2019.2.0.dev0 (obtained from terminal).

from dolfin import *

mesh = UnitIntervalMesh(4)
mesh

The error is

---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
File ~/.local/lib/python3.10/site-packages/IPython/core/formatters.py:344, in BaseFormatter.__call__(self, obj)
    342     method = get_real_method(obj, self.print_method)
    343     if method is not None:
--> 344         return method()
    345     return None
    346 else:

File /usr/lib/petsc/lib/python3/dist-packages/dolfin/mesh/__init__.py:40, in _repr_html_(self)
     39 def _repr_html_(self):
---> 40     return cpp.io.X3DOM.html(self)

RuntimeError: 

That’s a new one, I think we have never seen this error before in this forum.

Close your notebook, try using the system wide ipython installation, i.e. do a mv ~/.local/lib/python3.10 ~/.local/lib/python3.10.bak, and start the notebook again.

2 Likes

The full error message contains useful info

*** -------------------------------------------------------------------------
*** DOLFIN encountered an error. If you are not able to resolve this issue
*** using the information listed below, you can ask for help at
***
***     https://fenicsproject.discourse.group/
***
*** Remember to include the error message listed below and, if possible,
*** include a *minimal* running example to reproduce the error.
***
*** -------------------------------------------------------------------------
*** Error:   Unable to get X3DOM string representation of a mesh.
*** Reason:  X3D works only for 2D and 3D meshes.
*** Where:   This error was encountered inside X3DOM.cpp.
*** Process: 0
*** 
*** DOLFIN version: 2019.2.0.dev0
*** Git changeset:  982f37614ec24299add4e09024d7d5f985474a91
*** -------------------------------------------------------------------------

Note that the error only happens when you end the cell with the word mesh, i.e. you try to represent it in the notebook. Mesh generation itself works. If you really want to represent the mesh, you can use repr(mesh), but I can’t see why the info you get from there would be relevant.

1 Like

Thanks @francesco-ballarin. repr(mesh)/ plot(mesh) is showing the 1D mesh.
Noted point: the mesh was generated previously, but, with typing only mesh to work was my error.