fusionsc.geometry.Geometry

class fusionsc.geometry.Geometry(val=None, msgSize=1024, byReference=False)

Methods

__init__([val, msgSize, byReference])

Creates a new instance by either: - Allocating a new message of size msgSize (if val is None) - Storing a reference to the target (if byReference is set) - Copying the message from the given target (accepts Cap'n'proto messages, YAML strings, lists, dicts, and NumPy arrays)

asPolyMesh([triangulate])

Exports as a single merged polygon mesh.

asPyvista([reduce])

Convert the given geometry into a PyVista / VTK mesh Note Has asynchronous variant '.asnc(...)' that returns Promise[...]

cache(filename)

Note Has asynchronous variant '.asnc(...)' that returns Promise[...]

download()

For a geometry of 'ref' type, downloads the contents of the referenced geometry and wraps them in a new Geometry instance Note Has asynchronous variant '.asnc(...)' that returns Promise[...]

exportTo(filename[, binary, triangulate])

Saves the geometry to the given filename.

filter(filter)

Restricts the geometry to meshes where the given tags meet one (or more) specified values

from2D(r, z[, nPhi, phi1, phi2, close, tags])

Creates a geometry out of a 2D RZ array by wrapping it toroidally

fromFieldAligned(mapping, r0, phi0)

Transforms the mesh from a field-aligned coordinate system to real-space.

fromPyvista(polyData)

Creates a geometry from a pyvista.PolyData object

getMerged()

After merging the geometry, downloads the merged data and returns them Note Has asynchronous variant '.asnc(...)' that returns Promise[...]

getTags()

Note Has asynchronous variant '.asnc(...)' that returns Promise[...]

graph(**kwargs)

Visualizes the contents in a graph structure.

importFrom(filename)

Creates a geometry from a file (non-PLY loaded using meshio)

index([geometryGrid])

Computes an indexed geometry for accelerated intersection tests Note Has asynchronous variant '.asnc(...)' that returns Promise[...]

intersect(pStart, pEnd[, grid])

Computes a line intersection test Note Has asynchronous variant '.asnc(...)' that returns Promise[...]

load()

Loads an instance of this class from a previously written archive file.

merge()

Creates a merged geometry (all meshes combined into one big message) Note Has asynchronous variant '.asnc(...)' that returns Promise[...]

planarClip([phi, normal, center])

Computed a new geometry obtained by clipping the target geometry along the given plane (half space intersection) Note Has asynchronous variant '.asnc(...)' that returns Promise[...]

planarCut([phi, normal, center])

Computes a planar cut of the geometry along either a given plane or a given phi plane Note Has asynchronous variant '.asnc(...)' that returns Promise[...]

plotCut([phi, ax, plot])

Plot the phi cut of a given geometry in either the given axes or the current active matplotlib axes Note Has asynchronous variant '.asnc(...)' that returns Promise[...]

polyMesh(vertices, polyIndices)

Creates a polygon mesh from a [N, 3] array-like of vertices and a list of polygins (which is each a list of vertex indices)

ptree()

Prints a tree version of this object.

quadMesh(vertices[, wrapU, wrapV])

Creates a geometry out of a quad mesh

reduce([maxVerts, maxIndices])

Creates a new geometry with small meshes combined into a small number of large meshes Note Has asynchronous variant '.asnc(...)' that returns Promise[...]

resolve()

Returns a new geometry with all unresolved nodes replaced by their resolved equivalents.

rotate(angle, axis[, center])

Returns a new geometry rotated around the prescribed axis and center point

save(filename)

Saves the object into an archive file (including all referenced data)

scale([by])

Returns a geometry scaled by the given factor

toFieldAligned(mapping, r0, phi0)

Transforms the mesh from XYZ (or RPhiZ) real-space to a X'Y'Z' field-aligned coordinate system.

toYaml([flow])

Prints the contents as block-structured YAML

translate(dx)

Returns a new geometry shifted by the given vector

triangulate([maxEdgeLength])

Note Has asynchronous variant '.asnc(...)' that returns Promise[...]

unroll(phi1, phi2[, clip])

