How to access print assembled matrix from variational form

Next time, please make a minimal reproducable example.
Your can print the vector with get_local() as illustrated in the code below.:

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

v = TestFunction(V)

L = v*dx
b = assemble(L)
print(b.get_local())

or for a matrix, use array:

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

v = TestFunction(V)
u = TrialFunction(V)
L = u*v*dx
A = assemble(L)
print(A.array())
1 Like