Create Super-droplets Sub-Module¶
Header file: <libs/runcleo/createsupers.hpp>
[source]
This sub-module defines functions and classes called by RunCLEO to create and initialise super-droplets in Kokkos view (on device).
-
class GenSuperdrop¶
Struct that holds data for the initial conditions of super-droplets.
This struct holds data for the initial conditions of some properties of super-droplets and provides an operator which returns a super-droplet generated using them.
Public Functions
-
template<typename SuperdropInitConds>
inline explicit GenSuperdrop(const SuperdropInitConds &sdic)¶ Constructs a GenSuperdrop instance.
This constructor initializes a GenSuperdrop instance using the provided SuperdropInitConds instance to fetch initial data.
- Template Parameters:
SuperdropInitConds – The type of the data for super-droplets’ initial conditions.
- Parameters:
sdic – The instance of the data for super-droplets’ initial conditions.
-
inline unsigned int get_local_nsupers()¶
-
Superdrop operator()(const unsigned int kk) const¶
Generate a super-droplet using initial data for the kk’th superdrop.
This function returns a superdrop generated from the specified position ‘kk’ in the initial conditions data.
- Parameters:
kk – The index of the superdrop to generate.
- Returns:
The generated super-droplet.
Private Functions
-
std::array<double, 3> coords_at(const unsigned int kk) const¶
Returns initial spatial coordinates of the kk’th super-droplet.
A coordinate is only copied from the corresponding coords vector if that coordinate is consistent with the number of spatial dimensions of the model. Otherwise, the coordinate is set to 0.0. For example, if the model is 1-D, only coord3 is obtained from the initial data vector; coord1 and coord2 are set to 0.0.
- Parameters:
kk – The index of the super-droplet in the initial data (0 <= kk < total number of super-droplets).
- Returns:
An array containing the kk’th superdroplet’s spatial coordinates (coord3, coord1, coord2).
-
SuperdropAttrs attrs_at(const unsigned int kk) const¶
Function returns a superdroplet’s attributes from position ‘kk’ in the initial conditions data. All super-droplets have the same solute properties.
- Parameters:
kk – The index of the super-droplet in the initial data (0 <= kk < total number of super-droplets).
- Returns:
The attributes of the superdrop from index ‘kk’.
-
template<typename SuperdropInitConds>
-
template<typename SuperdropInitConds>
viewd_supers create_supers(const SuperdropInitConds &sdic)¶ Create a view of super-droplets in (device) memory.
This function creates an ordered view of superdrops in device memory, where the number of superdrops is specified by the parameter
totnsupers
. The superdrops are ordered by the gridbox indexes and generated using a generator which uses the initial conditions provided by theSuperdropInitConds
type.Kokkos::Profiling are null pointers unless a Kokkos profiler library has been exported to “KOKKOS_TOOLS_LIBS” prior to runtime so the lib gets dynamically loaded.
- Template Parameters:
SuperdropInitConds – The type of the super-droplets’ initial conditions data.
- Parameters:
sdic – The instance of the super-droplets’ initial conditions data.
- Returns:
A view of super-droplets in device memory.
-
template<typename SuperdropInitConds>
viewd_supers initialise_supers(const SuperdropInitConds &sdic)¶ Return an initialised view of superdrops in device memory.
This function initialises a view of superdrops in device memory by creating a view on the device and copying a host mirror view that is initialised using the
SuperdropInitConds
instance.- Template Parameters:
SuperdropInitConds – The type of the super-droplets’ initial conditions data.
- Parameters:
sdic – The instance of the super-droplets’ initial conditions data.
- Returns:
A view of superdrops in device memory.
-
template<typename SuperdropInitConds>
viewd_supers::HostMirror initialise_supers_on_host(const SuperdropInitConds &sdic, const viewd_supers supers)¶ Return a mirror view of superdrops on host memory.
This function initialises a mirror view of superdrops on host memory, using the super-droplet generator instance
GenSuperdrop
to generate the kk’th super-droplet with their initial Gridbox index, spatial coordinates, and attributes. Kokkos::parallel_for is used to perform parallel initialisation of the mirror view, where each superdrop is generated by the providedgen
function object.The equivalent serial version of the Kokkos::parallel_for([…]) is:
for (size_t kk(0); kk < totnsupers; ++kk) { h_supers(kk) = gen(kk); }
- Parameters:
sdic – The instance of the super-droplets’ initial conditions data.
supers – The view of superdrops on device memory.
- Returns:
A mirror view of superdrops on host memory.
-
void is_sdsinit_complete(const viewd_constsupers supers)¶
Check if superdroplets initialisation is complete.
This function checks if the initialisation of supers view is complete by checking if the superdroplets are sorted by ascending gridbox indexes. If the initialisation is incomplete (the superdroplets are not sorted), it throws an exception with an appropriate error message.
- Parameters:
supers – The view of super-droplets in device memory.
- Throws:
std::invalid_argument – If the initialisation is incomplete i.e. the super-droplets are not ordered correctly.
-
void print_supers(const viewd_constsupers supers)¶
Print statement about initialised super-droplets.
This function prints information about each superdroplet, including its ID, Gridbox index, spatial coordinates, and attributes.
- Parameters:
supers – The view of super-droplets in device memory.