Hello!
I want to create an indicator function that is 1 on some chosen boundary segment and 0 elsewhere.
For this purpose, I have attempted to use a GridFunction defined using the following code:
from netgen.geom2d import unit_square
import ngsolve as ng
from ngsolve.webgui import Draw
domain = unit_square
mesh = ng.Mesh(domain.GenerateMesh(maxh=1./32))
fes = ng.H1(mesh, order=1, dirichlet="top|bottom|left|right")
v = ng.GridFunction(fes)
v.Set(1, definedon=mesh.Boundaries("top"))
Draw(v, mesh)
I have
two one question
s regarding the output of this code (see link at bottom).
1.
Why does the non-zero region extend so far into the domain interior? I would assume that it is at least possible for the elements not touching the boundary to be all zero.
2. Is it possible to force v to be zero on the entirety of the left boundary?
Any help would be much appreciated!
Best regards,
Sindre
Link to image:
github.com/blakseth/images/blob/main/indicator.PNG
Link to new image:
github.com/blakseth/images/blob/main/indicator2.PNG