Call .Apply of BilinearForm with Complex Space

Does anyone have an idea or thoughts on this issue?

from ngsolve import *

mesh = Mesh(unit_square.GenerateMesh(maxh=1))

for b in [False, True]:
    fes = H1(mesh, order=0, complex=b)

    u, v = fes.TnT()
    gfu = GridFunction(fes)
    res = gfu.vec.CreateVector()

    a = BilinearForm(fes)
    a += 1 * v * dx
    a.Apply(gfu.vec, res)

    print(sum(res))

It would be crucial for a Newton-Raphson scheme with a complex function space, see [1].

Best,
Valentin

Actually, there are not so many complex-valued problems which can be solved by Newton’s method - complex differentiable is a very strong condition.

Thus, the Apply for complex symbolic forms is not overloaded, and falls back to the base class. The base class calls CalcElementMatrix, and then matrix-vector multiplication (assuming to have a bilinear form in the precise definition). Since no trial-functions are found, it gives the 0-matrix.

Recommendation: Use a LinearForm for the residual, and setup an (approximate) linearization (with a BilinearForm) by hand.

Joachim