Norming a gradient grad(u)

More
5 years 3 months ago #1738 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 ;) )
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
I uncommentet the not working line
More
5 years 3 months ago #1740 by joachim
Replied by joachim on topic Norming a gradient grad(u)
this was a bug, and the fix will be in the nightly release.

now you can replace it by
Code:
b = 1/Norm(b) * b

thx for the report,
Joachim
Time to create page: 0.118 seconds