Skip to content

Commit

Permalink
reorder funcs
Browse files Browse the repository at this point in the history
  • Loading branch information
yoctoyotta1024 committed Nov 23, 2023
1 parent 583dc74 commit ed49dc0
Showing 1 changed file with 42 additions and 32 deletions.
74 changes: 42 additions & 32 deletions libs/superdrops/coalbure.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* Copyright (c) 2023 MPI-M, Clara Bayley
* -----
* File Description:
* functionality to enact collision-
* functionality to enact collision-
* coalescence, breakup or rebound events
* in SDM analagous to to Shima et al. 2009.
* CoalBuRe struct satisfies PairEnactX
Expand Down Expand Up @@ -58,6 +58,16 @@ struct DoCoalBuRe
return coal.coalescence_gamma(xi1, xi2, prob, phi);
}

KOKKOS_FUNCTION
unsigned int coalbure_flag(Superdrop &drop1,
Superdrop &drop2) const;
/* function returns flag indicating rebound or
coalescence or breakup. If flag = 1 -> coalescence.
If flag = 2 -> breakup. Otherwise -> rebound.
Flag decided based on the kinetic arguments in
section 2.2 of Szakáll and Urbich 2018
(neglecting grazing angle considerations) */

KOKKOS_FUNCTION
bool coalesce_breakup_or_rebound(const unsigned long long gamma,
Superdrop &drop1,
Expand All @@ -81,9 +91,9 @@ struct DoCoalBuRe
template <PairProbability Probability, NFragments NFrags>
inline MicrophysicalProcess auto
CoalBuRe(const unsigned int interval,
const std::function<double(unsigned int)> int2realtime,
const Probability collprob,
const NFrags nfrags)
const std::function<double(unsigned int)> int2realtime,
const Probability collprob,
const NFrags nfrags)
/* constructs Microphysical Process for collision-
coalscence, breakup or rebound of superdroplets with
a constant timestep 'interval' and probability
Expand Down Expand Up @@ -123,32 +133,6 @@ that satistfies the PairEnactX concept */
return 0;
}

template <NFragments NFrags>
KOKKOS_FUNCTION bool
DoCoalBuRe<NFrags>::
coalesce_breakup_or_rebound(const unsigned long long gamma,
Superdrop &drop1,
Superdrop &drop2) const
/* function enacts rebound or coalescence or breakup
depending on value of flag. If flag = 1 -> coalescence.
If flag = 2 -> breakup. Otherwise -> rebound. */
{
const unsigned int flag(coalbure_flag(drop1, drop2));

bool is_null(0);
switch (flag)
{
case 1: // coalescence
is_null = coalesce_superdroplet_pair(gamma, drop1, drop2);
break;
case 2: // breakup
bu.breakup_superdroplet_pair(drop1, drop2);
break;
}

return is_null;
}

template <NFragments NFrags>
KOKKOS_FUNCTION unsigned int
DoCoalBuRe<NFrags>::coalbure_flag(Superdrop &drop1,
Expand All @@ -170,7 +154,7 @@ section 2.2 of Szakáll and Urbich 2018

if (cke < surfenergy(Kokkos::fmin(r1, r2))) // cke < surface energy of small drop
{
return 0; // rebound
return 0; // rebound
}
else if (cke < coal_surfenergy(r1, r2)) // weber number < 1 : coalescence
{
Expand All @@ -181,5 +165,31 @@ section 2.2 of Szakáll and Urbich 2018
return 2; // breakup
}
}


template <NFragments NFrags>
KOKKOS_FUNCTION bool
DoCoalBuRe<NFrags>::
coalesce_breakup_or_rebound(const unsigned long long gamma,
Superdrop &drop1,
Superdrop &drop2) const
/* function enacts rebound or coalescence or breakup
depending on value of flag. If flag = 1 -> coalescence.
If flag = 2 -> breakup. Otherwise -> rebound. */
{
const unsigned int flag(coalbure_flag(drop1, drop2));

bool is_null(0);
switch (flag)
{
case 1: // coalescence
is_null = coalesce_superdroplet_pair(gamma, drop1, drop2);
break;
case 2: // breakup
bu.breakup_superdroplet_pair(drop1, drop2);
break;
}

return is_null;
}

#endif // COALBURE_HPP

0 comments on commit ed49dc0

Please sign in to comment.