Line data Source code
1 0 : // Distributed under the MIT License. 2 : // See LICENSE.txt for details. 3 : 4 : // This file is tested in Test_InboxTags.cpp 5 : 6 : #pragma once 7 : 8 : #include <cstddef> 9 : #include <map> 10 : 11 : #include "Domain/Structure/DirectionalIdMap.hpp" 12 : #include "Evolution/DiscontinuousGalerkin/BoundaryData.hpp" 13 : #include "Time/TimeStepId.hpp" 14 : 15 : /// \cond 16 : namespace PUP { 17 : class er; 18 : } // namespace PUP 19 : /// \endcond 20 : 21 : namespace evolution::dg { 22 : /// Class wrapping a map and mirroring the AtomicInboxBoundaryData 23 : /// interface so that code accessing the inbox doesn't need to care 24 : /// which implementation is in use. 25 : template <size_t Dim> 26 1 : struct InboxBoundaryData { 27 0 : using mapped_type = DirectionalIdMap<Dim, evolution::dg::BoundaryData<Dim>>; 28 : 29 0 : std::map<TimeStepId, mapped_type> messages; 30 : 31 : /// Number of messages needed to restart the algorithm. This should 32 : /// be decremented whenever a new message is added to the inbox. 33 1 : int missing_messages = 0; 34 : 35 0 : bool empty() const; 36 : 37 : /// In AtomicInboxBoundaryData, this moves elements from the 38 : /// threadsafe structure to the `messages` field. This class stores 39 : /// messages in the `messages` field directly, so this method just 40 : /// zeros the missing message count. 41 1 : void collect_messages(); 42 : 43 : /// Set a lower bound on the number of messages required for the 44 : /// algorithm to make progress since the most recent call to 45 : /// `collect_messages`. After that number of new messages have been 46 : /// received, `BoundaryCorrectionAndGhostCellsInbox` will restart 47 : /// the algorithm. 48 : /// 49 : /// \return whether enough messages have been received. 50 1 : bool set_missing_messages(size_t count); 51 : 52 0 : void pup(PUP::er& p); 53 : }; 54 : } // namespace evolution::dg