@@ -173,83 +173,94 @@ 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)
176+ if (!opts_init.periodic_topbot_walls )
178177 {
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- // precipitation on the bottom edge of the domain
189- // // first: count the volume of particles below the domain
190- // TODO! (using tranform_reduce?)
191- // // second: zero-out multiplicities so they will be recycled
192- {
193- 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+ }
194189
195- thrust_device::vector<real_t > &n_filtered (tmp_device_real_part);
190+ // precipitation on the bottom edge of the domain
191+ // // first: count the volume of particles below the domain
192+ // TODO! (using tranform_reduce?)
193+ // // second: zero-out multiplicities so they will be recycled
194+ {
195+ namespace arg = thrust::placeholders;
196196
197- thrust::fill (n_filtered. begin (), n_filtered. end (), 0 . );
197+ thrust_device::vector< real_t > & n_filtered (tmp_device_real_part );
198198
199- // copy n of SDs that are out of the domain (otherwise remains n_filtered=0)
200- thrust::transform_if (
201- n.begin (), n.end (), // input 1
202- z.begin (), // stencil
203- n_filtered.begin (), // output
204- thrust::identity<n_t >(), // operation
205- arg::_1 < opts_init.z0 // condition
206- );
199+ thrust::fill (n_filtered.begin (), n_filtered.end (), 0 .);
207200
208- // add total liquid water volume that fell out in this step
209- output_puddle[common::outliq_vol] +=
210- thrust::transform_reduce (
211- thrust::make_zip_iterator (thrust::make_tuple (
212- n_filtered.begin (), rw2.begin ())), // input start
213- thrust::make_zip_iterator (thrust::make_tuple (
214- n_filtered.begin (), rw2.begin ())) + n_part, // input end
215- detail::count_vol<real_t >(3 ./2 .), // operation
216- real_t (0 ), // init val
217- thrust::plus<real_t >()
201+ // copy n of SDs that are out of the domain (otherwise remains n_filtered=0)
202+ thrust::transform_if (
203+ n.begin (), n.end (), // input 1
204+ z.begin (), // stencil
205+ n_filtered.begin (), // output
206+ thrust::identity<n_t >(), // operation
207+ arg::_1 < opts_init.z0 // condition
218208 );
219209
220- // add total dry volume that fell out in this step
221- output_puddle[common::outdry_vol ] +=
222- thrust::transform_reduce (
223- thrust::make_zip_iterator (thrust::make_tuple (
224- n_filtered.begin (), rd3 .begin ())), // input start
225- thrust::make_zip_iterator (thrust::make_tuple (
226- n_filtered.begin (), rd3 .begin ())) + n_part, // input end
227- detail::count_vol<real_t >(1 .), // operation
228- real_t (0 ), // init val
229- thrust::plus<real_t >()
230- );
210+ // add total liquid water volume that fell out in this step
211+ output_puddle[common::outliq_vol ] +=
212+ thrust::transform_reduce (
213+ thrust::make_zip_iterator (thrust::make_tuple (
214+ n_filtered.begin (), rw2 .begin ())), // input start
215+ thrust::make_zip_iterator (thrust::make_tuple (
216+ n_filtered.begin (), rw2 .begin ())) + n_part, // input end
217+ detail::count_vol<real_t >(3 ./ 2 .), // operation
218+ real_t (0 ), // init val
219+ thrust::plus<real_t >()
220+ );
231221
232- if (opts_init.chem_switch )
233- {
234- for (int i = 0 ; i < chem_all; ++i)
235- output_puddle[static_cast <common::output_t >(i)] +=
236- thrust::transform_reduce (
237- thrust::make_zip_iterator (thrust::make_tuple (
238- n_filtered.begin (), chem_bgn[i])), // input start
239- thrust::make_zip_iterator (thrust::make_tuple (
240- n_filtered.end (), chem_end[i])), // input end
241- detail::count_mass<real_t >(), // operation
242- real_t (0 ), // init val
243- thrust::plus<real_t >()
244- );
245- }
222+ // add total dry volume that fell out in this step
223+ output_puddle[common::outdry_vol] +=
224+ thrust::transform_reduce (
225+ thrust::make_zip_iterator (thrust::make_tuple (
226+ n_filtered.begin (), rd3.begin ())), // input start
227+ thrust::make_zip_iterator (thrust::make_tuple (
228+ n_filtered.begin (), rd3.begin ())) + n_part, // input end
229+ detail::count_vol<real_t >(1 .), // operation
230+ real_t (0 ), // init val
231+ thrust::plus<real_t >()
232+ );
233+
234+ if (opts_init.chem_switch )
235+ {
236+ for (int i = 0 ; i < chem_all; ++i)
237+ output_puddle[static_cast <common::output_t >(i)] +=
238+ thrust::transform_reduce (
239+ thrust::make_zip_iterator (thrust::make_tuple (
240+ n_filtered.begin (), chem_bgn[i])), // input start
241+ thrust::make_zip_iterator (thrust::make_tuple (
242+ n_filtered.end (), chem_end[i])), // input end
243+ detail::count_mass<real_t >(), // operation
244+ real_t (0 ), // init val
245+ thrust::plus<real_t >()
246+ );
247+ }
246248
247- // zero-out multiplicities
248- thrust::transform_if (
249- z.begin (), z.end (), // input
250- n.begin (), // output
251- detail::flag<n_t , real_t >(), // operation (zero-out)
252- arg::_1 < opts_init.z0 // condition
249+ // zero-out multiplicities
250+ thrust::transform_if (
251+ z.begin (), z.end (), // input
252+ n.begin (), // output
253+ detail::flag<n_t , real_t >(), // operation (zero-out)
254+ arg::_1 < opts_init.z0 // condition
255+ );
256+ }
257+ }
258+ else // periodic top/bot walls
259+ {
260+ thrust::transform (
261+ z.begin (), z.end (),
262+ z.begin (),
263+ detail::periodic<real_t >(opts_init.z0 , opts_init.z1 )
253264 );
254265 }
255266 }
0 commit comments