Element stiffness matrix

Hello,

I am trying to figure, how to print out Element Stiffness matrix for a particular cell in the mesh?

I understand it is trivial to print out the global/assembled stiffness matrix.

Any suggestions will be helpful.

thanks,
-ss

You can do something like: assemble_local(form, cell) to get the local stiffness corresponding to cell. For e.g.,

from dolfin import *

# check for a trivial case of a mesh comprised of two elements
mesh = UnitSquareMesh(1, 1)
V = FunctionSpace(mesh, "CG", 1)
u = TrialFunction(V)
v = TestFunction(V)
for i, cell in enumerate(cells(mesh)):
    if i==1: # for the second element
        A = assemble_local(inner(grad(u), grad(v)) *dx, cell)  # A is the local stiffness

I have personally never done this, but it is easily verifiable by a simple hand calculation.

2 Likes

Iā€™d like to ask you a question. Do you know how to get the unit degree matrix in dolfinx v0.7.2?