Is there a standard way to visualize a mesh created using a python script?

Hello,

I would like to dive deeper into Anisotropic Meshes to get an understanding of the prismatic layer generation.

I adapted the script from the webpage: Mesh Size and Refinement — NGS-Py 6.2.1906 documentation

from netgen.csg import *
from ngsolve import *

existing code…

geo = CSGeometry()
box = OrthoBrick(Pnt(0,0,0),Pnt(1,1,1))
top = Plane(Pnt(0,0,0.52),Vec(0,0,1))
bot = Plane(Pnt(0,0,0.48),Vec(0,0,-1))
plate = box * top * bot

geo.Add((box-top).mat(“air”))
geo.Add(plate.mat(“plate”))
geo.Add((box-bot).mat(“air”))

slices = [2**(-i) for i in reversed(range(1,6))]
geo.CloseSurfaces(bot,top,slices)
nmesh = geo.GenerateMesh(maxh=0.3)
ZRefinement(nmesh,geo)

mesh = Mesh(nmesh)

VTK export

vtk = VTKOutput(mesh, filename=“mesh_visualization”)
vtk.Do()
print(“Mesh exported to mesh_visualization.vtu”)
print(“Open this file in ParaView to visualize”)

My problem is, that I can’t import the mesh successfully into Paraview to get a better idea of the result and start experimenting.

Is there another or even standard way to visualize a mesh created using a python script?

BR,
Klaus

Hi, you can just run the script with the netgen gui:

netgen myscript.py

and then use the Draw function to visualize the mesh

Best
Christopher