Curl at boundaries in HCurl space

Hi all!
First off, thanks for putting Netgen/NGSolve together! It works really well and is quite easy to use!

That said, I’m having trouble implementing the adjoint optimization method described in Optica Publishing Group for the vector wave equation in electromagnetism (HCurl space) because it needs the curl of the test function calculated at a specific internal boundary of the domain — last term in the RHS of the equation below — (22) in the paper:

[tex]\int_{\mathcal D}\left(\nabla\times V\cdot\nabla\times W - k_0^{2}n^{2}V\cdot W\right)\mathrm dx = \\varphi_\ell^{\ast}(E_m)\int_\Gamma\left(h_\ell\times\hat n\cdot W + \hat n\times j_\ell\cdot\nabla\times W\right)\mathrm ds[/tex]

I understand that w.Trace() will give me only the tangential component of the test function, so I cannot get the curl I need. On the other hand, it should be possible to get the curl calculated at the elements adjacent to the boundary in question (it might just not be continuous).

I was able to implement the curl at the boundary in FEniCS/dolfin by specifying on what side of the boundary I wanted it calculated (they use a notation like w.curl(“+”) and w.curl(“-”) to specify the side with respect to the normal).

Would something like this be at all possible in NGSolve? I could definitely help implementing it if given some directions as well.

Hi,
this should be possible using skeleton integrators on that boundary.
The gridfunctions provide a gf.Other() to evaluate on the other side. See for example the DG documentation for this:

https://ngsolve.org/docu/latest/i-tutorials/unit-2.8-DG/DG.html

Best
Christopher

Thanks for the quick reply, Christopher!

I tried the skeleton argument and got a different error:

FacetLinearFormIntegrator::CalcFacetVector<complex> not implemented!in Assemble LinearForm

Just to be sure I’m not making any mistakes, this is what I’m trying:

b = ngsolve.LinearForm(fes)
b += complex_constant * w.Deriv() * ngsolve.ds("gamma", skeleton=True)
# Same error:
# b += complex_constant * w.Other().Deriv() * ngsolve.ds("gamma", skeleton=True)

So, from the error I’m guessing this should be possible, it’s just not implemented yet, right?

Yes you are right, complex facet integrators were missing. I’ve added calcfacetvector and calcelementmatrix methods. Please test. They are on the current master and will be in upcoming nigthly. See

Best
Christopher

Looks like it is working. Thanks for the quick implementation! I have to say, being able to use complex FE and quickly define PMLs makes everything MUCH easier than my previous implementation in FEniCS!