Laplace with Mixed Conditions

from ngsolve import *
from netgen.occ import *
from ngsolve.krylovspace import CG, GMRes
from ngsolve.webgui import Draw
from ngsolve.bem import *

keys: homogeneous Laplace bvp with mixed conditions, Calderon projector, Dirichlet data, Neumann data

Laplace with Mixed Conditions#

We consider an interior boundary value problem with mixed boundary conditions like this:

\( \begin{array}{r rcl r} & \Delta u &=& 0 &\mathrm{in}\; \Omega\,,\\ \textnormal{Dirichlet condition} & \gamma_0 u &=& m & \mathrm{on}\; \Gamma_0\,,\\ \textnormal{Neumann condition} & \gamma_1 u &=& j & \mathrm{on}\; \Gamma_1\,. \end{array} \)

\(\quad\quad\quad\)

The following representation formula for the solution \(u\) holds:

\[ x \in \Omega: \quad u(x) = \displaystyle{ \int\limits_\Gamma} \displaystyle{\frac{1}{4\,\pi}\, \frac{1}{\| x-y\|} } \, \gamma_1 u (y)\, \mathrm{d} s_y - \displaystyle{ \int\limits_\Gamma} \displaystyle{\frac{1}{4\,\pi}\, \frac{\langle n(y) , x-y\rangle }{\| x-y\|^3} } \, \gamma_0 u (y)\, \mathrm{d} s_y\,. \]

NGSolve solution

Define the geometry and the mesh:

topsphere = Sphere((0,0,0), 1) * Box((-1,-1,0),(1,1,1))
botsphere = Sphere((0,0,0), 1) - Box((-1,-1,0),(1,1,1))
topsphere.faces.name = "neumann"
botsphere.faces.name = "dirichlet"
shape = Fuse( [topsphere,botsphere] )

order = 3
mesh = Mesh(OCCGeometry(shape).GenerateMesh(maxh=0.25)).Curve(order)
Draw (mesh);

Define the finite element product space \(H^{\frac12}(\Gamma)\times H^{-\frac12}(\Gamma)\) with \(H^{\frac12}(\Gamma)\) conforming elements for the Dirichlet and \(H^{-\frac12}(\Gamma)\) for the Neumann trace.

# use L2 conform elements for the Neumann trace, label all dofs where Neumann data is given:
fesL2 = SurfaceL2(mesh, order=order-1, dirichlet="neumann")
# use H1 conform elements for the Dirichlet trace, label all dofs where Dirichlet data is given:
fesH1 = H1(mesh, order=order, dirichlet="dirichlet", definedon=mesh.Boundaries(".*"))

fes = fesH1 * fesL2
fes.ndof

uH1,uL2 = fes.TrialFunction()
vH1,vL2 = fes.TestFunction()

print ("ndofL2 = ", fesL2.ndof, "ndofH1 = ", fesH1.ndof, "ndof fes =", fes.ndof)
ndofL2 =  2736 ndofH1 =  2116 ndof fes = 4852

Compute and set the Dirichlet and the Neumann data:

uexa = CF(x)
mj = GridFunction(fes)
mjexa = GridFunction(fes)
mjexa.components[0].Interpolate(uexa, definedon=mesh.Boundaries(".*"))
mj.components[0].Set( mjexa.components[0], definedon=mesh.Boundaries("dirichlet")) # given Dirichlet data m

n = specialcf.normal(3)
gradn_uexa = CF((uexa.Diff(x), uexa.Diff(y), uexa.Diff(z))) * n

mjexa.components[1].Interpolate(gradn_uexa, definedon=mesh.Boundaries(".*"))
mj.components[1].Set( mjexa.components[1], definedon=mesh.Boundaries("neumann")) # given Neumann data j

Draw(mj.components[0], mesh, draw_vol=False);

Boundary Integral Equation

The Calderon projector relates the Dirichlet and the Neumann traces of the solution \(u\), i.e.,

