Hello! me and my group mates are trying to run a nonlinear structural problem to solve for the variable ho0 and are encountering this particular PETSc function 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-DneRIZ/dolfin-2019.2.0~git20201207.b495043/dolfin/la/PETScMatrix.cpp.
*** Process: 0
This is our minimal runing code(Example-ho0-possion ):
Example-ho0-possion:
from dolfin import *
from fenics import *
from mshr import *
import matplotlib.pyplot as plt
tol=1E-12
mesh = UnitSquareMesh(8, 8)
V = FunctionSpace(mesh, 'Lagrange', 1)
# Define boundary condition
u_D = Expression('1 + x[0]*x[0] + 2*x[1]*x[1]', degree=2)
def boundary(x, on_boundary):
return on_boundary
bc = DirichletBC(V, u_D, boundary)
# Define variational problem
u = TrialFunction(V)
v = TestFunction(V)
f = Constant(-6.0)
a = dot(grad(u), grad(v))*dx
L = f*v*dx
# Compute solution
u = Function(V)
solve(a == L, u, bc)
Laplace=plot(u, title='show u')
plt.colorbar(Laplace)
plt.show()
class Top(SubDomain):
def inside(self, x, on_boundary):
return near(x[1], 1)
top = Top()
boundarie = MeshFunction("size_t", mesh, mesh.topology().dim() - 1)
boundarie.set_all(0)
top.mark(boundarie, 1)
ds = ds(subdomain_data=boundarie)
ho0=TrialFunction(V)
s=TestFunction(V)
t = TestFunction(V)
ho0= Function(V)
F0 = dot((-1*(ho0**2)/0.001),s)* ds(1) + dot((3-u),t)*ds(1)
ho0J=derivative(F0,ho0)
Ho0problem = NonlinearVariationalProblem(F0, ho0, None , ho0J)
Ho0solver = NonlinearVariationalSolver(Ho0problem)
Ho0prm = Ho0solver.parameters
Ho0solver.solve()
ho0plot=plot(ho0, title='show ho0')
plt.colorbar(ho0plot)
plt.show()
print ('rho0 calculated')
Any help is much appreciated!