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 : size_t integration_order;
49 0 : ::TimeStepId current_time_step_id;
50 0 : ::TimeStepId next_time_step_id;
51 0 : Direction<Dim> neighbor_direction;
52 0 : ElementId<Dim> element_id;
53 0 : Mesh<Dim> volume_or_ghost_mesh;
54 0 : Mesh<Dim - 1> interface_mesh;
55 :
56 : // If set to nullptr then we aren't sending that type of data.
57 0 : double* subcell_ghost_data;
58 0 : double* dg_flux_data;
59 :
60 0 : BoundaryMessage() = default;
61 :
62 0 : BoundaryMessage(size_t subcell_ghost_data_size_in,
63 : size_t dg_flux_data_size_in, bool owning_in,
64 : bool enable_if_disabled_in, size_t sender_node_in,
65 : size_t sender_core_in, int tci_status_in,
66 : size_t integration_order_in,
67 : const ::TimeStepId& current_time_step_id_in,
68 : const ::TimeStepId& next_time_step_id_in,
69 : const Direction<Dim>& neighbor_direction_in,
70 : const ElementId<Dim>& element_id_in,
71 : const Mesh<Dim>& volume_or_ghost_mesh_in,
72 : const Mesh<Dim - 1>& interface_mesh_in,
73 : double* subcell_ghost_data_in, double* dg_flux_data_in);
74 :
75 : /*!
76 : * \brief This is the size (in bytes) necessary to allocate a BoundaryMessage
77 : * including the arrays of data as well.
78 : *
79 : * This will add `(subcell_size + dg_size) * sizeof(double)` number of bytes
80 : * to `sizeof(BoundaryMessage<Dim>)`.
81 : */
82 1 : static size_t total_bytes_with_data(size_t subcell_size, size_t dg_size);
83 :
84 0 : static void* pack(BoundaryMessage*);
85 0 : static BoundaryMessage* unpack(void*);
86 : };
87 :
88 : template <size_t Dim>
89 0 : bool operator==(const BoundaryMessage<Dim>& lhs,
90 : const BoundaryMessage<Dim>& rhs);
91 : template <size_t Dim>
92 0 : bool operator!=(const BoundaryMessage<Dim>& lhs,
93 : const BoundaryMessage<Dim>& rhs);
94 :
95 : template <size_t Dim>
96 0 : std::ostream& operator<<(std::ostream& os, const BoundaryMessage<Dim>& message);
97 :
98 : } // namespace evolution::dg
99 :
100 0 : #define CK_TEMPLATES_ONLY
101 : #include "Evolution/DiscontinuousGalerkin/Messages/BoundaryMessage.def.h"
102 : #undef CK_TEMPLATES_ONLY
|