Shape Function in H1 element

I have generated one tetrahedron element.

from netgen.csg import Pnt
from netgen.meshing import Element3D, Element2D, MeshPoint, FaceDescriptor, Mesh
mesh = Mesh()
mesh.dim = 3
dom = {}
dom[1] = mesh.Add(FaceDescriptor(bc=1,domin=1,surfnr=1))
v = []
v.append(mesh.Add(MeshPoint(Pnt(0,0,0))))
v.append(mesh.Add(MeshPoint(Pnt(1,0,0))))
v.append(mesh.Add(MeshPoint(Pnt(0,1,0))))
v.append(mesh.Add(MeshPoint(Pnt(0,0,1))))
mesh.Add(Element2D(dom[1], [v[0],v[1],v[2]]))
mesh.Add(Element2D(dom[1], [v[0],v[1],v[3]]))
mesh.Add(Element2D(dom[1], [v[1],v[2],v[3]]))
mesh.Add(Element2D(dom[1], [v[2],v[0],v[3]]))
mesh.Add(Element3D(dom[1], v))
import ngsolve
mesh = ngsolve.Mesh(mesh)

When I draw the function like

from ngsolve import *
fes1 = H1(mesh, order=3)
gfA = GridFunction(fes1)
ndof=fes1.ndof;
print([ndof])
from ngsolve.webgui import Draw
for m in [4,5]:
    print("Shape function ", m)
    gfA.vec[:] = 0
    gfA.vec[m] = 1
    Draw (gfA)

We can see contour plots when m=4, but not m=5. Are there any reason for this?

In my opinion it is a Drawing issue. Using a finer mesh to draw the Shape functions of the coarse mesh results in good plots for me:

  from netgen.csg import *
  from netgen.meshing import Element3D, Element2D, MeshPoint, FaceDescriptor, Mesh
  
  meshCoarse = Mesh()
  from ngsolve import *
  mesh.dim = 3
  dom = {}
  dom[1] = meshCoarse.Add(FaceDescriptor(bc=1,domin=1,surfnr=1))
  v = []
  v.append(meshCoarse.Add(MeshPoint(Pnt(0,0,0))))
  v.append(meshCoarse.Add(MeshPoint(Pnt(1,0,0))))
  v.append(meshCoarse.Add(MeshPoint(Pnt(0,1,0))))
  v.append(meshCoarse.Add(MeshPoint(Pnt(0,0,1))))
  meshCoarse.Add(Element2D(dom[1], [v[0],v[1],v[2]]))
  meshCoarse.Add(Element2D(dom[1], [v[0],v[1],v[3]]))
  meshCoarse.Add(Element2D(dom[1], [v[1],v[2],v[3]]))
  meshCoarse.Add(Element2D(dom[1], [v[2],v[0],v[3]]))
  meshCoarse.Add(Element3D(dom[1], v))
  
  meshCoarse = Mesh(meshCoarse)
  
  bottom = Plane(Pnt(0, 0, 0), Vec(0, 0, -1))
  left = Plane(Pnt(0, 0, 0), Vec(-1, 0, 0))
  front = Plane(Pnt(0, 0, 0), Vec(0, -1, 0))
  diag = Plane(Pnt(0, 0, 1), Vec(1, 1, 1))
  tet = bottom*left*front*diag
  
  geo = CSGeometry()
  geo.Add (tet)
  
  meshFine = Mesh(geo.GenerateMesh(maxh=0.2))
  
  
  print("Vol mesh1", Integrate(1, meshCoarse))
  print("Vol meshFine", Integrate(1, meshFine))
  
  
  
  
  fes1 = H1(meshCoarse, order=3)
  gfA = GridFunction(fes1)
  ndof=fes1.ndof;
  print([ndof])
  from ngsolve.webgui import Draw

  
  print(len(gfA.vec))
  
  
  
  for m in [0, 1, 2, 3, 4,5]:
      print("Shape function ", m)
      gfA.vec[:] = 0
      gfA.vec[m] = 1
      print("int mesh1", Integrate(gfA, meshCoarse))
      print("int meshFine", Integrate(gfA, meshFine))
      
      Draw(gfA, meshFine, "test")

image

yes this is just lacking visualization options. For these edge functions you can also give the order=3 parameter

Draw(gfA, order=3)

but higher order are not yet possible in webgui. Also subdivision is still missing (but hopefully coming soon). For this you could use the old desktop gui for now