I am trying to solve a flow problem on a complicated mesh. Occasionally my nonlinear solver will say the solution failed to converge in 0 iterations. I have only observed this on meshes with a periodicity condition when using over a certain number of threads. A MWE is pasted below:
from dolfin import *
mesh = UnitCubeMesh(20, 20, 20)
#Setting up periodicity on y, z faces
class PeriodicDomain(SubDomain):
def inside(self, x, on_boundary):
return bool((near(x[1], 0) or near(x[2], 0)) and (not ((near(x[1], 0) and near(x[2], 1.0)) or (near(x[1], 1.0) and near(x[2], 0.0)))) and on_boundary)
def map(self, x, y):
if near(x[1], 1.0) and near(x[2], 1.0):
y[0] = x[0]
y[1] = x[1] - 1.0
y[2] = x[2] - 1.0
elif near(x[1], 1.0):
y[0] = x[0]
y[1] = x[1] - 1.0
y[2] = x[2]
elif near(x[2], 1.0):
y[0] = x[0]
y[1] = x[1]
y[2] = x[2] - 1.0
else:
y[0] = -1000
y[1] = -1000
y[2] = -1000
pbc = PeriodicDomain()
#Spaces, function definitions
lin_space2 = FunctionSpace(mesh, "CG", 2, constrained_domain = pbc)
u2 = Function(lin_space2)
v2 = TestFunction(lin_space2)
f = Constant(1.0)
#W.F.
F2 = inner(grad(u2), grad(v2))*dx + inner(f, v2)*dx
J2 = derivative(F2, u2)
pde2 = NonlinearVariationalProblem(F2, u2, [], J2)
solver2 = NonlinearVariationalSolver(pde2)
solver2.solve()
I am using a 28-core Ubuntu 18.04 system on version 2018.1.0 with 512Gb of memory. Using 20 or more threads results in the error
*** -------------------------------------------------------------------------
*** Error: Unable to solve linear system using PETSc Krylov solver.
*** Reason: Solution failed to converge in 0 iterations (PETSc reason DIVERGED_PCSETUP_FAILED, residual norm ||r|| = 0.000000e+00).
*** Where: This error was encountered inside PETScKrylovSolver.cpp.
*** Process: 19
***
*** DOLFIN version: 2018.1.0
*** Git changeset: unknown
*** -------------------------------------------------------------------------
In this MWE, increase or decreasing the number of elements can remove the error, as does removing the periodicity condition. However, I only observe this error using the periodic condition. Does anyone know what might be the issue?