Skip to content

hexmesh 0.8.0

Latest

Choose a tag to compare

@sigveka sigveka released this 18 Nov 21:54
· 189 commits to main since this release

The API review before the 1.0 freeze (decisions 0042 and 0053): the
public surface is listed in docs/api-1.0.json and checked by a test,
and from here to 1.0 only fixes go in. Before the freeze, the calls were
made readable: keyword-only arguments, plain names in place of mesh
jargon, profiles as values, named outlets, and meshing without a
Session (Assembly.to_mesh()). Also: scale= on the writers, per-arc
counts on a circle, an assembly written twice in one session, fixes for
volunteer runs on Windows, a wheel and an sdist on each GitHub release,
and a volunteer command line for people. There is no 0.7.0.

Breaking: arguments after the first one or two are keyword-only;
PipeSpec.core() and .shell() return a new spec; nang, nrad,
mprg and mbmp are renamed (n_arc, n_radial, radial_grading,
arc_bump) and lc is removed, with the error codes that named them;
Reducer(profile=…) takes a Profile; the tee's run port is run.
python3 -m hexmesh.agent.schema is gone (run hexmesh schema); the
modules hexmesh.agent.advise and hexmesh.interchange.build are
private (the functions of those names are unchanged);
hexmesh.io.readers is removed. Saved descriptions are version 4;
older ones still load. Meshes are unchanged.

