1 Introduction

A new approach to two-dimensional time-harmonic Maxwell’s equations with the perfectly conducting boundary condition was introduced in [3], where the problem was reduced to standard second order scalar elliptic boundary value problems through the Hodge decomposition. This approach makes it possible to apply many standard numerical techniques to computational electromagnetics. A \(P_1\) finite element method based on this approach was analyzed in [3]. Adaptive versions and multigrid algorithms for the \(P_1\) finite element method were subsequently developed in [4, 6].

In a recent paper [5], the Hodge decomposition approach was extended to transverse magnetic problems that involve general materials and the impedance boundary condition. The goal of this paper is to extend the adaptive methods in [4] to the general problem for time-harmonic Maxwell’s equations treated in [5], whose setting is recalled below.

We take the material domain \(\varOmega \subset \mathbb {R}^2\) to be a bounded polygon whose boundary consists of two disjoint closed subsets \({{\varGamma }_\mathrm{pc}}\) (where the perfectly conducting boundary condition is posed) and \({{\varGamma }_\mathrm{imp}}\) (where the impedance boundary condition is posed). We denote the magnetic permeability by \(\mu \), the electric permittivity by \(\epsilon \), the impedance on \({{\varGamma }_\mathrm{imp}}\) by \(1/\lambda \), the electric current density by \(\varvec{f}\), and the magnetic field density imposed on \({{\varGamma }_\mathrm{imp}}\) by g.

We assume that \(\varvec{f}\in {[L_2(\varOmega )]^2}\) (the space of complex \(L_2\) vector fields on \(\varOmega \)), \(g\in {L_2({{\varGamma }_\mathrm{imp}})}\) (the space of complex \(L_2\) functions on \({{\varGamma }_\mathrm{imp}}\)), \(\lambda \) is a smooth strictly positive function defined on \({{\varGamma }_\mathrm{imp}}\), \(\mu \) and \(1/\mu \) are real-valued functions in \(L_\infty (\varOmega )\), and \(\epsilon \) is a smooth real symmetric positive definite \(2\times 2\) tensor field defined on \(\bar{\varOmega }\).

Remark 1

Note that the magnetic permeability \(\mu \) is allowed to change sign in our setting, and the electric permittivity can be inhomogeneous and anisotropic. We will also allow \(\epsilon \) to change sign in the numerical experiment for a flat lens. Thus the results in this paper are also relevant for electromagnetic problems involving metamaterials [12, 19].

The model transverse magnetic problem is to find \(\varvec{u}\in \mathbb {E}\) such that

$$\begin{aligned} (\mu ^{-1}\nabla \times \varvec{u}, \nabla \times {\varvec{v}}) - k^2(\epsilon \varvec{u},{\varvec{v}}) - ik\langle \lambda {\varvec{n}}\times \varvec{u}, {\varvec{n}}\times {\varvec{v}} \rangle _{{\varGamma }_\mathrm{imp}}= (\varvec{f},{\varvec{v}}) + \langle g, {\varvec{n}}\times {\varvec{v}} \rangle _{{\varGamma }_\mathrm{imp}}\end{aligned}$$
(1)

for all \({\varvec{v}}\in \mathbb {E}\).

Here \(i=\sqrt{-1}\), \(k>0\) is the frequency, \((\cdot ,\cdot )\) (resp. \(\langle \cdot , \cdot \rangle _{{\varGamma }_\mathrm{imp}}\)) denotes the inner product of the complex function space \({[L_2(\varOmega )]^2}\) (resp. \({L_2({{\varGamma }_\mathrm{imp}})}\)),

$$\begin{aligned} \mathbb {E}=H_\mathrm{imp}(\mathrm{curl};\varOmega ;{{\varGamma }_\mathrm{imp}})\cap {H_0(\mathrm{curl};\varOmega ;{{\varGamma }_\mathrm{pc}})}\cap {H(\mathrm{div}^0;\varOmega ;\epsilon )}, \end{aligned}$$

and the spaces \(H_\mathrm{imp}(\mathrm{curl};\varOmega ;{{\varGamma }_\mathrm{imp}})\), \({H_0(\mathrm{curl};\varOmega ;{{\varGamma }_\mathrm{pc}})}\) and \({H(\mathrm{div}^0;\varOmega ;\epsilon )}\) are defined as follows:

$$\begin{aligned} {H(\mathrm{curl};\varOmega )}&=\left\{ \varvec{v}\!=\!\begin{bmatrix}v_1\\ v_2 \end{bmatrix}\in {[L_2(\varOmega )]^2}:\,\nabla \times \varvec{v}\!=\!\partial v_2/\partial x_1-\partial v_1/\partial x_2 \in {L_2(\varOmega )}\right\} ,\\ H_\mathrm{imp}(\mathrm{curl};\varOmega ;{{\varGamma }_\mathrm{imp}})&=\left\{ \varvec{v}\in {H(\mathrm{curl};\varOmega )}:\,\varvec{n}\times \varvec{v}\big |_{{\varGamma }_\mathrm{imp}}\in {L_2({{\varGamma }_\mathrm{imp}})}\right\} ,\\ {H_0(\mathrm{curl};\varOmega ;{{\varGamma }_\mathrm{pc}})}&=\left\{ \varvec{v}\in {H(\mathrm{curl};\varOmega )}:\,\varvec{n}\times \varvec{v}\big |_{{\varGamma }_\mathrm{pc}}=0 \right\} ,\\ {H(\mathrm{div}^0;\varOmega )}&=\left\{ \varvec{v}=\begin{bmatrix}v_1\\ v_2 \end{bmatrix}\in {[L_2(\varOmega )]^2}:\,0=\nabla \cdot \varvec{v}=\partial v_1/\partial x_1+\partial v_2/\partial x_2 \right\} ,\\ {H(\mathrm{div}^0;\varOmega ;\epsilon )}&=\left\{ \varvec{v}\in {[L_2(\varOmega )]^2}:\,\epsilon \varvec{v}\in {H(\mathrm{div}^0;\varOmega )}\right\} , \end{aligned}$$

