Problem with stiffness matrices

Hi there,

I have the following problem:

Just a simple poisson problem; I need the stiffness matrices, so simply dot(grad(u),grad(v)) on a 2d mesh.

the type of mesh I’m using is mesh = UnitSquareMesh(10,10, “right”).

The problem is that when increase my number of elements, so a mesh 50x50, or 100x100, the entrie of the stiffness matrix do not change, while looking at the entries of the mass matrix, the scaling happens.

Now, I’m not a matematician, I just need the matrices to be studied, so Can you tell me what I’m doing wrong?

The code is as follows:

mesh = UnitSquareMesh(10,10,  "right")
V = FunctionSpace(mesh, 'P', 1)

u_D = Expression('cos(x[0])', degree=2)

def boundary(x, on_boundary):
  return on_boundary

bc = DirichletBC(V, u_D, boundary)

u = TrialFunction(V)
v = TestFunction(V)
f = Constant(-6.0)
a = dot(grad(u), grad(v))*dx
m = dot(u, v)*dx
L = f*v*dx

A = assemble(a)

A.array()

The derivatives (with respect to physical coordinates) of the shape functions each scale like 1/h, while the Jacobian determinant of the mapping from the reference to physical element scales like h^d, where d is the space dimension. Thus, for d=2, the effects cancel for the stiffness matrix. If you try in 1D, you will see that the entries scale like 1/h.

Thank you!! That’s the part I was missing