Skip to main content

Crate llevant

Crate llevant 

Source
Expand description

llevant: a fast geometry engine for MCNP constructive solid geometry.

Load a model with Model::load, then classify batches of points with Model::classify, trace batches of lines with Model::trace, find where rays first meet visible cells with Model::first_hits, and fingerprint cells and universes with Model::fingerprints. Views build on these: Model::slice traces a Slice of a plane row by row, and Model::render casts a Camera’s rays, and Model::volumes measures the volume of every label (and finds gaps and overlaps) on a VolumeGrid of lines.

Results refer to cells by index into Model::cells and to surfaces by compiled-surface index; Model::cell_id, Model::surface_id and Model::describe give the MCNP numbers. export gives a flat copy of the compiled model for other evaluators (the GPU renderer). Model::instances numbers the places each cell occupies (a cell of a universe that fills several cells, a lattice cell in each element), and Model::instance gives the instance holding a point. Model::save and Model::read keep a compiled model as bytes (for caches). draft moves a surface live while it is dragged (for interactive frontends; it may change in any 0.x release).

The engine answers geometry questions only: colouring hits and slices into images, and what materials look like, is the llevant-render crate.

Queries check their arguments and return Error rather than panic.

Re-exports§

pub use instance::ElementRange;
pub use instance::Instances;
pub use instance::NO_BIN;
pub use vec3::Vec3;
pub use migjorn;

Modules§

draft
Drafts: a surface moved while it is dragged, previewed live.
export
A flat copy of a compiled model for other evaluators (the GPU renderer).
instance
Cell instances: each place a cell occupies in the model, numbered.
reference
The reference the fast paths are tested against: classification and tracing by brute force (every cell of each universe a candidate, no boxes, BVH or octrees), and when two tracings agree.
vec3
Small helpers for Vec3 points and directions.

Structs§

Aabb
Affine
A rigid map from a parent frame to a local frame: local = rot · p + disp.
BinTarget
What Model::instance_volumes aims for.
BinVolumes
Volumes of sets of instances (Model::instance_volumes), one per set.
Camera
A camera: width × height pixels looking from eye at target, up any vector not along the view direction, rays reaching reach cm. A pinhole with fov_deg the vertical field of view, or with ortho the height of the view (cm) seen straight on, every ray parallel. cut is cut away from what it shows.
Cell
A compiled cell card.
Changed
What changed between a model and its recompiled version.
Changes
The differences of one kind of thing (cells or universes).
Classification
Classification of a batch of points: one label id per point, into labels.
Clip
A plane that cuts away the half-space its normal points into: points p with (p - point)·normal > 0 are removed from a render.
Converged
Groups refined towards a VolumeTarget (Model::volumes_to).
Cutaway
Space cut away from a render: the union of regions, each the intersection of the half-spaces its Clips remove. One region of one plane is a clip plane; others make wedges about an axis (Cutaway::wedge), boxes kept (Cutaway::keep_box) or removed (Cutaway::remove_box). A clip with a zero normal removes nothing.
Diagnostic
A problem found while compiling (an unsupported feature, an undefined reference, a duplicate card). It does not stop the compile: an affected cell is compiled as unsupported.
Digest
A BLAKE3 digest.
Fingerprint
The two digests of a cell or universe (see the module documentation).
FingerprintDiff
What Model::fingerprint_diff finds. Display gives a report, one line per change.
Fingerprints
Fingerprints of every cell and every universe of a model.
Ghost
The ghost boundaries a ray crossed before its hit (or all of them, when it hits nothing): how many, and the first one.
Group
Volume of a group of labels (Volumes::grouped).
Hits
First hits of a batch of rays: per ray, the t where it enters its first visible segment (INFINITY if none), that segment’s label id (or NO_HIT), the surface it enters through (NO_SURFACE when the ray starts inside), and that surface’s unit normal in the global frame, facing the ray (zero without a surface).
Kept
Part of a ray a Cutaway keeps: t from t0 to t1, and the normal of the cut face the ray leaves the removed space through at t0 (facing the ray), None where the part starts at the ray’s own start.
Label
The full description of where a point is.
Lattice
A lattice (LAT=1 or LAT=2): element [i,j,k] is element [0,0,0] shifted by i·a + j·b + k·c.
Line
A line origin + t·dir for t in [t_min, t_max]. dir must be a unit vector and the range finite.
Model
A compiled model: read-only, shared by all query threads.
NearSurface
The surface crossed nearest a point, from Model::nearest_surface.
Options
Options for compiling a model: start from Options::default() and change what you need, with the with_* methods or by assigning fields.
PlacedBox
The global box of one instance of a cell (Model::placed_boxes).
Progress
Steps done of a call’s total, and whether it should stop. Calls that take one (Model::volumes) set the total, count steps as they finish and return Error::Cancelled soon after Progress::cancel.
Segment
One segment, for Model::trace_line.
Skip
What Model::skip finds for one visibility.
Slice
A rectangle of a plane, sampled by nx × ny pixels: points origin + a·u + b·v for a in [0, width], b in [0, height]. u and v are orthogonal unit vectors. Pixel rows run along u; row 0 is at the top (largest b).
Stats
Summary numbers for reports and benchmarks.
Step
One level of a path: a cell, and the lattice element when the cell is a lattice.
SurfaceId
Where a compiled shape came from.
Target
What fills a cell or a lattice element: a universe, seen through a transform from the filled cell’s frame.
Tracing
Segments of a batch of lines, in ragged form: line i has segments offsets[i] .. offsets[i + 1], in order along the line, covering [t_min, t_max] without gaps (uncovered stretches are segments with status Status::Gap).
Unit
The cells of one universe and their search structure.
Veils
What a ray went through, seen as veils (Visibility::veil), before its hit (or along all of it, when it hits nothing).
Visibility
Which segments count as visible.
Volume
Volume of one label (or a group of labels), in cm³.
VolumeGrid
Lines over a region, in probes independent lattices of parallel lines. h sets the cost: as many lines as three families parallel to x, y and z with spacing h, so each probe’s lines are spacing = h·√(probes / 3) apart.
VolumeTarget
What Model::volumes_to aims for.
Volumes
Volumes per label, labels numbered by first occurrence along the lines (probes in order).

