Conversation
583d870 to
7ee7597
Compare
| if (H5Lexists(file, name.c_str(), H5P_DEFAULT) > 0) { | ||
| std::string new_name; | ||
| int suffix = 2; | ||
| do { | ||
| new_name = name + "_" + std::to_string(suffix++); | ||
| } while (H5Lexists(file, new_name.c_str(), H5P_DEFAULT) > 0); |
There was a problem hiding this comment.
i haven't wrapped my head around what this is for yet...
There was a problem hiding this comment.
if multiple materials are named the same thing but have different matids, this lets you add duplicates of them. It has to walk through the file and increment the "index" of the material, so you might have steel, steel_2, steel_3, etc... I'm not sure how important this is, but now that the file is queried, keeping the old functionality requires this do while loop.
There was a problem hiding this comment.
Although actually, would a cleaner implementation be while(H5Lexists) and drop the if () { do {} while()} construction?
There was a problem hiding this comment.
I think this new section in the README should also be added to the singularity-eos sphinx-rst. These readmes should maybe be deprecated as I want people to not have to hunt through multiple places for documentation.
|
|
||
| ### Added (new features/APIs/variables/...) | ||
| - [[PR658]](https://github.com/lanl/singularity-eos/pull/XXX) Add `MinimumInternalEnergy`/`MaximumInternalEnergy` to the EOS introspection API, so energy bounds are reachable through modifiers and the `singularity::EOS` variant | ||
| - Added `sesame2spiner::saveAllMaterials` overloads taking a list of matids instead of a list of input files, with optional per-material `Params` overrides, so host codes can generate an sp5 file without writing input decks to disk. Also added an overload taking an already-open `hid_t`, plus `writeSP5RootAttributes`, so a single sp5 file can be built up one material at a time. |
There was a problem hiding this comment.
This change should be pinned to an MR link.
| - `sesame2spiner` now honors the requested verbosity when reading material metadata, rather than always using `Verbosity::Debug`. Default command line output is correspondingly quieter. | ||
| - `sesame2spiner::getMatBounds` no longer takes a leading index argument, which was unused. |
There was a problem hiding this comment.
These changes should be pinned to an MR link.
| if (H5Lexists(file, name.c_str(), H5P_DEFAULT) > 0) { | ||
| std::string new_name; | ||
| int suffix = 2; | ||
| do { | ||
| new_name = name + "_" + std::to_string(suffix++); | ||
| } while (H5Lexists(file, new_name.c_str(), H5P_DEFAULT) > 0); |
There was a problem hiding this comment.
if multiple materials are named the same thing but have different matids, this lets you add duplicates of them. It has to walk through the file and increment the "index" of the material, so you might have steel, steel_2, steel_3, etc... I'm not sure how important this is, but now that the file is queried, keeping the old functionality requires this do while loop.
| if (H5Lexists(file, name.c_str(), H5P_DEFAULT) > 0) { | ||
| std::string new_name; | ||
| int suffix = 2; | ||
| do { | ||
| new_name = name + "_" + std::to_string(suffix++); | ||
| } while (H5Lexists(file, new_name.c_str(), H5P_DEFAULT) > 0); |
There was a problem hiding this comment.
Although actually, would a cleaner implementation be while(H5Lexists) and drop the if () { do {} while()} construction?
| // Track status per material so that one failure does not get reported against | ||
| // every material that follows it. | ||
| const herr_t mat_status = saveMaterial(file, metadata, lRhoBounds, lTBounds, leBounds, | ||
| name, add_subtables, eospacWarn); | ||
| if (mat_status != H5_SUCCESS) { | ||
| std::cerr << "ERROR [" << matid << "]: problem with HDF5 while saving material." | ||
| << std::endl; | ||
| num_failed += 1; | ||
| } | ||
| } | ||
|
|
||
| if (num_failed > 0) { | ||
| std::cerr << "WARNING: " << num_failed << " of " << matids.size() | ||
| << " materials could not be saved." << std::endl; | ||
| } | ||
| // Count failures rather than summing herr_t values, which can cancel out and | ||
| // report success. | ||
| return (num_failed == 0) ? H5_SUCCESS : -1; |
There was a problem hiding this comment.
perhaps we should track which matids failed and summarize them at the end. I know it's in the error messages above, but I think that might still be nice to have a summary at the bottom.
Add API for a vector of matid's in the sesame2spiner library.
PR Summary
Adds a saveAllMaterials interface to the sesame2spiner library so host codes can generate an sp5 file directly from a list of sesame matids — with or without per-material Params overrides — instead of having to write out input files first, plus an hid_t overload that lets callers build a file up one material at a time. All overloads, including the existing file-based one, now funnel into a single core implementation, so duplicate matid and name detection queries the HDF5 file itself (H5Lexists) rather than in-memory sets and stays correct across incremental calls. Also fixes three latent bugs surfaced by the refactor: a matid absent from the sesame file previously yielded all-zero metadata bounds that reached log() and produced NaN grids with no diagnostic (now reported and skipped, other materials still save), eosGetMetadata no longer ignores the caller's verbosity in favor of a hardcoded Verbosity::Debug, and appending to an existing file now validates its log_type root attribute against the current build.
make formatcommand after configuring withcmake.plan_historiesfolder, with a filename the same as the MR number.If preparing for a new release, in addition please check the following: