# Differences between Webgui Draw and Paraview

Hi,

I tried a simple example from the tutorial and visualized with Draw and VTKOutput/Paraview.

Code:

``````from netgen.csg import CSGeometry, Plane, Pnt, Vec

geo = CSGeometry()

left  = Plane (Pnt(0,0,0), Vec(-1,0,0) )
right = Plane (Pnt(1,1,1), Vec( 1,0,0) )
front = Plane (Pnt(0,0,0), Vec(0,-1,0) ).bc("outer")
back  = Plane (Pnt(1,1,1), Vec(0, 1,0) ).bc("outer")
bot   = Plane (Pnt(0,0,0), Vec(0,0,-1) ).bc("outer")
top   = Plane (Pnt(1,1,1), Vec(0,0, 1) ).bc("outer")
cube =  left * right * front * back * bot * top
geo.PeriodicSurfaces(left,right)
geo.PeriodicSurfaces(front,back)
geo.PeriodicSurfaces(bot,top)

from ngsolve import *
mesh = Mesh(geo.GenerateMesh(maxh=0.3))

from ngsolve.webgui import Draw

fes = Periodic(H1(mesh,order=3,dirichlet="outer"))

u,v = fes.TrialFunction(), fes.TestFunction()

a = BilinearForm(fes,symmetric=True)

f = LinearForm(fes)
f += SymbolicLFI(x*v)

u = GridFunction(fes,"u")

a.Assemble()
f.Assemble()
u.vec.data = a.mat.Inverse(fes.FreeDofs()) * f.vec

Draw(u)

import ngsolve as ng
vtk = ng.VTKOutput(mesh,coefs=[u],names=["u"],filename="results/rve")
vtk.Do(time=0.0)
``````

What I don’t understand is the difference of the solution.
While the Draw looks symmetrical and smooth, Paraview’s result looks heavely influenced by the element shape.

Is there an option to get a similar picture in Paraview?
Are there Informations that Draw uses, that are not exported vie VTKOutput?

I would be very thankful for any help!

Best
Willi

It probably has something to do with the degree of the elements you are using. Paraview (as far as I know) will only visualize piecewise linear solutions. I believe Webgui Draw can visualize any degree polynomial solution. You are using degree 3.

When you save to VTK, NGSolve automatically “down-samples” it.

-Shawn

Based on this post:

Paraview should not be the issue. It seems more likely that NGSolve’s austomatical down-sampling seems the issue.
Any idea’s how to prevent this?

you can add order parameter to vtk output

``````vtkout = VTKOutput(..., order=2)
``````

or subdivision

``````vtkout = VTKOutput(..., subdivision=2)
``````

In my code I use:

So why is does

return:

``````NgException: Invalid element order: 3
``````

vtk output is only up to order 2 implemented, for better resolution you can combine it with subdivision.