-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Extract restart read/write IO from M2ulPhyS
#243
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Based on kevin's comments, we don't use or maintain this anymore, so better get rid of it.
On the path to making the IO capabilities more reusable, in this commit we extract 5 functions out of M2ulPhyS and into standalone functions. The refactored functions are write_soln_data read_partitioned_soln_data read_serialized_soln_data partitioning_file_hdf5 serialize_soln_for_write
This is an intermediate commit. The idea is to extract the most of the read and write functionality from M2ulPhyS::restart_files_hdf5 into separate functions. In the previous state the read and write code were intertwined, which made it difficult to understand. The eventual goal is to move the parts that are generic into IODataOrganizer (and related classes), in order to minimize the restart read/write code within M2ulPhyS, which should make it easier to reuse these capabilities for other Solver types down the road.
This involves 3 functions that now perform the bulk of the work. First, the (previously standalone) function serialize_soln_for_write is moved into the IOFamily class, as serializeForWrite. Second, two new functions (IODataOrganizer::write and IODataOrganizer::writeSerial) are introduced to handle writing field data that has been registered through the IODataOrganizer class. At the moment these functions are separate b/c they require different input data (i.e., writeSerial needs information, such as the partitioning array, that write does not). They could be unified, potentially by extending IODataOrganizer::initializeSerial to obtain this extra information rather than passing it directly to writeSerial. But, this refactor is left for later.
This is mostly analogous to the write support from the previous commit, with new read functions being added to IODataOrganizer. But, in addition we have to support the option to read data from a different order solution (to support restarting from lower order fields). This is facilitated by adding "aux" objects (FiniteElementCollection FiniteElementSpace, and ParGridFunction) to the IOFamily class. In the previous implementation, these were instantiated directly within the read function and were specific to the DG discretization used by M2ulPhyS. The new implementation should be generic (although that generality is not yet tested).
Closed
Refactor functions in IODataOrganizer so that capabilities previously distributed between read, readSerial, and readChangeOrder are all now handled by a single read function.
The logic in IODataOrganizer::read is hard to follow in big chunks, so move those big chunks into the IOFamily class, which is where they belong. Also, move IOVar vector into IOFamily, which simplifies the code slightly, and just makes more sense than storing the info in IODataOrganizer where we have to map from the family name to the variables.
Now the methods IOFamily::writePartitioned and IOFamily::writeSerial handle the data write, making the logic in IODataOrganizer::write easier to follow.
And rename to readDistributeSerializedVariable. This function needed the IOFamily info, so makes more sense as a class method.
To reduce duplicated code in size consistency checks. Also, some other minor cleaning up.
Plus a couple name changes to be a tiny bit more descriptive
Trailing underscore indicates class member variable.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The goal of this PR is to refactor the restart file IO capabilities currently housed within
M2ulPhyS
so that they may be better used by other classes in the future. Specifically, we have moved the bulk of the data read/write functions into theIODataOrganizer
andIOFamily
classes. The parts that remain withinM2ulPhyS
are metadata read/write capabilities that, at least in principle, could change in other classes and therefore should remain class-specific.Merging this PR closes #244.