Hi all, here is my question:
Suppose we have this simple mesh, and there are 4 elements and 6 nodes in total. For the 2D elasticity problem, the numbering of degrees of freedom (dofs) should be 1-12.
I can use the assemble_local
function to obtain the 6-by-6 element (local) stiffness matrix ke for each element. But for each element, what is the mapping between and local and globals dofs? For example, where should the element of ke(1,1) sit in the 12-by-12 global stiffness matrix?
I ask this question since I want to calculate element-wise value U.T@ke*U
, where U is the element displacement vector obtained from the global one.
I try to use dm.cell_dofs
function to obtain the dof, but I am not sure whether it is correct. This is the demo code.
from dolfin import *
import matplotlib.pyplot as plt
mesh = RectangleMesh(Point(0, 0), Point(2, 1), 2, 1)
V = VectorFunctionSpace(mesh, "CG", 1)
u = TrialFunction(V)
v = TestFunction(V)
dm = V.dofmap()
for i, cell in enumerate(cells(mesh)):
ke = assemble_local(inner(grad(u), grad(v))*dx, cell) # element stiffness matrix
print(dm.cell_dofs(i)) # dofs
plot(mesh)
plt.savefig('mesh.jpg')