Skip to content

Commit d714de1

Browse files
committed
add in place SF callers
1 parent 6352f9f commit d714de1

6 files changed

Lines changed: 1048 additions & 197 deletions

File tree

ext/StructureFunctionsDistributedExt.jl

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,4 +281,97 @@ function SFC.parallel_calculate_structure_function(
281281
)
282282
end
283283

284+
function SFC.parallel_calculate_structure_function!(
285+
sums::AbstractVector{OT},
286+
counts::AbstractVector{OT},
287+
structure_function_type::SFT.AbstractStructureFunctionType,
288+
x_vecs::Tuple,
289+
u_vecs::Tuple,
290+
distance_bins::AbstractVector;
291+
kwargs...,
292+
) where {OT}
293+
result = SFC.parallel_calculate_structure_function(
294+
structure_function_type,
295+
x_vecs,
296+
u_vecs,
297+
distance_bins,
298+
Val(true);
299+
kwargs...,
300+
)
301+
sums .+= result.sums
302+
counts .+= result.counts
303+
return nothing
304+
end
305+
306+
function SFC.parallel_calculate_structure_function!(
307+
sums::AbstractVector{OT},
308+
counts::AbstractVector{OT},
309+
structure_function_type::SFT.AbstractStructureFunctionType,
310+
x_arr::AbstractArray{FT1},
311+
u_arr::AbstractArray{FT2},
312+
distance_bins::AbstractVector{Tuple{FT3, FT3}};
313+
kwargs...,
314+
) where {OT, FT1 <: Number, FT2 <: Number, FT3 <: Number}
315+
N_dims = size(x_arr, 1)
316+
x_tuple = ntuple(k -> view(x_arr, k, :), N_dims)
317+
u_tuple = ntuple(k -> view(u_arr, k, :), N_dims)
318+
return SFC.parallel_calculate_structure_function!(
319+
sums,
320+
counts,
321+
structure_function_type,
322+
x_tuple,
323+
u_tuple,
324+
distance_bins;
325+
kwargs...,
326+
)
327+
end
328+
329+
function SFC.parallel_calculate_structure_function!(
330+
sums_2d::AbstractMatrix{OT},
331+
counts_2d::AbstractMatrix{OT},
332+
structure_function_type::SFT.AbstractStructureFunctionType,
333+
x_vecs::Tuple,
334+
u_vecs::Tuple,
335+
distance_bins::AbstractVector,
336+
value_bins::AbstractVector;
337+
kwargs...,
338+
) where {OT}
339+
result = SFC.parallel_calculate_structure_function(
340+
structure_function_type,
341+
x_vecs,
342+
u_vecs,
343+
distance_bins,
344+
value_bins;
345+
kwargs...,
346+
)
347+
sums_2d .+= result.sums
348+
counts_2d .+= result.counts
349+
return nothing
350+
end
351+
352+
function SFC.parallel_calculate_structure_function!(
353+
sums_2d::AbstractMatrix{OT},
354+
counts_2d::AbstractMatrix{OT},
355+
structure_function_type::SFT.AbstractStructureFunctionType,
356+
x_arr::AbstractArray{FT1},
357+
u_arr::AbstractArray{FT2},
358+
distance_bins::AbstractVector{Tuple{FT3, FT3}},
359+
value_bins::AbstractVector;
360+
kwargs...,
361+
) where {OT, FT1 <: Number, FT2 <: Number, FT3 <: Number}
362+
N_dims = size(x_arr, 1)
363+
x_tuple = ntuple(k -> view(x_arr, k, :), N_dims)
364+
u_tuple = ntuple(k -> view(u_arr, k, :), N_dims)
365+
return SFC.parallel_calculate_structure_function!(
366+
sums_2d,
367+
counts_2d,
368+
structure_function_type,
369+
x_tuple,
370+
u_tuple,
371+
distance_bins,
372+
value_bins;
373+
kwargs...,
374+
)
375+
end
376+
284377
end

0 commit comments

Comments
 (0)