Line data Source code
1 : #ifndef AMREX_PERIODICITY_H_ 2 : #define AMREX_PERIODICITY_H_ 3 : #include <AMReX_Config.H> 4 : 5 : #include <AMReX_IntVect.H> 6 : #include <AMReX_Box.H> 7 : #include <vector> 8 : 9 : namespace amrex { 10 : 11 : /** 12 : * \brief This provides length of period for periodic domains. 0 means it is 13 : * not periodic in that direction. 14 : * It is also assumed that the periodic domain starts with index 0. 15 : */ 16 : class Periodicity 17 : { 18 : public: 19 : Periodicity () noexcept : period(AMREX_D_DECL(0,0,0)) {} 20 10184 : explicit Periodicity (const IntVect& v) noexcept : period(v) {} 21 : 22 0 : [[nodiscard]] bool isAnyPeriodic () const noexcept 23 0 : { return AMREX_D_TERM(period[0]>0, || period[1]>0, || period[2]>0); } 24 : [[nodiscard]] bool isAllPeriodic () const noexcept 25 : { return AMREX_D_TERM(period[0]>0, && period[1]>0, && period[2]>0); } 26 : [[nodiscard]] bool isPeriodic (int dir) const noexcept 27 : { return period[dir]>0; } 28 : 29 : bool operator==(const Periodicity& rhs) const noexcept 30 : { return period == rhs.period; } 31 : 32 : //! Cell-centered domain Box "infinitely" long in non-periodic directions. 33 : [[nodiscard]] Box Domain () const noexcept; 34 : 35 : [[nodiscard]] std::vector<IntVect> shiftIntVect () const; 36 : 37 : static const Periodicity& NonPeriodic () noexcept; 38 : 39 : private: 40 : IntVect period; 41 : }; 42 : 43 : } 44 : 45 : #endif