Repository navigation
Conversation
The IBM mask file name was built from the periodicity of each direction (ibm_000.bp, ibm_100.bp, ...), so users had to rename the generated file to match their BCs. The suffix never checked the contents either: a mask made for another grid was read without complaint. - Add ibm_file to &solver_params (default 'ibm.bp') and drop the suffix. - Add reader_session%read_shape, which returns the global shape of a 3D variable without reading it, and use it to stop with a clear error when the mask size differs from the mesh's vertex count. - Update examples/cylinder and document ibm_on/ibm_file.
|
This PR also closes #481 |
Resolve the conflict in src/module/ibm.f90: keep the ibm_file argument of ibm_t's init and drop ibm_mask_filename, which main added for x3d2-memcheck (#326). x3d2-memcheck now checks solver_cfg%ibm_file for the mask file, and its docs say so.
write_data for an integer(i8) scalar defined the variable as integer4 and then put an 8-byte value, so ADIOS2 rejected every call with a type mismatch. Nothing in src wrote an i8 scalar, so it went unnoticed; the i8 reader already expects integer8, which is what Python writes for the iibm of an IBM mask.
test_ibm_mask_read writes a mask whose every point holds its global index, reads it through ibm_t on a grid split over the ranks and checks each point of ep1. The mismatch variant writes a mask one point too big in x and must stop with the shape error. Both run on every backend with ADIOS2. Reword the comment on the mask layout in ibm_t: ADIOS2 reverses the shape of a C-order file for a Fortran reader, so x3d2 reverses nothing itself.
kaanolgu
left a comment
There was a problem hiding this comment.
The CI tests pass on this branch, apart from the known test_penta_omp_4 failure in the Debug builds (#468). I also ran the cylinder on this branch and on main with OpenMP on 1 and 2 ranks and with CUDA on 1 GPU. The enstrophy history agrees with main bit for bit, restarts work, and a missing or wrong-size mask stops all ranks with a clear message
| deallocate (mask) | ||
| call MPI_Barrier(MPI_COMM_WORLD, ierr) | ||
|
|
||
| ibm = ibm_t(backend, mesh, runtime%host_allocator, trim(mask_file)) |
There was a problem hiding this comment.
In the mismatch run, ibm_t stops all ranks here, so the rm -rf at the end does not run. Each run then leaves test_ibm_mask_read_omp_4_mismatch.bp in the build tree. Could a CTest cleanup fixture with cmake -E remove_directory remove the file instead? The fixture also runs after an abort, and the test then does not call a shell
There was a problem hiding this comment.
Thanks, done in c6e6d75. Each run of test_ibm_mask_read now has a <test>_cleanup test (FIXTURES_CLEANUP) that runs cmake -E remove_directory on its .bp, so the mask is removed after the mismatch abort too, and the test no longer calls a shell. I used remove_directory rather than -E rm -rf because our minimum CMake is 3.13. Checked locally: no .bp left after ctest -R ibm_mask, or after running the mismatch test on its own.
The mismatch run of test_ibm_mask_read stops in ibm_t before its rm -rf, so it left <test name>.bp in the build tree. A cleanup test per run now removes the file with cmake -E remove_directory. ctest runs it after the test whether that passed, failed or aborted, and adds it when only the test itself is selected. The test no longer calls a shell.
Closes #456. Closes #481.
Problem
Since #290 the IBM mask file name is built from the periodicity of each direction (
ibm_000.bp,ibm_100.bp, ...). Users have to work out the suffix and rename the generatedibm.bpby hand. The suffix also never checks the file: a mask made for a different grid is read without complaint, and the run carries on with a wrong mask until it diverges (#481).Changes
ibm_filein&solver_params(default'ibm.bp') names the mask file. The suffix logic is removed fromsrc/module/ibm.f90.reader_session%read_shape()returns the global shape of a 3D variable without reading it (ADIOS2:adios2_variable_shape; the dummy backend reports the usual "recompile with ADIOS2" error). Ifep1doesn't match the mesh's global vertex dims, the run stops:[nz, ny, nx]in the file. ADIOS2 reverses the shape and the selection for a Fortran reader, so the check compares x, y, z with x, y, z whichever language wrote the mask. The comment ininitnow says this.x3d2-memcheck(merged from main, Add x3d2-memcheck: estimate and measure the GPU memory a case run needs #326) used the removed suffix helper to look for the mask. It now checks the file thatibm_filenames, anddocs/source/user/memcheck.rstsays so.write_datafor aninteger(i8)scalar defined the variable asinteger4and then wrote 8 bytes, so ADIOS2 stopped every callwith a type mismatch. Nothing insrcwrote ani8scalar, so this went unnoticed until the new test wroteiibm. It now definesinteger8, which is what thei8reader already expected.examples/cylinder: the rename table is removed from the readme,input.x3dsetsibm_file, and the readme now points to x3d2-tools.docs/source/user/input_file.rstcoveringibm_onandibm_file.New test:
test_ibm_mask_readUntil now no test read an IBM mask from a file.
tests/unit/test_ibm_mask_read.f90writes its own mask, so it needs no data files and no Python:SZ, so the padded copy ininitis used.i + 100 j + 10000 k, so a wrong offset, a swapped axis or a bad padded copy gives a wrong value. The values are exact in single precision too.ibm_treads the mask, and every rank copiesep1back from the device and compares each point with the index pattern.mismatchvariant writes one point more in x and must stop with the shape error. As with the other abort tests, ctest checks the output (PASS_REGULAR_EXPRESSION/FAIL_REGULAR_EXPRESSION), not the exit code, which depends on the MPI launcher.test_ibm_mask_read_<backend>_<np>and..._mismatch), next to the other ADIOS2 I/O tests. Each one writes to a file named after its executable, soctest -jruns don't share a mask.To check the test can fail, I set the read offsets in
initto zero: ranks 1 to 3 then fail with7770 points of ep1 are wrong.Testing
GNU + ADIOS2 Debug build (
-Werror), OpenMP backend, a 64×32×16 TGV withibm_on, using masks written the same way as x3d2-tools (shape=[nz, ny, nx]):ibmsnapshot field equals the input mask exactlyibmsnapshot field equals the input mask exactlyibm_file, noibm.bpIBM file not found: ibm.bpAfter merging main, NVHPC 25.3 Release builds:
ctestx3d2-memchecktest_ibm_mask_readtests (OMP and CUDA, 4 ranks)The cylinder case (257×128×32, mask written from Python) on the CUDA + ADIOS2 build runs on 1 and 2 ranks. With
dims_globalset to 257×128×64 it stops withIBM mask in ibm_100.bp is 257 x 128 x 32 but the mesh has 257 x 128 x 64 vertices.fprettify (
--config .fprettify.ini --recursive src, as in CI) and on the new test: no changes.Notes
dims_globalwith different BCs has the same shape but a different spacing (L/n vs L/(n−1)), so it isn't caught. The old suffix didn't catch that either. Catching it would needx3d2-tools to store the spacing or BCs in the file.ibm_XYZ.bpfiles still work: setibm_fileto that name..bpfile in the build'stests/directory.