From 00b4d1a4b070b12a5507539306940140e20a2686 Mon Sep 17 00:00:00 2001 From: CompatHelper Julia Date: Fri, 16 Aug 2024 00:20:34 +0000 Subject: [PATCH 1/3] CompatHelper: bump compat for OhMyThreads in [weakdeps] to 0.6, (keep existing compat) --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index 3d3f52c..49f9d30 100644 --- a/Project.toml +++ b/Project.toml @@ -26,7 +26,7 @@ DimensionalData = "0.27" DocStringExtensions = "0.8, 0.9" Enzyme = "0.12" EnzymeCore = "0.6, 0.7" -OhMyThreads = "0.5" +OhMyThreads = "0.5, 0.6" PolarizedTypes = "0.1" PrecompileTools = "1" Reexport = "1" From 5aab74b311656e684329179b0970c15ae2cdbc82 Mon Sep 17 00:00:00 2001 From: rohandahale Date: Fri, 16 Aug 2024 15:47:16 -0400 Subject: [PATCH 2/3] Lookup for visdomain for Ti and/or Fr --- src/domain.jl | 13 +++++ test/multidomain.jl | 118 ++++++++++++++++++++++++++++++++++++++++++++ test/runtests.jl | 1 + 3 files changed, 132 insertions(+) create mode 100644 test/multidomain.jl diff --git a/src/domain.jl b/src/domain.jl index 08996e8..c325735 100644 --- a/src/domain.jl +++ b/src/domain.jl @@ -397,6 +397,19 @@ function domainpoints(d::UnstructuredDomain) return getfield(d, :dims) end +#This function helps us to lookup UnstructuredDomain at a particular Ti or Fr +#visdomain[Ti=T,Fr=F] or visdomain[Ti=T] or visdomain[Fr=F] calls work. +function Base.getindex(domain::UnstructuredDomain; Ti=nothing, Fr=nothing) + points = domainpoints(domain) + indices = if Ti !== nothing && Fr !== nothing + findall(p -> (p.Ti == Ti) && (p.Fr == Fr), points) + elseif Ti !== nothing + findall(p -> (p.Ti == Ti), points) + else + findall(p -> (p.Fr == Fr), points) + end + return UnstructuredDomain(points[indices], executor(domain), header(domain)) +end function Base.summary(io::IO, g::UnstructuredDomain) n = propertynames(domainpoints(g)) diff --git a/test/multidomain.jl b/test/multidomain.jl new file mode 100644 index 0000000..39543aa --- /dev/null +++ b/test/multidomain.jl @@ -0,0 +1,118 @@ +function domain4d(N, Nt, Nf) + U_vals = range(-10e9, 10e9, length=N) + U_vals = U_vals' .* ones(N) + V_vals = range(-10e9, 10e9, length=N) + V_vals = V_vals' .* ones(N) + U_vals = U_vals' + + # Flatten the U and V grids + U_final = vec(U_vals) + V_final = vec(V_vals) + + ti = 10 * rand(Nt) |> sort + fr = 1e11 * rand(Nf) |> sort + + # Repeat U and V to match Ti dimensions + U_repeated = repeat(U_final, outer=(length(ti))) + V_repeated = repeat(V_final, outer=(length(ti))) + Ti_repeated = repeat(ti, inner=(Int(length(U_final)))) + + # Repeat U and V and Ti to match Fr dimensions + U_repeated = repeat(U_repeated, outer=(length(fr))) + V_repeated = repeat(V_repeated, outer=(length(fr))) + Ti_repeated = repeat(Ti_repeated, outer=(length(fr))) + Fr_repeated = repeat(fr, inner=(Int(length(U_repeated)/length(fr)))) + visdomain = UnstructuredDomain((;U=U_repeated, V=V_repeated, Ti=Ti_repeated, Fr=Fr_repeated)) + + C1 = true + for ti_point in ti + for fr_point in fr + f = visdomain[Ti=ti_point, Fr=fr_point] + g = UnstructuredDomain((;U=U_final, V=V_final, Ti=vcat(fill(ti_point, length(U_final))), Fr=vcat(fill(fr_point, length(U_final))))) + C1 = C1 && (domainpoints(f) == domainpoints(g)) + end + end + + #Switch Ti and Fr order + C2 = true + for ti_point in ti + for fr_point in fr + f = visdomain[Fr=fr_point, Ti=ti_point] + g = UnstructuredDomain((;U=U_final, V=V_final, Ti=vcat(fill(ti_point, length(U_final))), Fr=vcat(fill(fr_point, length(U_final))))) + C2 = C2 && (domainpoints(f) == domainpoints(g)) + end + end + + return C1, C2 +end + +function domain3df(N, Nf) + U_vals = range(-10e9, 10e9, length=N) + U_vals = U_vals' .* ones(N) + V_vals = range(-10e9, 10e9, length=N) + V_vals = V_vals' .* ones(N) + U_vals = U_vals' + + # Flatten the U and V grids + U_final = vec(U_vals) + V_final = vec(V_vals) + + fr = 1e11 * rand(Nf) |> sort + + # Repeat U and V to match Fr dimensions + U_repeated = repeat(U_final, outer=(length(fr))) + V_repeated = repeat(V_final, outer=(length(fr))) + Fr_repeated = repeat(fr, inner=(Int(length(U_final)))) + + visdomain = UnstructuredDomain((;U=U_repeated, V=V_repeated, Fr=Fr_repeated)) + + C = true + for fr_point in fr + f = visdomain[Fr=fr_point] + g = UnstructuredDomain((;U=U_final, V=V_final, Fr=vcat(fill(fr_point, length(U_final))))) + C = C && (domainpoints(f) == domainpoints(g)) + end + + return C +end + +function domain3dt(N, Nt) + U_vals = range(-10e9, 10e9, length=N) + U_vals = U_vals' .* ones(N) + V_vals = range(-10e9, 10e9, length=N) + V_vals = V_vals' .* ones(N) + U_vals = U_vals' + + # Flatten the U and V grids + U_final = vec(U_vals) + V_final = vec(V_vals) + + ti = 10 * rand(Nt) |> sort + + # Repeat U and V to match Ti dimensions + U_repeated = repeat(U_final, outer=(length(ti))) + V_repeated = repeat(V_final, outer=(length(ti))) + Ti_repeated = repeat(ti, inner=(Int(length(U_final)))) + + visdomain = UnstructuredDomain((;U=U_repeated, V=V_repeated, Ti=Ti_repeated)) + + C = true + for ti_point in ti + f = visdomain[Ti=ti_point] + g = UnstructuredDomain((;U=U_final, V=V_final, Ti=vcat(fill(ti_point, length(U_final))))) + C = C && (domainpoints(f) == domainpoints(g)) + end + + return C +end + + +@testset "Test getindex for visdomain" begin + C1, C2 = domain4d(64,10,4) + @test C1 + @test C2 + C3 = domain3dt(64,10) + @test C3 + C4 = domain3df(64,4) + @test C4 +end \ No newline at end of file diff --git a/test/runtests.jl b/test/runtests.jl index 5036560..d17c9a3 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -16,4 +16,5 @@ import DimensionalData as DD include(joinpath(@__DIR__, "images.jl")) include(joinpath(@__DIR__, "visibilities.jl")) include(joinpath(@__DIR__, "executors.jl")) + include(joinpath(@__DIR__, "multidomain.jl")) end From 924908a0b930066ba70c98c2d5a3945a99515bdc Mon Sep 17 00:00:00 2001 From: Paul Tiede Date: Fri, 16 Aug 2024 16:14:05 -0400 Subject: [PATCH 3/3] Update Project.toml --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index 49f9d30..181deca 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "ComradeBase" uuid = "6d8c423b-a35f-4ef1-850c-862fe21f82c4" authors = ["Paul Tiede and contributors"] -version = "0.8.0" +version = "0.8.1" [deps] DimensionalData = "0703355e-b756-11e9-17c0-8b28908087d0"