AssembleLinearization with a RestrictedBilinearForm

I’m trying to use ngsxfem to solve a nonlinear problem defined on a subset of my domain, but I keep getting the error “SparseMatrixTM::AddElementMatrix: illegal dnumsin AssembleLinearization”. Does anyone know what could be causing this?


The RestrictedBilinearForm only replaces the Graph-Construction of the usual BilinearForm. In that respect, I do not see where this conflicts with the AssembleLinearization.

Are you using any sort of jump terms (DG or ghost penalty)? In that case you may have forgotten to add the “dgjumps” flag to the FESpace?

If that is not the case, it’s hard to guess where the problem comes from. Can you post your problem file or (better) a minimal (not) working example? And: which versions for ngsxfem(ngsolve) are you using?


Hi Christoph,

The current version of my code doesn’t include any jump terms. I was under the impression that they were incompatible with AssembleLinearization. Am I wrong?

I’ve attached a simplified version of my code. I’m not sure which version of ngsxfem I’m using. How would I go about checking that? If it narrows it down at all, I installed it in June of this year.


Dear JSR,

The definedonelements flag has not been used completely in the AssembleLinearization method, so that zero element matrices still wanted to be added to the sparse matrix. This crashed.

It’ll be fixed soon. If you update your NGSolve on - let’s say - monday, it should work again. If a fix until monday doesn’t work out, I will come back to you.


Hi Christoph,

Thanks for diagnosing the problem. Has there been any progress on the fix? I tried updating ngsolve, but I’m still getting the same error.

best regards,


it’s fixed, yes.
Are you using the nightly?