@@ -263,4 +263,55 @@ function SFC._dispatch_single_pass(
263263 return SFC. postprocess_single_pass_results (sums, counts, distance_bins)
264264end
265265
266+ function SFC. threaded_calculate_structure_function (
267+ structure_function_type:: SFT.AbstractStructureFunctionType ,
268+ x_vecs:: Tuple ,
269+ u_vecs:: Tuple ,
270+ distance_bins:: AbstractVector ,
271+ value_bins:: AbstractVector ;
272+ distance_metric:: DI.PreMetric = DI. Euclidean (),
273+ verbose = true ,
274+ show_progress = true ,
275+ )
276+ if verbose
277+ @info (" calculating 2D joint structure function (threaded reduction via OhMyThreads)" )
278+ end
279+ _ = show_progress
280+
281+ sums_and_counts = OMT. tmapreduce (+ , eachindex (x_vecs[1 ])) do i
282+ SFC. calculate_structure_function_2d_i (
283+ structure_function_type,
284+ i,
285+ x_vecs,
286+ u_vecs,
287+ distance_bins,
288+ value_bins;
289+ distance_metric = distance_metric,
290+ )
291+ end
292+
293+ return sums_and_counts
294+ end
295+
296+ function SFC. threaded_calculate_structure_function (
297+ structure_function_type:: SFT.AbstractStructureFunctionType ,
298+ x_arr:: AbstractArray{FT1} ,
299+ u_arr:: AbstractArray{FT2} ,
300+ distance_bins:: AbstractVector{Tuple{FT3, FT3}} ,
301+ value_bins:: AbstractVector ;
302+ kwargs... ,
303+ ) where {FT1 <: Number , FT2 <: Number , FT3 <: Number }
304+ N_dims = size (x_arr, 1 )
305+ x_tuple = ntuple (k -> view (x_arr, k, :), N_dims)
306+ u_tuple = ntuple (k -> view (u_arr, k, :), N_dims)
307+ return SFC. threaded_calculate_structure_function (
308+ structure_function_type,
309+ x_tuple,
310+ u_tuple,
311+ distance_bins,
312+ value_bins;
313+ kwargs... ,
314+ )
315+ end
316+
266317end
0 commit comments