# Visualisation of surface PDE solution

1 month 1 week ago #3635
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.

#### File Attachment:

File Name: surf_pde.py
File Size:1 KB

Best
Michael
##### Attachments:

1 month 1 week ago #3654 by mary
Thanks a lot - it's working now

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
But how do I get its norm and assign it to a gridfunction?

Thanks a lot
Marie-Therese

1 month 1 week ago #3655
With
u_0 = Normalize(grad(u))
#or equivalently
u_0 = 1/Norm(grad(u))*grad(u)

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.

Best
Michael

1 month 1 week ago #3656 by mary
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
Marie-Therese

1 month 1 week ago - 1 month 1 week ago #3657
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)
mesh.ngmesh.SetGeometry(geo)

Best
Christopher

1 month 5 days ago #3672 by mary
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.

Thanks!
Marie-Therese