-
Notifications
You must be signed in to change notification settings - Fork 191
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
Add function to copy mutable creation items from DataBox into a TaggedTuple #4678
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This technically adds a cyclic dependency between Parallel and DataStructures. Should probably be resolved by moving PUP things out of Parallel. But I have another suggestion: I have needed a get_items
function in some places in the elliptic code (search for "get_items", implemented as a lambda in some places). It gets multiple items from the DataBox and returns a tuple that can be assigned to structured bindings. How about we make that a DataBox function. Then I think you can build the TaggedTuple using get_items and serialize/deserialize where you need it.
@@ -203,6 +204,12 @@ class DataBox<tmpl::list<Tags...>> : private detail::Item<Tags>... { | |||
using mutable_subitem_tags = tmpl::flatten< | |||
tmpl::transform<mutable_item_tags, db::Subitems<tmpl::_1>>>; | |||
|
|||
/// A list of all the immutable item tags used to create the DataBox |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"mutable"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
duh 👍
@@ -244,26 +251,28 @@ class DataBox<tmpl::list<Tags...>> : private detail::Item<Tags>... { | |||
std::string print_types() const; | |||
|
|||
/// Print the items | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
drop
Yes, I agree we should probably make a Serialization library somewhere and put various things in it to break the dependency. |
Yes to the Serialization lib. We can place it in Utilities/Serialization/, as its own lib (because it's sort of an extension of Charm and has to live at the same low level as Utilities, below DataStructures). I didn't suggest to switch TaggedTuple -> tuple. My suggestion is to make a const auto& [x, y] = db::get_items<Tags::X, Tags::Y>(box); It replaces long lists of |
Okay, so I'd prefer to refactor in a separate PR. And yes, I see the usefulness of |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sounds good. please squash the changes above directly.
Also rename some template parameters to match names of type aliases.
This will be used to send data needed to initialize new elements from their parent or children.
08b9d44
to
1fd77ad
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, one question
* the mutable_item_creation_tags of the DataBox | ||
*/ | ||
template <typename CopiedItemsTagList, typename DbTagList> | ||
SPECTRE_ALWAYS_INLINE auto copy_items(const DataBox<DbTagList>& box) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do you only want a copy, or would a move one be useful too? If it's always a copy, that's fine, just asking :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A move could also be useful and might be the right choice; I'll do that in a separate PR as moving an item will need to reset subitems and compute items that depend on the moved item...
Proposed changes
This allows data to be sent to newly created Elements from their parent or children during AMR
Upgrade instructions
Code review checklist
make doc
to generate the documentation locally intoBUILD_DIR/docs/html
.Then open
index.html
.code review guide.
bugfix
ornew feature
if appropriate.Further comments