I have a question related to the Bilinear and Linear form integrators and corresponding assembly in NGSolve. More specifically, I would like an efficient way to access specific entries in a.mat/f.vec, avoiding the complete assembly of the related bilinear/linear forms. For instance, how could one detect the specific nodes of the mesh which correspond to a non–zero contribution for (i,j)-entry of a.mat and then calculate the related element contributions compute the (i,j)-entry? Thank you in advance for your consideration,
George

you can compute element-matrices (and vectors) via the Python interface, and you can query the degrees of freedom of a certain element as in the example below.

thank you for your reply - this was exactly what i was looking for. However, I would appreciate an additional clarification. For my purposes, the Bilinear form includes terms with normal derivative jumps on specific facets:

since you need jump-terms, you set the skeleton=True flag. Such integrators calculate the element matrices for both elements at the facet at once.
This requires both finite elements, and both element transformations.
These FacetBilinearFormIntegrators don’t provide the usual CalcElementMatrix, thus the exception.

The two-element CalcElementMatrix is not available from Python.
I recommend to use a hybrid-DG like formulation for the (normal-derivative) jump term, then you don’t need the skeleton integration.

thank you for your response and for pointing me to the tutorial with the dG formulation. However, I am not sure I understand how skeleton integration can be avoided through this approach and I was hoping for some additional information.

Please find attached a partial code containing the ghost penalty term I am interested in calculating element matrices for. As you will see, an additional complication in my case is that the Bilinear Form is defined on specific facets marked via an indicator coefficient function. Is it possible without skeleton integration? Now the error message reads: ‘ngsolve.comp.SumOfIntegrals’ object has no attribute ‘CalcElementMatrix’.