Hi,
I have an issue when I use the mult operation between a matrix and a vector. I’m not sure what that error means, I think that the matrix A is not well defined.
import dolfinx
import ufl
from petsc4py import PETSc
from mpi4py import MPI
import numpy as np
from dolfinx import fem
xc = 25
yc = 25
R = 25
mesh = dolfinx.mesh.create_box(MPI.COMM_WORLD, [np.array([0,0,0]), np.array([50, 50, 50])], [5,5,5])
V = fem.VectorFunctionSpace(mesh, ("CG", 1))
def w_init(x):
values = np.zeros((3, x.shape[1]))
condition = ((x[0, :]-xc)**2 + (x[1, :]-yc)**2) < R*R
values[2, condition] = 1.0
values[0, ~condition] = 0
values[1, ~condition] = 1.0
values[2, ~condition] = 0
return values
w = dolfinx.fem.Function(V)
w.interpolate(w_init)
FL = ufl.inner(ufl.grad(w), ufl.grad(w))
dFdw =ufl.derivative(FL * ufl.dx, w)
dFdwdw = ufl.derivative(dFdw, w)
A = dolfinx.fem.petsc.assemble_matrix(dolfinx.fem.form(dFdwdw))
A.assemble()
vectors= PETSc.Vec().createSeq(V.dofmap.index_map.size_local)
# vectors = A.createVecs()
A.mult(w.vector, vectors)
File PETSc/Mat.pyx:1311, in petsc4py.PETSc.Mat.mult()
Error: error code 73
[0] MatMult() at ...
[0] Object is in wrong state
[0] Not for unassembled matrix
thanks