Massmoments Observer¶
Header file: <libs/observers/massmoments_observer.hpp>
[source]
-
struct MassMomentsFunc¶
Functor to perform calculation of 0th, 1st, and 2nd moments of the (real) droplet mass distribution in each gridbox.
This operator is a functor to perform the calculation of the 0th, 1st, and 2nd moments of the droplet mass distribution in each gridbox within a Kokkos::parallel_for range policy loop over superdroplets. The calculation is equivalent to 0th, 3rd, and 6th moments of the droplet radius distribution for each gridbox.
Note: the conversion from 8 to 4-byte precision for all three moments.
Public Functions
-
inline void operator()(const TeamMember &team_member, const viewd_constgbx d_gbxs, Buffer<uint64_t>::mirrorviewd_buffer d_mom0, Buffer<float>::mirrorviewd_buffer d_mom1, Buffer<float>::mirrorviewd_buffer d_mom2) const¶
Functor operator to perform calculation of 0th, 1st, and 2nd moments of the (real) droplet mass distribution in each gridbox.
This operator is a functor to call function to perform the calculation of the 0th, 1st, and 2nd moments of the droplet mass distribution in each gridbox (i.e. 0th, 3rd, and 6th moments of the droplet radius distribution).
Note: possible conversion from 8 to 4-byte precision for all mass moments: mom0 from size_t (architecture dependent usually long unsigned int = 8 bytes) to 8 byte unsigned integer, and mom1 and mom2 from double (8 bytes) to float (4 bytes).
- Parameters:
team_member – The Kokkos team member.
d_gbxs – The view of gridboxes on device.
d_mom0 – The mirror view buffer for the 0th mass moment.
d_mom1 – The mirror view buffer for the 1st mass moment.
d_mom2 – The mirror view buffer for the 2nd mass moment.
-
inline void operator()(const TeamMember &team_member, const viewd_constgbx d_gbxs, Buffer<uint64_t>::mirrorviewd_buffer d_mom0, Buffer<float>::mirrorviewd_buffer d_mom1, Buffer<float>::mirrorviewd_buffer d_mom2) const¶
-
struct RaindropsMassMomentsFunc¶
Functor to perform calculation of 0th, 1st, and 2nd moments of the (real) rain-droplet mass distribution in each gridbox.
This operator is a functor to perform the calculation of the 0th, 1st, and 2nd moments of the rain-droplet mass distribution in each gridbox within a Kokkos::parallel_for range policy loop over superdroplets. The calculation is equivalent to 0th, 3rd, and 6th moments of the rain-droplet radius distribution for each gridbox.
A raindroplet is a droplet with a radius >= rlim = 40microns.
Note: the conversion from 8 to 4-byte precision for all three moments.
Public Functions
-
inline void operator()(const TeamMember &team_member, const viewd_constgbx d_gbxs, Buffer<uint64_t>::mirrorviewd_buffer d_mom0, Buffer<float>::mirrorviewd_buffer d_mom1, Buffer<float>::mirrorviewd_buffer d_mom2) const¶
Functor operator to perform calculation of 0th, 1st, and 2nd moments of the (real) droplet mass distribution in each gridbox.
This operator is a functor to call function for the calculation of the 0th, 1st, and 2nd moments of the raindroplet mass distribution in each gridbox (i.e. 0th, 3rd, and 6th moments of the droplet radius distribution) within a Kokkos::parallel_for range policy loop over superdroplets.
Note: possible conversion from 8 to 4-byte precision for all mass moments: mom0 from size_t (architecture dependent usually long unsigned int = 8 bytes) to 8 byte unsigned integer, and mom1 and mom2 from double (8 bytes) to float (4 bytes).
- Parameters:
team_member – The Kokkos team member.
d_gbxs – The view of gridboxes on device.
d_mom0 – The mirror view buffer for the 0th mass moment.
d_mom1 – The mirror view buffer for the 1st mass moment.
d_mom2 – The mirror view buffer for the 2nd mass moment.
-
inline void operator()(const TeamMember &team_member, const viewd_constgbx d_gbxs, Buffer<uint64_t>::mirrorviewd_buffer d_mom0, Buffer<float>::mirrorviewd_buffer d_mom1, Buffer<float>::mirrorviewd_buffer d_mom2) const¶
-
template<typename Store, typename FunctorFunc>
struct CollectMassMoments¶ A struct satisfying CollectDataForDataset for collecting the 0th, 1st, and 2nd moments of the (rain)droplet mass distribution in each gridbox.
This struct is similar to the GenericCollectData struct but specialized with xarrays and a functor that stores three variables (the 0th, 1st, and 2nd mass moments) and with a functor which can act inside a Kokkos team policy rather than a range policy.
Public Functions
-
inline CollectMassMoments(const FunctorFunc ffunc, const XarrayZarrArray<Store, uint64_t> xzarr_mom0, const XarrayZarrArray<Store, float> xzarr_mom1, const XarrayZarrArray<Store, float> xzarr_mom2, const size_t dataview_size)¶
Constructor to initialize CollectMassMoments.
- Parameters:
ffunc – Functor function-like object for calculting mass moments within parallel loop.
xzarr_mom0 – Xarray for the 0th mass moment.
xzarr_mom1 – Xarray for the 1st mass moment.
xzarr_mom2 – Xarray for the 2nd mass moment.
dataview_size – Size of the data view used to collect data from within the functor function call.
-
inline Functor get_functor(const viewd_constgbx d_gbxs, const viewd_constsupers totsupers) const¶
Returns a functor for getting 0th, 1st, and 2nd mass moments from every gridbox within a Kokkos::parallel_for loop over gridboxes with a team policy.
- Parameters:
d_gbxs – View of gridboxes on device.
totsupers – View of superdroplets on device.
- Returns:
Functor for collecting mass moments.
-
inline void write_to_arrays(const Dataset<Store> &dataset) const¶
Writes all three mass moments to arrays in the dataset.
- Parameters:
dataset – The dataset to write data to.
-
inline void write_arrayshapes(const Dataset<Store> &dataset) const¶
Writes the shape of all three arrays to the dataset.
- Parameters:
dataset – The dataset to write data to.
-
inline void write_to_ragged_arrays(const Dataset<Store> &dataset) const¶
Null function to satisfy CollectDataForDataset concept.
- Parameters:
dataset – The dataset to write data to.
-
inline void write_ragged_arrayshapes(const Dataset<Store> &dataset) const¶
Null function to satisfy CollectDataForDataset concept.
- Parameters:
dataset – The dataset to write data to.
-
inline void reallocate_views(const size_t sz) const¶
Null function to satisfy CollectDataForDataset concept.
- Parameters:
sz – The size for reallocation of a view.
Private Functions
Deep copies data from a device view to the host and then writes the host data to an array in the dataset.
- Template Parameters:
T – The data type.
- Parameters:
ptr – A pointer to a struct with the data views to be copied and the Xarray to write to.
dataset – The dataset for the Xarray.
Calls a function to write the shape of the array according to the dataset.
- Template Parameters:
T – The data type.
- Parameters:
ptr – A pointer to struct with the Xarray whose shape must be written.
dataset – The dataset to write array shape to.
Private Members
-
FunctorFunc ffunc¶
-
std::shared_ptr<XarrayAndViews<Store, uint64_t>> mom0_ptr¶
Xarray for 0th mass moment
-
std::shared_ptr<XarrayAndViews<Store, float>> mom1_ptr¶
Xarray for 1st mass moment
-
std::shared_ptr<XarrayAndViews<Store, float>> mom2_ptr¶
Xarray for 2nd mass moment
-
struct Functor¶
Generic functor to collect all three mass moments from within a Kokkos::parallel_for loop over gridboxes with a team policy.
Public Types
-
using mirrorviewd_mom0 = XarrayAndViews<Store, uint64_t>::mirrorviewd_data¶
-
using mirrorviewd_mom1 = XarrayAndViews<Store, float>::mirrorviewd_data¶
-
using mirrorviewd_mom2 = XarrayAndViews<Store, float>::mirrorviewd_data¶
Public Functions
-
inline Functor(FunctorFunc ffunc, const viewd_constgbx d_gbxs, mirrorviewd_mom0 d_mom0, mirrorviewd_mom1 d_mom1, mirrorviewd_mom2 d_mom2)¶
Constructs a Functor object.
- Parameters:
ffunc – The functor to calculate mass moments within a parallel team policy loop.
d_gbxs – The view of gridboxes on the device.
d_mom0 – The mirror view for the 0th mass moment on the device.
d_mom1 – The mirror view for the 1st mass moment on the device.
d_mom2 – The mirror view for the 2nd mass moment on the device.
-
inline void operator()(const TeamMember &team_member) const¶
Adapter to call functor to perform calculation of massmoments in each gridbox from within a Kokkos::parallel_for loop with a team policy.
Public Members
-
FunctorFunc ffunc¶
Functor to calculate mass moments within parallel team policy loop
-
viewd_constgbx d_gbxs¶
View of gridboxes on device
-
mirrorviewd_mom0 d_mom0¶
Mirror view on device for 0th mass moment
-
mirrorviewd_mom1 d_mom1¶
Mirror view on device for 1st mass moment
-
mirrorviewd_mom2 d_mom2¶
Mirror view on device for 2nd mass moment
-
using mirrorviewd_mom0 = XarrayAndViews<Store, uint64_t>::mirrorviewd_data¶
-
inline CollectMassMoments(const FunctorFunc ffunc, const XarrayZarrArray<Store, uint64_t> xzarr_mom0, const XarrayZarrArray<Store, float> xzarr_mom1, const XarrayZarrArray<Store, float> xzarr_mom2, const size_t dataview_size)¶
-
template<typename Store, typename T>
XarrayZarrArray<Store, T> create_massmoment_xarray(const Dataset<Store> &dataset, const std::string_view name, const std::string_view units, const double scale_factor, const size_t maxchunk, const size_t ngbxs)¶ Creates an XarrayZarrArray for storing the mass moments of each gridbox in a dataset.
- Template Parameters:
Store – The type of data store in the dataset.
T – The type of the mass moment data to store in the XarrayZarrArray.
- Parameters:
dataset – The dataset where the XarrayZarrArray will be created.
name – The name of the Xarray.
units – The units of the mass moment data.
scale_factor – The scale factor for the data.
maxchunk – The maximum chunk size (number of elements) for the Xarray.
ngbxs – The number of gridboxes.
- Returns:
XarrayZarrArray<Store, T> The created XarrayZarrArray.
-
template<typename Store>
XarrayZarrArray<Store, uint64_t> create_massmom0_xarray(const Dataset<Store> &dataset, const std::string_view name, const size_t maxchunk, const size_t ngbxs)¶ Creates an XarrayZarrArray for storing the 0th mass moment in a dataset.
Calls create_massmoment_xarray for data that is represented by 8 byte unsigned integers with no units and is called “name” - e.g. the 0th mass moment of a droplet distribution.
- Template Parameters:
Store – The type of data store in the dataset.
- Parameters:
dataset – The dataset where the XarrayZarrArray will be created.
name – The name of the (0th mass moment) Xarray.
maxchunk – The maximum chunk size for the Xarray (number of elements).
ngbxs – The number of gridboxes.
- Returns:
XarrayZarrArray<Store, uint64_t> The created XarrayZarrArray (for the 0th mass moment).
-
template<typename Store>
XarrayZarrArray<Store, float> create_massmom2_xarray(const Dataset<Store> &dataset, const std::string_view name, const size_t maxchunk, const size_t ngbxs)¶ Creates an XarrayZarrArray for storing the 2nd mass moment in a dataset.
Calls create_massmoment_xarray for data that is represented by 4 byte float with units “g^2” and is called “name” - e.g. the 2nd mass moment of a droplet distribution.
- Template Parameters:
Store – The type of data store in the dataset.
- Parameters:
dataset – The dataset where the XarrayZarrArray will be created.
name – The name of the (2nd mass moment) Xarray.
maxchunk – The maximum chunk size for the Xarray (number of elements).
ngbxs – The number of gridboxes.
- Returns:
XarrayZarrArray<Store, uint64_t> The created XarrayZarrArray (for the 2nd mass moment).