Enums§

Axis
A coordinate axis.
BoxCut
Where a box lies against a Cutaway (Cutaway::place_box).
Change
How a cell or universe (by MCNP number) differs between two models.
Cut
The box a universe opened on its own is cut to (Model::universe).
Depth
How deep labels go: down to the cells that are not filled, or to a universe level at most, as MCNP’s plotter shows LEVEL n.
Element
What lies in one lattice element.
Error
What can go wrong in a call to llevant. Problems in the MCNP input are not errors: they are Diagnostics, and the cells they affect are compiled as unsupported.
Fill
What fills a cell.
GridMode
Which universes get an octree of candidate cells on top of their BVH.
GroupBy
What Volumes::grouped adds up by.
Scope
Which part of a model Model::bounds and Model::extent cover.
Status
How a point was classified.
Subject
What a Diagnostic is about.

Constants§

DEFAULT_PRECISION
Default relative precision of every hashed value.
DEFAULT_PROBES
Probes of VolumeGrid::new and VolumeGrid::seeded.
ENGINE_HASH
Digest of this build of the engine: its source, version and dependency versions (build.rs). Saved models carry it, and a model saved by a build with another digest is not read. Caches put it in their keys.
FINGERPRINT_VERSION
Bumped whenever a change to llevant could change the segments of an unchanged input, or the canonical forms: digests of different versions never match.
FORMAT_VERSION
Version of the layout Model::save writes (the header and the sections; what is inside them is tied to ENGINE_HASH).
MAX_LISTED_INSTANCES
Instances up to which Model::volumes_to lists every one by GroupBy::Label.
MAX_PROBES
Probes at one spacing that BinTarget::new allows (max_probes): more probes cost less than a finer spacing for groups a little above their target, and beyond this a finer spacing is cheaper anyway.
NO_CELL
Cell of a Ghost when the ray crossed no ghost boundary.
NO_HIT
Label id of a ray that hits nothing.
NO_SURFACE
surface_in / surface_out of a segment end that is not on a surface (the ends of the line).

Functions§

spacing_within
The spacing h that gives about lines lines through the union of boxes within region (as VolumeGrid::h counts them: three axis-parallel families h apart), for Model::volumes_within. The union’s area seen along each axis is measured on a raster of its projection, so overlapping boxes count about once. None when nothing of the boxes is within region.

Type Aliases§

Result
Result with llevant’s Error.