Dirichlet Lame Indirect Method

Dirichlet Lame Indirect Method#

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

Define the geometry \(\Omega \subset \mathbb R^3\) and create a mesh:

sp = Glue ( Sphere( (0,0,0), 1).faces)
mesh = Mesh( OCCGeometry(sp).GenerateMesh(maxh=1)).Curve(3)
Draw( mesh )
WebGLScene

Create test and trial function finite element spaces for \(H^{-\frac12}(\Gamma)\) according to the given mesh:

fesL2 = VectorValued(SurfaceL2(mesh, order=3, dual_mapping=False))
# fesL2 = VectorH1(mesh, order=3)
print (fesL2.ndof)
u,v = fesL2.TnT()
3360

Define Dirichlet data \(u_0\) and compute the right hand side vector:

p0 = CF( (2,2,2) )
X = CF( (x,y,z) )

E, nu = 210, 0.2
alpha = (1+nu)/((1-nu)*2*E)
norm = Norm(X-p0)
lapkernel = alpha/(4*pi) * 1/norm

u0 = (3-4*nu) * lapkernel * CF( (1,0,0) ) \
   + lapkernel/norm**2 * (X-p0) * (X-p0)[0] 
u0 *= 1000
rhs = LinearForm (u0*v.Trace()*ds(bonus_intorder=3)).Assemble()

Draw (u0, mesh)
WebGLScene
j = GridFunction(fesL2)
pre = BilinearForm(u*v*ds, diagonal=True).Assemble().mat.Inverse()

with TaskManager():
    V = LameSL(u*ds,E,nu) *v*ds
    CG(mat = V.mat, pre=pre, rhs = rhs.vec, sol=j.vec, tol=1e-8, maxsteps=100, initialize=False, printrates=True)
we know what we do - evaluateDeriv not implemented for dipoles in SingularMLExpansion
we know what we do - evaluateDeriv not implemented for dipoles in SingularMLExpansion
CG iteration 1, residual = 0.7606077059115475     
CG iteration 2, residual = 0.09170406274108531     
CG iteration 3, residual = 0.01999460773660455     
CG iteration 4, residual = 0.007391896571316929     
CG iteration 5, residual = 0.001310686445822047     
CG iteration 6, residual = 0.0006070847932383752     
CG iteration 7, residual = 0.00048356767184389824     
CG iteration 8, residual = 0.0006162054439692487     
CG iteration 9, residual = 0.0001949840594536254     
CG iteration 10, residual = 6.868587919008015e-05     
CG iteration 11, residual = 5.228338761663628e-05     
CG iteration 12, residual = 3.810124231330273e-05     
CG iteration 13, residual = 1.5701076228973533e-05     
CG iteration 14, residual = 1.7901632405025188e-05     
CG iteration 15, residual = 2.0794660708851807e-05     
CG iteration 16, residual = 1.3638046312395134e-05     
CG iteration 17, residual = 9.093264706180836e-06     
CG iteration 18, residual = 5.910982086916957e-06     
CG iteration 19, residual = 4.9426809790902995e-06     
CG iteration 20, residual = 4.3116185815101865e-06     
CG iteration 21, residual = 3.765108414064075e-06     
CG iteration 22, residual = 3.6058763228777395e-06     
CG iteration 23, residual = 1.8771355068181854e-06     
CG iteration 24, residual = 1.186047964131844e-06     
CG iteration 25, residual = 6.975842905597043e-07     
CG iteration 26, residual = 5.957668501829707e-07     
CG iteration 27, residual = 6.731271220895246e-07     
CG iteration 28, residual = 4.80139355562186e-07     
CG iteration 29, residual = 2.2937246516424812e-07     
CG iteration 30, residual = 2.0572958351908715e-07     
CG iteration 31, residual = 2.155606484011016e-07     
CG iteration 32, residual = 1.3240380459982628e-07     
CG iteration 33, residual = 1.632866716978615e-07     
CG iteration 34, residual = 1.1069728069014693e-07     
CG iteration 35, residual = 6.474813616860696e-08     
CG iteration 36, residual = 5.210062639965161e-08     
CG iteration 37, residual = 2.6346790320366244e-08     
CG iteration 38, residual = 4.467105273864252e-08     
CG iteration 39, residual = 2.5093178418417907e-08     
CG iteration 40, residual = 1.8486864748707882e-08     
CG iteration 41, residual = 1.7078196379866955e-08     
CG iteration 42, residual = 1.0403841809460065e-08     
CG iteration 43, residual = 7.103670714637564e-09     
Draw (j, order=3);
vismesh = (WorkPlane().RectangleC(4,4).Face()*Sphere((0,0,0),1)).GenerateMesh(maxh=0.1).Curve(4)
sol = GridFunction(VectorH1(vismesh,order=3))

SL = LameSL(u*ds(bonus_intorder=4), E, nu)(j)
# SL = (LameSL(u*ds(bonus_intorder=4), E, nu) * v*ds) . GetPotential(j)

sol.Set (SL, definedon=vismesh.Boundaries(".*"))
Draw (sol, vismesh, order=3);
Draw (u0, vismesh, order=3);
Draw (sol-u0, vismesh, order=3);