Line data Source code
1 0 : // Distributed under the MIT License.
2 : // See LICENSE.txt for details.
3 :
4 : #pragma once
5 :
6 : #include <memory>
7 : #include <optional>
8 : #include <tuple>
9 :
10 : #include "DataStructures/Tensor/Tensor.hpp"
11 : #include "DataStructures/Tensor/TypeAliases.hpp"
12 : #include "DataStructures/Variables.hpp"
13 : #include "Evolution/Systems/GeneralizedHarmonic/Tags.hpp"
14 : #include "Options/String.hpp"
15 : #include "PointwiseFunctions/GeneralRelativity/Tags.hpp"
16 : #include "Time/TimeStepId.hpp"
17 : #include "Utilities/Serialization/CharmPupable.hpp"
18 :
19 : namespace Cce {
20 : /// \brief Code for interfacing between the characteristic and Cachy systems.
21 1 : namespace InterfaceManagers {
22 :
23 : /// \cond
24 : class GhLocalTimeStepping;
25 : class GhLockstep;
26 : /// \endcond
27 :
28 : /*!
29 : * \brief Abstract base class for storage and retrieval of generalized harmonic
30 : * quantities communicated from a Cauchy simulation to the Cce system.
31 : *
32 : * \details The functions that are required to be overriden in the derived
33 : * classes are:
34 : * - `GhInterfaceManager::get_clone()`: should return a
35 : * `std::unique_ptr<GhInterfaceManager>` with cloned state.
36 : * - `GhInterfaceManager::insert_gh_data()`: should store the portions
37 : * of the provided generalized harmonic data that are required to provide useful
38 : * boundary values for the CCE evolution at requested timesteps.
39 : * - `GhInterfaceManager::request_gh_data()`: should register requests
40 : * from the CCE evolution for boundary data.
41 : * - `GhInterfaceManager::retrieve_and_remove_first_ready_gh_data()`:
42 : * should return a `std::optional<std::tuple<TimeStepId,
43 : * tnsr::aa<DataVector, 3>, tnsr::iaa<DataVector, 3>, tnsr::aa<DataVector, 3>>>`
44 : * containing the boundary data associated with the oldest requested timestep if
45 : * enough data has been supplied via `insert_gh_data()` to determine the
46 : * boundary data. Otherwise, return a `std::nullopt` to indicate that the CCE
47 : * system must continue waiting for generalized harmonic input.
48 : * - `GhInterfaceManager::number_of_pending_requests()`: should return
49 : * the number of requests that have been registered to the class that do not yet
50 : * been retrieved via `retrieve_and_remove_first_ready_gh_data()`.
51 : * - `GhInterfaceManager::number_of_gh_times()`: should return the
52 : * number of time steps sent to `insert_gh_data()` that have not yet been
53 : * retrieved via `retrieve_and_remove_first_ready_gh_data()`.
54 : */
55 1 : class GhInterfaceManager : public PUP::able {
56 : public:
57 0 : using gh_variables = Variables<
58 : tmpl::list<gr::Tags::SpacetimeMetric<DataVector, 3>,
59 : gh::Tags::Pi<DataVector, 3>, gh::Tags::Phi<DataVector, 3>>>;
60 :
61 0 : WRAPPED_PUPable_abstract(GhInterfaceManager); // NOLINT
62 :
63 0 : virtual std::unique_ptr<GhInterfaceManager> get_clone() const = 0;
64 :
65 0 : virtual void request_gh_data(const TimeStepId&) = 0;
66 :
67 0 : virtual auto retrieve_and_remove_first_ready_gh_data()
68 : -> std::optional<std::tuple<TimeStepId, gh_variables>> = 0;
69 :
70 0 : virtual size_t number_of_pending_requests() const = 0;
71 :
72 0 : virtual size_t number_of_gh_times() const = 0;
73 : };
74 :
75 : } // namespace InterfaceManagers
76 : } // namespace Cce
|