where \(\varvec{n}=(n_1, n_2)^t\) is the outward pointing unit normal along \(\partial \varOmega \) and \(\varvec{n}\times \varvec{v}=n_1v_2-n_2v_1\) is the tangential component of \(\varvec{v}\).

Note that (1) is well-posed for k outside a (possibly empty) discrete subset of \(\mathbb {R}_+\) [5, 11].

Remark 2

In the case where \({{\varGamma }_\mathrm{imp}}\) is the outer boundary of \(\varOmega \) and \({{\varGamma }_\mathrm{pc}}\) is the inner boundary of \(\varOmega \) (cf. Fig. 1), problem (1) can be used to model a truncated scattering problem where \({{\varGamma }_\mathrm{pc}}\) is the boundary of the scatterer(s) and the impedance boundary condition acts as an absorbing boundary condition [11, 18].

The rest of the paper is organized as follows. We first recall the Hodge decomposition approach to (1) in Sect. 2. We then develop an adaptive \(P_1\) finite element method in Sect. 3. Numerical results are presented in Sect. 4 and we end with some concluding remarks in Sect. 5.

Throughout this paper we use the notation \(x\lesssim y\) to represent the inequality \(x\le C_1 y\) and the notation \(x\approx y\) to represent the inequalities \(C_2y\le x\le C_1 y\), with constants \(C_1,C_2>0\) that do not depend on the mesh size but may depend on \(\epsilon \), \(\mu \), and k.

2 The Hodge Decomposition Approach

Let the nonnegative integer m be the Betti number of \(\varOmega \) (cf. Fig. 1). In the Hodge decomposition approach for (1), we write the electric field \(\varvec{u}\) as

$$\begin{aligned} \varvec{u}= \epsilon ^{-1}\nabla \times \phi + \sum _{j=1}^m c_j\nabla \varphi _j, \end{aligned}$$
(2)

where \(\phi \in H^1(\varOmega )\) satisfies \((\phi ,1)=0\) and the functions \(\varphi _1,\ldots ,\varphi _m\) are defined as follows.

Fig. 1
figure 1

Betti numbers for \(\varOmega \)

Let the outer boundary of \(\varOmega \) be denoted by \({\varGamma }_0\) and the m components of the inner boundary be denoted by \({\varGamma }_1,\ldots ,{\varGamma }_m\). Then the functions \(\varphi _j\in H^1(\varOmega )\) for \(1\le j\le m\) are determined by the scalar problems

$$\begin{aligned}&(\epsilon \nabla \varphi _j,\nabla v) = 0 \quad \forall \, v\in H^1_0(\varOmega ), \end{aligned}$$
(3a)
$$\begin{aligned}&\varphi _j|_{{\varGamma }_0} = 0\quad \text {and} \quad \varphi _j|_{{\varGamma }_l} = \delta _{jl} \quad \text {for}\;1\le l\le m, \end{aligned}$$
(3b)

where \(\delta _{jl} = 1\) if \(j=l\) and \(\delta _{jl} = 0\) if \(j\ne l\).

It was shown in [5, Section 2] that there exists a discrete subset \(S_+\) of \(\mathbb {R}_+\) such that the model problem (1) is uniquely solvable for \(k\in \mathbb {R}_+{\setminus } S_+\), in which case the function \(\phi \) in (2) is determined by

$$\begin{aligned} (\nabla \times \phi , \epsilon ^{-1}\nabla \times \psi ) =\frac{i}{k}\langle (\xi -g)/\lambda , \psi \rangle _{{\varGamma }_\mathrm{imp}}+ (\mu \xi ,\psi )\qquad \forall \,\psi \in H^1(\varOmega ) \end{aligned}$$
(4)

together with the constraint \((\phi ,1)=0\), and the function \(\xi =\mu ^{-1}\nabla \times \varvec{u}\in H^1(\varOmega )\) (which is the magnetic field multiplied by \(-ik\)) is determined by

$$\begin{aligned}&(\nabla \times \xi ,\epsilon ^{-1}\nabla \times \psi ) - k^2(\mu \xi ,\psi ) - i k\langle \xi /\lambda , \psi \rangle _{{\varGamma }_\mathrm{imp}}\nonumber \\&\quad = (\varvec{f}, \epsilon ^{-1}\nabla \times \psi ) - i k\langle g/\lambda , \psi \rangle _{{\varGamma }_\mathrm{imp}}\qquad \forall \,\psi \in H^1(\varOmega ). \end{aligned}$$
(5)

Remark 3

The discrete subset \(S_+\) (possibly empty) is determined by the well-posedness of the Fredholm problem (5). For \(k\in \mathbb {R}_+{\setminus } S_+\), the solution of (5) satisfies

