trenchfoot 0.1.0__py3-none-any.whl → 0.1.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of trenchfoot might be problematic. Click here for more details.

@@ -442,10 +442,15 @@ def generate_trench_volume(
442
442
  for dim, tag in gmsh.model.getPhysicalGroups():
443
443
  name = gmsh.model.getPhysicalName(dim, tag) or f"dim{dim}_tag{tag}"
444
444
  entities = tuple(gmsh.model.getEntitiesForPhysicalGroup(dim, tag))
445
- pg_types, pg_elem_tags = gmsh.model.mesh.getElementsForPhysicalGroup(dim, tag)
445
+ elem_accum: Dict[int, List[int]] = {}
446
+ for entity_tag in entities:
447
+ et_types, et_elem_tags, _ = gmsh.model.mesh.getElements(dim, entity_tag)
448
+ for etype, tags in zip(et_types, et_elem_tags):
449
+ bucket = elem_accum.setdefault(int(etype), [])
450
+ bucket.extend(int(t) for t in tags)
446
451
  elements_map: Dict[int, np.ndarray] = {
447
- int(t): np.array(tags, dtype=int)
448
- for t, tags in zip(pg_types, pg_elem_tags)
452
+ etype: np.array(values, dtype=int)
453
+ for etype, values in elem_accum.items()
449
454
  }
450
455
  physical_groups.append(
451
456
  PhysicalGroupInfo(
@@ -0,0 +1,113 @@
1
+ Metadata-Version: 2.4
2
+ Name: trenchfoot
3
+ Version: 0.1.1
4
+ Summary: Synthetic trench scenario generator bundle (surfaces + volumetrics).
5
+ Author: Liam Moore
6
+ License-File: LICENSE
7
+ Requires-Python: >=3.12
8
+ Requires-Dist: numpy>=1.26
9
+ Provides-Extra: dev
10
+ Requires-Dist: pytest>=8.3; extra == 'dev'
11
+ Provides-Extra: mesher
12
+ Requires-Dist: gmsh>=4.11; extra == 'mesher'
13
+ Provides-Extra: preview
14
+ Requires-Dist: matplotlib>=3.8; extra == 'preview'
15
+ Provides-Extra: viz
16
+ Requires-Dist: plotly>=5.24; extra == 'viz'
17
+ Description-Content-Type: text/markdown
18
+
19
+ # Trenchfoot
20
+
21
+ Surface and volumetric trench mesh generator with shipped presets, Plotly previews, and a lightweight Python SDK.
22
+
23
+ ## Install
24
+
25
+ ```bash
26
+ pip install trenchfoot
27
+ ```
28
+
29
+ Want volumetrics or visualisations? Install extras as needed:
30
+ - `pip install "trenchfoot[mesher]"` for gmsh-powered volume meshes.
31
+ - `pip install "trenchfoot[preview]"` for matplotlib snapshot renders.
32
+ - `pip install "trenchfoot[viz]"` for Plotly HTML viewers.
33
+
34
+ ## Scenario Gallery
35
+
36
+ Color key: trench surfaces use warm soil tones; embedded geometry is colour-coded per group.
37
+
38
+ | Scenario | Top | Side | Oblique |
39
+ | --- | --- | --- | --- |
40
+ | S01_straight_vwalls | ![S01 top](packages/trenchfoot/scenarios/S01_straight_vwalls/preview_top.png) | ![S01 side](packages/trenchfoot/scenarios/S01_straight_vwalls/preview_side.png) | ![S01 oblique](packages/trenchfoot/scenarios/S01_straight_vwalls/preview_oblique.png) |
41
+ | S02_straight_slope_pipe | ![S02 top](packages/trenchfoot/scenarios/S02_straight_slope_pipe/preview_top.png) | ![S02 side](packages/trenchfoot/scenarios/S02_straight_slope_pipe/preview_side.png) | ![S02 oblique](packages/trenchfoot/scenarios/S02_straight_slope_pipe/preview_oblique.png) |
42
+ | S03_L_slope_two_pipes_box | ![S03 top](packages/trenchfoot/scenarios/S03_L_slope_two_pipes_box/preview_top.png) | ![S03 side](packages/trenchfoot/scenarios/S03_L_slope_two_pipes_box/preview_side.png) | ![S03 oblique](packages/trenchfoot/scenarios/S03_L_slope_two_pipes_box/preview_oblique.png) |
43
+ | S04_U_slope_multi_noise | ![S04 top](packages/trenchfoot/scenarios/S04_U_slope_multi_noise/preview_top.png) | ![S04 side](packages/trenchfoot/scenarios/S04_U_slope_multi_noise/preview_side.png) | ![S04 oblique](packages/trenchfoot/scenarios/S04_U_slope_multi_noise/preview_oblique.png) |
44
+ | S05_wide_slope_pair | ![S05 top](packages/trenchfoot/scenarios/S05_wide_slope_pair/preview_top.png) | ![S05 side](packages/trenchfoot/scenarios/S05_wide_slope_pair/preview_side.png) | ![S05 oblique](packages/trenchfoot/scenarios/S05_wide_slope_pair/preview_oblique.png) |
45
+ | S06_bumpy_wide_loop | ![S06 top](packages/trenchfoot/scenarios/S06_bumpy_wide_loop/preview_top.png) | ![S06 side](packages/trenchfoot/scenarios/S06_bumpy_wide_loop/preview_side.png) | ![S06 oblique](packages/trenchfoot/scenarios/S06_bumpy_wide_loop/preview_oblique.png) |
46
+
47
+ ### S06 preset at a glance
48
+
49
+ ```json
50
+ {
51
+ "path_xy": [[0, 0], [4, -1], [8, 0], [8, 5], [2, 5], [-1, 2]],
52
+ "width": 2.6,
53
+ "depth": 1.4,
54
+ "wall_slope": 0.12,
55
+ "ground": {"z0": 0.2, "slope": [0.015, 0.03], "size_margin": 7.0},
56
+ "pipes": [
57
+ {"radius": 0.18, "length": 6.0, "angle_deg": 35, "s_center": 0.3, "z": -0.9, "offset_u": 0.35},
58
+ {"radius": 0.14, "length": 4.8, "angle_deg": -40, "s_center": 0.6, "z": -0.95, "offset_u": -0.45}
59
+ ],
60
+ "spheres": [{"radius": 0.35, "s": 0.82, "offset_u": 0.3, "z": -0.65}],
61
+ "noise": {
62
+ "enable": true,
63
+ "amplitude": 0.035,
64
+ "corr_length": 0.5,
65
+ "octaves": 4,
66
+ "gain": 0.55,
67
+ "apply_to": ["trench_walls", "trench_bottom", "pipe*_pipe_side"]
68
+ }
69
+ }
70
+ ```
71
+
72
+ ## CLI quick start
73
+
74
+ ```bash
75
+ trenchfoot-generate --help
76
+ trenchfoot-generate --preview --skip-volumetric --gallery docs/scenario_gallery.md
77
+ trenchfoot-plot packages/trenchfoot/scenarios/S05_wide_slope_pair/trench_scene.obj --open
78
+ ```
79
+
80
+ Set `TRENCHFOOT_SCENARIO_OUT_ROOT=/tmp/trench-previews` (or another writable path) to keep generated assets out of your checkout.
81
+
82
+ ## Python API
83
+
84
+ ```python
85
+ from trenchfoot import scene_spec_from_dict, generate_surface_mesh, generate_trench_volume, gmsh_available
86
+
87
+ spec_dict = {
88
+ "path_xy": [[0.0, 0.0], [5.0, 0.0]],
89
+ "width": 1.0,
90
+ "depth": 1.2,
91
+ "pipes": [{"radius": 0.1, "length": 1.8, "angle_deg": 0.0, "s_center": 0.5}],
92
+ "boxes": [],
93
+ "spheres": [],
94
+ "noise": {"enable": False},
95
+ }
96
+
97
+ scene = scene_spec_from_dict(spec_dict)
98
+ surface = generate_surface_mesh(scene, make_preview=True)
99
+ surface.persist("./surface")
100
+
101
+ if gmsh_available():
102
+ volume = generate_trench_volume(spec_dict, lc=0.4, persist_path="./volume/trench_volume.msh")
103
+ ```
104
+
105
+ `SurfaceMeshResult` keeps per-group faces, metrics, and optional preview PNG bytes; call `.persist(...)` when you need files. `VolumeMeshResult` exposes node coordinates, elements, and physical groups while still letting you stay in memory.
106
+
107
+ ## Testing
108
+
109
+ ```bash
110
+ pytest -rs
111
+ ```
112
+
113
+ The suite exercises each preset (surface + volumetric), the gallery helpers, and the SDK smoke paths.
@@ -2,7 +2,7 @@ trenchfoot/Dockerfile,sha256=TjwHTNOZF6eHxpDjw29uruEmvJ4FWQEv1XRDE3qMJvY,210
2
2
  trenchfoot/README.md,sha256=PGpBwprT0ZgR-ASx7bDLm9SvYR8yCbIzML7amq3oJ-k,5483
3
3
  trenchfoot/__init__.py,sha256=jI30sofuw13hesvaShlAaatpswxY8wRFVsTJq06TKo8,1672
4
4
  trenchfoot/generate_scenarios.py,sha256=drQ6a2bKnkcyIDXP4EKHe4m6CtLHW9NjJzXSIgbTQso,22561
5
- trenchfoot/gmsh_sloped_trench_mesher.py,sha256=IQf2x4mtufxIwf17U7ub3wqjdoAehp_nj1p3W80KIlg,20938
5
+ trenchfoot/gmsh_sloped_trench_mesher.py,sha256=GJz8acg80dZbO8s6iW71X7aLg3qvOjlgW0ImPG7mKFE,21211
6
6
  trenchfoot/plot_mesh.py,sha256=26dOlVfaM1WsUfr_sXVqA7axtY9qjY3WCNM7cUBTS7Q,3810
7
7
  trenchfoot/render_colors.py,sha256=EfldvoshgaZ6iZFk-UDL67-tvwGYaiZFS2NQZBMwhDM,1596
8
8
  trenchfoot/scene_spec_example.json,sha256=UcV25ku422UO0ZZPDrJwrT1zwmjoOIpnBdLuEdh-AZA,1028
@@ -62,8 +62,8 @@ trenchfoot/scenarios/S06_bumpy_wide_loop/preview_side.png,sha256=OoBdaEeiFIV9pOY
62
62
  trenchfoot/scenarios/S06_bumpy_wide_loop/preview_top.png,sha256=rVHFPNicx98ja0oaZf_9dG5v7tEmjBSVzRHgan4sgu4,48554
63
63
  trenchfoot/scenarios/S06_bumpy_wide_loop/scene.json,sha256=jy00g_SHAQzHg7N4wY0nM-WUMRSsP3dF1NzscqM1BMk,1106
64
64
  trenchfoot/scenarios/S06_bumpy_wide_loop/trench_scene.obj,sha256=u8ME1nB1jXSRydtvXtg8_wiod_YxXb_QydCQ-mjHV68,842349
65
- trenchfoot-0.1.0.dist-info/METADATA,sha256=tAneMkSgiKHUFyEpSW0rUOvVi8eO2bRA30W0Pxs3_Ug,6245
66
- trenchfoot-0.1.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
67
- trenchfoot-0.1.0.dist-info/entry_points.txt,sha256=5TejAGmc4GnNYLn7MhhLtSCNz9240RvzcNaetF4IHfg,119
68
- trenchfoot-0.1.0.dist-info/licenses/LICENSE,sha256=hIahDEOTzuHCU5J2nd07LWwkLW7Hko4UFO__ffsvB-8,34523
69
- trenchfoot-0.1.0.dist-info/RECORD,,
65
+ trenchfoot-0.1.1.dist-info/METADATA,sha256=fxDjnkJr7i8bLvVYhkCOrpfNnbHjIAllItrztjlhAjU,4941
66
+ trenchfoot-0.1.1.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
67
+ trenchfoot-0.1.1.dist-info/entry_points.txt,sha256=5TejAGmc4GnNYLn7MhhLtSCNz9240RvzcNaetF4IHfg,119
68
+ trenchfoot-0.1.1.dist-info/licenses/LICENSE,sha256=hIahDEOTzuHCU5J2nd07LWwkLW7Hko4UFO__ffsvB-8,34523
69
+ trenchfoot-0.1.1.dist-info/RECORD,,
@@ -1,104 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: trenchfoot
3
- Version: 0.1.0
4
- Summary: Synthetic trench scenario generator bundle (surfaces + volumetrics).
5
- Author: Liam Moore
6
- License-File: LICENSE
7
- Requires-Python: >=3.12
8
- Requires-Dist: numpy>=1.26
9
- Provides-Extra: dev
10
- Requires-Dist: pytest>=8.3; extra == 'dev'
11
- Provides-Extra: mesher
12
- Requires-Dist: gmsh>=4.11; extra == 'mesher'
13
- Provides-Extra: preview
14
- Requires-Dist: matplotlib>=3.8; extra == 'preview'
15
- Provides-Extra: viz
16
- Requires-Dist: plotly>=5.24; extra == 'viz'
17
- Description-Content-Type: text/markdown
18
-
19
- # Trenchfoot
20
-
21
- Synthetic trench scenario generator extracted from the Survi monorepo. This repository bundles
22
- surface + volumetric scene generation tooling and prebuilt scenarios.
23
-
24
- ## Layout
25
- - `packages/trenchfoot/`: the generator bundle (surface CLI, Gmsh mesher, scenario specs, Dockerfile).
26
- - `packages/trenchfoot/scenarios/`: prebuilt scenes (OBJ meshes, previews, metrics).
27
-
28
- ## Getting Started
29
- ```bash
30
- uv sync
31
- uv run python -m trenchfoot.generate_scenarios --help
32
- ```
33
-
34
- Optional extras:
35
- - Install `gmsh` and `meshio` to emit volumetric meshes.
36
- - Install `matplotlib` to refresh preview renders.
37
- - Set `TRENCHFOOT_SCENARIO_OUT_ROOT=/tmp/trench-previews` (or another writable path) to keep generated assets out of the repo checkout; the CLI uses this location unless `--out` is specified.
38
- - Install `plotly` via `pip install "trenchfoot[viz]"` to enable Plotly HTML meshes.
39
- - Use `uv run python -m trenchfoot.generate_scenarios --preview --gallery docs/scenario_gallery.md` to regenerate previews and emit a Markdown gallery (the README table below was generated this way).
40
-
41
- See `packages/trenchfoot/README.md` for the original usage notes and the CLI examples.
42
-
43
- ### CLI Shortcuts
44
- - `uv run python -m trenchfoot.generate_scenarios --scratch --skip-volumetric` runs the generator in a temporary directory (no repo churn) and prints the scratch path.
45
- - Add `--include-prebuilt` if you want the shipped assets copied into the scratch directory before regeneration.
46
- - Combine `--preview` with `--gallery docs/scenario_gallery.md` to refresh previews and the Markdown gallery in one go.
47
- - `trenchfoot-plot packages/trenchfoot/scenarios/S05_wide_slope_pair/trench_scene.obj --open` writes an interactive Plotly HTML (requires the `[viz]` extra) and opens it in your browser.
48
-
49
- ## Python API
50
-
51
- Trenchfoot now exposes a light-weight SDK so you can work entirely in memory:
52
-
53
- ```python
54
- from trenchfoot import (
55
- SceneSpec,
56
- scene_spec_from_dict,
57
- generate_surface_mesh,
58
- generate_trench_volume,
59
- gmsh_available,
60
- )
61
-
62
- spec_dict = {
63
- "path_xy": [[0.0, 0.0], [5.0, 0.0]],
64
- "width": 1.0,
65
- "depth": 1.2,
66
- "wall_slope": 0.1,
67
- "ground": {"z0": 0.0, "slope": [0.0, 0.0], "size_margin": 2.0},
68
- "pipes": [{"radius": 0.1, "length": 1.8, "angle_deg": 0.0, "s_center": 0.5}],
69
- "boxes": [],
70
- "spheres": [],
71
- "noise": {"enable": False},
72
- }
73
-
74
- scene = scene_spec_from_dict(spec_dict)
75
- surface = generate_surface_mesh(scene)
76
- print(surface.metrics["surface_area_by_group"]["trench_walls"])
77
- surface.persist("./tmp/surface", include_previews=False)
78
-
79
- if gmsh_available():
80
- volume = generate_trench_volume(spec_dict, lc=0.4, persist_path="./tmp/volume/trench_volume.msh")
81
- print(len(volume.element_blocks), "element blocks", "across", volume.nodes.shape[0], "nodes")
82
- ```
83
-
84
- `SurfaceMeshResult` keeps the per-group vertex/face arrays, metrics, and optional preview PNGs (as bytes). Call `.persist(path)` when you want OBJ + metrics written to disk. `VolumeMeshResult` exposes the raw node coordinates, element connectivity, and the discovered physical groups while still letting you emit `.msh` files on demand.
85
-
86
- ## Mesh Clearance Guard Rails
87
- The volumetric mesher enforces a minimum 50 mm gap between the trench walls and any embedded geometry, scaling the threshold with each pipe’s radius and the current wall slope. When clearance gets tight, the generator shortens the pipe run and records per-pipe margins in `SUMMARY.json` under `pipe_clearances` so you can spot scenarios that are at risk before Gmsh complains.
88
-
89
- ## Scenario Gallery
90
- Color key: trench surfaces use warm soil tones, embedded geometry is color-coded per object (pipes in rotating palette, boxes teal/olive, spheres magenta/gray).
91
- | Scenario | Top | Side | Oblique |
92
- | --- | --- | --- | --- |
93
- | S01_straight_vwalls | ![S01 top](packages/trenchfoot/scenarios/S01_straight_vwalls/preview_top.png) | ![S01 side](packages/trenchfoot/scenarios/S01_straight_vwalls/preview_side.png) | ![S01 oblique](packages/trenchfoot/scenarios/S01_straight_vwalls/preview_oblique.png) |
94
- | S02_straight_slope_pipe | ![S02 top](packages/trenchfoot/scenarios/S02_straight_slope_pipe/preview_top.png) | ![S02 side](packages/trenchfoot/scenarios/S02_straight_slope_pipe/preview_side.png) | ![S02 oblique](packages/trenchfoot/scenarios/S02_straight_slope_pipe/preview_oblique.png) |
95
- | S03_L_slope_two_pipes_box | ![S03 top](packages/trenchfoot/scenarios/S03_L_slope_two_pipes_box/preview_top.png) | ![S03 side](packages/trenchfoot/scenarios/S03_L_slope_two_pipes_box/preview_side.png) | ![S03 oblique](packages/trenchfoot/scenarios/S03_L_slope_two_pipes_box/preview_oblique.png) |
96
- | S04_U_slope_multi_noise | ![S04 top](packages/trenchfoot/scenarios/S04_U_slope_multi_noise/preview_top.png) | ![S04 side](packages/trenchfoot/scenarios/S04_U_slope_multi_noise/preview_side.png) | ![S04 oblique](packages/trenchfoot/scenarios/S04_U_slope_multi_noise/preview_oblique.png) |
97
- | S05_wide_slope_pair | ![S05 top](packages/trenchfoot/scenarios/S05_wide_slope_pair/preview_top.png) | ![S05 side](packages/trenchfoot/scenarios/S05_wide_slope_pair/preview_side.png) | ![S05 oblique](packages/trenchfoot/scenarios/S05_wide_slope_pair/preview_oblique.png) |
98
- | S06_bumpy_wide_loop | ![S06 top](packages/trenchfoot/scenarios/S06_bumpy_wide_loop/preview_top.png) | ![S06 side](packages/trenchfoot/scenarios/S06_bumpy_wide_loop/preview_side.png) | ![S06 oblique](packages/trenchfoot/scenarios/S06_bumpy_wide_loop/preview_oblique.png) |
99
-
100
- ## Testing
101
- ```bash
102
- uv run pytest -rs
103
- ```
104
- The test suite exercises the single-scenario code path, runs all bundled presets (surface + volumetric) into a scratch directory, and checks that the CLI honours `TRENCHFOOT_SCENARIO_OUT_ROOT`.