I am trying to implement an error estimator for Maxwell’s equation. For this I followed tutorial 1.6 which wasn’t a problem in the first place.

h = specialcf.mesh_size
n = specialcf.normal(mesh.dim)
err1 = Integrate ( h * Norm( (curl(A)-(curl(A).Other()) ) - (n*(curl(A)-(curl(A).Other()))*n) )**2*dx(element_boundary=True), mesh, element_wise=True)
...

Now I tried to apply this error estimator to a problem which contains a PML which doesn’t seem to work, as it becomes an integration over a complex domain. Therefore, I would like to localize these integrals to ignore the PML, yet still run over the boundary of each element. I tried the “definedon” flag, but it always returned some error.
Could someone tell me the correct way to achieve this?

thanks for your reply. Even though my code is a bit messy, there is already a “Norm( … )” contained in it. From my understanding the problem arises with the PML, as this area becomes a complex domain (therefore i want to exclude it from the computation).
Please correct me if I am mistaken.

Greetings,
Philipp

Edit: I tried integrating over the “inner” (not “pml”) area via

“NgException: ComputeNormalsAndMeasure not available for complex IR”.

Edit2: I found a workaround by unsetting the PML during each error estimation and reapplying it to the refined mesh, but this seems quite a bruteforce method.

the complex stretching for boundary integrals is not implemented (we did not need it so far), thus the exception.

Unsetting the PML computes something, but (I guess) the jump terms will not be consistent, and thus overestimate the error at the interface to the PML region. You can filter out these edges by multiplying with a GridFunction in FacetFESpace set to 0 or 1, depending on which faces you want to include. Anyway you miss some terms …

My favourite, practical estimators for Maxwell equations are ZZ-type estimators, where we average the H-field into an H(curl) space, and the total current density into an H(div) space. Very similar to the tutorial.
Should work fine also together with PML.