Create Gridboxes Sub-Module

Header file: <libs/runcleo/creategbxs.hpp> [source]

This sub-module defines functions and classes called by RunCLEO to create and initialise Gridboxes (i.e. GBxs).

class GenGridbox

A generator for initial Gridboxes.

This class provides functionality to generate Gridbox instances based on the gridbox maps and on the initial conditions stored in this struct’s vectors.

Public Functions

template<typename GbxInitConds>
inline explicit GenGridbox(const GbxInitConds &gbxic)

Constructs a GenGridbox object.

Constructs a GenGridbox object based on the provided initial conditions in ‘GbxInitConds’.

Template Parameters:

GbxInitConds – Type of the Gridboxes’ initial conditions.

Parameters:

gbxic – The initial conditions for the Gridboxes.

template<GridboxMaps GbxMaps>
inline Gridbox operator()(const unsigned int ii, const GbxMaps &gbxmaps, const viewd_supers totsupers) const

Serial version of operator to generate a Gridbox from the data at the ii’th position of the initial conditions data.

This function generates a Gridbox corresponding to the ii’th position in the initial conditions data and using the gridbox maps and view of (all) superdroplets.

Template Parameters:

GbxMaps – Type of the Gridbox Maps.

Parameters:
  • ii – The index of the Gridbox.

  • gbxmaps – The Gridbox Maps.

  • totsupers – The view of all super-droplets (both in and out of bounds of domain).

Returns:

The generated Gridbox.

template<GridboxMaps GbxMaps>
inline Gridbox operator()(const HostTeamMember &team_member, const unsigned int ii, const GbxMaps &gbxmaps, const viewd_supers totsupers, const viewd_constsupers::HostMirror h_totsupers) const

Parallel-safe version of operator to generate a Gridbox from the data at the ii’th position of the initial conditions data.

This function generates a gridbox at the specified index using gridbox maps, total superdroplets, and host team member. Given a Kokkos team thread (‘team_member’), this function generates a Gridbox corresponding to the ii’th position in the initial conditions data and using the gridbox maps and view of (all) superdroplets on device and host.

Template Parameters:

GbxMaps – Type of the Gridbox Maps.

Parameters:
  • team_member – The host team member reference.

  • ii – The index of the Gridbox.

  • gbxmaps – The Gridbox Maps.

  • totsupers – The view of all super-droplets (both in and out of bounds of domain).

  • h_totsupers – The host mirror of all super-droplets (both in and out of bounds of domain).

Returns:

The generated Gridbox.

Private Functions

State state_at(const unsigned int ii, const double volume) const

Get the state of a specified Gridbox from the initial conditions.

This function returns the state of the Gridbox at the ii’th index in the initial conditions given by the GenGridbox struct.

Parameters:
  • ii – The index of the Gridbox in the initial conditions data.

  • volume – The volume of the Gridbox.

Returns:

The State of the Gridbox.

Private Members

std::shared_ptr<Gbxindex::Gen> GbxindexGen

Pointer to gridbox index generator, Gbxindex::Gen object

std::vector<double> presss

Vector of pressures for each gridbox

std::vector<double> temps

Vector of temperatures for each gridbox

std::vector<double> qvaps

Vector of vapor mass mixing ratio for each gridbox

std::vector<double> qconds

Vector of condensed water mass mixing ratio for each gridbox

std::vector<std::pair<double, double>> wvels

Vector of vertical (coord3) wind velocities for each gridbox

std::vector<std::pair<double, double>> uvels

Vector of eastward (coord1) wind velocities for each gridbox

std::vector<std::pair<double, double>> vvels

Vector of northward (coord2) wind velocities for each gridbox

template<GridboxMaps GbxMaps, typename GbxInitConds>
dualview_gbx create_gbxs(const GbxMaps &gbxmaps, const GbxInitConds &gbxic, const viewd_supers totsupers)

Create Gridboxes from initial conditions.

This function creates Gridboxes based on the provided gridbox maps and initial conditions, and given super-droplets.

Template Parameters:
  • GbxMaps – Type representing Gridbox Maps.

  • GbxInitConds – Type representing Gridbox initial conditions.

Parameters:
  • gbxmaps – The Gridbox Maps.

  • gbxic – The Gridbox initial conditions.

  • totsupers – The view of all super-droplets (both in and out of bounds of domain).

Returns:

The view of initialised Gridboxes.

template<GridboxMaps GbxMaps, typename GbxInitConds>
inline dualview_gbx initialise_gbxs(const GbxMaps &gbxmaps, const GbxInitConds &gbxic, const viewd_supers totsupers)

Initialise a view of Gridboxes.

This function initialises a view of gridboxes in device memory using data from an instance of GbxInitConds for each Gridbox’s index, initial State and view of super-droplets.

Template Parameters:
  • GbxMaps – Type representing Gridbox Maps.

  • GbxInitConds – Type representing Gridbox initial conditions.

Parameters:
  • gbxmaps – The Gridbox Maps.

  • gbxic – The initial conditions for the Gridboxes.

  • totsupers – The view of all super-droplets (both in and out of bounds of domain).

Returns:

The initialised view of Gridboxes.

template<GridboxMaps GbxMaps>
inline void initialise_gbxs_on_host(const GbxMaps &gbxmaps, const GenGridbox &gen, const viewd_supers totsupers, const viewh_gbx h_gbxs)

Initialise host view of Gridboxes.

This function initialises Gridboxes in host memory using data from Gridbox Maps, a Gridbox generator, and a view of super-droplets.

The equivalent serial version of Kokkos::parallel_for([…]) loop is:

for (size_t ii(0); ii < ngbxs; ++ii)
{
 h_gbxs(ii) = gen(ii, gbxmaps, totsupers);
}

Template Parameters:

GbxMaps – Type representing Gridbox Maps.

Parameters:
  • gbxmaps – The Gridbox Maps.

  • gen – The Gridbox generator.

  • totsupers – The view of all super-droplets (both in and out of bounds of domain).

  • h_gbxs – The view of Gridboxes on the host.

void is_gbxinit_complete(const size_t ngbxs_from_maps, dualview_gbx gbxs)

Check if gridbox initialisation is complete.

This function checks if the number of created gridboxes is consistent with the number of gridboxes from gridbox maps and if each gridbox has correct references to superdroplets.

Parameters:
  • ngbxs_from_maps – The number of gridboxes from gridbox maps.

  • gbxs – The dualview containing gridboxes.

void print_gbxs(const viewh_constgbx gbxs)

Print some information about initial Gridboxes.

This function prints information about each Gridbox, including its index, volume, and number of super-droplets.

Parameters:

h_gbxs – The host view of Gridboxes.