\[\begin{split} \left( \begin{array}{c} \gamma_0 u \\ \gamma_1 u \end{array}\right) = \left( \begin{array}{cc} V & \frac12 - K \\ \frac12 + K^\intercal & D \end{array} \right) \left( \begin{array}{c} \gamma_1 u \\ \gamma_0 u \end{array}\right)\,, \end{split}\]

and we use it to solve for the Dirchlet trace on \(\Gamma_1\) and the Neumann trace on \(\Gamma_0\).

Compute boundary integral operators \(\mathrm{V}, \mathrm{K}, \mathrm{D}\) and the mass matrix \(\mathrm{M}\):

eps = 1e-6
intorder = 2 * order + 6
with TaskManager():
    V = LaplaceSL( uL2*ds ) * vL2*ds
    K = LaplaceDL( uH1*ds ) * vL2*ds
    D = LaplaceSL( curl(uH1)*ds ) * curl(vH1)*ds
    M = BilinearForm( uH1 * vL2 * ds(bonus_intorder=3)).Assemble()

Insert all given data in the Dirichlet-to-Neumann map and compute the right hand side vector:

with TaskManager():  
    rhs  = ((0.5 * ( M.mat + M.mat.T) + ( K.mat - K.mat.T) - V.mat - D.mat) * mj.vec).Evaluate()
    lhs = V.mat - K.mat + K.mat.T + D.mat 

Solve for the missing trace data:

with TaskManager():
    pre = BilinearForm( (uH1 * vH1 + uL2 * vL2) * ds(bonus_intorder=3) ).Assemble().mat.Inverse(freedofs=fes.FreeDofs())
    sol = GMRes(A=lhs, b=rhs, pre=pre, tol=1e-8, maxsteps=500)
