@@ -22,6 +22,21 @@ namespace libcloudphxx
2222 const arrinfo_t <real_t > courant_z, // defaults to NULL-NULL pair (e.g. kinematic model)
2323 std::map<enum chem_species_t , arrinfo_t <real_t > > ambient_chem
2424 )
25+ {
26+ sync_in (th, rv, rhod, courant_x, courant_y, courant_z, ambient_chem);
27+ step_cond (opts, th, rv, ambient_chem);
28+ }
29+
30+ template <typename real_t , backend_t device>
31+ void particles_t <real_t , device>::sync_in(
32+ arrinfo_t <real_t > th,
33+ arrinfo_t <real_t > rv,
34+ const arrinfo_t <real_t > rhod, // defaults to NULL-NULL pair (e.g. kinematic or boussinesq model)
35+ const arrinfo_t <real_t > courant_x, // defaults to NULL-NULL pair (e.g. kinematic model)
36+ const arrinfo_t <real_t > courant_y, // defaults to NULL-NULL pair (e.g. kinematic model)
37+ const arrinfo_t <real_t > courant_z, // defaults to NULL-NULL pair (e.g. kinematic model)
38+ std::map<enum chem_species_t , arrinfo_t <real_t > > ambient_chem
39+ )
2540 {
2641 // sanity checks
2742 if (!pimpl->init_called )
@@ -67,6 +82,9 @@ namespace libcloudphxx
6782 if (!courant_z.is_null ()) pimpl->init_e2l (courant_z, &pimpl->courant_z , 0 , 0 , 1 , pimpl->n_x_bfr * max (1 , pimpl->opts_init .ny ) - pimpl->halo_z );
6883 }
6984
85+ // did rhod change
86+ pimpl->var_rho = !rhod.is_null ();
87+
7088 // syncing in Eulerian fields (if not null)
7189 pimpl->sync (th, pimpl->th );
7290 pimpl->sync (rv, pimpl->rv );
@@ -98,6 +116,23 @@ namespace libcloudphxx
98116 );
99117 }
100118 }
119+
120+ pimpl->should_now_run_cond = true ;
121+ }
122+
123+ template <typename real_t , backend_t device>
124+ void particles_t <real_t , device>::step_cond(
125+ const opts_t <real_t > &opts,
126+ arrinfo_t <real_t > th, // for sync-out
127+ arrinfo_t <real_t > rv, // for sync-out
128+ std::map<enum chem_species_t , arrinfo_t <real_t > > ambient_chem // for sync-out
129+ )
130+ {
131+ // sanity checks
132+ if (!pimpl->should_now_run_cond )
133+ throw std::runtime_error (" please call sync_in() before calling step_cond()" );
134+
135+ pimpl->should_now_run_cond = false ;
101136
102137 // condensation/evaporation
103138 // if const_p == True, pressure is not substepped
@@ -122,7 +157,7 @@ namespace libcloudphxx
122157 {
123158 for (int step = 0 ; step < pimpl->opts_init .sstp_cond ; ++step)
124159 {
125- pimpl->sstp_step (step, !rhod. is_null () );
160+ pimpl->sstp_step (step);
126161 pimpl->hskpng_Tpr ();
127162 pimpl->cond (pimpl->opts_init .dt / pimpl->opts_init .sstp_cond , opts.RH_max );
128163 }
@@ -146,7 +181,7 @@ namespace libcloudphxx
146181 if (opts.chem_dsl )
147182 {
148183 // adjust trace gases to substepping
149- pimpl->sstp_step_chem (step, !rhod. is_null () );
184+ pimpl->sstp_step_chem (step);
150185
151186 // dissolving trace gases (Henrys law)
152187 pimpl->chem_henry (pimpl->opts_init .dt / pimpl->opts_init .sstp_chem );
0 commit comments