Repository navigation
hexmesh 0.5.0
The launch release.
- For agents: structured, coded errors, and the
hexmeshcommand
(manifest,validate,estimate,describe,advise,apply,
build). It answers in JSON, and onlybuildneeds gmsh. - From plant data: PCF networks, with cut, join and merge, a shipped
sample and--insulation. - Validation: the manufactured-solution study is accepted, and no
published result went through a hex that gmshToFoam inverted. - Fittings: lateral tees (
Tee(angle=…)) and second-order export. - Breaking: Python 3.11 is the oldest supported.
Breaking: Python 3.10 is no longer supported (end of life, October
2026); 3.11 is the oldest (task 0113, decision 0039). CI tests 3.11 and
the newest 3.x.
A PCF sample ships with the package, and the commands read its
insulation (task 0114).
hexmesh.examples.applications.pcf_line: an insulated line, written
for hexmesh, from a vessel nozzle through a reducing tee, an elbow, a
concentric reducer and a bare valve.SAMPLEis its path, and it's in
the gallery. The README's PCF code reads it, so it runs as written:
35 712 cells, 28 800 bare.--insulationon everyhexmeshcommand that reads a network: on a
PCF file it meansto_assembly(insulation=True). On a description it
iscli_input_unreadable, since a description says where its
insulation is.- The README's quoted
equal_tee_unsupportederror is now what an
equal-tee variant of the sample gives, checked by a test.
Networks with a wye are faster to check (task 0112).
Wye.layoutkeeps its last 32 layouts, keyed on the wye's, the
frames' and the spec's values, and returns a copy of each.hexmesh adviseon the hero network halves, 2.9 s → 1.35 s: it builds
2 layouts instead of 5. Run as separate commands,validateand
estimateare unchanged, at one layout each.- In one Python process, the README's agent session (
validate,
estimate,advise,apply,validate) drops from about 6 s to
3.7 s, since the repeats no longer rebuild the wall. - Meshes are unchanged, byte for byte.
No validation result went through a hex that gmshToFoam turned inside
out (task 0108).
- The audit rebuilt every level of every case (199 meshes and side
meshes, 128 distinct) and counted the hexes gmshToFoam's orientation
test would flip. Four MMS wye levels would be flipped (32 hexes), and
all four were converted with-keepOrientation. Everything else
counts zero, and every mesh's worst scaled Jacobian is positive.
validation/tools/orientation_audit.py, results in its JSON. hexmesh.study.openfoam: newwould_invert(msh), which counts
those hexes on a written.mshwithout gmsh, andfoam_would_invert
andmsh_hexes. OpenFOAM v1912 and v2406 run the same test.- The validation drivers pass
keep_orientation=Truewhenever the
worst scaled Jacobian is positive. Eachcase.jsonsays so, under
toolchain.conversion.convert()'s default is unchanged. The
GUIDE's OpenFOAM section says when to pass it. - A study's case stage does the same. It converts with
-keepOrientationwhen the variant's worst scaled Jacobian is
positive. Otherwise it converts with the test on and warns
mesh_sj_not_positive: the mesh has an inverted corner.
The manufactured-solution study is accepted (task 0074; V1,
validation/mms/).
- Verified: the straight, bend, spline, stack change and
rectangular duct converge at the straight's order, and the wyes outside
their split region. The other fittings are reported. - The miter's first order is the scheme on its kinked grid lines:
least-squares gradients lift it to 1.67, the straight's 1.83 under the
same scheme. - The reducer, transition and tees stay near first order with either
gradient. Their wall faces keep a non-orthogonality that refinement
doesn't shrink (reducer median 21–24°), andfixedValuedoesn't
correct for it. Their geometry tightens (reducer, second order) or is
exact (transition). - The duct taps' cell aspect doesn't grow under refinement.
laplacianFoam's stall beyond k = 2 has a stopgap note in
docs/integrations/openfoam.md. study.openfoam.check_meshalso returnsmax_aspect_ratio.
The README's numbers are generated (task 0078).
docs/gallery/build.pyrewrites two marked blocks ofREADME.mdon
every run,--markdown-onlyincluded, and nothing else in the file:- the
insulated_teemetrics, frommetrics.json; - the validation table, one row per
case.json.
- the
case.jsongains an optionalheadline: the result in one line,
with its numbers from RESULTS.md. All 12 cases have one.- The validation table had drifted:
- it listed
rect_duct,square_bendandturbulent_pipeas planned
(they are accepted), and left outmmsandhelical_pipe(in
progress); - the stenosis line quoted an older reattachment length (11.12 D); the
accepted result is 10.97 D against the database's 11.03 D (−0.5 %); - the heated rod and Womersley lines quoted their gates (0.1 %, 1 %),
not the results (0.01 %, 0.31 %).
- it listed
- A cut-away hero image (
docs/gallery/img/hero.png,
build.py --hero):insulated_networkwith a quarter removed, so the
fluid core, the steel and the insulation show through the tee and the
wye. - New tests (
tests/test_readme.py):- the README's first code block builds the gallery's
insulated_tee,
with the cell count the metrics table quotes; a slow variant runs it
as written, meshing included; - every relative link and image in
README.md,docs/WHY.mdand
docs/GUIDE.mdresolves, anchors included; CITATION.cff's version matchespyproject.toml's.
- the README's first code block builds the gallery's
The light commands load neither gmsh nor scipy (decision 0040,
amendment 2026-11-07; task 0107).
- gmsh is imported on first use, through
hexmesh._gmsh;Session
imports it when it starts.scipy.interpolateis imported only where a
spline edge is meshed. import hexmesh.agenttakes 0.27 s, down from 0.52 s.hexmesh validateon a small network takes 0.37 s, down from 0.64 s.- Where gmsh can't load,
import hexmeshand every command butbuild
still work.buildandSessionraiseGmshUnavailable(an
ImportError, codegmsh_unavailable); its hint gives the install
command and, on Linux, the system libraries. - Meshes are unchanged: all 28 gallery examples are byte-identical.
Every user-facing error coded, internal errors marked (decision 0040;
task 0106).
- The last 21 user-reachable bare
ValueError,TypeError,
RuntimeErrorandNotImplementedErrorraises now carry codes. Each
keeps its built-in class, so existingexceptclauses still work:SpecUsageError(aRuntimeError) forPipeSpec.core()twice,
shell()beforecore(), and a spec with no core;ReaderFileNotFound(aFileNotFoundError) for a missing PCF file;study.openfoam.FoamCommandFailed(aRuntimeError) for a failed
OpenFOAM command;agent_input_type,fitting_declares_no_strategies,
quality_mode_unknownandopenfoam_value_uniform;check_supportedraisessection_not_supporteditself.
InternalError(codeinternal_invariant, aRuntimeError) marks
a failed internal check: a bug in hexmesh, not in the input. Its
message asks for a report. 21 former bare raises use it.- Three rejections fixed (found by the manifest's probe, task 0102):
- a
Switchon a circle now raisesswitch_needs_rectangle; it used
to raise anAttributeError; - a duct tap on a shelled H rectangle now raises
junction_shells_unsupported; it used to raise the internal Switch's
switch_changes_shells; - an unsupported section (
n_outer = 8) now raises
section_not_supportedinadd(), before aTeeorWyebuilds its
layout.
- a
- The support matrix now shows that a
Switchon a shelled rectangle is
supported; the probe had given it a shell-less outlet. - Hints: 58 of 443 coded raises had one; now 134 of 464 do. They are
in spec and section errors, the fittings' fit checks (each with the
length, angle, count orrotto use), the PCF and network builder, and
the CLI. For example,nang_not_divisiblesuggests "nang=4 or nang=6
(a multiple of 2)".
Laterals: Tee(angle=…) (decision 0031 stage 1; task 0060).
angle(degrees, default 90) leans the branch from the run's
downstream direction: 45 is a 45° lateral. The saddle is the exact
cylinder–cylinder intersection, shells included; walls stay on their
cylinders.angle=90meshes identically to before.- The room checks are measured on the acute side:
run_lengthmust
exceed the hole's reach downstream,branch_lengththe turning
station's distance along the leaning axis. - The predicted-quality tiers are unchanged and set the range: a 45°
lateral needs r/R ≥ 0.50, 35° needs 0.875, and 30° is rejected at every
ratio. Laterals below about 57° always warn. A lateral's message
names the smallest r/R that reaches the tier at its angle, and
run_length=Nonefalls back to the shortest run passing the minimum
when none reaches the warning tier. - New limit
TEE_MAX_RATIO(0.95). A pipe tee with r/R above it is
rejected (tee_ratio_above_max), and r = R isequal_tee_unsupported.
Up to 0.95 the meshed corner SJ is within 0.025 of the prediction; at
0.99 it was 0.30 against 0.57. - New codes
tee_angle_out_of_rangeandangle_on_duct_tap. Saved
tees now write"angle".
Structured errors (decision 0040; task 0094).
- Every error that bad input can cause is now a
hexmesh.HexmeshError.
It is still aValueError, and it carriescode,where,value,
limitandhint.err.to_dict()gives them as JSON data. - The layers raise their own subclasses:
SpecError,AssemblyError,
EquipmentError,LayoutError,ReaderErrorandStudyError.
FormerTypeErrors stayTypeErrors (SpecTypeError,
AssemblyTypeError,StudyTypeError). - Warnings are
hexmesh.HexmeshWarning(aUserWarning), with the same
fields. - Messages are unchanged. The codes are listed in
API.md.
A JSON Schema of the saved description, and limits as data
(decision 0040; task 0095).
hexmesh.agent.schema()returns a JSON Schema (draft 2020-12) of
Assembly.to_dict().python3 -m hexmesh.agent.schemaprints it.
It is generated from the registries, and every field has a type,
unit (x-unit), description, range and default.hexmesh.assembly.limits.LIMITSholds every limit as
Limit(value, unit, kind, doc); the module constants are unchanged.
The limits inline elsewhere moved into it: the miter cuts, the sweep
caps, the wye angle range and the venturi divergent range.- Four errors now name their limit in
limitinstead of giving its
value: an unresolvablen_layers, the wye angle, and the cosine and
venturi profile ranges. Messages are unchanged.
describe and preview (decision 0040; task 0097).
hexmesh.agent.describe(x)summarises anAssembly, its saved
description or aNetworkModelas JSON data, without GMSH:- for an assembly: fittings, open ends with their patch names,
junction angles, totals, andvalidate()'s warnings and error; - for a model: parts, connections, and the parts the builder would
reject.
- for an assembly: fittings, open ends with their patch names,
hexmesh.agent.preview(x, path)draws it to a deterministic PNG, in
three orthographic views and an isometric one. It needs the new
previewextra (matplotlib).
Resolution advice and the hexmesh command (decision 0040; task 0098).
hexmesh.agent.advise(asm, inputs)chooses the counts from the flow:
the fluid, a velocity or flow rate, an accuracy class, and a budget.
It explains each choice and returns a resolution table.
apply(description, table)writes the table into a description.- The counts come from
hexmesh/agent/calibration.json, generated
from the validation results. A class no case measured says
"validated": false. - Turbulent flow is graded to y⁺; it isn't validated yet.
- The counts come from
- The
hexmeshcommand:schema,validate,estimate,describe,
preview,advise,applyandbuild. It writes JSON with exit
codes 0, 1 and 2. - Validation results now record each level's
nang,nrad,nang_w
andnang_h.
hexmesh manifest: one account of the suite for agents (decision 0040;
task 0102).
hexmesh.agent.manifest()andhexmesh manifest: the commands (from
the CLI's parser), the workflow, a probed support matrix per fitting
and section,LIMITS,CODES, the advisor's classes and their basis,
the validation status per feature, and the conventions.- The support matrix and the validation summary are package data,
regenerated bypython3 -m hexmesh.agent._probeandpython3 -m validation.tools.summary; tests fail when either is stale. hexmeshis the console script apip installcreates;python3 -m hexmesh.agent.cliruns the same command without one.
Cut, join and merge network models (decision 0032; task 0066).
NetworkModel.select,cut,cut_at,joinand
NetworkModel.merge: break a network at a valve, build each side, and
join it back. Or merge two files and join them at their shared end.- Every cut, join and merge is logged in
model.log, after the
importer's entry.replayre-applies the log to a fresh import, and
undoreverts the last operation. - The builder leaves cut ports as open ends. It names an end at a cut,
or at a selection's boundary, from its port. Other names are
unchanged. - The readers moved to
hexmesh.interchange.importers, and
hexmesh.interchangeexportsread_pcfandread_bathymetry.
hexmesh.io.readersstill re-exports them. hexmesh validate | estimate | describe | preview | advise | build
read a.pcfwith--spec SPEC.json.
Shells around a rectangle keep unequal counts (decision 0041,
option B; task 0101).
- A stack of rectangular outlines no longer needs
nang_w = nang_h.
Every outline takes the core's(nang_w, nang_h), so a 2:1 duct with
a wall and lagging can be 8 × 4 throughout. - A stack with a circle and a rectangle, a circle ↔ rectangle
Transition, a round duct tap andBundleSpeckeep equal counts per
side: a circle carries one count. adviseno longer ties a stack of rectangles, and names the fitting
or layer that ties the counts.lagged_ductat "medium" goes from
936 000 to 526 500 cells.- Nothing that built before changes.
Second-order export (decision 0034; task 0076).
Assembly.mesh(order=2)(andwrite(..., order=2)) writes Hex27, or
Hex20 withincomplete=True, with the high-order nodes on the true
walls:- junction walls are re-projected;
- bends are placed exactly on their arcs.
Volume and wall area converge at order 4, against 2 for linear.
- An inverted second-order hex is an error naming the fitting.
- A
Wyeis rejected at order 2. write_openfoam(order=2)is refused, becausegmshToFoamreads
first-order elements only.