You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to assemble the Jacobian of a side constraint in a PDE-constrained optimisation problem. The constraint is that u*dx == V. I test this equation with a TestFunction from FunctionSpace(mesh, "R", 0). However, when I take its Jacobian and try to assemble it, I can't seem to get an explicit PETSc matrix out. (I intend to pass the assembled Jacobian to IPOPT.)
Consider the following code:
from firedrake import *
mesh = UnitSquareMesh(2, 2)
V = FunctionSpace(mesh, "CG", 1)
R = FunctionSpace(mesh, "R", 0)
v = TestFunction(R)
u = TrialFunction(V)
form = inner(u, v)*dx
J = assemble(form, mat_type="aij")
J.force_evaluation()
print(J.petscmat.type)
I was expecting it to print "aij", but instead it prints "python". How can I get the matrix entries out? (mat_type="dense" isn't recognised.)
The text was updated successfully, but these errors were encountered:
The rectangular blocks produced by the "R" space are represented as PyOP2 dats wrapped in PETSc Python matrices. I think J.petscmat.getPythonContext().dat will give you the entries which live on this process. This possibly should be done with a PETSc dense matrix. At the time, I didn't know such things existed.
(Possibly not a bug/user error)
I'm trying to assemble the Jacobian of a side constraint in a PDE-constrained optimisation problem. The constraint is that
u*dx == V
. I test this equation with aTestFunction
fromFunctionSpace(mesh, "R", 0)
. However, when I take its Jacobian and try to assemble it, I can't seem to get an explicit PETSc matrix out. (I intend to pass the assembled Jacobian to IPOPT.)Consider the following code:
I was expecting it to print
"aij"
, but instead it prints"python"
. How can I get the matrix entries out? (mat_type="dense"
isn't recognised.)The text was updated successfully, but these errors were encountered: