PETSc error code 63 (argument out of range)

Hi everyone,
I’m trying to solve a 0D equation to use the result as the Neumann condition for a 1D equation. I get the following error code after the first iteration (iteration 0) of the solver:

Solving nonlinear variational problem.
Newton iteration 0: r (abs) = 2.026e+09 (tol = 1.000e-10) r (rel) = 1.000e+00 (tol = 1.000e-09)
Traceback (most recent call last):
File “demo.py”, line 622, in
run(parameters)
File “demo.py”, line 366, in run
solver.solve()
*** -------------------------------------------------------------------------
*** DOLFIN encountered an error. If you are not able to resolve this issue
*** using the information listed below, you can ask for help at


*** fenics-support@googlegroups.com


*** Remember to include the error message listed below and, if possible,
*** include a minimal running example to reproduce the error.


*** -------------------------------------------------------------------------
*** Error: Unable to successfully call PETSc function ‘MatSetValuesLocal’.
*** Reason: PETSc error code is: 63 (Argument out of range).
*** Where: This error was encountered inside /build/dolfin-V0jMTP/dolfin->2018.1.0.post1/dolfin/la/PETScMatrix.cpp.
*** Process: 0


*** DOLFIN version: 2018.1.0
*** Git changeset: unknown
*** -------------------------------------------------------------------------

Here is the code (I left out the mesh, marking of the facets, declaration of the constants used in the FV, … to keep it simple):

p = 1
Ve = FiniteElement("CG", mesh.ufl_cell(),1)
V_ele = VectorElement("CG", mesh.ufl_cell(), 1, len(traps))
R_ele = FiniteElement("R", mesh.ufl_cell(), 0)

MS = FunctionSpace(mesh, MixedElement([Ve, R_ele, R_ele, Ve, Ve]))

#Solution and previous solution
U = Function(MS)  
U_n = Function (MS) 
dU = TrialFunction(MS)
testfunction_concentration, testfunction_P, testfunction_Cs, testfunction_t1, testfunction_t2 = TestFunction(MS)

#Initial pressure
e_p0 = Expression('Pmax', degree=1, Pmax=Pmax)
p0 = interpolate(e_p0, MS.sub(1).collapse())
assign(U_n.sub(1), p0)

#Splitting of U into concentration, pressure, surface concentration and trapped concentrations
u, P, Cs, u_t1, u_t2 = split(U)
u_n, P_n, Cs_n, u_tn1, u_tn2 = split(U_n)

n = FacetNormal(mesh)

F1 = 0

F1 += ((Cs - Cs_n)/dt)*testfunction_Cs*ds(1, domain=mesh) - nu_gas[0]*P*(1-Cs/n_s)**2*testfunction_Cs*ds(1, domain=mesh) \
 + 2*nu_des*Cs**2*testfunction_Cs*ds(1, domain=mesh) + nu_sb*Cs*testfunction_Cs*ds(1, domain=mesh) \
  - nu_bs*(1-Cs/n_s)*u*testfunction_Cs*ds(1, domain=mesh)

F1 += l*(u - u_n)/dt*testfunction_concentration*ds(1, domain=mesh) - nu_sb*Cs*testfunction_concentration*ds(1, domain=mesh) \
 + nu_bs*(1-Cs/n_s)*u*testfunction_concentration*ds(1, domain=mesh)\
  - D*assemble(dot(grad(u),n)*ds(1, domain=mesh))*(1-Cs/n_s)*testfunction_concentration*ds(1,domain=mesh)

F1 += ((P - P_n)/dt)*testfunction_P*ds(1, domain=mesh) - Ae*R*T/(Na*Vol1)*(2*nu_des*Cs**2 - \
    nu_gas[0]*P*(1-Cs/n_s)**2)*testfunction_P*ds(1, domain=mesh)

while t < Time:
    t += float(dt)
    print("Current time", t," s")
    J1 = derivative(F1, U, dU)
    problem = NonlinearVariationalProblem(F1,U,bcs,J1)
    solver = NonlinearVariationalSolver(problem)
    solver.solve()

I’ve checked that i am using split(U) and not U.split() based on this previous question.

Could it be that I’m not using functions u_t1 and u_t2 in this first FV to solve (they are used in another formulation) ?

1 Like

My guess is that this has something to do with assembling a residual entirely on the boundary, since I only see ds measures in the definition of F1. Take a look at the following minimal example, which includes a possible solution:

from dolfin import *
mesh = UnitIntervalMesh(10)
V = FunctionSpace(mesh,"CG",1)

# Constrain all interior nodes:
bc = DirichletBC(V,Constant(0.0),"!(near(x[0],0.0)||near(x[0],1.0))",
                 "pointwise")

# Try to solve a variational problem on the boundary:
u = Function(V)
v = TestFunction(V)

# Causes error code 63 on its own:
residual = (u-1.0)*v*ds

# Fix:
residual += Constant(0.0)*u*v*dx

solve(residual==0,u,bcs=[bc,])
1 Like

Hi @kamensky,

thank you for your sharing.
I got the same PETSc error due to split(), and fix with this (https://fenicsproject.org/qa/11964/petsc-problem-when-solving-nonlinear-variational-problem/).
However, I still don’t understand, what does actually the PETSc error code 63 tell?

Thank you in advance.