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

Generalize LTS communication handling #5864

Merged
merged 4 commits into from
Mar 28, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions src/Time/TimeStepId.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,16 @@ bool operator<(const TimeStepId& a, const TimeStepId& b) {
return evolution_less<Time>{a.time_runs_forward()}(a.step_time(),
b.step_time());
}
ASSERT(a.substep() == 0 or b.substep() == 0 or a.step_size() == b.step_size(),
"Meaning of ordering for LTS substeps is unclear.");
return a.substep() < b.substep();
if (a.substep() != b.substep()) {
return a.substep() < b.substep();
}
if (a.substep() == 0) {
// Objects are equal.
return false;
}
// Arbitrary, but need a total ordering of TimeStepId to use it as a
// std::map key.
return a.step_size() < b.step_size();
}
bool operator<=(const TimeStepId& a, const TimeStepId& b) { return not(b < a); }
bool operator>(const TimeStepId& a, const TimeStepId& b) { return b < a; }
Expand Down
7 changes: 7 additions & 0 deletions src/Time/TimeStepId.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,19 @@ class TimeStepId {
double substep_time_{};
};

/// These comparisons define a total order on all TimeStepIds with the
/// same direction of time flow. For any two objects representing
/// states of the same element, the ordering will match the
/// computational ordering of those states. For others, (e.g.,
/// overlapping steps) it is arbitrary.
Comment on lines +75 to +76
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we maybe say what the arbitrary decision is? Just that for the arbitrary case, we check which step size is smaller?

Copy link
Member Author

Choose a reason for hiding this comment

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

It's not that simple. That's just the last tie-breaker. The part of the algorithm that does the meaningful ordering also distinguishes some arbitrary cases.

/// @{
bool operator==(const TimeStepId& a, const TimeStepId& b);
bool operator!=(const TimeStepId& a, const TimeStepId& b);
bool operator<(const TimeStepId& a, const TimeStepId& b);
bool operator<=(const TimeStepId& a, const TimeStepId& b);
bool operator>(const TimeStepId& a, const TimeStepId& b);
bool operator>=(const TimeStepId& a, const TimeStepId& b);
/// @}

std::ostream& operator<<(std::ostream& s, const TimeStepId& id);

Expand Down