Hey, if I have e.g. in the following solution of the laplace equation and I want to use its gradient as a coefficient function, how to I scale it, I get dimension problems (I thnink I understand why but it doesnt help me to solve it )
import netgen.gui
from ngsolve import *
from netgen.geom2d import unit_square
mesh = Mesh(unit_square.GenerateMesh(maxh=0.2))
fes = H1(mesh, order=2, dirichlet="bottom|right")
u = fes.TrialFunction() # symbolic object
v = fes.TestFunction() # symbolic object
gfu = GridFunction(fes) # solution
a = BilinearForm(fes, symmetric=True)
a += grad(u)*grad(v)*dx
a.Assemble()
f = LinearForm(fes)
f += x*v*dx
f.Assemble()
gfu.vec.data = \
a.mat.Inverse(freedofs=fes.FreeDofs()) * f.vec
Draw(gfu)
b=-grad(gfu) #works obviously
#b=b/Norm(b) this line doesnt work
b=CoefficientFunction(b) #is that needed? I assume no
I uncommentet the not working line