Note Has asynchronous variant '.asnc(...)' that returns Promise[...]

upload()

Note Has asynchronous variant '.asnc(...)' that returns Promise[...]

weightedSample(scale)

Converts the geometry into a point cloud Note Has asynchronous variant '.asnc(...)' that returns Promise[...]

withTags(extraTags)

Returns a new geometry with the given tags

Attributes

data

Underlying Cap'n'proto struct (usually a builder type).

type

Methods

Geometry.__init__(val=None, msgSize=1024, byReference=False)

Creates a new instance by either: - Allocating a new message of size msgSize (if val is None) - Storing a reference to the target (if byReference is set) - Copying the message from the given target (accepts Cap’n’proto messages,

YAML strings, lists, dicts, and NumPy arrays)

Geometry.asPolyMesh(triangulate: bool = False) → Any

Exports as a single merged polygon mesh.

Params:
  • triangluate: If set to true, polygons will be subdivided into triangles.

Returns (as tuple):
  • A [nPoints, 3] shaped array of points

  • A list[list[int]] holding all the polygon indices.

Note Has asynchronous variant ‘.asnc(…)’ that returns Promise[…]

Geometry.asPyvista(reduce: bool = True) → Any

Convert the given geometry into a PyVista / VTK mesh Note Has asynchronous variant ‘.asnc(…)’ that returns Promise[…]

Geometry.cache(filename) → Any

Note Has asynchronous variant ‘.asnc(…)’ that returns Promise[…]

Geometry.download() → Any

For a geometry of ‘ref’ type, downloads the contents of the referenced geometry and wraps them in a new Geometry instance Note Has asynchronous variant ‘.asnc(…)’ that returns Promise[…]

Geometry.exportTo(filename: str, binary=True, triangulate=True) → Any

Saves the geometry to the given filename. Supports ‘.ply’, ‘.stl’, and ‘.vtk’ files. Note Has asynchronous variant ‘.asnc(…)’ that returns Promise[…]

Geometry.filter(filter)

Restricts the geometry to meshes where the given tags meet one (or more) specified values

static Geometry.from2D(r, z, nPhi=100, phi1=None, phi2=None, close=True, tags={})

Creates a geometry out of a 2D RZ array by wrapping it toroidally

Geometry.fromFieldAligned(mapping, r0, phi0) → Any

Transforms the mesh from a field-aligned coordinate system to real-space. The mesh is assumed to be oriented so that its local XZ plane corresponds to the RZ plane at phi = phi0, Y axis corresponds to angles scaled by 2 * pi * r0, and Y-lines beign warped to conform to magnetic field lines.

This function can be used to design components in field-aligned coordinates and then quickly produce a mesh in real-space to check their structure and run magnetic field calculations.

The transform is the inverse of toFieldAligned(…).

Parameters: - mapping: Field line mapping to be used for the transform - r0: Radius to assume for the angle <-> Y’ axis conversion - phi0: Reference plane for the magnetic geometry in RZ direction

Returns: - Geometry in real-space coordinates

Note Has asynchronous variant ‘.asnc(…)’ that returns Promise[…]

static Geometry.fromPyvista(polyData)

Creates a geometry from a pyvista.PolyData object

Geometry.getMerged() → Any

After merging the geometry, downloads the merged data and returns them Note Has asynchronous variant ‘.asnc(…)’ that returns Promise[…]

Geometry.getTags() → Any

Note Has asynchronous variant ‘.asnc(…)’ that returns Promise[…]

Geometry.graph(**kwargs)

Visualizes the contents in a graph structure. Requires graphviz

static Geometry.importFrom(filename: str)

Creates a geometry from a file (non-PLY loaded using meshio)

Geometry.index(geometryGrid=None) → Any

Computes an indexed geometry for accelerated intersection tests Note Has asynchronous variant ‘.asnc(…)’ that returns Promise[…]

Geometry.intersect(pStart, pEnd, grid=None) → Any

Computes a line intersection test Note Has asynchronous variant ‘.asnc(…)’ that returns Promise[…]

Geometry.load() → Any