$$\begin{aligned} (\mu \xi ,1)=\frac{i}{k}\langle (g-\xi )/\lambda , 1 \rangle _{{\varGamma }_\mathrm{imp}}, \end{aligned}$$
(6)

which then implies that the singular Neumann problem (4) is solvable.

In the case where \(m\ge 1\) the coefficients \(c_j\) in (2) are determined by the symmetric positive definite system

$$\begin{aligned} \sum _{j=1}^m (\epsilon \nabla \varphi _j,\nabla \varphi _l)c_j = -\frac{1}{k^2}(\varvec{f},\nabla \varphi _l)\qquad \text {for}\; 1\le l \le m. \end{aligned}$$
(7)

From now on we assume that \(k\in \mathbb {R}_+{\setminus } S_+\). We can then solve (1) numerically by the following \(P_1\) finite element method.

Let \(\mathcal {T}_\ell \) be a regular triangulation of \(\varOmega \) with mesh size \(h_\ell =\max _{T\in \mathcal {T}_\ell }h_T\), where \(h_T=\text {diam}\, T\), and let \(V_\ell \subset H^1(\varOmega )\) be the \(P_1\) finite element space associated with \(\mathcal {T}_\ell \). The space \(V_\ell \cap H^1_0(\varOmega )\) is denoted by \(\mathring{V}_\ell \).

First we find an approximate solution of (5) by computing \(\xi _\ell \in V_\ell \) such that

$$\begin{aligned}&(\nabla \times \xi _\ell ,\epsilon ^{-1}\nabla \times \psi _\ell ) - k^2(\mu \xi _\ell ,\psi _\ell ) - i k \langle \xi _\ell /\lambda , \psi _\ell \rangle _{{\varGamma }_\mathrm{imp}}\nonumber \\&\quad = (\varvec{f}, \epsilon ^{-1}\nabla \times \psi _\ell ) - i k \langle g/\lambda , \psi _\ell \rangle _{{\varGamma }_\mathrm{imp}}\qquad \forall \,\psi _\ell \in V_\ell . \end{aligned}$$
(8)

Then we find an approximate solution of (4) by replacing \(\xi \) with \(\xi _\ell \) and computing \(\phi _\ell \in V_\ell \) such that \((\phi _\ell ,1)=0\) and

$$\begin{aligned} (\nabla \times \phi _\ell , \epsilon ^{-1}\nabla \times \psi _\ell ) = \frac{i}{k}\langle (\xi _\ell -g)/\lambda , \psi _\ell \rangle _{{\varGamma }_\text {imp}} + (\mu \xi _\ell ,\psi _\ell )\qquad \forall \,\psi \in V_\ell . \end{aligned}$$
(9)

If \(\varOmega \) is not simply connected (\(m\ge 1\)), we find approximate solutions of (3a, 3b) by computing \(\varphi _{1,\ell },\ldots ,\varphi _{m,\ell }\in V_\ell \) such that

$$\begin{aligned}&(\epsilon \nabla \varphi _{j,\ell },\nabla v_\ell ) = 0 \qquad \forall \,v_\ell \in \mathring{V}_\ell , \end{aligned}$$
(10a)
$$\begin{aligned}&\varphi _{j,\ell }|_{{\varGamma }_0} = 0\quad \text {and} \quad \varphi _{j,\ell }|_{{\varGamma }_l} = \delta _{jl} \quad \text {for}\;1\le l\le m, \end{aligned}$$
(10b)

and then we find an approximate solution of (7) by replacing \(\varphi _j\) with \(\varphi _{j,\ell }\) and solving

$$\begin{aligned} \sum _{j=1}^m (\epsilon \nabla \varphi _{j,\ell },\nabla \varphi _{l,\ell })c_{j,\ell } = -\frac{1}{k^2}(\varvec{f},\nabla \varphi _{l,\ell })\quad \text {for } 1\le l\le m. \end{aligned}$$
(11)

The approximate solution of (1) is given by

$$\begin{aligned} \varvec{u}_\ell = \epsilon ^{-1}\nabla \times \phi _\ell + \sum _{j=1}^m c_{j,\ell }\nabla \varphi _{j,\ell }. \end{aligned}$$
(12)

The a priori error analysis of this \(P_1\) finite element method can be found in [5, Section 3].

Remark 4

The scalar functions \(\phi \) and \(\xi \) become vector fields for the Hodge decomposition in three dimensions and hence (1) will not be reduced to scalar problems.

3 An Adaptive \(P_1\) Finite Element Method

We will use the following notation in the a posteriori error analysis. Let \(\mathcal {E}_\ell \) (resp. \(\mathcal {E}_\ell ^i\)) denote the set of edges (resp. interior edges) and \(h_e\) denote the length of \(e\in \mathcal {E}_\ell \). For \(e\in \mathcal {E}_\ell ^i\), let \(T_\pm \in \mathcal {T}_\ell \) be the two neighboring triangles that share the edge e and \(\varvec{n}_\pm \) be the unit normal of E pointing towards the outside of \(T_\pm \). The normal jump of a piecewise smooth vector field \({\varvec{v}}\) across e is defined by \([\![\varvec{n}_e\cdot {\varvec{v}} ]\!]= \varvec{n}_{+}\cdot {\varvec{v}}_++\varvec{n}_{-}\cdot {\varvec{v}}_-\) and the tangential jump across e is defined by \([\![\varvec{n}_e\times {\varvec{v}} ]\!]=\varvec{n}_{+}\times {\varvec{v}}_++\varvec{n}_{-}\times {\varvec{v}}_-\), where \(\varvec{v}_\pm =\varvec{v}\big |_{T_\pm }\).

