# I need to have exact access to the blocks of stiffness matrix

Hi, I am trying to apply a technique called the decimation technique to my stiffness matrix in a 2D plane strain problem. Let’s say the domain is a simple rectangle that has a homogeneous Dirichlet BC on its left edge and homogeneous Neumann BC on other edges. This method needs to consider the whole domain (here the rectangle) as connected sub-elements (small rectangles connected to each other). More specifically, if we consider that the whole rectangle is made of 20 thin rectangles, to apply the decimation technique I need to know what are those parts of the stiffness matrix corresponding to each of the thin rectangles. Certainly, in addition to those blocks in the stiffness matrix which are related to the thin rectangles, there should be some blocks which define the connection between each pair of rectangles which are next to each other. Is there any way I can do it in Fenics?

for how to get the local element matrix/vector for a given kernel/form.

Im not sure what you mean by block. You can get the connectivity from a cell to a facet by

``````tdim = mesh.topology.dim
mesh.topology.create_connectivity(tdim,tdim-1) c_to_f = mesh.topology.connectivity(tdim,tdim-1)
``````

and the connectivity from a facet to cells by

``````mesh.topology.create_connectivity(tdim-1,tdim)
f_to_c = mesh.topology.connectivity(tdim-1,tdim)
``````

Thanks Dokken. I think my explanation was not clear enough. Please consider the following pic:

So, I mean I would like to have access to those parts of the stiffness matrix which are related to each of these small rectangles.
As blocks of stiffness matrix, I mean:
After assembling a “K” (stiffness) matrix in Fenics and saving it in excel format, if you zoom out the big picture of your K matrix is something like:

Right? Can you see the blocks which I colored? Technically, in each stiffness matrix, we should be able to categorize the elements to be placed in a specific block that corresponds to a specific part of the mesh. I need to have the blocks corresponding to each of the small rectangles. Do you know any way? Thanks.

You should then figure out what degrees of freedom each element contain, Which can be accessed via
`dolfinx.fem.FunctionSpace.dofmap.cell_dofs(cell_index)` this will give you want degrees of freedom (not unrolled with the block size of the problem, 3 for 3D elasticity) are in the cell. You can then use this to extract the rows and columns of the matrix, by either converting the PETSc mat to a dense matrix, or a csr matrix.

Thanks, Jorgen. I will work on it, and will reply here if I can fix it.