API Reference#
The high-level Draw() function is the easiest
entry point. The classes below let you compose custom scenes from individual
renderers.
Mesh rendering#
- class ngsolve_webgpu.mesh.MeshData(mesh, el2d_bitarray=None, el3d_bitarray=None)#
- set_needs_update()#
Update GPU data on next render call
- class ngsolve_webgpu.mesh.MeshWireframe2d(
- data: MeshData,
- label='MeshElements2d',
- clipping=None,
- symmetry=None,
- class ngsolve_webgpu.mesh.MeshElements2d(
- data: MeshData,
- clipping=None,
- colors: list | None = None,
- label='MeshElements2d',
Coefficient functions#
- class ngsolve_webgpu.cf.FunctionData(
- mesh_data: MeshData,
- cf: ngs.CoefficientFunction,
- order: int,
- order3d: int = -1,
- property component_param#
Shared GuiParam for component selection. Created on first access.
- property max_values#
Dict mapping component option value -> max. {-1: norm, 0: comp0, ...}
- property min_values#
Dict mapping component option value -> min. {-1: norm, 0: comp0, ...}
- set_needs_update()#
Set this data to be updated on the next render call
- class ngsolve_webgpu.cf.CFRenderer(
- data: FunctionData,
- component=None,
- label='CFRenderer',
- clipping: Clipping = None,
- colormap: Colormap = None,
- symmetry=None,
Use "vertices", "index" and "trig_function_values" buffers to render a mesh
- class ngsolve_webgpu.facet_cf.FacetFunctionData(
- mesh_data: MeshData,
- cf,
- order: int,
- deformation_cf=None,
Extract and pack CF values on element-boundary facets for GPU rendering.
- class ngsolve_webgpu.facet_cf.FacetCFRenderer(
- facet_data: FacetFunctionData,
- colormap: Colormap = None,
- clipping: Clipping = None,
- subdivision: int = 4,
- thickness: float = 0.008,
- label: str = 'FacetCFRenderer',
Render CF values on element-boundary facets as colored thick lines.
- class ngsolve_webgpu.facet_cf.FacetCFRenderer3D(
- mesh_data,
- cf,
- order,
- colormap=None,
- clipping=None,
- shrink=0.999,
- component=None,
Render CF on 3D element faces with slight shrink to reveal inter-element jumps.
Clipping#
- class ngsolve_webgpu.clipping.ClippingCF(
- data: FunctionData,
- clipping: Clipping = None,
- colormap: Colormap = None,
- component=-1,
- symmetry=None,
Vectors and isosurfaces#
- class ngsolve_webgpu.vectors.SurfaceVectors(
- function_data: FunctionData,
- grid_size: float = 20,
- clipping: Clipping = None,
- colormap: Colormap = None,
- symmetry=None,
- vector_symmetry='polar',
- scale_by_value: bool = False,
- class ngsolve_webgpu.vectors.ClippingVectors(
- function_data: FunctionData,
- grid_size: float = 20,
- clipping: Clipping = None,
- colormap: Colormap = None,
- symmetry=None,
- vector_symmetry='polar',
- scale_by_value: bool = False,
Geometry#
- class ngsolve_webgpu.geometry.GeometryRenderer(geo, label='Geometry', clipping=None, symmetry=None)#
Entity numbering#
- class ngsolve_webgpu.entity_numbers.EntityNumbers(
- data: MeshData,
- entity: str = 'vertices',
- font_size=20,
- clipping=None,
- zero_based=True,
Render numbers for mesh entities (vertices, edges, facets, surface/volume elements).
Positions are derived on the GPU from the mesh buffer. For edges and facets, a small connectivity buffer is uploaded on demand.
Picking#
- class ngsolve_webgpu.pick.MeshPickResult(event, mesh, options, kind='surface')#
Rich pick result for mesh-based renderers.
Decodes the raw SelectEvent user_data (2 x uint32) written by select2dElement / select3dElement / select_clipping shaders:
channel 2 = element instance id
channel 3 = region index (0-based)
- class ngsolve_webgpu.pick.GeoPickResult(event, geo, options)#
Pick result for geometry renderers (OCC faces/edges).
Select texture encoding from geo shaders:
channel 2 (uint32[0]) = geo_type: 0=vertex, 1=edge, 2=face
channel 3 (uint32[1]) = index (face/edge descriptor index)
- class ngsolve_webgpu.pick.HighlightUniforms(**kwargs)#
Symmetry#
- class ngsolve_webgpu.symmetry.Symmetry#
Defines geometric symmetry operations for rendering full solutions computed on a reduced domain.
- Usage:
sym = Symmetry() sym.mirror_x() # 2 copies sym.mirror_y() # 4 copies (group closure) renderer = CFRenderer(data, symmetry=sym)
- For fields with antisymmetric behavior under mirrors, specify parity:
sym_odd = sym.with_parity([-1, 1]) # odd under mirror_x, even under mirror_y
Jupyter helpers#
- ngsolve_webgpu.jupyter.Draw(
- obj: CoefficientFunction | Mesh | OCCGeometry | TopoDS_Shape,
- mesh: Mesh | None = None,
- name: str | None = None,
- width=600,
- height=600,
- order: int = 2,
- vectors=None,
- deformation=None,
- subdivision: int | None = None,
- contact: ContactBoundary | None = None,
- clipping: bool | dict | None = None,
- **kwargs,
NGSolve Draw command. Draws a CoefficientFunction or a Mesh with a set of options using the NGSolve webgpu framework.
Parameters#
- objngs.CoefficientFunction | ngs.Mesh
The CoefficientFunction or Mesh to draw.
- meshngs.Mesh | None
The mesh to draw. If obj is a CoefficientFunction, mesh is required.
- widthint
The width of the canvas.
- heightint
The height of the canvas.
- orderint
The order which is used to render the CoefficientFunction. Default is 2.