Using (2), (12) and the triangle inequality, it is straightforward (cf. [4, Lemma 1]) to show that

$$\begin{aligned} ||\varvec{u}-\varvec{u}_\ell ||_{L_2(\varOmega ;\epsilon )} \lesssim ||\epsilon ^{-1}\nabla \times (\phi -\phi _\ell ) ||_{L_2(\varOmega ;\epsilon )} + \sum _{j=1}^m ||\nabla \varphi _{j}-\nabla \varphi _{j,\ell } ||_{L_2(\varOmega ;\epsilon )}, \end{aligned}$$
(13)

where \(||\varvec{v} ||_{L_2(\varOmega ;\epsilon )}=\Big (\int _{\varOmega } (\epsilon \varvec{v})\cdot \bar{\varvec{v}}\,dx\Big )^\frac{1}{2}\).

The following estimate for the second term on the right-hand side of (13) is also standard (cf., for example, [10, Section 3.2.1] and the references therein).

Lemma 1

Let \(\varphi _{j,\ell }\in V_\ell \), \(j=1,\ldots ,m\), be the solutions of (10a, 10b). We have

$$\begin{aligned} ||\nabla (\varphi _{j}-\varphi _{j,\ell }) ||_{L_2(\varOmega ;\epsilon )}^2 \lesssim \sum _{T\in \mathcal {T}_\ell } h_T^2 ||\nabla \cdot (\epsilon \nabla \varphi _{j,\ell }) ||_{L_2(T)}^2 + \sum _{e\in \mathcal {E}_\ell ^i}h_e||[\![\varvec{n}_e\cdot \epsilon \nabla \varphi _{j,\ell } ]\!] ||_{L_2(E)}^2. \end{aligned}$$

The next lemma provides an estimate for the first term on the right-hand side of (13).

Lemma 2

Let \(\phi _\ell \) be the solution of (9). We have

$$\begin{aligned}&||\epsilon ^{-1}\nabla \times (\phi -\phi _\ell ) ||_{L_2(\varOmega ;\epsilon )}^2 \lesssim \sum _{T\in \mathcal {T}_\ell } h_T^2||\mu \xi _\ell - \nabla \times (\epsilon ^{-1}\nabla \times \phi _\ell ) ||_{L_2(T)}^2\\&\qquad +\sum _{e\in \mathcal {E}_\ell ^i}h_e||[\![\varvec{n}_e\times (\epsilon ^{-1}\nabla \times \phi _\ell ) ]\!] ||_{L_2(e)}^2 + \sum _{e\subset {{\varGamma }_\mathrm{pc}}} h_e||{\varvec{n}}\times (\epsilon ^{-1}\nabla \times \phi _\ell ) ||_{L_2(e)}^2\\&\qquad +\sum _{E\subset {{\varGamma }_\mathrm{imp}}} h_e||{\varvec{n}}\times (\epsilon ^{-1}\nabla \times \phi _\ell ) + \frac{i}{k}(\xi _\ell - g)/\lambda ||_{L_2(e)}^2\\&\qquad + ||\xi -\xi _\ell ||_{L_2(\varOmega )}^2 + ||\xi -\xi _\ell ||_{L_2({{\varGamma }_\mathrm{imp}})}^2, \end{aligned}$$

where \(\xi _\ell \) is the solution of (8).

Proof

It follows from (4) that

$$\begin{aligned}&||\epsilon ^{-1}\nabla \times (\phi -\phi _\ell ) ||_{L_2(\varOmega ;\epsilon )}^2\\&\quad = -(\epsilon ^{-1}\nabla \times \phi _\ell , \nabla \times (\phi -\phi _\ell )) +\frac{i}{k}\langle (\xi -g)/\lambda , \phi -\phi _\ell \rangle _{{\varGamma }_\text {imp}}+(\mu \xi ,\phi -\phi _\ell )\\&\quad = \, \text {Res}_\ell (\phi -\phi _\ell ) +\frac{i}{k}\langle (\xi -\xi _\ell )/\lambda , \phi -\phi _\ell \rangle _{{\varGamma }_\text {imp}} +(\mu (\xi -\xi _\ell ),\phi -\phi _\ell ), \end{aligned}$$

where

$$\begin{aligned} \text {Res}_\ell (\psi )= \frac{i}{k}\langle (\xi _\ell -g)/\lambda , \psi \rangle _{{\varGamma }_\mathrm{imp}}+ (\mu \xi _\ell ,\psi )-(\epsilon ^{-1}\nabla \times \phi _\ell , \nabla \times \psi ) \qquad \forall \,\psi \in H^1(\varOmega ). \end{aligned}$$

Hence we have

$$\begin{aligned}&||\epsilon ^{-1}\nabla \times (\phi -\phi _\ell ) ||_{L_2(\varOmega ;\epsilon )}^2 \le ||\text {Res}_\ell ||_{*}||\nabla \times (\phi -\phi _\ell ) ||_{L_2(\varOmega )}\nonumber \\&\qquad + ||\mu (\xi -\xi _\ell ) ||_{L_2(\varOmega )}||\phi -\phi _\ell ||_{L_2(\varOmega )} +\frac{1}{k}||(\xi -\xi _\ell )/\lambda ||_{L_2({{\varGamma }_\mathrm{imp}})} ||\phi -\phi _\ell ||_{L_2({{\varGamma }_\mathrm{imp}})}, \end{aligned}$$
(14)

where \(\Vert \text {Res}_\ell \Vert _*=\sup _{\psi \in H^1(\varOmega )}{\text {Res}_\ell (\psi )}/{\Vert \psi \Vert _{H^1(\varOmega )}}\).

Since \((\phi -\phi _\ell ,1)=0\), we can apply a Poincaré-Friedrichs inequality and a trace inequality to deduce from (14) that

$$\begin{aligned} ||\epsilon ^{-1}\nabla \times (\phi -\phi _\ell ) ||_{L_2(\varOmega ;\epsilon )}\lesssim ||\text {Res}_\ell ||_{*} + ||\mu (\xi -\xi _\ell ) ||_{L_2(\varOmega )} + \frac{1}{k}||(\xi -\xi _\ell )/\lambda ||_{L_2({{\varGamma }_\mathrm{imp}})}, \end{aligned}$$

and it only remains to estimate \(\Vert \text {Res}_\ell \Vert _*\).

For any \(\psi _\ell \in V_\ell \), we have \(\text {Res}_\ell (\psi _\ell )=0\) because of (9). Integration by parts then leads to

$$\begin{aligned} \text {Res}_\ell (\psi )&=\text {Res}_\ell (\psi -\psi _\ell )\\&= \sum _{T\in \mathcal {T}_\ell } \int _T h_T(\mu \xi _\ell -\nabla \times (\epsilon ^{-1}\nabla \times \phi _\ell )) h_T^{-1}\overline{(\psi -\psi _\ell )} \, dx\\&\quad +\sum _{e\in \mathcal {E}_\ell ^i} \int _e h_e^{1/2}[\![\varvec{n}_e\times (\epsilon ^{-1}\nabla \times \phi _\ell ) ]\!]) h_e^{-1/2}\overline{(\psi -\psi _\ell )} \, ds\\&\quad + \sum _{e\subset {{\varGamma }_\mathrm{pc}}} \int _e h_e^{1/2}\left( {\varvec{n}}\times (\epsilon ^{-1}\nabla \times \phi _\ell ) \right) h_e^{-1/2}\overline{(\psi -\psi _\ell )}\, ds\\&\quad + \sum _{e\subset {{\varGamma }_\mathrm{imp}}} \int _e h_e^{1/2}\left( {\varvec{n}}\times (\epsilon ^{-1}\nabla \times \phi _\ell ) + \frac{i}{k}(\xi _\ell - g)/\lambda \right) h_e^{-1/2}\overline{(\psi -\psi _\ell )}\, ds. \end{aligned}$$

The estimate for \(\Vert \text {Res}_\ell \Vert _*\) (and the proof of the lemma) is completed by the Cauchy-Schwarz inequality after choosing \(\psi _\ell \in V_\ell \) such that (cf. [17])

$$\begin{aligned} \sum _{T\in \mathcal {T}_\ell }||h_T^{-1}(\psi -\psi _\ell ) ||_{L_2(T)}^2 + \sum _{e\in \mathcal {E}_\ell }||h_e^{-1/2}(\psi -\psi _\ell ) ||_{L_2(e)}^2 \lesssim ||\nabla \psi ||_{L_2(\varOmega )}^2. \end{aligned}$$

\(\square \)

Remark 5

If \(\varvec{f}\in [H^1(\varOmega )]^2\) and \(g\in H^\frac{1}{2}(E)\) for all the edges E of \(\varOmega \) that belong to \({{\varGamma }_\mathrm{imp}}\) (which is the case for all the numerical experiments in Sect. 4), then \(\Vert \xi -\xi _\ell \Vert _{L_2(\varOmega )}\) and \(\Vert \xi -\xi _\ell \Vert _{L_2({{\varGamma }_\mathrm{imp}})}\) are of higher order compared with \(\Vert \varvec{u}-\varvec{u}_\ell \Vert _{L_2(\varOmega )}\) (cf. [3, Remark 4.4] and [5, Theorem 3.8 and Corollary 3.3]).

Based on (13), Lemma 1, Lemma 2 and Remark 5, we define the local error indicator \(\eta _\ell (T)\) by

$$\begin{aligned} \eta _\ell ^2(T)&=\sum _{j=1}^m h_T^2 ||\nabla \cdot (\epsilon \nabla \varphi _{j,\ell }) ||_{L_2(T)}^2 + \sum _{j=1}^m\sum _{e\subset \partial T, e\in \mathcal {E}_\ell ^i}h_e||[\![\varvec{n}_e\cdot \epsilon \nabla \varphi _{j,\ell } ]\!] ||_{L_2(e)}^2 \nonumber \\&\quad +h_T^2||\mu \xi _\ell - \nabla \times (\epsilon ^{-1}\nabla \times \phi _\ell ) ||_{L_2(T)}^2 +\sum _{e\subset \partial T, e\in \mathcal {E}_\ell ^i}h_e||[\![\varvec{n}_e\times (\epsilon ^{-1}\nabla \times \phi _\ell ) ]\!] ||_{L_2(e)}^2 \nonumber \\&\quad + \sum _{e\subset \partial T, e\subset {{\varGamma }_\mathrm{pc}}} h_e||{\varvec{n}}\times (\epsilon ^{-1}\nabla \times \phi _\ell ) ||_{L_2(e)}^2 \nonumber \\&\quad + \sum _{e\subset \partial T, e\subset {{\varGamma }_\mathrm{imp}}} h_e||{\varvec{n}}\times (\epsilon ^{-1}\nabla \times \phi _\ell ) + \frac{i}{k}(\xi _\ell - g)/\lambda ||_{L_2(e)}^2, \end{aligned}$$
(15)

