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
Vec3points and directions.
Structs§
- Aabb
- Affine
- A rigid map from a parent frame to a local frame:
local = rot · p + disp. - BinTarget
- What
Model::instance_volumesaims for. - BinVolumes
- Volumes of sets of instances (
Model::instance_volumes), one per set. - Camera
- A camera:
width × heightpixels looking fromeyeattarget,upany vector not along the view direction, rays reachingreachcm. A pinhole withfov_degthe vertical field of view, or withorthothe height of the view (cm) seen straight on, every ray parallel.cutis 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
pwith(p - point)·normal > 0are 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 itsClips 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).
- Fingerprint
Diff - What
Model::fingerprint_difffinds.Displaygives 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
twhere it enters its first visible segment (INFINITYif none), that segment’s label id (orNO_HIT), the surface it enters through (NO_SURFACEwhen 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
Cutawaykeeps:tfromt0tot1, and the normal of the cut face the ray leaves the removed space through att0(facing the ray),Nonewhere the part starts at the ray’s own start. - Label
- The full description of where a point is.
- Lattice
- A lattice (
LAT=1orLAT=2): element[i,j,k]is element[0,0,0]shifted byi·a + j·b + k·c. - Line
- A line
origin + t·dirfortin[t_min, t_max].dirmust be a unit vector and the range finite. - Model
- A compiled model: read-only, shared by all query threads.
- Near
Surface - 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 thewith_*methods or by assigning fields. - Placed
Box - 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 returnError::Cancelledsoon afterProgress::cancel. - Segment
- One segment, for
Model::trace_line. - Skip
- What
Model::skipfinds for one visibility. - Slice
- A rectangle of a plane, sampled by
nx × nypixels: pointsorigin + a·u + b·vforain[0, width],bin[0, height].uandvare orthogonal unit vectors. Pixel rows run alongu; row 0 is at the top (largestb). - 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.
- Surface
Id - 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
ihas segmentsoffsets[i] .. offsets[i + 1], in order along the line, covering[t_min, t_max]without gaps (uncovered stretches are segments with statusStatus::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³.
- Volume
Grid - Lines over a region, in
probesindependent lattices of parallel lines.hsets the cost: as many lines as three families parallel to x, y and z with spacingh, so each probe’s lines arespacing= h·√(probes / 3)apart. - Volume
Target - What
Model::volumes_toaims 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.
- Grid
Mode - Which universes get an octree of candidate cells on top of their BVH.
- GroupBy
- What
Volumes::groupedadds up by. - Scope
- Which part of a model
Model::boundsandModel::extentcover. - Status
- How a point was classified.
- Subject
- What a
Diagnosticis about.
Constants§
- DEFAULT_
PRECISION - Default relative precision of every hashed value.
- DEFAULT_
PROBES - Probes of
VolumeGrid::newandVolumeGrid::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::savewrites (the header and the sections; what is inside them is tied toENGINE_HASH). - MAX_
LISTED_ INSTANCES - Instances up to which
Model::volumes_tolists every one byGroupBy::Label. - MAX_
PROBES - Probes at one spacing that
BinTarget::newallows (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
Ghostwhen the ray crossed no ghost boundary. - NO_HIT
- Label id of a ray that hits nothing.
- NO_
SURFACE surface_in/surface_outof a segment end that is not on a surface (the ends of the line).
Functions§
- spacing_
within - The spacing
hthat gives aboutlineslines through the union ofboxeswithinregion(asVolumeGrid::hcounts them: three axis-parallel familieshapart), forModel::volumes_within. The union’s area seen along each axis is measured on a raster of its projection, so overlapping boxes count about once.Nonewhen nothing of the boxes is withinregion.