Visualisation of surface PDE solution

Dear all,

I copy&pasted your surface_pde notebook and ran it as a py file - all works fine, except for the visualisation. I do see the mesh in the gui, but there is no solution (also when I click on the visual tab - I can’t find the solution ‘u’ even though it should be set). I do think that the program works fine otherwise - I can output the solution vector (all real numbers …), so I think something is not working for the visualisation (since also the other examples work - for example is fine and it shows the solution).
Is there anything else that I need to set for surface pdes?

Thanks a lot

Hi Marie-Therese,

if you want to run the code as a python file with Netgen you have to remove the line

from ngsolve.webgui import Draw

Otherwise the solutions will not be drawn.

Attached I copied parts of the surface pde tutorial into a python file, which draws the solution in Netgen.[sup][/sup]



Thanks a lot - it’s working now :slight_smile:

I actually have another question - is it possible to calculate the normalised gradient of u on the surface? So u is a solution of the surface Laplacian - how do I calc \nabla u /\lVert \nabla u \rVert?

I started with
gradu = grad(u).Trace()
But how do I get its norm and assign it to a gridfunction?

Thanks a lot


u_0 = Normalize(grad(u))
#or equivalently
u_0 = 1/Norm(grad(u))*grad(u)

you can normalize your solution.

If you want to set something into a GridFunction on the surface you have to use the syntax

gf.Set(..., definedon=mesh.Boundaries(".*")).

Otherwise the result will be zero.


Thank you so much - I used the HDivSurface space to interpolate it, so that’s fine.

Sorry to bother you with one more thing - I would like to solve the equation on a more complicated geometry. I imported the respective stl file into ngsolve and I meshed the domain. Can I just go ahead an use the surface mesh in the python file then - like import the stl and the mesh file?

Thanks a lot and good Easter weekend

Hi Mary,
you can do the meshing from python:

from netgen.stl import STLGeometry
from ngsolve import *
geo = STLGeometry(filename)
mesh = Mesh(geo.GenerateMesh(maxh=, ..., perfstepsend=MeshingStep.MESHSURFACE) )

this also only meshes the surface and no volume. To do this in the gui you can select meshing options → Last Step → Optimize Surface.

you can also load generated meshes, but the stl geometry is not stored with the mesh, so for example curving or refinement (that respects the true geometry) would not work, to allow this as well set the geometry:

mesh = Mesh(meshfile)
geo = STLGeometry(geofile)


Thanks a lot - I tried to load the stl a colleague sent me (he wants to mesh a hippo). I can load the geo, and it also looks like a hippo in NgSolve but when I load the file I get the following error

ERROR: TRIG 295 has 2 neighbours!!!
ERROR: TRIG 300 has 2 neighbours!!!
ERROR: TRIG 301 has 2 neighbours!!!
ERROR: TRIG 303 has 2 neighbours!!!
ERROR: TRIG 652 has 2 neighbours!!!
ERROR: TRIG 655 has 2 neighbours!!!
ERROR: TRIG 657 has 2 neighbours!!!
ERROR: TRIG 659 has 2 neighbours!!!

And a seg fault when I try to mesh it. I assume that something is wrong with the STL file - is there a way to find out what’s going on.


I just found a free online stl repair website - so I can mesh the hippo now!

Thanks a lot for all your help so far!