where the terms involving \(\xi -\xi _\ell \) are ignored. The global error estimator \(\eta _{\ell }\) then reads \( \eta _{\ell } =\left( \sum _{T\in \mathcal {T}_\ell } \eta _\ell ^2(T)\right) ^{1/2}\).

Remark 6

Under the conditions in Remark 5, the estimator \(\eta _{\ell }\) is reliable up to higher order terms. Its efficiency will be demonstrated by the numerical experiments in Sect. 4.

We can now use the adaptive loop

$$\begin{aligned} \text {Solve} \rightarrow \text {Estimate} \rightarrow \text {Mark} \rightarrow \text {Refine} \end{aligned}$$

to generate a sequence of triangulations \(\mathcal {T}_0,\mathcal {T}_1,\ldots \) with associated finite element spaces \( V_0\subsetneq V_1\subsetneq \ldots \subset V \) and approximate solutions \(\xi _\ell \) and \(\varvec{u}_\ell \) for \(\ell \ge 0\).

  • Solve The approximate solutions \(\xi _\ell \) and \(\varvec{u}_\ell \) on the mesh \(\mathcal {T}_\ell \) are computed by the procedure described in (8)–(12).

  • Estimate The error \(||\varvec{u}-\varvec{u}_\ell ||_{L_2(\varOmega ;\epsilon )}\) is estimated by the a posteriori error estimator \(\eta _{\ell }\) defined in (15).

  • Mark Based on the local refinement indicator \(\eta _\ell (T)\), the elements in \(\mathcal {T}_\ell \) are marked for refinement using a bulk criterion [7] with parameter \(0<\theta < 1\). It results in a minimal set \(\mathcal {M}_\ell \subset \mathcal {T}_\ell \) of marked triangles that satisfies

    $$\begin{aligned} \theta \sum _{T\in \mathcal {T}_\ell }\eta _\ell ^2(T)\le \sum _{T\in \mathcal {M}_\ell } \eta _\ell ^2(T). \end{aligned}$$
  • Refine Once a triangle is marked for refinement, all of its edges are marked for refinement. In a closure algorithm additional edges are marked for refinement such that if an edge of a triangle is marked for refinement, then the reference edge of that triangle is marked as well. After the closure algorithm has been applied the triangles are refined by one of the red-green-blue refinement rules depicted in Fig. 2.

Fig. 2
figure 2

Refinement rules: sub-triangles with corresponding reference edges depicted with a second edge

4 Numerical Experiments

In this section we present some numerical examples for the model problem (1) with inhomogeneous material parameters and sign changing \(\mu \). We also demonstrate the robustness of our method with the numerical results of a semiconductor simulation, a cloaking simulation and a flat lens simulation (where \(\epsilon \) also changes signs) that are not covered by the a priori analysis in [5] or the a posteriori analysis in Sect. 3. In all numerical experiments we take \(\lambda \) to be 1.

4.1 Inhomogeneous and Anisotropic Medium

The first example considers the square domain \(\varOmega = (-1,1)^2\) with inhomogeneous material parameters [9]

$$\begin{aligned} \epsilon = \left( \begin{array}{cc} 1+x^2 &{}\quad xy \\ xy &{}\quad 1+y^2 \end{array} \right) \qquad \text{ and } \qquad \mu =(1+x^2+y^2)^{-1}. \end{aligned}$$

For \(k=1\), we chose the analytic solution

$$\begin{aligned} u=\left( y/(x^2+y^2+0.02), -x/(x^2+y^2+0.02)\right) ^t, \end{aligned}$$

and compute \(\varvec{f}\) accordingly. The impedance boundary condition on \(\partial \varOmega \) is given by the exact solution. Figure 3 shows that both uniform and adaptive refinement lead to optimal \(\mathcal {O}(N_\ell ^{-1/2})\) convergence for the error \(||\varvec{u}-\varvec{u}_\ell ||_{L_2(\varOmega ;\epsilon )}\), where \(N_\ell \) is the dimension of \(V_\ell \). (Note that for uniform refinement \(N_\ell ^{-1/2}\approx h_\ell \).) The a posteriori error estimator \(\eta _{\ell }\) is empirically shown to be reliable and efficient. We also observe that the errors \(||\xi -\xi _\ell ||_{L_2(\varOmega )}\) and \(\Vert \xi -\xi _\ell \Vert _{L_2(\partial \varOmega )}\) (not shown) are of higher order for both uniform and adaptive mesh refinements.

Fig. 3
figure 3

Convergence history for the first example

4.2 L-Shaped Domain

