Skip to content

Commit

Permalink
feat(cartesiandomain): functions in place for when to add superdrops
Browse files Browse the repository at this point in the history
  • Loading branch information
yoctoyotta1024 committed Apr 18, 2024
1 parent dd29091 commit 7cc5b98
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 2 deletions.
50 changes: 49 additions & 1 deletion libs/cartesiandomain/add_supers_at_domain_top.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,60 @@
#ifndef LIBS_CARTESIANDOMAIN_ADD_SUPERS_AT_DOMAIN_TOP_HPP_
#define LIBS_CARTESIANDOMAIN_ADD_SUPERS_AT_DOMAIN_TOP_HPP_

#include <Kokkos_Core.hpp>

#include "../cleoconstants.hpp"
#include "../kokkosaliases.hpp"
#include "cartesiandomain/cartesianmaps.hpp"
#include "gridboxes/sortsupers.hpp"

struct AddSupersAtDomainTop {
double coord3lim; /**< gridboxes with upper bound > coord3lim get new super-droplets */

void new_supers_for_gridbox(const Gridbox &gbx, const viewd_supers totsupers) const {
std::cout << "new supers for gbx: " << gbx.get_gbxindex() << "\n";
}

/* (re)sorting supers based on their gbxindexes and then updating the span for each
gridbox accordingly.
Kokkos::parallel_for([...]) (on host) is equivalent to:
for (size_t ii(0); ii < ngbxs; ++ii){[...]}
when in serial */
void move_supers_between_gridboxes(const viewd_gbx d_gbxs, const viewd_supers totsupers) const {
sort_supers(totsupers);

const size_t ngbxs(d_gbxs.extent(0));
Kokkos::parallel_for(
"move_supers_between_gridboxes", TeamPolicy(ngbxs, Kokkos::AUTO()),
KOKKOS_CLASS_LAMBDA(const TeamMember &team_member) {
const int ii = team_member.league_rank();

auto &gbx(d_gbxs(ii));
gbx.supersingbx.set_refs(team_member);
});
}

/* New super-droplets are added to domain with coord3 >= COORD3LIM [m] */
explicit AddSupersAtDomainTop(const double COORD3LIM) : coord3lim(COORD3LIM / dlc::COORD0) {}

void operator()(const CartesianMaps &gbxmaps, viewd_gbx d_gbxs,
const viewd_supers totsupers) const {}
const viewd_supers totsupers) const {
const size_t ngbxs(d_gbxs.extent(0));

bool is_supers_added = false;
for (size_t ii(0); ii < ngbxs; ++ii) { // TODO(CB) parallelise?
auto &gbx(d_gbxs(ii));
const auto bounds = gbxmaps.coord3bounds(gbx.get_gbxindex());
if (bounds.second > coord3lim) {
new_supers_for_gridbox(gbx, totsupers);
is_supers_added = true;
}
}

if (is_supers_added) { // resort totsupers view and set gbx references
move_supers_between_gridboxes(d_gbxs, totsupers);
}
}
};

#endif // LIBS_CARTESIANDOMAIN_ADD_SUPERS_AT_DOMAIN_TOP_HPP_
4 changes: 3 additions & 1 deletion src/main_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,9 @@ inline auto create_boundary_conditions(const Config &config) {
// ngbxs,
// ngbxs4reset); //TODO(CB) Delete option (!)

return AddSupersAtDomainTop{};
const auto COORD3LIM = double{800}; /* supers added to domain with coord3 >= COORD3LIM [m] */

return AddSupersAtDomainTop(COORD3LIM);

// return NullBoundaryConditions{};
}
Expand Down

0 comments on commit 7cc5b98

Please sign in to comment.