Plotting L2 grid function in 3D


I am trying to plot a grid function from a 3D L2 space, and I am getting an error. Below is the test code. The error I get says

“VisualizeCoefficientFunction::GetSurfValue caught exception:
don’t know how I shall evaluate, vb = BNDVisualizeCoefficientFunction::GetSurfValue caught exception:”

If I create the mesh in 2D, the code works fine. Any idea of what could be going wrong here?

Thank you!


from ngsolve import *
from ngsolve.solvers import *
import ngsolve.meshes as ngm

mesh = ngm.MakeStructured3DMesh(hexes=True, nx=1, ny=3, nz=3)

order = 2
fes_V = VectorL2(mesh, order=order,dgjumps=True)

gf = GridFunction(fes_V)
exact_d = CoefficientFunction((x,y,z))


Hi Giselle,

L2-spaces don’t support boundary evaluation.
You can do

Draw (BoundaryFromVolumeCF (gfl2), mesh, "gf")

which evaluates the volume element behind the boundary element.

Just to avoid the exception, you can disable boundary drawing

Draw(gfl2, mesh, draw_surf=False)

and clip inside.


Thank you so much, this worked!