GMRes iteration 1, residual = 112.3290025041915     
GMRes iteration 2, residual = 54.829167865703994     
GMRes iteration 3, residual = 19.95215874424285     
GMRes iteration 4, residual = 7.676443042754458     
GMRes iteration 5, residual = 5.913732488335805     
GMRes iteration 6, residual = 5.22432385083731     
GMRes iteration 7, residual = 4.6503923778215315     
GMRes iteration 8, residual = 3.7539555791204093     
GMRes iteration 9, residual = 2.8268745029691114     
GMRes iteration 10, residual = 2.0461142925326445     
GMRes iteration 11, residual = 1.7686496183311804     
GMRes iteration 12, residual = 1.576146878815298     
GMRes iteration 13, residual = 1.3880795333755203     
GMRes iteration 14, residual = 1.2495313358009166     
GMRes iteration 15, residual = 1.153034720870797     
GMRes iteration 16, residual = 1.049209165453428     
GMRes iteration 17, residual = 0.9284610287426481     
GMRes iteration 18, residual = 0.8213577570403819     
GMRes iteration 19, residual = 0.6749708581529229     
GMRes iteration 20, residual = 0.4767019289541812     
GMRes iteration 21, residual = 0.30758563013645457     
GMRes iteration 22, residual = 0.21252744016187164     
GMRes iteration 23, residual = 0.1467193002017252     
GMRes iteration 24, residual = 0.09874900899659829     
GMRes iteration 25, residual = 0.07934385195845436     
GMRes iteration 26, residual = 0.07394056273430497     
GMRes iteration 27, residual = 0.0717805871379147     
GMRes iteration 28, residual = 0.07036900176471528     
GMRes iteration 29, residual = 0.06840474128212357     
GMRes iteration 30, residual = 0.06256540065912618     
GMRes iteration 31, residual = 0.05068811435171124     
GMRes iteration 32, residual = 0.036583851048477396     
GMRes iteration 33, residual = 0.026633114718735227     
GMRes iteration 34, residual = 0.021558561459199654     
GMRes iteration 35, residual = 0.019495722831207568     
GMRes iteration 36, residual = 0.018667947138949446     
GMRes iteration 37, residual = 0.017946031747522403     
GMRes iteration 38, residual = 0.01746447422656091     
GMRes iteration 39, residual = 0.017201068264557265     
GMRes iteration 40, residual = 0.016775000157125186     
GMRes iteration 41, residual = 0.016329545547247123     
GMRes iteration 42, residual = 0.015829590443841843     
GMRes iteration 43, residual = 0.014668241992738836     
GMRes iteration 44, residual = 0.013480234686796884     
GMRes iteration 45, residual = 0.012090021051129177     
GMRes iteration 46, residual = 0.010495348653406924     
GMRes iteration 47, residual = 0.009554663116470406     
GMRes iteration 48, residual = 0.009057775635797969     
GMRes iteration 49, residual = 0.008734239064888289     
GMRes iteration 50, residual = 0.008477709731326463     
GMRes iteration 51, residual = 0.00818671042835216     
GMRes iteration 52, residual = 0.007683916777447101     
GMRes iteration 53, residual = 0.007076472659107241     
GMRes iteration 54, residual = 0.0067086081110468545     
GMRes iteration 55, residual = 0.006537509423690601     
GMRes iteration 56, residual = 0.006447591187313348     
GMRes iteration 57, residual = 0.006351433468161323     
GMRes iteration 58, residual = 0.006193068837203389     
GMRes iteration 59, residual = 0.005960156762070569     
GMRes iteration 60, residual = 0.005797103270319589     
GMRes iteration 61, residual = 0.005704193192398413     
GMRes iteration 62, residual = 0.005619281886648571     
GMRes iteration 63, residual = 0.005463709325688876     
GMRes iteration 64, residual = 0.005140944804664389     
GMRes iteration 65, residual = 0.00472859675714301     
GMRes iteration 66, residual = 0.004325655999676835     
GMRes iteration 67, residual = 0.0039599151337653005     
GMRes iteration 68, residual = 0.003557297778420034     
GMRes iteration 69, residual = 0.003172653042383673     
GMRes iteration 70, residual = 0.002993203873322764     
GMRes iteration 71, residual = 0.002927596038781512     
GMRes iteration 72, residual = 0.002883834597093741     
GMRes iteration 73, residual = 0.0028359813995184444     
GMRes iteration 74, residual = 0.002808758859540738     
GMRes iteration 75, residual = 0.0027870859644858314     
GMRes iteration 76, residual = 0.00274518163051264     
GMRes iteration 77, residual = 0.0026773707585778187     
GMRes iteration 78, residual = 0.002582136737515955     
GMRes iteration 79, residual = 0.0024679572951129738     
GMRes iteration 80, residual = 0.0022512871273128905     
GMRes iteration 81, residual = 0.0019898156532451032     
GMRes iteration 82, residual = 0.0018311542385626974     
GMRes iteration 83, residual = 0.001651794419221923     
GMRes iteration 84, residual = 0.0015243600896040566     
GMRes iteration 85, residual = 0.0014545635920244285     
GMRes iteration 86, residual = 0.0013915533482377407     
GMRes iteration 87, residual = 0.0013528729883346962     
GMRes iteration 88, residual = 0.0013364809609947828     
GMRes iteration 89, residual = 0.0013242854434929513     
GMRes iteration 90, residual = 0.001314940530007591     
GMRes iteration 91, residual = 0.0013035772070048514     
GMRes iteration 92, residual = 0.0012824315576458912     
GMRes iteration 93, residual = 0.0012441367542681064     
GMRes iteration 94, residual = 0.0011534916690414286     
GMRes iteration 95, residual = 0.0009981394695553361     
GMRes iteration 96, residual = 0.0008109124232151331     
GMRes iteration 97, residual = 0.0006668403030519294     
GMRes iteration 98, residual = 0.0006092749449048108     
GMRes iteration 99, residual = 0.0005865745972896663     
GMRes iteration 100, residual = 0.0005773171048784162     
GMRes iteration 101, residual = 0.0005726430500996531     
GMRes iteration 102, residual = 0.000567859182119556     
GMRes iteration 103, residual = 0.0005585358361657408     
GMRes iteration 104, residual = 0.0005361912454769883     
GMRes iteration 105, residual = 0.0004955757364829176     
GMRes iteration 106, residual = 0.0004547479012098443     
GMRes iteration 107, residual = 0.0004281514582408992     
GMRes iteration 108, residual = 0.0004183380521863665     
GMRes iteration 109, residual = 0.0004138178063053356     
GMRes iteration 110, residual = 0.000409396694728521     
GMRes iteration 111, residual = 0.00040060090179476444     
GMRes iteration 112, residual = 0.0003748235824984793     
GMRes iteration 113, residual = 0.0003309143486567003     
GMRes iteration 114, residual = 0.0002821410025672858     
GMRes iteration 115, residual = 0.00025070066642878067     
GMRes iteration 116, residual = 0.0002325862434891192     
GMRes iteration 117, residual = 0.00022360712772439837     
GMRes iteration 118, residual = 0.00021789815807006133     
GMRes iteration 119, residual = 0.0002153594330548935     
GMRes iteration 120, residual = 0.00021405061522536696     
GMRes iteration 121, residual = 0.0002128068372813419     
GMRes iteration 122, residual = 0.00021010612432914875     
GMRes iteration 123, residual = 0.00020409959286102052     
GMRes iteration 124, residual = 0.00019669733664858042     
GMRes iteration 125, residual = 0.00018875430108486964     
GMRes iteration 126, residual = 0.00018122080350305237     
GMRes iteration 127, residual = 0.00017572564112415323     
GMRes iteration 128, residual = 0.00017132693549645292     
GMRes iteration 129, residual = 0.0001690218587843808     
GMRes iteration 130, residual = 0.00016670323982378256     
GMRes iteration 131, residual = 0.0001611647887492855     
GMRes iteration 132, residual = 0.0001493092577224429     
GMRes iteration 133, residual = 0.0001314784303372227     
GMRes iteration 134, residual = 0.00011614751246272972     
GMRes iteration 135, residual = 0.00010597826325636267     
GMRes iteration 136, residual = 0.00010031394078601842     
GMRes iteration 137, residual = 9.821598845683368e-05     
GMRes iteration 138, residual = 9.746214585775476e-05     
GMRes iteration 139, residual = 9.692399860350809e-05     
GMRes iteration 140, residual = 9.610781422092448e-05     
GMRes iteration 141, residual = 9.459854769817359e-05     
GMRes iteration 142, residual = 9.304822150486569e-05     
GMRes iteration 143, residual = 9.077759139029725e-05     
GMRes iteration 144, residual = 8.722885016353331e-05     
GMRes iteration 145, residual = 8.291875229969461e-05     
GMRes iteration 146, residual = 7.894304301690904e-05     
GMRes iteration 147, residual = 7.538790906360292e-05     
GMRes iteration 148, residual = 7.321156451621429e-05     
GMRes iteration 149, residual = 7.221355781957582e-05     
GMRes iteration 150, residual = 7.163221996327708e-05     
GMRes iteration 151, residual = 7.045962286796909e-05     
GMRes iteration 152, residual = 6.749453252183543e-05     
GMRes iteration 153, residual = 6.13955136255766e-05     
GMRes iteration 154, residual = 5.27771266165618e-05     
GMRes iteration 155, residual = 4.569336238571664e-05     
GMRes iteration 156, residual = 4.28905626849992e-05     
GMRes iteration 157, residual = 4.229621199083973e-05     
GMRes iteration 158, residual = 4.212638083488797e-05     
GMRes iteration 159, residual = 4.199618235382009e-05     
GMRes iteration 160, residual = 4.1810377642908164e-05     
GMRes iteration 161, residual = 4.137600316992999e-05     
GMRes iteration 162, residual = 3.9246824037165045e-05     
GMRes iteration 163, residual = 3.406807705727562e-05     
GMRes iteration 164, residual = 3.0399147714260343e-05     
GMRes iteration 165, residual = 2.86575492949875e-05     
GMRes iteration 166, residual = 2.8090221108652465e-05     
GMRes iteration 167, residual = 2.7922908295949526e-05     
GMRes iteration 168, residual = 2.7773860294310114e-05     
GMRes iteration 169, residual = 2.7538809575173866e-05     
GMRes iteration 170, residual = 2.7296772426887254e-05     
GMRes iteration 171, residual = 2.6969673603143667e-05     
GMRes iteration 172, residual = 2.6302376306546348e-05     
GMRes iteration 173, residual = 2.507612097035655e-05     
GMRes iteration 174, residual = 2.3572631774171878e-05     
GMRes iteration 175, residual = 2.2742027946266574e-05     
GMRes iteration 176, residual = 2.2430037491072994e-05     
GMRes iteration 177, residual = 2.231266880125366e-05     
GMRes iteration 178, residual = 2.2246173193544694e-05     
GMRes iteration 179, residual = 2.2146553738254012e-05     
GMRes iteration 180, residual = 2.196356110633712e-05     
GMRes iteration 181, residual = 2.1483707796999556e-05     
GMRes iteration 182, residual = 2.0301712375042427e-05     
GMRes iteration 183, residual = 1.765931961753596e-05     
GMRes iteration 184, residual = 1.4868699238916477e-05     
GMRes iteration 185, residual = 1.3489621460264062e-05     
GMRes iteration 186, residual = 1.3075117425982133e-05     
GMRes iteration 187, residual = 1.2912890398448073e-05     
GMRes iteration 188, residual = 1.2819556872601218e-05     
GMRes iteration 189, residual = 1.2739681910121863e-05     
GMRes iteration 190, residual = 1.2635533101981428e-05     
GMRes iteration 191, residual = 1.2411286118503598e-05     
GMRes iteration 192, residual = 1.1845087128765244e-05     
GMRes iteration 193, residual = 1.0869297284518466e-05     
GMRes iteration 194, residual = 1.0134434844980407e-05     
GMRes iteration 195, residual = 9.808928897357162e-06     
GMRes iteration 196, residual = 9.67953220675352e-06     
GMRes iteration 197, residual = 9.594717598624406e-06     
GMRes iteration 198, residual = 9.520752318284521e-06     
GMRes iteration 199, residual = 9.461303300233324e-06     
GMRes iteration 200, residual = 9.33466761181364e-06     
GMRes iteration 201, residual = 8.92189216240833e-06     
GMRes iteration 202, residual = 7.732142390807427e-06     
GMRes iteration 203, residual = 6.321424010186317e-06     
GMRes iteration 204, residual = 5.0050569575293416e-06     
GMRes iteration 205, residual = 4.458327357313938e-06     
GMRes iteration 206, residual = 4.289179331281138e-06     
GMRes iteration 207, residual = 4.241809828507647e-06     
GMRes iteration 208, residual = 4.22745978510494e-06     
GMRes iteration 209, residual = 4.211022321839545e-06     
GMRes iteration 210, residual = 4.148782444651646e-06     
GMRes iteration 211, residual = 3.981373788142593e-06     
GMRes iteration 212, residual = 3.6887457290226383e-06     
GMRes iteration 213, residual = 3.3401278224814077e-06     
GMRes iteration 214, residual = 3.0788931073118796e-06     
GMRes iteration 215, residual = 2.966339316186559e-06     
GMRes iteration 216, residual = 2.9163262640567723e-06     
GMRes iteration 217, residual = 2.879021646365044e-06     
GMRes iteration 218, residual = 2.8508954136595976e-06     
GMRes iteration 219, residual = 2.825117125347111e-06     
GMRes iteration 220, residual = 2.7605509670036706e-06     
GMRes iteration 221, residual = 2.5177027462866305e-06     
GMRes iteration 222, residual = 2.025365191661312e-06     
GMRes iteration 223, residual = 1.7009142645764692e-06     
GMRes iteration 224, residual = 1.5984468830400746e-06     
GMRes iteration 225, residual = 1.5652975753048796e-06     
GMRes iteration 226, residual = 1.5532800789428834e-06     
GMRes iteration 227, residual = 1.5471722033345065e-06     
GMRes iteration 228, residual = 1.5377872520063731e-06     
GMRes iteration 229, residual = 1.5170649920435598e-06     
GMRes iteration 230, residual = 1.4808887114929538e-06     
GMRes iteration 231, residual = 1.4152618958476652e-06     
GMRes iteration 232, residual = 1.2783025258955362e-06     
GMRes iteration 233, residual = 1.196001479840233e-06     
GMRes iteration 234, residual = 1.1751693182908263e-06     
GMRes iteration 235, residual = 1.1675166100055105e-06     
GMRes iteration 236, residual = 1.161089161231788e-06     
GMRes iteration 237, residual = 1.149426962813205e-06     
GMRes iteration 238, residual = 1.1103736668034526e-06     
GMRes iteration 239, residual = 9.711411278437074e-07     
GMRes iteration 240, residual = 8.329523626654288e-07     
GMRes iteration 241, residual = 7.731936400999927e-07     
GMRes iteration 242, residual = 7.401939552498969e-07     
GMRes iteration 243, residual = 7.284270349941683e-07     
GMRes iteration 244, residual = 7.242286901873298e-07     
GMRes iteration 245, residual = 7.205359097993664e-07     
GMRes iteration 246, residual = 7.140903831066094e-07     
GMRes iteration 247, residual = 6.909375584385336e-07     
GMRes iteration 248, residual = 6.228516223967743e-07     
GMRes iteration 249, residual = 5.642883432143708e-07     
GMRes iteration 250, residual = 5.425431912249144e-07     
GMRes iteration 251, residual = 5.375606809397396e-07     
GMRes iteration 252, residual = 5.360446911045682e-07     
GMRes iteration 253, residual = 5.344896395683573e-07     
GMRes iteration 254, residual = 5.31765382981677e-07     
GMRes iteration 255, residual = 5.261041400066825e-07     
GMRes iteration 256, residual = 5.069896362977944e-07     
GMRes iteration 257, residual = 4.6403994762649276e-07     
GMRes iteration 258, residual = 4.0046177728992086e-07     
GMRes iteration 259, residual = 3.5703831142612283e-07     
GMRes iteration 260, residual = 3.342241929784057e-07     
GMRes iteration 261, residual = 3.241389102789008e-07     
GMRes iteration 262, residual = 3.2048693170810193e-07     
GMRes iteration 263, residual = 3.185710539993618e-07     
GMRes iteration 264, residual = 3.158484513043732e-07     
GMRes iteration 265, residual = 3.066037343450232e-07     
GMRes iteration 266, residual = 2.8184350748577504e-07     
GMRes iteration 267, residual = 2.5657304669552645e-07     
GMRes iteration 268, residual = 2.446196854918401e-07     
GMRes iteration 269, residual = 2.400653752024321e-07     
GMRes iteration 270, residual = 2.3832492506736467e-07     
GMRes iteration 271, residual = 2.3739310138473116e-07     
GMRes iteration 272, residual = 2.3573635131856328e-07     
GMRes iteration 273, residual = 2.3101589411884605e-07     
GMRes iteration 274, residual = 2.14550924658647e-07     
GMRes iteration 275, residual = 1.9519565098065075e-07     
GMRes iteration 276, residual = 1.8888516342803348e-07     
GMRes iteration 277, residual = 1.8674523487711826e-07     
GMRes iteration 278, residual = 1.8562780252409944e-07     
GMRes iteration 279, residual = 1.840854886207203e-07     
GMRes iteration 280, residual = 1.8102096267129903e-07     
GMRes iteration 281, residual = 1.7063047523352403e-07     
GMRes iteration 282, residual = 1.4786997782045105e-07     
GMRes iteration 283, residual = 1.2102062401161708e-07     
GMRes iteration 284, residual = 1.0203935503690185e-07     
GMRes iteration 285, residual = 9.462998989931017e-08     
GMRes iteration 286, residual = 9.244054212168169e-08     
GMRes iteration 287, residual = 9.186121646094816e-08     
GMRes iteration 288, residual = 9.157610935632046e-08     
GMRes iteration 289, residual = 9.086959564267078e-08     
GMRes iteration 290, residual = 8.767197250277042e-08     
GMRes iteration 291, residual = 8.04411461162057e-08     
GMRes iteration 292, residual = 7.269873788821698e-08     
GMRes iteration 293, residual = 6.858449569802438e-08     
GMRes iteration 294, residual = 6.726522981738178e-08     
GMRes iteration 295, residual = 6.683100305429219e-08     
GMRes iteration 296, residual = 6.659620190818444e-08     
GMRes iteration 297, residual = 6.616354370032474e-08     
GMRes iteration 298, residual = 6.522647826831453e-08     
GMRes iteration 299, residual = 6.186721746590297e-08     
GMRes iteration 300, residual = 5.109277767528133e-08     
GMRes iteration 301, residual = 3.9614652416682244e-08     
GMRes iteration 302, residual = 3.569661531015805e-08     
GMRes iteration 303, residual = 3.490677276898829e-08     
GMRes iteration 304, residual = 3.463891909719154e-08     
GMRes iteration 305, residual = 3.4460401982230607e-08     
GMRes iteration 306, residual = 3.425993708488798e-08     
GMRes iteration 307, residual = 3.370495762643005e-08     
GMRes iteration 308, residual = 3.249931176361678e-08     
GMRes iteration 309, residual = 2.991365960858445e-08     
GMRes iteration 310, residual = 2.5606067142684446e-08     
GMRes iteration 311, residual = 2.3236215613995052e-08     
GMRes iteration 312, residual = 2.2701282208551863e-08     
GMRes iteration 313, residual = 2.2540376487934464e-08     
GMRes iteration 314, residual = 2.244661739667838e-08     
GMRes iteration 315, residual = 2.2381171096911592e-08     
GMRes iteration 316, residual = 2.2143871165788328e-08     
GMRes iteration 317, residual = 2.1275000496410035e-08     
GMRes iteration 318, residual = 1.839650823895445e-08     
GMRes iteration 319, residual = 1.4758250741970312e-08     
GMRes iteration 320, residual = 1.3487168414250897e-08     
GMRes iteration 321, residual = 1.3257343136592911e-08     
GMRes iteration 322, residual = 1.3198745569506478e-08     
GMRes iteration 323, residual = 1.3144244391701873e-08     
GMRes iteration 324, residual = 1.2959693453856798e-08     
GMRes iteration 325, residual = 1.1748096302537037e-08     
GMRes iteration 326, residual = 9.778266879210675e-09     

