From 97ba92172c344d5b3f889ac2320d73417d249d6b Mon Sep 17 00:00:00 2001 From: Florian Atteneder <florian.atteneder@uni-jena.de> Date: Mon, 17 Oct 2022 09:52:29 +0200 Subject: [PATCH] wip --- src/dg1d.jl | 3 +- src/mwe.jl | 101 +++++++++++++++++++++++++++++++++++++++++++-- src/tensorbasis.jl | 7 +++- 3 files changed, 104 insertions(+), 7 deletions(-) diff --git a/src/dg1d.jl b/src/dg1d.jl index d8ee23d9..5766220e 100644 --- a/src/dg1d.jl +++ b/src/dg1d.jl @@ -58,8 +58,9 @@ module dg1d include("tensorbasis.jl") include("box.jl") include("tree.jl") - include("cache.jl") + include("grid.jl") + include("callbacks.jl") include("numericalflux.jl") diff --git a/src/mwe.jl b/src/mwe.jl index fcfe9a25..1da493e8 100644 --- a/src/mwe.jl +++ b/src/mwe.jl @@ -1,9 +1,102 @@ -using StructArrays +function connected_matrix(Nx, Ny) + M = zeros(Int64, Nx, Ny) + NN = length(M) + ix, iy = 1, 1 + ix_dir = 1 + n = 1 + while n <= NN + M[ix,iy] = n + n += 1 -x, y, z = [ randn(5) for _ = 1:3 ] + if ix_dir > 0 + if ix < Nx + ix += 1 + else + iy += 1 + ix_dir *= -1 + end + else + if ix > 1 + ix -= 1 + else + iy += 1 + ix_dir *= -1 + end + end + end + + return M +end -Vf = Vector{Float64} -soa = StructArray{Tuple{Tuple{Vf,Vf}, Vf}}(((x,y),z)) +function connected_matrix(Nx, Ny, Nz) + M = zeros(Int64, Nx, Ny, Nz) + ijks = NTuple{3,Int64}[] + NN = length(M) + ix, iy, iz = 1, 1, 1 + ix_dir, iy_dir = 1, 1 + n = 1 + while n <= NN + M[ix,iy,iz] = n + push!(ijks, (ix,iy,iz)) + n += 1 + + if ix_dir > 0 + if ix < Nx + ix += 1 + else + if iy_dir > 0 + if iy < Ny + iy += 1 + else + iz += 1 + iy_dir *= -1 + end + else + if iy > 1 + iy -= 1 + else + iz += 1 + iy_dir *= -1 + end + end + ix_dir *= -1 + end + else + if ix > 1 + ix -= 1 + else + if iy_dir > 0 + if iy < Ny + iy += 1 + else + iz += 1 + iy_dir *= -1 + end + else + if iy > 1 + iy -= 1 + else + iz += 1 + iy_dir *= -1 + end + end + ix_dir *= -1 + end + end + + end + + return M, ijks +end + +M2d = connected_matrix(10, 10) +display(M2d) +M3d, ijks = connected_matrix(4,4,4) +display(ijks) +# display(M3d) +# for mijk in M3d +# println(mijk) +# end diff --git a/src/tensorbasis.jl b/src/tensorbasis.jl index fabb58a8..dd072597 100644 --- a/src/tensorbasis.jl +++ b/src/tensorbasis.jl @@ -19,6 +19,9 @@ const TensorBasis1d = TensorBasis{1} const TensorBasis2d = TensorBasis{2} const TensorBasis3d = TensorBasis{3} + +TensorBasis(se::SpectralElement...) = TensorBasis{length(se)}(se...) + Base.getindex(b::TensorBasis, idx::Int) = b.basis[idx] # avoid bounds check with enums # can we generalize Cart1d,Cart2d,Cart3d based on dimensions for other corodinates? @@ -53,10 +56,10 @@ end function range_volume(tb::TensorBasis, offset=1) - return range(offset, offset+n_points(tb)-1) + return Base.range(offset, length=offset+n_points(tb)-1) end function range_boundary(tb::TensorBasis, offset=1) - return range(offset, offset+n_points_boundary(tb)) + return Base.range(offset, length=offset+n_points_boundary(tb)) end -- GitLab