magnelio.mesh#

Mesh components. Mesh and MeshControl live in the core magnelio namespace; this component holds the grid container and face identification for custom setups.

class magnelio.mesh.BoxFace(value)#

Identifies one face of the simulation bbox by its outward normal.

The local (u, v) axes per face are chosen so u × v points into the simulation domain (matching the Poynting convention for forward modal waves).

property inward_sign: int#

+1 for MIN faces (inward = +axis); −1 for MAX faces.

property is_max: bool#

True for X_MAX / Y_MAX / Z_MAX faces.

property normal_axis: int#

Global axis index perpendicular to the face (0=x, 1=y, 2=z).

property u_axis: int#

Global axis index for the local-u tangential direction.

property v_axis: int#

Global axis index for the local-v tangential direction.

class magnelio.mesh.GridLines(x, y, z)#

Sorted node positions for a structured non-uniform hexahedral grid.

All coordinates are in meters.

The number of cells in each direction is len(x) - 1, etc.

Parameters:
  • x (np.ndarray) – Sorted array of x node positions, shape (Nx+1,).

  • y (np.ndarray) – Sorted array of y node positions, shape (Ny+1,).

  • z (np.ndarray) – Sorted array of z node positions, shape (Nz+1,).

property Nx: int#

Number of cells in x direction.

property Ny: int#

Number of cells in y direction.

property Nz: int#

Number of cells in z direction.

property courant_dt_max: float#

Maximum stable time step (Courant limit, safety factor = 1.0).

Use stability.courant_dt(grid, accuracy) for production use.

property dx: ndarray#

Cell sizes in x, shape (Nx,).

property dy: ndarray#

Cell sizes in y, shape (Ny,).

property dz: ndarray#

Cell sizes in z, shape (Nz,).

property n_cells: int#

Total number of cells.

class magnelio.mesh.GridPlanes(x=(), y=(), z=(), h_bulk=<factory>, dropped=<factory>, absorbed=<factory>, unplaced=<factory>, n_nodes=<factory>, pml_cells=<factory>, feature_gap=0.0)#

Provenance of every grid plane of a mesh, per axis.

Returned as mesh.planes by Mesh.from_geometry() (None on meshes built from a grid or loaded from an older store). print(mesh.planes) gives the report; as_dict() a JSON-serialisable form used by the store and by the example-model pins of the test suite.

Parameters:
  • x (tuple[PlaneRecord, ...])

  • y (tuple[PlaneRecord, ...])

  • z (tuple[PlaneRecord, ...])

  • h_bulk (dict[str, tuple[float, ...]])

  • dropped (dict[str, tuple[PlaneRecord, ...]])

  • absorbed (dict[str, tuple[PlaneRecord, ...]])

  • unplaced (dict[str, tuple[PlaneRecord, ...]])

  • n_nodes (dict[str, int])

  • pml_cells (dict[str, int])

  • feature_gap (float)

x, y, z

The planes of each axis in ascending order — the interval boundaries of the graded grid.

Type:

tuple of PlaneRecord

h_bulk#

The bulk cell size [m] of every interval of each axis (one entry fewer than planes).

Type:

dict of str to tuple of float

dropped#

Edge planes below the edge floor, reported by the mesher’s warning; gap holds the cell they would have created.

Type:

dict of str to tuple of PlaneRecord

absorbed#

Material planes merged into a neighbour by the hard min_cell_size floor.

Type:

dict of str to tuple of PlaneRecord

unplaced#

Requested planes that match no outcome. Empty in a consistent build; a non-empty list points at a rule that discards a plane without recording it.

Type:

dict of str to tuple of PlaneRecord

n_nodes#

Node count of each axis of the final grid (absorber cells included).

Type:

dict of str to int

pml_cells#

Absorber cells per domain face, as mesh.pml_cells.

Type:

dict of str to int

feature_gap#

The clustering tolerance [m] the planes were merged with.

Type:

float

classmethod from_dict(d)#

Inverse of as_dict().

Parameters:

d (dict)

Return type:

GridPlanes

as_dict(*, rounded=True)#

JSON-serialisable form (deterministic key order).

Parameters:

rounded (bool, default True) – Round positions to three decimals below the feature gap and cell sizes to four significant digits — the form the example-model pins are written in. False keeps every float verbatim (the store).

Return type:

dict

records(axis)#

The planes of one axis ("x", "y" or "z").

Parameters:

axis (str)

Return type:

tuple[PlaneRecord, …]

summary(scale_mm=True)#

Multi-line human-readable report (used by str()).

Parameters:

scale_mm (bool, default True) – Print lengths in millimetres; False prints metres.

Return type:

str

class magnelio.mesh.PlaneRecord(position, sources=(), node=None, singular=False, domain_end=False, h_fine=None, moved_to=None, gap=None)#

One grid plane (or one plane that did not make it into the grid).

Parameters:
  • position (float)

  • sources (tuple[PlaneSource, ...])

  • node (int | None)

  • singular (bool)

  • domain_end (bool)

  • h_fine (float | None)

  • moved_to (float | None)

  • gap (float | None)

position#

The merged plane coordinate [m] — the geometry position the grid line stands for, before absorber cells are appended and before a PMC face pulls its end node inwards.

Type:

float

sources#

Every rule and shape that asked for this plane, sorted.

Type:

tuple of PlaneSource

node#

Index of the plane’s node in mesh.grid.<axis>; None for planes that are not in the grid (dropped, absorbed, unplaced).

Type:

int or None

singular#

The plane holds a conductor edge with a field singularity and grades from the refined fine size.

Type:

bool

domain_end#

First or last plane of the axis (the domain bounding box).

Type:

bool

h_fine#

The fine cell size [m] the grading starts from at this plane.

Type:

float or None

moved_to#

Where the node actually sits when a PMC face pulled it inside the bounding box; None when the node is at position.

Type:

float or None

gap#

For a dropped edge plane: the cell it would have created [m].

Type:

float or None

property kinds: frozenset[str]#

The set of source kinds behind this plane.

class magnelio.mesh.PlaneSource(kind, shape=None, label='')#

One reason for a grid plane.

Parameters:
  • kind (str)

  • shape (int | None)

  • label (str)

kind#

"face" (analytic material face), "extent" (bounding-box extent of a shape), "edge" (a B-rep edge lying flat in the plane — a chamfer or fillet onset, a loft section), "sheet" (the grid plane of a thin metallisation), "wire" (a thin-wire vertex), "source" (a corner of a source’s total-field box), "symmetry" (a symmetry face with a position) or "forced" (MeshControl.forced_planes).

Type:

str

shape#

Index of the contributing shape in the model’s shape list; None for forced, source and symmetry planes.

Type:

int or None

label#

Human-readable shape label ("#1 Cylinder(pec)"), the face name of a symmetry plane ("xmin") or the name of a source.

Type:

str

classmethod parse(text)#

Inverse of __str__().

Parameters:

text (str)

Return type:

PlaneSource