-
Notifications
You must be signed in to change notification settings - Fork 5
/
couplingcomms.hpp
85 lines (78 loc) · 2.84 KB
/
couplingcomms.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
/*
* Copyright (c) 2024 MPI-M, Clara Bayley
*
* ----- CLEO -----
* File: couplingcomms.hpp
* Project: runcleo
* Created Date: Sunday 29th October 2023
* Author: Clara Bayley (CB)
* Additional Contributors:
* -----
* Last Modified: Thursday 8th February 2024
* Modified By: CB
* -----
* License: BSD 3-Clause "New" or "Revised" License
* https://opensource.org/licenses/BSD-3-Clause
* -----
* File Description:
* concept defining types which can be used for the
* coupling between SDMMethods and a dynamics solver
* in RunCLEO, also null instance for coupling called
* "NullComms"
*/
#ifndef LIBS_RUNCLEO_COUPLINGCOMMS_HPP_
#define LIBS_RUNCLEO_COUPLINGCOMMS_HPP_
#include <concepts>
#include "../kokkosaliases.hpp"
#include "./coupleddynamics.hpp"
/**
* @concept CouplingComms
* Concept representing types that handle communication between SDM and coupled dynamics solver.
*
* A type satisfies the CouplingComms concept if it provides the following functions:
* - `send_dynamics(h_gbxs, coupldyn)`: Sends dynamics information from SDM view of Gridboxes
* `h_gbxs` to coupled dynamics solver `coupldyn`.
* - `receive_dynamics(coupldyn, h_gbxs)`: Receives dynamics information from coupled dynamics
* solver `coupldyn` into SDM view of Gridboxes `h_gbxs`.
*
* @tparam Comms The type for communication to check against the CouplingComms concept.
* @tparam CD The type for the dyanmics solver to check against the CoupledDynamics concept.
*/
template <typename Comms, typename CD>
concept CouplingComms =
requires(Comms s, CD &coupldyn, viewh_gbx h_gbxs) {
{ s.template send_dynamics<CD>(h_gbxs, coupldyn) } -> std::same_as<void>;
{ s.template receive_dynamics<CD>(coupldyn, h_gbxs) } -> std::same_as<void>;
};
/**
* @struct NullComms
* @brief Represents a null communication handler that doesn't send or receive information.
*
* The NullComms struct implements the CouplingComms concept but doesn't perform any communication
* between SDM Gridboxes and CoupledDynamics solver.
*/
struct NullComms {
/**
* @brief Receives dynamics information.
*
* This function does nothing as it represents a null communication handler.
*
* @tparam CD The coupled dynamics solver type.
* @param coupldyn The coupled dynamics solver object.
* @param h_gbxs The view of Gridboxes.
*/
template <CoupledDynamics CD>
void receive_dynamics(const CD &coupldyn, const viewh_gbx h_gbxs) const {}
/**
* @brief Sends dynamics information.
*
* This function does nothing as it represents a null communication handler.
*
* @tparam CD The coupled dynamics solver type.
* @param h_gbxs The view of Gridboxes.
* @param coupldyn The coupled dynamics solver object.
*/
template <CoupledDynamics CD>
void send_dynamics(const viewh_constgbx h_gbxs, CD &coupldyn) const {}
};
#endif // LIBS_RUNCLEO_COUPLINGCOMMS_HPP_