Line data Source code
1 0 : // Distributed under the MIT License. 2 : // See LICENSE.txt for details. 3 : 4 : #pragma once 5 : 6 : #include <cstddef> 7 : #include <ostream> 8 : #include <type_traits> 9 : 10 : #include "Domain/Structure/Direction.hpp" 11 : #include "Domain/Structure/ElementId.hpp" 12 : #include "NumericalAlgorithms/Spectral/Mesh.hpp" 13 : #include "Time/TimeStepId.hpp" 14 : #include "Utilities/GetOutput.hpp" 15 : #include "Utilities/PrettyType.hpp" 16 : 17 : #include "Evolution/DiscontinuousGalerkin/Messages/BoundaryMessage.decl.h" 18 : 19 : namespace evolution::dg { 20 : /*! 21 : * \brief [Charm++ Message] 22 : * (https://charm.readthedocs.io/en/latest/charm%2B%2B/manual.html#messages) 23 : * intended to be used in `receive_data` calls on the elements to send boundary 24 : * data from one element on one node, to a different element on a (potentially) 25 : * different node. 26 : * 27 : * If this message is to be sent across nodes, the `pack()` and `unpack()` 28 : * methods will be called on the sending and receiving node, respectively. 29 : */ 30 : template <size_t Dim> 31 1 : struct BoundaryMessage : public CMessage_BoundaryMessage<Dim> { 32 0 : using base = CMessage_BoundaryMessage<Dim>; 33 : 34 : // Needed for charm registration 35 0 : static std::string name() { 36 : return "BoundaryMessage<" + get_output(Dim) + ">"; 37 : }; 38 : 39 0 : size_t subcell_ghost_data_size; 40 0 : size_t dg_flux_data_size; 41 : // Whether or not this BoundaryMessage owns the data that the subcell and dg 42 : // pointers point to 43 0 : bool owning; 44 0 : bool enable_if_disabled; 45 0 : size_t sender_node; 46 0 : size_t sender_core; 47 0 : int tci_status; 48 0 : ::TimeStepId current_time_step_id; 49 0 : ::TimeStepId next_time_step_id; 50 0 : Direction<Dim> neighbor_direction; 51 0 : ElementId<Dim> element_id; 52 0 : Mesh<Dim> volume_or_ghost_mesh; 53 0 : Mesh<Dim - 1> interface_mesh; 54 : 55 : // If set to nullptr then we aren't sending that type of data. 56 0 : double* subcell_ghost_data; 57 0 : double* dg_flux_data; 58 : 59 0 : BoundaryMessage() = default; 60 : 61 0 : BoundaryMessage(const size_t subcell_ghost_data_size_in, 62 : const size_t dg_flux_data_size_in, const bool owning_in, 63 : const bool enable_if_disabled_in, const size_t sender_node_in, 64 : const size_t sender_core_in, const int tci_status_in, 65 : const ::TimeStepId& current_time_step_id_in, 66 : const ::TimeStepId& next_time_step_id_in, 67 : const Direction<Dim>& neighbor_direction_in, 68 : const ElementId<Dim>& element_id_in, 69 : const Mesh<Dim>& volume_or_ghost_mesh_in, 70 : const Mesh<Dim - 1>& interface_mesh_in, 71 : double* subcell_ghost_data_in, double* dg_flux_data_in); 72 : 73 : /*! 74 : * \brief This is the size (in bytes) necessary to allocate a BoundaryMessage 75 : * including the arrays of data as well. 76 : * 77 : * This will add `(subcell_size + dg_size) * sizeof(double)` number of bytes 78 : * to `sizeof(BoundaryMessage<Dim>)`. 79 : */ 80 1 : static size_t total_bytes_with_data(const size_t subcell_size, 81 : const size_t dg_size); 82 : 83 0 : static void* pack(BoundaryMessage*); 84 0 : static BoundaryMessage* unpack(void*); 85 : }; 86 : 87 : template <size_t Dim> 88 0 : bool operator==(const BoundaryMessage<Dim>& lhs, 89 : const BoundaryMessage<Dim>& rhs); 90 : template <size_t Dim> 91 0 : bool operator!=(const BoundaryMessage<Dim>& lhs, 92 : const BoundaryMessage<Dim>& rhs); 93 : 94 : template <size_t Dim> 95 0 : std::ostream& operator<<(std::ostream& os, const BoundaryMessage<Dim>& message); 96 : 97 : } // namespace evolution::dg 98 : 99 0 : #define CK_TEMPLATES_ONLY 100 : #include "Evolution/DiscontinuousGalerkin/Messages/BoundaryMessage.def.h" 101 : #undef CK_TEMPLATES_ONLY