Skip to content

Keep dotted names when building geometry view and object paths - #1003

Merged
agianno merged 1 commit into
gprMax:masterfrom
SajalDevX:fix/geometry-output-dotted-names
Nov 23, 2026
Merged

agianno merged 1 commit into
gprMax:masterfrom
SajalDevX:fix/geometry-output-dotted-names

Conversation

@SajalDevX

Copy link
Copy Markdown
Contributor

Fixes #1002

#geometry_view and #geometry_objects_write passed the user's base name through Path.with_suffix, so layer_0.1m became layer_0.h5 / layer_0.vtkhdf. Two outputs that differ only after the dot then wrote the same file and the second silently replaced the first, and with -n the per-model geometry views collided too (survey_v1.2 + model number gave survey_v1.vtkhdf for every model).

Changes:

  • GeometryView.set_filename now appends .vtkhdf to the base name plus model number. It only replaces the suffix when the name already ends in .vtkhdf, .h5 or .vtk, which is the same rule the VTKHDF writer already uses.
  • GeometryObject now appends .h5 unless the name already ends in .h5. The materials database name is unchanged.
  • test_replaces_an_existing_suffix in tests/outputs/test_geometry_views.py asserted the truncation (geo.old -> geo.vtkhdf). Its docstring said "as for snapshots", but snapshots keep the dot now, so I changed it to expect geo.old.vtkhdf and added cases for the model number and for names that already carry a known extension.
  • Added unit tests for the geometry object file name and an end-to-end test (tests/outputs/test_geometry_output_dotted_names.py) that runs a hash-command input with two dotted views and two dotted objects through gprMax.run(..., n=2, geometry_only=True).

Testing:

  • On master the new and changed tests fail (['view_0.vtkhdf'] == ['view_0.1m1.vtkhdf', ...], 'layer_0.h5' == 'layer_0.1m.h5', 'survey_v1.vtkhdf' == 'survey_v1.22.vtkhdf') and pass with the fix.
  • pytest tests/outputs/test_geometry_*.py tests/outputs/test_subgrid_geometry_view_origin.py tests/geometry_objects tests/hash_cmds -k "not mpi": 613 passed, 7 skipped (no CUDA). Other tests that use geometry views or #geometry_objects_write (tests/user_objects/test_cmds_output.py, tests/impedance_surfaces/test_impedance_geometry_roundtrip.py, tests/fractals/test_material_range_solve.py and a few more): 164 passed, 16 skipped (no CUDA/OpenCL). MPI tests were not run, mpi4py is not installed here.
  • Real runs with python -m gprMax ... --geometry-only: the input from the issue now writes layer_0.1m.h5, layer_0.2m.h5, view_0.1m.vtkhdf and view_0.2m.vtkhdf, -n 2 gives survey_v1.21.vtkhdf and survey_v1.22.vtkhdf, and #geometry_objects_read: 0 0 0 layer_0.1m.h5 layer_0_1m_materials reads the object back.

#geometry_view and #geometry_objects_write used Path.with_suffix on the
user's base name, so a name such as layer_0.1m was cut to layer_0 and
distinct outputs overwrote each other. Append the extension instead and
only replace a known output extension, as the VTKHDF writer and
snapshots already do.
@agianno
agianno merged commit ea4718b into gprMax:master Nov 23, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

#geometry_view and #geometry_objects_write cut dotted file names, so outputs overwrite each other

2 participants