In a 2D elastic problem (in-plane), I found my stiffness and mass matrices for a 2D rectangle in which a homogeneous Dirichlet is applied on its left. Here: How to apply Dirichlet boundary conditions using a matrix free method - FEniCS Q&A , it is explained that when a homogeneous DC boundary conditions is applied, the diagonal entries for the relevant dofs are set to 1, and all off-diagonal entries in the same rows are set to zero. First, It would be great if someone can explain why should all the dofs on the diagonal be 1 and the rest zero, applying Dirichlet for a discrete chain gives me something else.
Second, here are first 36 dofs of my stiffness matrix:
and here is my mesh:
Why do the yellow blocks which are showing the coupling of the dofs on the boundary and those on their right side, are zero sub-matrices? Clearly, the degrees of freedom on the boundary are not disconnected to those on their right side.
As you have not supplied your implementation, it is hard to pinpoint the coupling issue. I suspect that you are using assemble_system.
See: How to implement the equivalence of `assemble_system` in DOLFINx - #2 by dokken
for an explaination of why the diagonal dofs in legacy dolfin is not equal to one.
I am sorry for that Jorgen. Here is how I assembled it:
k_form = inner(sigma(du),eps(u_))*dx
l_form = Constant(1.0)*u_*dx
K = PETScMatrix()
b = PETScVector()
e,o=assemble_system(k_form, l_form, bc, A_tensor=K, b_tensor=b)
and this is my boundary conditions:
def inside(self, x, on_boundary):
return x < DOLFIN_EPS/100 and on_boundary
bc = DirichletBC(V, Constant((0.,0.)), BCS)
When you call assemble_system, it applies boundary conditions in a symmetric fashion. This means that instead of only setting the bc rows to an identity/multiple of identity row.
One instead uses lifting, which results in a Matrix where all bc entries are discoupled, and is instead added in the rhs ( b-=Ag) where g is equal to the DirichletBC at respective dofs, 0 otherwise.