Skip to content
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 DirectionId and DirectionIdMap #5621

Merged
merged 3 commits into from
Nov 16, 2023

Conversation

kidder
Copy link
Member

@kidder kidder commented Nov 11, 2023

Proposed changes

These are used throughout the subcell code, and I also want to use them in some AMR code.

Upgrade instructions

Code review checklist

  • The code is documented and the documentation renders correctly. Run
    make doc to generate the documentation locally into BUILD_DIR/docs/html.
    Then open index.html.
  • The code follows the stylistic and code quality guidelines listed in the
    code review guide.
  • The PR lists upgrade instructions and is labeled bugfix or
    new feature if appropriate.

Further comments

Copy link
Member

@nilsdeppe nilsdeppe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Couple minor things. Could you also do a git grep "boost::hash<DirectionId"? those should all be replaceable with the defaulted std::hash

Edit: I'm happy to have the boost::hash removal be a separate commit after these two to make it easier :)

#include "Domain/Structure/Direction.hpp"
#include "Domain/Structure/ElementId.hpp"

namespace PUP {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wrap in /// \cond

return h;
}

// clang-tidy: do not modify namespace std
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we NOLINT(SPECIFIC_ERROR) here?

template <size_t Dim, typename T>
class DirectionIdMap
: public FixedHashMap<maximum_number_of_neighbors(Dim), DirectionId<Dim>, T,
boost::hash<DirectionId<Dim>>> {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not just leave the hasher defaulted? You added a std::hash for DirectionId

/// \endcond

template <size_t VolumeDim>
struct DirectionId {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two thoughts: (1) DirectionId sounds like the ID for a direction, which made me wonder why we need an ID for it until I realized it stands for "Direction and neighbor ID". Related: (2) this same type is defined as MortarId in MortarHelpers.hpp. So maybe name it MortarId? It's not always used to identify DG mortars but IMO that's fine. If you don't like it maybe we can give it a thought on the Monday call.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just as a note in case I can't make the meeting for some unexpected reason, we used to have this data structure and called it DirectionalElementId.

I don't love the subcell code using MortarId since there are no mortars, really. Most of the places that would use it are actually indexing volume data. I worry that the subcell code is already too complicated with my best efforts to use clear names, so using a name like MortarId for indexing volume data, volume fluxes, neighbor RDMP data, etc. would make it extra confusing :(

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DirectionalElementId sounds good enough to me. We could alias using MortarId = DirectionalElementId in the dg namespace (not requesting this change). Why was the data structure removed (I don't remember it).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good to both! My memory is that at some point we were only using it in a couple places and figured a std::pair was easier than having an extra class (turns out whatever group of us made that decision was wrong :P)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I won't be able to make the meeting tomorrow. I'll do whatever the consensus is, but I'll suggest DirectionalId as that is shorter. I presume you want the same name change for DirectionIdMap as well.

Copy link
Member

@nilsdeppe nilsdeppe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, one minor thing you can squash

@@ -16,7 +16,7 @@ class er;
/// \endcond

template <size_t VolumeDim>
struct DirectionId {
struct DirectionalId {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry I missed this on my last review. Could you document this a bit so it shows up in doxygen?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Use it instead of a std::pair<Direction<Dim>, ElementId<Dim>>.
Use it to when appropriate in subcell code.  It will also be useful in AMR code.
@nilsdeppe nilsdeppe added the auto-merge GitHub's auto-merge has been enabled for this PR. label Nov 15, 2023
@kidder kidder disabled auto-merge November 16, 2023 20:00
@kidder
Copy link
Member Author

kidder commented Nov 16, 2023

ignoring test timeout

@kidder kidder merged commit 357bd46 into sxs-collaboration:develop Nov 16, 2023
21 of 22 checks passed
@kidder kidder deleted the direction_id branch November 16, 2023 20:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auto-merge GitHub's auto-merge has been enabled for this PR.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants