Add MITC4 drilling diagnostics output and comparison contract

This commit is contained in:
KOKO\Mimi
2026-10-20 09:45:58 +09:00
parent 3d5c296651
commit a73d3fc9ca
31 changed files with 1175 additions and 45 deletions
@@ -0,0 +1,42 @@
#ifndef FESA_TESTS_UNIT_IO_HDF5_MITC4_FAULT_TEST_HELPERS_H_
#define FESA_TESTS_UNIT_IO_HDF5_MITC4_FAULT_TEST_HELPERS_H_
#include <string>
#include "io/hdf5/mitc4_file_hooks.h"
#include "io/hdf5/hdf5_raii.h"
namespace fesa::test {
inline herr_t CloseMitc4FileAndReportFailure(hid_t file) {
(void)H5Fclose(file);
return -1;
}
inline hdf5_internal::Mitc4FileHooks Mitc4LifecycleFault(const std::string& fault) {
hdf5_internal::Mitc4FileHooks hooks;
if (fault == "candidate-close") hooks.candidate_close = CloseMitc4FileAndReportFailure;
if (fault == "reader-close") hooks.reader_close = CloseMitc4FileAndReportFailure;
if (fault == "markers" || fault == "datasets") {
hooks.before_self_check = [fault](const std::filesystem::path& path) {
hdf5_internal::Hdf5Handle file{hdf5_internal::RequireHdf5Id(
H5Fopen(path.string().c_str(), H5F_ACC_RDWR, H5P_DEFAULT), "Cannot corrupt test candidate."), H5Fclose};
if (fault == "markers") {
hdf5_internal::Hdf5Handle metadata{H5Gopen2(file.Get(), "/metadata", H5P_DEFAULT), H5Gclose};
hdf5_internal::RequireHdf5(H5Adelete(metadata.Get(), "mitc4_drilling_formulation"), "Cannot remove mode.");
hdf5_internal::RequireHdf5(H5Adelete(metadata.Get(), "drilling_diagnostics_version"), "Cannot remove version.");
} else {
hdf5_internal::RequireHdf5(H5Ldelete(file.Get(),
"/steps/Step-1/frames/0/global/drilling_moment", H5P_DEFAULT), "Cannot remove moment.");
hdf5_internal::RequireHdf5(H5Ldelete(file.Get(),
"/steps/Step-1/frames/0/global/equilibrium_with_drilling", H5P_DEFAULT), "Cannot remove corrected balance.");
}
hdf5_internal::RequireHdf5(file.CloseChecked(), "Cannot close corrupted candidate.");
};
}
return hooks;
}
} // namespace fesa::test
#endif // FESA_TESTS_UNIT_IO_HDF5_MITC4_FAULT_TEST_HELPERS_H_