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
+17 -4
View File
@@ -22,6 +22,10 @@
#include "io/hdf5/hdf5_raii.h"
#include "math/finite_values.h"
#include "io/hdf5/mitc4_drilling_diagnostics.h"
#include "io/hdf5/mitc4_file_hooks.h"
namespace fesa {
namespace {
@@ -875,13 +879,14 @@ void WriteDiagnostics(hid_t file, const std::vector<Diagnostic>& diagnostics) {
} // namespace
Status EigenHdf5ResultsWriter::Write(
Status hdf5_internal::WriteEigenFile(
const std::filesystem::path& output_path, const Domain& domain,
const EigenAnalysisState& state,
const std::vector<Diagnostic>& diagnostics) {
const std::vector<Diagnostic>& diagnostics, const Mitc4FileHooks& hooks) {
const Status valid = Validate(domain, state, diagnostics);
if (!valid.IsOk()) return valid;
try {
hdf5_internal::RequireDrilling(state.drilling_mode.has_value());
hdf5_internal::Hdf5ErrorSilencer silence;
const auto candidate_path = hdf5_internal::MakeCandidatePath(output_path);
hdf5_internal::CandidateFileGuard cleanup{candidate_path};
@@ -890,7 +895,7 @@ Status EigenHdf5ResultsWriter::Write(
H5Fcreate(candidate_path.string().c_str(), H5F_ACC_EXCL,
H5P_DEFAULT, H5P_DEFAULT),
"Unable to create eigen candidate."),
H5Fclose};
hooks.candidate_close};
hdf5_internal::WriterModelData model{
{}, state.constraint_mask, state.prescribed_displacement};
(void)hdf5_internal::CreateGroup(file.Get(), "/model");
@@ -899,6 +904,7 @@ Status EigenHdf5ResultsWriter::Write(
WriteDensities(file.Get(), domain);
WriteDiagnostics(file.Get(), diagnostics);
WriteEigenMetadata(file.Get());
hdf5_internal::WriteDrillingMetadata(file.Get(), *state.drilling_mode);
WriteStep(file.Get(), domain, state);
(void)hdf5_internal::CreateGroup(file.Get(), kEigenRoot);
WriteModes(file.Get(), state, domain.Frequency()->source_step_name_raw);
@@ -940,8 +946,9 @@ Status EigenHdf5ResultsWriter::Write(
"Unable to flush eigen candidate.");
hdf5_internal::RequireHdf5(file.CloseChecked(),
"Unable to close eigen candidate.");
if (hooks.before_self_check) hooks.before_self_check(candidate_path);
const Status checked = hdf5_internal::SelfCheckEigenFile(
candidate_path, domain, state, diagnostics);
candidate_path, domain, state, diagnostics, hooks.reader_close);
const Status result = hdf5_internal::AtomicFinalizeValidatedCandidate(
candidate_path, output_path, checked);
if (result.IsOk()) cleanup.Release();
@@ -953,4 +960,10 @@ Status EigenHdf5ResultsWriter::Write(
}
}
Status EigenHdf5ResultsWriter::Write(
const std::filesystem::path& output_path, const Domain& domain,
const EigenAnalysisState& state, const std::vector<Diagnostic>& diagnostics) {
return hdf5_internal::WriteEigenFile(output_path, domain, state, diagnostics);
}
} // namespace fesa