- Thank you received: 0
Norming a gradient grad(u)
5 years 3 months ago #1738
by mischl
Norming a gradient grad(u) was created by mischl
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 )
I uncommentet the not working line
Code:
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
Time to create page: 0.118 seconds