Cannot import name 'vtk_mesh' from 'dolfinx.plot'

I used this tutorial some times back to solve the Navier Stokes equation and it worked very well.
However, looks like they have made some small modifications and the code,
from dolfinx.plot import vtk_mesh gives the following error:

---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
Input In [1], in <cell line: 10>()
      8 from dolfinx.io import VTXWriter
      9 from dolfinx.mesh import create_unit_square
---> 10 from dolfinx.plot import vtk_mesh
     11 from ufl import (FacetNormal, FiniteElement, Identity, TestFunction, TrialFunction, VectorElement,
     12                  div, dot, ds, dx, inner, lhs, nabla_grad, rhs, sym)
     14 mesh = create_unit_square(MPI.COMM_WORLD, 10, 10)

ImportError: cannot import name 'vtk_mesh' from 'dolfinx.plot' (/usr/local/dolfinx-real/lib/python3.10/dist-packages/dolfinx/plot.py)

Earlier, it was written as: from dolfinx.plot import create_vtk_mesh and there wasn’t any issue with that.
Appreciate your comments on this.

What version of dolfinx are you running?
The tutorial gets updated with every release of dolfinx.

Ah I see. I’m using dolfinx/lab:v0.5.0…

If you are using 0.5.0, you can look at the ipynb here: GitHub - jorgensd/dolfinx-tutorial at v0.5.0

1 Like

Thank you dokken! I will look into that

Hi @dokken do you know whether the variational formulation of this Navier Stokes Equation has also changed. Because, in my previous code I have
L2 = form(dot(nabla_grad(p_n), nabla_grad(q))*dx - (1/k)*div(u_)*q*dx)
and

a3 = form(dot(u, v)*dx)
L3 = form(dot(u_, v)*dx - k*dot(nabla_grad(p_ - p_n), v)*dx)

But now looks like it has:
L2 = form(dot(nabla_grad(p_n), nabla_grad(q)) * dx - (rho / k) * div(u_) * q * dx)
and

a3 = form(rho * dot(u, v) * dx)
L3 = form(rho * dot(u_, v) * dx - k * dot(nabla_grad(p_ - p_n), v) * dx)

Looks like the rho term is newly added… Could you please verify.

EDIT
It looks like the variational formulation has changed.( dolfinx-tutorial/chapter2/ns_code1.ipynb at v0.5.0 · jorgensd/dolfinx-tutorial · GitHub) Could you please tell me the reason for that…

See: Corrections on the N-S code by QLRO · Pull Request #97 · jorgensd/dolfinx-tutorial · GitHub
and
Improvements to Navier-Stokes demo by jorgensd · Pull Request #99 · jorgensd/dolfinx-tutorial · GitHub

1 Like

Phew. Thanks for pointing out. I also had my solution blowing up because of this missing rho.
May I know whether you have made any more changes to the NS solver?

You can find the diff here: Comparing v0.5.0...v0.7.1 · jorgensd/dolfinx-tutorial · GitHub
Under files changed

1 Like

Thank you Dokken. I will look into that. And appreciate your quick responses.