Visual bug when using Paraview after solving in parallel

I have prepared an MRE:

import dolfinx
from mpi4py import MPI
from petsc4py import PETSc
import numpy as np
import ufl
from dolfinx.fem.petsc import NonlinearProblem
from dolfinx.nls.petsc import NewtonSolver

nn = 5
domain = dolfinx.mesh.create_box(MPI.COMM_WORLD, [np.array([-1, -1,-1]), np.array([1, 1,1])],
                               [nn,nn,nn], dolfinx.mesh.CellType.tetrahedron, ghost_mode=dolfinx.mesh.GhostMode.shared_facet)

V = dolfinx.fem.functionspace(domain, ("Lagrange", 2))
u_test = ufl.TestFunction(V)

u_n = dolfinx.fem.Function(V)
u_n.x.array[:]=0
u_h = dolfinx.fem.Function(V)
u_h.x.array[:]=0

t = dolfinx.fem.Constant(domain, 0.0)
dt = dolfinx.fem.Constant(domain, 1.0)

diff_term = ufl.dot(ufl.grad(u_test), ufl.grad(u_h)) * ufl.dx
N_bc = u_test*ufl.ds
f_h = -diff_term + N_bc
F_E = u_h*u_test*ufl.dx - u_n*u_test*ufl.dx - dt*f_h

problem = NonlinearProblem(F_E, u_h)
solver = NewtonSolver(MPI.COMM_WORLD, problem)

vtxfile = dolfinx.io.VTXWriter(MPI.COMM_WORLD,"u_vtx.bp",u_h) 

for i in range(10):
    t.value = t.value + dt.value
    idx, converged = solver.solve(u_h)
    u_h.x.scatter_forward()
    u_n.x.array[:] = u_h.x.array
    vtxfile.write(t)
vtxfile.close()

When running with mpiexec -n 1 python script.py vs mpiexec -n 32 python script.py, after importing results to Paraview everything seems fine. After applying basic clip filter, when n=2 or more, following artifacts appear:

Did anyone encounter a similar issue or is something wrong with my code? Any help appreciated.

Paraview version 5.3.12
Dolfinx run in docker initialized with dolfinx/dolfinx:stable

If you turn on the option “Crinkle clip” this will disappear. The issue is due to how VTX stores the data locally per process, rather than as a big array

2 Likes

Thank you for the answer. This does solve the issue with missing elements, although “crinkle clip” is a different kind of clipping, especially for unstructured grids. But now I understand the problem lies outside of Dolfinx.