Hello all,
I am relatively new to NGSolve/NETGEN and came across the following problem:
A short description of what I am doing:
I am trying to solve Poisson’s Equation for a 3D model of a simple spine model I created with NETGEN. This should give me, for a given electric dipole in the spine, potentials on the surface of the spine. This is part of the forward problem so I then later can solve the inverse problem (e.g. with sLORETA)
After doing some basic definitions for my problem:
fes = H1(mesh, order = '1') # define Finite Element Space
u,v = fes.TnT() # define Trial and Test Space
sigma_coeff_ = {"spine" : 0.22, "vertebre" : 0.0014, "disc" : 0.008, "neck" : 0.01 , "trachea" : 0.015 , "oesophagus" : 0.015}
sigma_coeff = CoefficientFunction([sigma_coeff_[mat] for mat in mesh.GetMaterials()])
# create bounded X-elliptic bilinear form
a = BilinearForm(fes)
a += grad(v)*sigma_coeff*grad(u) * dx + 1e-8*sigma_coeff*u*v*dx
c = Preconditioner(a, "bddc")
# create bounded linear form
f = LinearForm(fes)
→ the changes of the linear form f are not in the code since they are not relevant ( I think) ←
I solved the equation with:
# Assemble equations
with TaskManager():
a.Assemble()
# Solve PDE
gfu = GridFunction(fes)
inv = CGSolver(a.mat, c.mat, printrates=False, precision=1e-8)
gfu.vec.data = inv * f.vec
So far this should do the trick but if there are more elegant ways please let me know!
Now to my first problem/question:
I only want the access some points of the GridFunction (those points where my electrodes will be placed). So when I write:
pnts_electrode = mesh(0,0,1)
val_gfu = gfu(pnts_electrode)
Is this the correct way to access the value of the GridFunction gfu at some point in the mesh that is closest to (0,0,1) ?
Somehow I get an error that my point is not in the mesh, although it should be.
Many thanks in advance!
Regards,
Markus