@@ -173,94 +173,105 @@ namespace libcloudphxx
173173 // z boundary, no distmem here
174174 if (n_dims > 1 )
175175 {
176- // hardcoded "open" boudary at the top of the domain
177- // (just for numerical-error-sourced out-of-domain particles)
178- // {
179- // namespace arg = thrust::placeholders;
180- // thrust::transform_if(
181- // z.begin(), z.end(), // input - arg
182- // n.begin(), // output
183- // detail::flag<n_t, real_t>(), // operation (zero-out, so recycling will take care of it)
184- // arg::_1 >= opts_init.z1 // condition (note: >= seems important as z==z1 would cause out-of-range ijk)
185- // );
186- // }
187-
188- // hardcoded perdiodic boundary at the top of the domain in ther vertical just for KiD 1D
189- {
190- namespace arg = thrust::placeholders;
191- thrust::transform_if (
192- z.begin (), z.end (), // input - arg
193- z.begin (), // output
194- arg::_1 - opts_init.z1 + opts_init.z0 , // operation
195- arg::_1 >= opts_init.z1 // condition (note: >= seems important as z==z1 would cause out-of-range ijk)
196- );
197- }
198-
199- // precipitation on the bottom edge of the domain
200- // // first: count the volume of particles below the domain
201- // TODO! (using tranform_reduce?)
202- // // second: zero-out multiplicities so they will be recycled
176+ if (!opts_init.periodic_topbot_walls )
203177 {
204- namespace arg = thrust::placeholders;
178+ // default "open" boudary at the top of the domain
179+ // (just for numerical-error-sourced out-of-domain particles)
180+ // {
181+ // namespace arg = thrust::placeholders;
182+ // thrust::transform_if(
183+ // z.begin(), z.end(), // input - arg
184+ // n.begin(), // output
185+ // detail::flag<n_t, real_t>(), // operation (zero-out, so recycling will take care of it)
186+ // arg::_1 >= opts_init.z1 // condition (note: >= seems important as z==z1 would cause out-of-range ijk)
187+ // );
188+ // }
205189
206- thrust_device::vector<real_t > &n_filtered (tmp_device_real_part);
190+ // hardcoded perdiodic boundary at the top of the domain in ther vertical just for KiD 1D
191+ {
192+ namespace arg = thrust::placeholders;
193+ thrust::transform_if (
194+ z.begin (), z.end (), // input - arg
195+ z.begin (), // output
196+ arg::_1 - opts_init.z1 + opts_init.z0 , // operation
197+ arg::_1 >= opts_init.z1 // condition (note: >= seems important as z==z1 would cause out-of-range ijk)
198+ );
199+ }
207200
208- thrust::fill (n_filtered.begin (), n_filtered.end (), 0 .);
201+ // precipitation on the bottom edge of the domain
202+ // // first: count the volume of particles below the domain
203+ // TODO! (using tranform_reduce?)
204+ // // second: zero-out multiplicities so they will be recycled
205+ {
206+ namespace arg = thrust::placeholders;
209207
210- // copy n of SDs that are out of the domain (otherwise remains n_filtered=0)
211- thrust::transform_if (
212- n.begin (), n.end (), // input 1
213- z.begin (), // stencil
214- n_filtered.begin (), // output
215- thrust::identity<n_t >(), // operation
216- arg::_1 < opts_init.z0 // condition
217- );
208+ thrust_device::vector<real_t > &n_filtered (tmp_device_real_part);
218209
219- // add total liquid water volume that fell out in this step
220- output_puddle[common::outliq_vol] +=
221- thrust::transform_reduce (
222- thrust::make_zip_iterator (thrust::make_tuple (
223- n_filtered.begin (), rw2.begin ())), // input start
224- thrust::make_zip_iterator (thrust::make_tuple (
225- n_filtered.begin (), rw2.begin ())) + n_part, // input end
226- detail::count_vol<real_t >(3 ./2 .), // operation
227- real_t (0 ), // init val
228- thrust::plus<real_t >()
229- );
210+ thrust::fill (n_filtered.begin (), n_filtered.end (), 0 .);
230211
231- // add total dry volume that fell out in this step
232- output_puddle[common::outdry_vol] +=
233- thrust::transform_reduce (
234- thrust::make_zip_iterator (thrust::make_tuple (
235- n_filtered.begin (), rd3.begin ())), // input start
236- thrust::make_zip_iterator (thrust::make_tuple (
237- n_filtered.begin (), rd3.begin ())) + n_part, // input end
238- detail::count_vol<real_t >(1 .), // operation
239- real_t (0 ), // init val
240- thrust::plus<real_t >()
212+ // copy n of SDs that are out of the domain (otherwise remains n_filtered=0)
213+ thrust::transform_if (
214+ n.begin (), n.end (), // input 1
215+ z.begin (), // stencil
216+ n_filtered.begin (), // output
217+ thrust::identity<n_t >(), // operation
218+ arg::_1 < opts_init.z0 // condition
241219 );
242220
243- if (opts_init.chem_switch )
244- {
245- for (int i = 0 ; i < chem_all; ++i)
246- output_puddle[static_cast <common::output_t >(i)] +=
247- thrust::transform_reduce (
248- thrust::make_zip_iterator (thrust::make_tuple (
249- n_filtered.begin (), chem_bgn[i])), // input start
250- thrust::make_zip_iterator (thrust::make_tuple (
251- n_filtered.end (), chem_end[i])), // input end
252- detail::count_mass<real_t >(), // operation
253- real_t (0 ), // init val
254- thrust::plus<real_t >()
255- );
256- }
221+ // add total liquid water volume that fell out in this step
222+ output_puddle[common::outliq_vol] +=
223+ thrust::transform_reduce (
224+ thrust::make_zip_iterator (thrust::make_tuple (
225+ n_filtered.begin (), rw2.begin ())), // input start
226+ thrust::make_zip_iterator (thrust::make_tuple (
227+ n_filtered.begin (), rw2.begin ())) + n_part, // input end
228+ detail::count_vol<real_t >(3 ./2 .), // operation
229+ real_t (0 ), // init val
230+ thrust::plus<real_t >()
231+ );
232+
233+ // add total dry volume that fell out in this step
234+ output_puddle[common::outdry_vol] +=
235+ thrust::transform_reduce (
236+ thrust::make_zip_iterator (thrust::make_tuple (
237+ n_filtered.begin (), rd3.begin ())), // input start
238+ thrust::make_zip_iterator (thrust::make_tuple (
239+ n_filtered.begin (), rd3.begin ())) + n_part, // input end
240+ detail::count_vol<real_t >(1 .), // operation
241+ real_t (0 ), // init val
242+ thrust::plus<real_t >()
243+ );
257244
258- // zero-out multiplicities
259- thrust::transform_if (
260- z.begin (), z.end (), // input
261- n.begin (), // output
262- detail::flag<n_t , real_t >(), // operation (zero-out)
263- arg::_1 < opts_init.z0 // condition
245+ if (opts_init.chem_switch )
246+ {
247+ for (int i = 0 ; i < chem_all; ++i)
248+ output_puddle[static_cast <common::output_t >(i)] +=
249+ thrust::transform_reduce (
250+ thrust::make_zip_iterator (thrust::make_tuple (
251+ n_filtered.begin (), chem_bgn[i])), // input start
252+ thrust::make_zip_iterator (thrust::make_tuple (
253+ n_filtered.end (), chem_end[i])), // input end
254+ detail::count_mass<real_t >(), // operation
255+ real_t (0 ), // init val
256+ thrust::plus<real_t >()
257+ );
258+ }
259+
260+ // zero-out multiplicities
261+ thrust::transform_if (
262+ z.begin (), z.end (), // input
263+ n.begin (), // output
264+ detail::flag<n_t , real_t >(), // operation (zero-out)
265+ arg::_1 < opts_init.z0 // condition
266+ );
267+ }
268+ }
269+ else // periodic top/bot walls
270+ {
271+ thrust::transform (
272+ z.begin (), z.end (),
273+ z.begin (),
274+ detail::periodic<real_t >(opts_init.z0 , opts_init.z1 )
264275 );
265276 }
266277 }
0 commit comments