The second example concerns the L-shaped domain \(\varOmega =(-1,1)^2\backslash [0,1]^2\) with sign changing \(\mu \). Such parameters occur in the study of metamaterials. For this example we chose \(\epsilon =1\), \(\mu =1\) in quadrant III and \(\mu =-1\) in quadrant II and IV. We chose the homogenous impedance boundary condition \(g=0\), the right-hand side \(\varvec{f}\) to be \((1,1)^t\), and the frequency k to be 1. Since the exact solution is unknown, we compute the errors by using a reference solution which is computed on a uniform refinement of the finest (adaptive) mesh.

The convergence history for the error \(||u-u_\ell ||_{L_2(\varOmega )}\) is shown in Fig. 4. Since the solution has a singularity at the origin, uniform refinement leads to sub-optimal convergence while adaptive refinement recovers optimal convergence \(\mathcal {O}(N_\ell ^{-1/2})\). Note that the errors \(||\xi -\xi _\ell ||_{L_2(\varOmega )}\) and \(\Vert \xi -\xi _\ell \Vert _{L_2(\partial \varOmega )}\) (not shown) are of higher order for both uniform and adaptive refinement.

Fig. 4
figure 4

Convergence history for the L-shaped domain

4.3 Doubly Connected Domain

The third example involves the doubly connected domain \(\varOmega =(-1,1)^2\backslash [-1/2,1/2]\). We chose \(\epsilon =1\), \(\mu =1\), \(k=1\), the homogenous impedance boundary condition \(g=0\) on the outer boundary and the homogeneous perfectly conducting boundary condition \({\varvec{n}}\times \varvec{u}= 0\) on the inner part of the boundary. As right-hand side we chose \(\varvec{f}=(e^{x_1},e^{x_2})^t\) so that the coefficient c in the Hodge decomposition for \(\varvec{u}\) is nonzero. Thus we have to solve three scalar equation for this example.

We approximate the unknown error as in the previous example and observe that uniform refinement leads to sub-optimal convergence rates as displayed in Fig. 5 for the error \(||\varvec{u}-\varvec{u}_\ell ||_{L_2(\varOmega )}\). In contrast, adaptive refinement leads to optimal convergence \(\mathcal {O}(N_\ell ^{-1/2})\). Note that in both cases \(||\xi -\xi _\ell ||_{L_2(\varOmega )}\) and \(\Vert \xi -\xi _\ell \Vert _{L_2({{\varGamma }_\mathrm{imp}})}\) (not shown) are of higher order.

Fig. 5
figure 5

Convergence history for the doubly connected domain

4.4 Semiconductor Simulation

In this example we demonstrate that the results in [3, 5] can be extended to the case where \(\epsilon \) is complex-valued. We consider a cavity problem where a conductor is wrapped inside a semiconductor. The domain \(\varOmega \) is the doubly connected domain \((-1,1)^2\backslash [-1/4,1/4]\). We take \(\epsilon \) to be 1 (resp. \(1+i/2\)) outside (resp. inside) the square \([-1/2,1/2]\). We choose \(\mu =1\), \(k=10\), \(\varvec{f} \equiv \mathbf{0}\) and the homogeneous perfectly conducting boundary condition on the inner boundary, and we use an impedance boundary condition on the outer boundary induced by the plane wave solution \(\varvec{p} e^{ik\varvec{d}\cdot \varvec{x}}\) with \(\varvec{d}=(1,0)^t\) and \(\varvec{p}=(0,1)^t\). The convergence history for this example is displayed in Fig. 6.

Fig. 6
figure 6

Convergence history for the semiconductor simulation

We observe that both uniform and adaptive refinements lead to optimal \(\mathcal {O}(N_\ell ^{-1/2})\) convergence for \(\varvec{u}_\ell \), which is different from the example in Sect. 4.3. The reasons are (i) the usual interface singularity for the Laplace operator [13] does not occur along the interface between the semiconductor and the vacuum, and (ii) the loss of energy inside the region occupied by the semiconductor (cf. Fig. 7) weakens the effects of the singularities at the reentrant corners of the inner boundary. Note that no reflections are visible in Fig. 7 due to the loss of energy.

As in the previous example \(||\xi -\xi _\ell ||_{L_2(\varOmega )}\) and \(\Vert \xi -\xi _\ell \Vert _{L_2({{\varGamma }_\mathrm{imp}})}\) (not shown) are of higher order.

Fig. 7
figure 7

Real values of the second component of \(\varvec{u}_\ell \) for the semiconductor simulation

Remark 7

The asymptotic efficiency indices for the first four examples are observed to be between 4 and 6.

4.5 Cloaking Simulation

The fifth example is for a cloaking simulation based on transformation optics [9, 16], where a perfectly conducting cylinder is wrapped by a cylindrical cloak of metamaterial. The domain \(\varOmega \) is the part of the square \((-1,1)^2\) outside the circle centered at the origin with radius \(R_1=1/4\), where a perfectly conducting boundary condition is imposed. We take \(\mu \) and \(\epsilon \) to be 1 outside a larger circle centered at the origin with radius \(R_2=1/2\). On the annular region \(\{x:\,R_1<|x|\le R_2\}\), the permeability and permittivity are defined by