Have a look at the Neumann data on \(\Gamma_0\) and compute the error:

gf = GridFunction(fes)
gf.vec[:] = sol
gfj = gf.components[1]
print ("Neumann error =", sqrt(Integrate(Norm(gfj + mj.components[1] - mjexa.components[1])**2, mesh.Boundaries(".*"), BND)))
Draw (gfj, mesh.Boundaries("dirichlet"));
Neumann error = 0.0003008600858528418

Have a look at the Dirichlet data on \(\Gamma_1\) and compute the error:

gfm = gf.components[0]
print ("Dirichlet error =", sqrt(Integrate(Norm(gfm + mj.components[0] - mjexa.components[0])**2, mesh.Boundaries(".*"), BND)))
Draw (gfm, mesh.Boundaries("neumann"));
Dirichlet error = 7.886510364732493e-06

Postprocessing on screen

screen = WorkPlane(Axes((0,0,0), Z, X)).RectangleC(0.5,0.5).Face()
screen.faces.name="screen"
mesh_screen = Mesh(OCCGeometry(screen).GenerateMesh(maxh=0.1)).Curve(1)
fes_screen = H1(mesh_screen, order=13)
gf_screen = GridFunction(fes_screen)
SLPotential = LaplaceSL(uL2*ds(bonus_intorder=intorder))
DLPotential = LaplaceDL(uH1*ds(bonus_intorder=intorder))
repformula = SLPotential(gf) - DLPotential(gf) + SLPotential(mj) - DLPotential(mj)
with TaskManager():
    gf_screen.Set(repformula, definedon=mesh_screen.Boundaries("screen"), dual=False)
Draw(gf_screen)
BaseWebGuiScene