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