This page was generated from appendix-webgui/webgui.ipynb.
Webgui¶
Webgui is a jupyter-widget for visualizing mesh data, available from project page. It can be easily installed using
pip install webgui_jupyter_widgets
Webgui contains a rendering area, and a simple user interface (which can be opened by clicking on the black rectangle showing 'Open Controls').
You can rotate, move and zoom the object in the rendering area, and click to query properties.
Drawing geometry, meshes and fields:¶
[1]:
from netgen.occ import *
from ngsolve import *
from ngsolve.webgui import Draw
Drawing on OCC-shape:
[2]:
shape = Box( (0,0,0), (5,3,2) )
shape.faces.Max(X).name="right"
Draw (shape);
Drawing an NGSolve-mesh:
[3]:
mesh = Mesh( OCCGeometry(shape).GenerateMesh(maxh=0.5))
Draw (mesh);
Drawing a scalar function on the mesh:
[4]:
func = x*y*z
Draw (func, mesh);
Setting min-max values:¶
[5]:
Draw (x*y*z, mesh, min=5, max=10);
Deformation¶
[6]:
deform = CF( (-0.05*z*x,0,0.05*x*x) )
Draw (mesh, deformation=deform);
print ("use deformation slider:")
Draw (deform, mesh);
use deformation slider:
Clipping planes:¶
[7]:
clipping = { "function" : True, "pnt" : (2.5,1.5,1), "vec" : (0,1,-1) }
Draw (func, mesh, clipping=clipping);
Vector plots¶
[8]:
rotfunc = CF( (y-0.5, 0.5-x) )
usmesh = Mesh(unit_square.GenerateMesh(maxh=0.1))
Draw (rotfunc, usmesh, max=0.7, vectors={"grid_size" : 20, "offset" : 0.5 } );
Setting gui parameters¶
all parameters from the gui can be set by their displayed names, for example:
[9]:
Draw (func, mesh, settings = { "subdivision" : 1, "Colormap" : { "ncolors" : 3 } });
[ ]: