-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: Split out time step from indexing header
- Loading branch information
Showing
2 changed files
with
49 additions
and
30 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/** | ||
* \file timestep.hpp | ||
* \brief Base class for timestep | ||
* \author Tobit Flatscher (github.com/2b-t) | ||
*/ | ||
|
||
#ifndef LBT__INDEXING__TIMESTEP | ||
#define LBT__INDEXING__TIMESTEP | ||
#pragma once | ||
|
||
#include <ostream> | ||
|
||
|
||
namespace lbt { | ||
|
||
/**\enum Timestep | ||
* \brief Strongly typed enum for even and odd time steps required for AA access pattern | ||
*/ | ||
enum class Timestep: bool { | ||
Even = false, | ||
Odd = true | ||
}; | ||
|
||
/**\fn operator! | ||
* \brief Negation operator for the timestep | ||
* | ||
* \param[in] ts Timestep to be negated | ||
* \return Negated timestep | ||
*/ | ||
inline constexpr Timestep operator! (Timestep const& ts) noexcept { | ||
return (ts == Timestep::Even) ? Timestep::Odd : Timestep::Even; | ||
} | ||
|
||
/**\fn Timestep output stream operator | ||
* \brief Output stream operator for the timestep | ||
* | ||
* \param[in,out] os Output stream | ||
* \param[in] ts Timestep to be printed to output stream | ||
* \return Output stream including the type of timestep | ||
*/ | ||
inline std::ostream& operator << (std::ostream& os, Timestep const& ts) noexcept { | ||
os << ((ts == Timestep::Even) ? "even time step" : "odd time step"); | ||
return os; | ||
} | ||
|
||
} | ||
|
||
#endif // LBT__INDEXING__TIMESTEP |