from ngsolve import *

from mygeom import MakeMesh
mesh = MakeMesh()


V = H1(mesh, order=2, dirichlet=[1,2])  # Approximation space 

epsl = DomainConstantCF([1, 10])        # Dielectric coefficient

a = BilinearForm(V, symmetric=True)     # Bilinear form
a+= Laplace(epsl)

f = LinearForm(V)                       # Volume sources
f+= Source(0)

extendone = DomainConstantCF([1,0])     
u = GridFunction(V)
u.Set(extendone, BND)                   # Boundary sources in an extension

c = Preconditioner(a, type="direct", flags= { "inverse" : "sparsecholesky" })

a.Assemble()                            
f.Assemble()

# Give extension as input in u and get the full solution output in u:

BVP(bf=a, lf=f, gf=u, pre=c).Do()       # Solve boundary value problem 

Draw(u)                                 # Put solution in visual menu