Loads an instance of this class from a previously written archive file.

Note Has asynchronous variant ‘.asnc(…)’ that returns Promise[…]

Geometry.merge() → Any

Creates a merged geometry (all meshes combined into one big message) Note Has asynchronous variant ‘.asnc(…)’ that returns Promise[…]

Geometry.planarClip(phi=None, normal=None, center=None) → Any

Computed a new geometry obtained by clipping the target geometry along the given plane (half space intersection) Note Has asynchronous variant ‘.asnc(…)’ that returns Promise[…]

Geometry.planarCut(phi=None, normal=None, center=None) → Any

Computes a planar cut of the geometry along either a given plane or a given phi plane Note Has asynchronous variant ‘.asnc(…)’ that returns Promise[…]

Geometry.plotCut(phi=0, ax=None, plot=True, **kwArgs) → Any

Plot the phi cut of a given geometry in either the given axes or the current active matplotlib axes Note Has asynchronous variant ‘.asnc(…)’ that returns Promise[…]

static Geometry.polyMesh(vertices, polyIndices)

Creates a polygon mesh from a [N, 3] array-like of vertices and a list of polygins (which is each a list of vertex indices)

Geometry.ptree()

Prints a tree version of this object. Requires the printree library.

static Geometry.quadMesh(vertices, wrapU=False, wrapV=False)

Creates a geometry out of a quad mesh

params:
  • vertices: A numpy array-like of shape [3, nU, nV] containing the individual vertices

  • wrapU: Whether to link the first and last slice of the “u” dimension

  • wrapV: Whether to link the first and last slice of the “v” dimension

Geometry.reduce(maxVerts=1000000, maxIndices=1000000) → Any

Creates a new geometry with small meshes combined into a small number of large meshes Note Has asynchronous variant ‘.asnc(…)’ that returns Promise[…]

Geometry.resolve() → Any

Returns a new geometry with all unresolved nodes replaced by their resolved equivalents. Note Has asynchronous variant ‘.asnc(…)’ that returns Promise[…]

Geometry.rotate(angle, axis, center=[0, 0, 0])

Returns a new geometry rotated around the prescribed axis and center point

Geometry.save(filename) → Any

Saves the object into an archive file (including all referenced data)

Note Has asynchronous variant ‘.asnc(…)’ that returns Promise[…]

Geometry.scale(by=1.0)

Returns a geometry scaled by the given factor

Geometry.toFieldAligned(mapping, r0, phi0) → Any

Transforms the mesh from XYZ (or RPhiZ) real-space to a X’Y’Z’ field-aligned coordinate system. The coordinates are chosen by 3 properties:

  • X’Y’ planes correspond to RZ planes, with Y’ = 2 * pi * r0 * (Phi - phi0)

  • If Phi = phi0 then X’ = R, Y’ = 0, Z’ = Z

  • Magnetic field lines point in Y’ direction

The transform is the inverse of fromFieldAligned(…).

Parameters: - mapping: Field line mapping to be used for the transform - r0: Radius to assume for the angle <-> Y’ axis conversion - phi0: Reference plane for the magnetic geometry in RZ direction

Returns: - Geometry in field aligned coordinates

Note Has asynchronous variant ‘.asnc(…)’ that returns Promise[…]

Geometry.toYaml(flow=False)

Prints the contents as block-structured YAML

Geometry.translate(dx)

Returns a new geometry shifted by the given vector

Geometry.triangulate(maxEdgeLength: float = 0) → Any

Note Has asynchronous variant ‘.asnc(…)’ that returns Promise[…]

Geometry.unroll(phi1: float, phi2: float, clip: bool = True) → Any

Note Has asynchronous variant ‘.asnc(…)’ that returns Promise[…]

Geometry.upload() → Any

Note Has asynchronous variant ‘.asnc(…)’ that returns Promise[…]

Geometry.weightedSample(scale: float) → Any

Converts the geometry into a point cloud Note Has asynchronous variant ‘.asnc(…)’ that returns Promise[…]

Geometry.withTags(extraTags)

Returns a new geometry with the given tags