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)
I have two one questions regarding the output of this code (see link at bottom).
- 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.
- Is it possible to force v to be zero on the entirety of the left boundary?
Any help would be much appreciated!
[s]Link to image: https://github.com/blakseth/images/blob/main/indicator.PNG[/s]
Link to new image: images/indicator2.PNG at main · blakseth/images · GitHub