-
Notifications
You must be signed in to change notification settings - Fork 5
/
superdrop.hpp
294 lines (262 loc) · 9.18 KB
/
superdrop.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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
/*
* Copyright (c) 2024 MPI-M, Clara Bayley
*
*
* ----- CLEO -----
* File: superdrop.hpp
* Project: superdrops
* Created Date: Friday 13th October 2023
* Author: Clara Bayley (CB)
* Additional Contributors:
* -----
* Last Modified: Monday 29th April 2024
* Modified By: CB
* -----
* License: BSD 3-Clause "New" or "Revised" License
* https://opensource.org/licenses/BSD-3-Clause
* -----
* File Description:
* Header file for definition of a superdropet.
* Equations referenced as (eqn [X.YY]) are from
* "An Introduction To Clouds From The Microscale
* to Climate" by Lohmann, Luond and Mahrt, 1st edition.
*/
#ifndef LIBS_SUPERDROPS_SUPERDROP_HPP_
#define LIBS_SUPERDROPS_SUPERDROP_HPP_
#include "./superdrop_attrs.hpp"
#include "./superdrop_ids.hpp"
/**
* @brief Class representing a super-droplet (synonyms: superdroplet, superdrop, SD).
*
* This class defines properties and operations of a super-droplet
* (synonyms: superdroplet, superdrop, SD).
*/
class Superdrop {
private:
unsigned int sdgbxindex; /**< Index of the gridbox the superdrop occupies */
double coord3; /**< 3rd spatial coordinate of the superdrop (vertical) */
double coord1; /**< 1st spatial coordinate of the superdrop (eastwards) */
double coord2; /**< 2nd spatial coordinate of the superdrop (northwards) */
SuperdropAttrs attrs; /**< instance of SuperdropAttrs for attributes of the super-droplet */
public:
// TODO(all): define superdrop IDType using macros
using IDType = IntID; /**< Type of ID to identify superdrop via 8 byte integer */
// using IDType = EmptyID; /**< Type of ID for non-existent superdrop identity */
[[no_unique_address]] IDType sdId;
/**< instance of super-droplet identity of Superdrop::IDType */
/**
* @brief Default constructor requirement for use of Superdrop in Kokkos View
*/
Superdrop() = default;
/**
* @brief Default destructor requirement for use of Superdrop in Kokkos View
*/
~Superdrop() = default;
/**
* @brief Parameterized constructor.
*
* @param i_sdgbxindex Index of the gridbox the superdrop occupies.
* @param i_coord3 3rd spatial coordinate of the superdroplet.
* @param i_coord1 1st spatial coordinate of the superdroplet.
* @param i_coord2 2nd spatial coordinate of the superdroplet.
* @param i_attrs Attributes of the superdroplet.
* @param i_sdId Unique ID of the superdroplet.
*/
KOKKOS_INLINE_FUNCTION
Superdrop(const unsigned int i_sdgbxindex, const double i_coord3, const double i_coord1,
const double i_coord2, const SuperdropAttrs i_attrs, const IDType i_sdId)
: sdgbxindex(i_sdgbxindex),
coord3(i_coord3),
coord1(i_coord1),
coord2(i_coord2),
attrs(i_attrs),
sdId(i_sdId) {}
/**
* @brief Get the index of the Gridbox the superdrop currently occupies.
*
* @return Gridbox Index.
*/
KOKKOS_INLINE_FUNCTION auto get_sdgbxindex() const { return sdgbxindex; }
/**
* @brief Get the 3rd spatial coordinate of the superdroplet.
*
* @return 3rd spatial coordinate.
*/
KOKKOS_INLINE_FUNCTION auto get_coord3() const { return coord3; }
/**
* @brief Get the 1st spatial coordinate of the superdroplet.
*
* @return 1st spatial coordinate.
*/
KOKKOS_INLINE_FUNCTION auto get_coord1() const { return coord1; }
/**
* @brief Get the 2nd spatial coordinate of the superdroplet.
*
* @return 2nd spatial coordinate.
*/
KOKKOS_INLINE_FUNCTION auto get_coord2() const { return coord2; }
/**
* @brief Returns 'true' if the super-droplet has solute.
*
* This function checks whether the super-droplet contains solute.
*
* @return true if the super-droplet has solute, false otherwise.
*/
KOKKOS_INLINE_FUNCTION auto is_solute() const { return attrs.is_solute(); }
/**
* @brief Get the solute of the superdroplet.
*
* @return super-droplet's solute
*/
KOKKOS_INLINE_FUNCTION auto get_solute() const { return attrs.get_solute(); }
/**
* @brief Get the density of the super-droplet's solute.
*
* @return density of the super-droplet's solute.
*/
KOKKOS_INLINE_FUNCTION auto get_rho_sol() const { return attrs.get_rho_sol(); }
/**
* @brief Get the molecular mass of the super-droplet's solute.
*
* @return molecular mass of the super-droplet's solute.
*/
KOKKOS_INLINE_FUNCTION auto get_mr_sol() const { return attrs.get_mr_sol(); }
/**
* @brief Get the van't Hoff ionic factor of the super-droplet's solute.
*
* @return van't Hoff ionic factor of the super-droplet's solute.
*/
KOKKOS_INLINE_FUNCTION auto get_ionic() const { return attrs.get_ionic(); }
/**
* @brief Get the multiplicity 'xi' of the super-droplet.
*
* @return multiplicity 'xi' of the super-droplet.
*/
KOKKOS_INLINE_FUNCTION auto get_xi() const { return attrs.xi; }
/**
* @brief Get the spherical radius of the super-droplet.
*
* @return spherical radius of the super-droplet.
*/
KOKKOS_INLINE_FUNCTION auto get_radius() const { return attrs.radius; }
/**
* @brief Get the mass of solute dissolved in the super-droplet.
*
* @return mass of solute in the super-droplet.
*/
KOKKOS_INLINE_FUNCTION auto get_msol() const { return attrs.msol; }
/**
* @brief Get the mass of the super-droplet.
*
* @return mass of the super-droplet.
*/
KOKKOS_INLINE_FUNCTION double mass() const { return attrs.mass(); }
/**
* @brief Get the volume of the super-droplet.
*
* @return volume of the super-droplet.
*/
KOKKOS_INLINE_FUNCTION double vol() const { return attrs.vol(); }
/**
* @brief Get the radius of the super-droplet cubed.
*
* @return radius of the super-droplet cubed.
*/
KOKKOS_INLINE_FUNCTION double rcubed() const { return attrs.rcubed(); }
/**
* @brief Set the multiplicity 'xi' of the super-droplet.
*
* This function sets the value of the super-droplet's multiplicity 'xi' to the specified value.
*
* @param i_xi The value to set for xi
*/
KOKKOS_INLINE_FUNCTION
void set_xi(const uint64_t i_xi) { attrs.set_xi(i_xi); }
/**
* @brief Set the radius of the super-droplet.
*
* This function sets the value of the super-droplet's radius to the specified value.
*
* _Note:_ See also change_radius which limits super-droplet radius to its dry radius.
*
* @param i_radius The value to set for radius.
*/
KOKKOS_INLINE_FUNCTION
void set_radius(const double i_radius) { attrs.set_radius(i_radius); }
/**
* @brief Sets the value of the super-droplet's mass of solute.
*
* This function sets the value of the super-droplet's solute mass to the specified value.
*
* @param i_msol The value to set for msol.
*/
KOKKOS_INLINE_FUNCTION
void set_msol(const double i_msol) { attrs.set_msol(i_msol); }
/**
* @brief Set the radius of the super-droplet no less than its dry radius.
*
* This function sets the value of the super-droplet's radius to the specified value
* if its new radius >= its dry radius. Return is difference in radius accoding to super-droplet's
* attributes struct.
*
* _Note:_ See also set_radius which allows super-droplet radius less than its dry radius
*
* @param newr The value to set the radius >= dry radius.
* @return change in radius of the super-droplet.
*/
KOKKOS_INLINE_FUNCTION
double change_radius(const double newr) { return attrs.change_radius(newr); }
/**
* @brief Sets the value of the super-droplet's Gridbox index.
*
* This function sets the value of the super-droplet's sdgbxindex to the specified value.
*
* @param i_sdgbxindex The value to set for sdgbxindex.
*/
KOKKOS_INLINE_FUNCTION
void set_sdgbxindex(const unsigned int i_sdgbxindex) { sdgbxindex = i_sdgbxindex; }
/**
* @brief Sets the value of the 3rd coordinate.
*
* This function sets the value of coord3 of the super-droplet to the specified value.
*
* @param i_coord3 The value to set for coord3.
*/
KOKKOS_INLINE_FUNCTION
void set_coord3(const double i_coord3) { coord3 = i_coord3; }
/**
* @brief Sets the value of the 1st coordinate.
*
* This function sets the value of coord1 of the super-droplet to the specified value.
*
* @param i_coord1 The value to set for coord1.
*/
KOKKOS_INLINE_FUNCTION
void set_coord1(const double i_coord1) { coord1 = i_coord1; }
/**
* @brief Sets the value of the 2nd coordinate.
*
* This function sets the value of coord2 of the super-droplet to the specified value.
*
* @param i_coord2 The value to set for coord2.
*/
KOKKOS_INLINE_FUNCTION
void set_coord2(const double i_coord2) { coord2 = i_coord2; }
/**
* @brief Increments the coordinates by the specified deltas.
*
* This function increments the coordinates of the super-droplet by the specified deltas along
* each dimension.
*
* @param delta3 The delta for the third coordinate (coord3).
* @param delta1 The delta for the first coordinate (coord1).
* @param delta2 The delta for the second coordinate (coord2).
*/
KOKKOS_INLINE_FUNCTION
void increment_coords(const double delta3, const double delta1, const double delta2) {
coord3 += delta3;
coord1 += delta1;
coord2 += delta2;
}
};
#endif // LIBS_SUPERDROPS_SUPERDROP_HPP_