Calls that stay readable after 1.0 (task 0164, decision 0053).

  • Breaking: keyword-only arguments. A public callable keeps at most
    two positional arguments, the ones a reader understands without their
    name; the rest are keyword-only. Straight(length, *, …),
    Bend(radius, angle, *, …), MiterBend(radius, angle, *, …),
    Elbow(angle, schedule, *, …), Reducer(outlet, *, length, …),
    Transition(outlet, *, length, …); Tee, Wye, Switch, Closure
    and SplinePipe take keywords only. PipeSpec(*, …),
    .core(name, *, …), .shell(name, *, …), CircleShape(radius, *, …),
    RectShape(half_w, half_h, *, n_width, n_height); Assembly(spec, *, …),
    add(source, fitting, *, …), close(source, target, fitting, *, …),
    write(path, *, dim, …), check_quality(quality_name, *, …);
    Drum(name, *, …), Nozzle(name, *, spec, location), OnHead,
    OnShell; read_pcf(path, *, …), read_bathymetry(surface_path, route, *, …), build(model, spec, *, selection, …); the interchange
    parts after their id; Study(path, *, …) and the study functions.
    Reducer(outlet, 0.2) becomes Reducer(outlet, length=0.2). A test
    keeps every public callable to two, apart from a listed few (the
    fitting protocol's methods, Frame, results users only read).
  • Breaking: PipeSpec is copy-on-write. core() and shell()
    return a new spec and leave the one they were called on unchanged, so
    a spec is safe to share: ins = base.shell("insulation", …) no longer
    insulates base too. Code that called spec.shell(…) without keeping
    the result must write spec = spec.shell(…).
  • Named outlets. add returns a named tuple for a fitting with
    several outlets: TeeOutlets(run, branch), WyeOutlets(left, right).
    It unpacks as before; ports.branch reads by name. Breaking: the
    tee's run port is called run, not main, in add(…, names={…}).
  • Limits (README Stability): a limit's value and level may change
    in 1.x as measurements justify; tightening one is noted under
    Behaviour.

Names a reader understands (task 0166, decision 0053).

  • Breaking: the mesh-jargon names are renamed, with no aliases:
    nang → n_arc, nang_w/nang_h → n_width/n_height, nrad →
    n_radial, mprg → radial_grading, mbmp → arc_bump, wherever
    they appear: arguments, properties, the description's fields, the
    schema, error fields and messages, the command line's JSON. Names
    built on them follow (branch_mprg → branch_radial_grading,
    insulation_nrad → insulation_n_radial).
  • Breaking: lc is removed from Assembly, Assembly.from_nozzle,
    build, NetworkSpec.to_assembly and to_assemblies. It was gmsh's
    characteristic length, which a structured mesh doesn't use: meshes are
    unchanged.
  • Breaking: error codes renamed: arcs_with_nang →
    arcs_with_n_arc, nang_missing → n_arc_missing,
    nang_not_divisible → n_arc_not_divisible, nrad_on_h_core →
    n_radial_on_h_core, shell_nrad_missing → shell_n_radial_missing.
  • Saved descriptions are version 3. Older files still load: their
    fields are renamed and lc is dropped (a test loads every example as
    0.6 saved it).

Profiles as values; a section kind (task 0165, decision 0053).

  • Breaking: Reducer(profile=…) takes a Profile, exported from
    hexmesh: Profile.cosine(s0), Profile.venturi(beta, divergent=15)
    and Profile.table([(s, r), …]). The tuple forms (("cosine", s0),
    ("venturi", beta, divergent) and the bare list of pairs) are gone: a
    tuple is a profile_type_invalid error whose hint gives the call. The
    constructors check the parameters, with the codes the tuples had, plus
    profile_fields_invalid for a kind given the wrong fields. A profile
    saves as {"kind": "cosine", "s0": 0.25}.
  • Every saved PipeSpec carries "kind": "concentric" (PipeSpec.KIND).
    A spec without one loads as concentric; any other kind is a
    section_kind_unsupported error, until decision 0035 stage B adds
    pipe-in-pipe and multi-core sections.
  • Saved descriptions are version 4. Version 3 files load: their profile
    tuples become objects.

Meshing without a Session: Assembly.to_mesh() (task 0167,
decision 0053).

  • asm.to_mesh(dim=3, order=1, incomplete=False) meshes a copy of the
    assembly in a gmsh model of its own and returns a Mesh, exported from
    hexmesh: nodes, cells and groups as read-only arrays (element
    types named by hexmesh.ELEMENT_TYPES), cell_count,
    check_quality(), description, and write / write_openfoam,
    which give the bytes a Session gives. The assembly stays unmeshed,
    so it meshes again with other options without a new Session.
  • gmsh starts on first use and stops when the last Mesh closes
    (close(), a with block, or when it's collected). In a Session
    it shares that gmsh; the caller's model and gmsh's options are left
    as they were. Not thread-safe: the GUIDE builds in a process pool.
    A Mesh can't be pickled (mesh_not_picklable); a closed one raises
    mesh_closed.
  • write and write_openfoam outside a Session no longer raise
    no_gmsh_session: they write through to_mesh(), the same bytes.
    mesh(), check_quality() and the pipeline steps still need a
    Session; the error's hint names to_mesh().
  • A Session opened while a Mesh is open shares its gmsh: at its end
    it removes its own model and closes the meshes made in it, instead of
    finalizing gmsh.

Fixed: writing an assembly twice (task 0163).

  • A second write or write_openfoam in the same session failed on a
    tee ("Surface 1 is transfinite but has 8 corners"): mesh() meshed
    again. mesh() now runs once per option set: the same dim, order
    and incomplete again do nothing, and another walls_by_fitting
    rewrites only the physical groups. Other options raise
    remesh_with_other_options: build the assembly in a new Session.

Fixed: gmsh the caller started first (task 0177). import gmsh; gmsh.initialize() before hexmesh had loaded gmsh, then assembly.mesh(),
raised no_gmsh_session; that gmsh now counts as the caller's.

Windows: OpenFOAM commands run after meshing (decision 0039; task
0173). gmsh.initialize() (gmsh 4.15.2) replaces the process's native
PATH on Windows. Every docker command after meshing then failed
with FileNotFoundError: [WinError 2], e.g. gmshToFoam in the
volunteer tool's prepare. hexmesh's start of gmsh (Session,
to_mesh) now puts PATH back, and the OpenFOAM helpers look the
program up on os.environ's PATH.

Windows: parallel solves run in Docker (task 0173). A Windows
host's container runs as root, and mpirun refused root. The Docker
runner now sets Open MPI's opt-in (OMPI_ALLOW_RUN_AS_ROOT) when it
passes no --user. run_solver removes the processor directories
inside the runner: their Linux symlinks can't be opened by Windows,
so shutil.rmtree failed after the first parallel chunk.

Volunteer contributions with the old names merge (task 0173). The
volunteer tags predate the renames of task 0166, so their files say
nang/nrad; volunteer check failed on them (KeyError: 'n_arc').
It now renames them on reading and says so in its report.

A runner that can't run says why (task 0173). A stopped Docker
engine was reported as "has no OpenFOAM". require_version now gives
the runner's own error ("could not run (failed to connect to the docker
API …)") and a hint to start the engine. The error code is unchanged.

scale= on the writers (task 0150, decision 0047).

  • Assembly.write(..., scale=1.0) and write_openfoam(..., scale=1.0)
    multiply the written node coordinates, once. The assembly, its cell
    count and its checks keep the built size; the .msh recipe block
    records scale=. Build a small part at a reference size and scale it
    at output: the nodes are the full-size mesh × the scale to 1e-15,
    where building it small moves junction nodes by up to 0.6 % below
    about 1:30. A scale that isn't positive and finite raises
    value_not_positive.

The API review before the 1.0 freeze (task 0150, decision 0042).

  • Breaking: python3 -m hexmesh.agent.schema is gone; run
    hexmesh schema (the schema is the envelope's result), or call
    hexmesh.agent.dumps(). Its module shared the name of the
    hexmesh.agent.schema function, and importing it replaced the
    function for the rest of the process.
  • Breaking: the modules hexmesh.agent.advise and
    hexmesh.interchange.build are private (_advise, _build), for the
    same reason. The functions hexmesh.agent.advise and
    hexmesh.interchange.build are unchanged; import them from the
    packages. A test now keeps any package from exporting a name that is
    also one of its submodules.
  • hexmesh.sections is importable but no longer promised: it has no
    __all__. Choose a layout with PipeSpec.core(layout=…).
  • Breaking: hexmesh.io.readers is removed (task 0148 deprecated
    it during this cycle; no release carried the warning). Import read_pcf and read_bathymetry from
    hexmesh.interchange, and the modules from
    hexmesh.interchange.importers.
  • One promised path per name: hexmesh.io (not hexmesh.io.writers)
    for write_openfoam_case and read_recipe; hexmesh or
    hexmesh.assembly (not hexmesh.assembly.fittings) for the fittings.
    The other paths still import, but aren't promised.
  • Degrees in every public member (decision 0047). New
    PipeSpec.period_deg, the section's symmetry period in degrees.
    Deprecated: PipeSpec.period (radians; use period_deg) and
    PipeSpec.rot_rad (use math.radians(spec.rot)); both warn. The
    shapes' outline methods (corner, ring_corner, corners_from,
    side, side_count, extent, max_extent, distance, grown,
    lerp, period), which the face builders use in radians, are not
    promised.
  • hexmesh.interchange exports NetworkSpec (what read_pcf returns),
    Cut and Selection (what NetworkModel.cut and .select return).
    The junctions' block-layout methods (layout, skeleton, wall) and
    the constructors of Interface and FillResult (users get these back
    but never build them) are not promised.
  • Tee(branch_shells=None) is reserved: a branch with shells of its own
    is planned for 1.x (decision 0051). Any other value raises
    branch_shells_reserved.

Per-arc counts on a circle (task 0147, decision 0041).

  • CircleShape(radius, arcs=[a, b, a, b]): each quadrant arc its own
    count, instead of n_arc. Such a circle meets a duct with
    n_width = a, n_height = b, in a stack or through a Transition.
  • Straight, Bend, Reducer and Transition take it; every other
    fitting raises arcs_unsupported, naming itself. Opposite arcs must
    be equal (arc_counts_not_opposite), on n_outer = 4.
  • The arcs are density, like a duct's n_width/n_height: refined(k)
    multiplies every arc, and the signature is that of an O-H rectangle
    with the same counts.
  • Saved as "arcs": [a, b, a, b] in place of "n_arc". Descriptions
    without it load and save unchanged.

The volunteer command line, for people (task 0160).

  • A wrong case or level name is caught first, before OpenFOAM or gmsh
    is looked for: one line naming the card's levels, with a suggestion
    (did you mean 're3000_n24'?), exit 2. So are run/collect given a
    case instead of the run directory, a missing check file and a
    runner's error: no tracebacks for a person's mistake.
  • list prints one line per level (cores, wall time, memory, disk,
    cells; ~ marks an estimate) and the prepare command to copy. New
    info <case> [<level>] prints the card in full as wrapped text.
  • -h lists the commands. The card and VOLUNTEERS.md give one way to
    get the version: git clone --branch <tag>.

Validation: an equal tee's loss coefficients (task 0162).

  • A new V3 case, validation/junction_loss, against Štigler, Klas &
    Šperka (2014): an equal 90° tee, k-ω SST, Div a at q = 0.6 at three
    levels (65 k to 1.8 M cells). ξ_MGb passes its gate; ξ_PG, 0.605
    against a measured 0.50, misses it. The levels converge (GCI 0.012),
    so the gap is the model and set-up's, not the mesh's.
  • A case's status may be missed (decision 0012's note): run to the
    end, at least one gate missed, the miss explained in its RESULTS.md.
    It replaces the unused rejected.

Validation: Re 3000 at n_arc 24 in the helical pipe (task 0173), the
last missing level: f +0.53 % from Ito; convergence over n_arc 12, 16, 24
of order 1.84, GCI 1.44 %. Every gate of the case now passes; its
verdict is task 0075's.

A wheel and an sdist on each GitHub release (task 0149).

  • From the next release on, each GitHub release carries
    hexmesh-X.Y.Z-py3-none-any.whl and hexmesh-X.Y.Z.tar.gz.
    pip install <the wheel's URL> needs no git and no PyPI. A
    workflow (.github/workflows/release.yml) builds and checks them,
    attaches them, and installs the wheel by its URL on Linux, macOS and
    Windows.
  • hexmesh --version prints hexmesh X.Y.Z.