Your test only uses 2D elements (?)
This line makes no sense:
gmsh::model::mesh::generate(2); // Dimension of element
Your geometry is 3D. You should generate a 3D mesh with generate(3)
and work with volume elements (tetrahedra or hexahedra).
By the way I would recommend to remove the source term from your test as long as it does not work (s=0
). I would also deactivate the Neuman BCs.
=> do not expect your code to work the first time you run it. You must add one feature after the other and test each new feature separately. The first feature is the calculation of the K matrix which is mandatory for any problem you could imagine. => print and debug the K matrix first (without even solving something - just print the computed matrix and calculate it by hand on a simple case)