$$\begin{aligned} \mu&= \left( \left( \frac{R_2-R_1}{R_2}\right) ^2\frac{r}{r-R_1} \right) ^{-1},\\ \epsilon _{xx}&= \left( \left( \frac{R_2-R_1}{R_2}\right) ^2 + \left( 1+2\left( \frac{R_2-R_1}{R_2}\right) ^2\frac{R_1}{r-R_1}\right) \sin ^2\theta \right) \mu ,\\ \epsilon _{xy}&= \epsilon _{yx} = -\left( \left( 1+2\left( \frac{R_2-R_1}{R_2}\right) ^2\frac{R_1}{r-R_1}\right) \sin \theta \cos \theta \right) \mu ,\\ \epsilon _{yy}&=\left( \left( \frac{R_2-R_1}{R_2}\right) ^2 + \left( 1+2\left( \frac{R_2-R_1}{R_2}\right) ^2\frac{R_1}{r-R_1}\right) \cos ^2\theta \right) \mu . \end{aligned}$$

The right-hand side \(\varvec{f}\) for this example is \(\mathbf{0}\) and the frequency k is 10. The impedance boundary condition on the outer boundary is induced by the plane wave solution \(\varvec{p} e^{ik\varvec{d}\cdot \varvec{x}}\), where \(\varvec{d}=(1,0)^t\) and \(\varvec{p}=(0,1)^t\).

The real part of the second component of the adaptive approximation is shown in Fig. 8. Note that the wave is moving from left to right and that the discrete solution near the right boundary (almost) looks as if the cylinder is not present, i.e., no reflections or shadows are visible. The plot in Fig. 8 is produced with roughly one hundred thousand degrees of freedom, while generating a similar plot with a uniform mesh will require roughly two million degrees of freedom.

Fig. 8
figure 8

Real values of the second component of \(\varvec{u}_\ell \) for the cloaking simulation

An adaptively refined mesh is displayed in Fig. 9 which shows stronger refinement in the region of the cloaking material, especially near the radius \(r=R_1\).

Fig. 9
figure 9

Adaptive mesh for the cloaking simulation

Remark 8

Note that the permittivity \(\epsilon \) is discontinuous at the circle with radius \(R_2\) and it is only positive semi-definite at the circle with radius \(R_1\). Moreover, the permeability \(\mu \) vanishes at the circle with radius \(R_1\) and hence \(\mu ^{-1}\) does not belong to \(L_\infty (\varOmega )\). Therefore \(\epsilon \) and \(\mu \) do not satisfy the assumptions underlying the a priori analysis in [5] and the a posteriori analysis in Sect. 3. Nevertheless the adaptive \(P_1\) finite element method still works for this example.

4.6 Flat Lens Simulation

For this experiment, \(\varOmega \) is the rectangular domain \((0,2)\times \left( -\frac{1}{2},\frac{1}{2} \right) \), \(\epsilon = 1\) and \(\mu = 1\) outside the rectangle \((7/16,39/32)\times \left( -\frac{1}{2},\frac{1}{2} \right) \) and \(\epsilon = -1.1\) and \(\mu = 1/\epsilon \) inside that rectangle. We chose \(k=30\), \(\varvec{f}=\mathbf{0}\) outside a small square of length 1 / 16 close to the left boundary and \(\varvec{f}=(0,-2000)^t\) inside that square. The boundary condition is the homogeneous impedance boundary condition.

This example simulates the refocusing effect of a flat lens using a negative index metamaterial with \(n=-1\) (cf. [15] and the references therein). The wave emitted from the point near the left boundary of the domain travels from left to right. Once the wave encounters a metamaterial interface it is refocused towards a point as displayed in Fig. 10. The results are similar to those obtained by time domain flat lens simulations [8, 20].

Figure 11 shows an adaptively refined mesh. Note that the mesh is more refined at the two vertical interfaces of the metamaterial.

Fig. 10
figure 10

Real values of the second component of \(\varvec{u}_\ell \) for the flat lens simulation. The rectangle with the negative index metamaterial is indicated with black lines

Fig. 11
figure 11

Adaptive mesh for the flat lens simulation

Remark 9

According to the theory in [5, Section 5], the model problem (1) on a simply connected domain with the impedance boundary condition and sign-changing \(\mu \) and \(\epsilon \) is a Fredholm problem if the following condition is satisfied: Given any \(w\in H^1_0(\varOmega )\) there exists \(\zeta _w\in H^1_0(\varOmega )\) such that

$$\begin{aligned} (\epsilon \nabla \zeta _w,\nabla v)=(\nabla w,\nabla v) \qquad \forall \,v\in H^1_0(\varOmega ). \end{aligned}$$

For the flat lens problem considered here, this condition can be verified through the theory developed in [1, 2, 14]. But the well-posedness of the discrete problems on adaptive meshes and the a priori and a posteriori analyses remain open. Nevertheless the adaptive \(P_1\) finite element method appears to also work for this example.

5 Concluding Remarks

By extending the Hodge decomposition approach to include the impedance boundary condition (which can act as an absorbing boundary condition), we are able to solve problems involving the propagation of electromagnetic waves in the frequency domain by solving simple scalar problems with the \(P_1\) finite element.

We have developed a reliable residual based error estimator for the \(P_1\) finite element method and demonstrated numerically that it is also efficient. The resulting adaptive algorithm exhibits optimal convergence in numerical experiments involving general material properties, general domains and general boundary conditions. Proving mathematically the local efficiency of the error estimator is an interesting open problem.

Furthermore we have demonstrated the robustness of the adaptive \(P_1\) finite element method by applying it successfully to a semiconductor problem, a cloaking problem and a flat lens problem whose settings are outside our theoretical framework.