Error in opening 3D plots in fenics and .pvd files in Paraview 5.8.0 in Ubuntu 19.04

Hi Guys,

I am encountering two errors in the opening of the plots of example file elasticity

from __future__ import print_function
# from mpl_toolkits.mplot3d import Axes3D
import matplotlib.pyplot as plt
%matplotlib inline

from fenics import *
# from dolfin import *
# from mshr import *
from ufl import nabla_div

# Scaled Variables

L = 1
W = 0.2
mu = 1
rho = 1
delta = W/L
gamma = 0.4*delta**2
beta = 1.25
lambda_ = beta
g = gamma

# Create Mesh and define function space

mesh = BoxMesh(Point(0,0,0), Point(L,W,W), 10, 3, 3)
V = VectorFunctionSpace(mesh, 'P', 1)

# Define Boundary Conditions

tol = 1e-14

def clamped_boundary(x, on_boundary):
    return on_boundary and x[0] < tol

bc = DirichletBC(V, Constant((0,0,0)), clamped_boundary)

# Define Strain and Stress

def epsilon(u):
    return 0.5 * (nabla_grad(u) + nabla_grad(u).T)

def sigma(u):
    return lambda_*nabla_div(u)*Identity(d) + 2*mu*epsilon(u)

# Define variational problem

u = TrialFunction(V)
d = u.geometric_dimension() # space dimension
v = TestFunction(V)
f = Constant((0,0,-rho*g))
T = Constant((0,0,0))
a = inner(sigma(u), epsilon(v))*dx
L = dot(f, v)*dx + dot(T, v)*ds


# Compute Solution

u = Function(V)
solve(a == L, u, bc)

# Plot Solution
plot(u)

Everything works fine except the plot and error is

---------------------------------------------------------------------------
NotImplementedError                       Traceback (most recent call last)
<ipython-input-64-bc2b1359fe27> in <module>
     61 
     62 # Plot Solution
---> 63 plot(u)

~/anaconda3/envs/fenicsproject/lib/python3.7/site-packages/dolfin/common/plotting.py in plot(object, *args, **kwargs)
    436     # Plot
    437     if backend == "matplotlib":
--> 438         return _plot_matplotlib(object, mesh, kwargs)
    439     elif backend == "x3dom":
    440         return _plot_x3dom(object, kwargs)

~/anaconda3/envs/fenicsproject/lib/python3.7/site-packages/dolfin/common/plotting.py in _plot_matplotlib(obj, mesh, kwargs)
    280     else:
    281         ax = plt.gca()
--> 282     ax.set_aspect('equal')
    283 
    284     title = kwargs.pop("title", None)

~/anaconda3/envs/fenicsproject/lib/python3.7/site-packages/matplotlib/axes/_base.py in set_aspect(self, aspect, adjustable, anchor, share)
   1279         if (not cbook._str_equal(aspect, 'auto')) and self.name == '3d':
   1280             raise NotImplementedError(
-> 1281                 'It is not currently possible to manually set the aspect '
   1282                 'on 3D axes')
   1283 

NotImplementedError: It is not currently possible to manually set the aspect on 3D axes

I also save the .pvd and .vtu files and tried to open it in Paraview 5.8.0. But I encountered this error

ERROR: In /home/buildslave/dashboards/buildbot/paraview-pvbinsdash-linux-shared-release_superbuild/build/superbuild/paraview/src/VTK/IO/XML/vtkXMLUnstructuredDataReader.cxx, line 649
vtkXMLUnstructuredGridReader (0x95efa70): Error reading cell offsets: Unsupported array type: vtkUnsignedIntArray

I am currently using ubuntu 19.04 to run the cases.

This looks like a basic error but can’t solve it. Can anyone tell me how to resolve this issue?

Thanks a lot

1 Like

This is fixed in the development version of FEniCS, with the following commit. You can alternatively use vtkplotter to visualize the data.
Could you share how you saved it to pvd, as older versions of paraview seem to work fine. (Latest release of paraview 5.8 is just one day old.)

1 Like

Thanks a lot for the reply. I installed vtlplotter in it is working and I can view the plot within the jupyter-notebook.

To save the solution I used following code.

# Save solution to file in VTK format
vtkfile = File('elasticity/solution.pvd')
vtkfile << u

I just want to confirm that this is an error that I get with ParaView 5.8 RC3. ParaView 5.7 works. Is it a deprecated format or a bug in ParaView? The former would require a fix on FEniCS side, the latter not.

1 Like

I tried it in the Paraview 5.7 version and it is working !!!

I think it might be a bug in the Paraview 5.8 version.

Thanks again for the help

Issue added to Paraview gitlab

1 Like

Will be Fixed in Paraview release 5.8.1