-
Notifications
You must be signed in to change notification settings - Fork 37
Allow for accessing flux Metadata
from Metadata::WithFluxes
Metadata
#1161
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
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.
LGTM! Should we have a test?
Let's have a Sam based test first. Once that passes I can add one to the unit tests. |
@Yurlungur: Maybe this isn't the "right" way to do things. It seems like we will have to add a second flag for many options just so that it can pass through to the fluxes. Maybe we should really be making a Also, I added a flag |
I think this is a nice idea... though I would suggest it be optional.
👍 |
It would have to be optional for backward compatibility, but the idea would be to just have a set of default Metadata (which we effectively have now) and allow that to be overridden with by the new constructor. |
Metadata::OneCopy
Metadata
from Metadata::WithFluxes
Metadata
@@ -213,7 +213,7 @@ TaskStatus ReceiveBoundBufs(std::shared_ptr<MeshData<Real>> &md) { | |||
[&all_received](auto pbuf) { all_received = pbuf->TryReceive() && all_received; }); | |||
|
|||
int ibound = 0; | |||
if (Globals::sparse_config.enabled) { | |||
if (Globals::sparse_config.enabled && all_received) { |
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 changes to allocating fields only after all boundary buffers are received. This should have no impact on code behavior, but can have a performance impact in some cases. The change is unrelated to the rest of the PR.
@@ -138,7 +138,7 @@ struct PackDescriptor { | |||
// default constructor needed for certain use cases | |||
PackDescriptor() | |||
: nvar_groups(0), var_group_names({}), var_groups({}), with_fluxes(false), | |||
coarse(false), flat(false), identifier("") {} | |||
coarse(false), flat(false), identifier(""), nvar_tot(0) {} |
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 just counts the total number of variables included in the pack at the time of PackDescriptor
construction so it doesn't have to be redone every time the cache is checked to see if a given pack is stale. Unrelated to the bulk of this PR.
astat[idx++] = | ||
uid_map.count(uid) > 0 ? (uid_map.at(uid))->GetAllocationStatus() : -1; |
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.
Try to limit branching and preallocate the std::vector
for SparsePack
cache checking. Unrelated to the rest of the PR.
Metadata
from Metadata::WithFluxes
Metadata
Metadata
from Metadata::WithFluxes
Metadata
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 all looks good to me.
PR Summary
This PR adds a
std::shared_ptr<Metadata> flux_metadata
member toMetadata
that is initialized in theMetadata
constructor when the flagMetadata::WithFluxes
is set. A newMetadata
constructor is added that takes a list of flags for both the original field and the flux field, as well as separate prolongation and restriction operations for the base field and the flux field (but all of the old constructors behavior is unchanged). The easier way to set non-default properties of the fluxMetadata
is to get access to it through the methodMetadata::GetSPtrFluxMetadata()
andSet
andUnset
flags there and register refinement operations, e.g.This PR also adds a flag
Metadata::CellMemAligned
, which causes a field to have memory allocated with the same size as a cell variable no matter what its topological type is. This is set by default for fluxes associated with cell centered fields (to ensure backwards compatibility). Obviously, having this flag set means that face, edge, and nodal fields will be missing one layer of ghosts on some sides, but having it set can allow for vectorization in some downstream codes.Finally, (sorry) this PR includes a couple of small changes to sparse pack cache checking and to boundary communication. These are just performance enhancements that got merged into this branch by mistake and it was easier to leave them in than jump through a bunch of git hoops. If people are strongly opposed to including them here, let me know.
PR Checklist