Skip to content
Snippets Groups Projects
Commit 97ba9217 authored by Florian Atteneder's avatar Florian Atteneder
Browse files

wip

parent 955d5258
No related tags found
No related merge requests found
...@@ -58,8 +58,9 @@ module dg1d ...@@ -58,8 +58,9 @@ module dg1d
include("tensorbasis.jl") include("tensorbasis.jl")
include("box.jl") include("box.jl")
include("tree.jl") include("tree.jl")
include("cache.jl") include("cache.jl")
include("grid.jl")
include("callbacks.jl") include("callbacks.jl")
include("numericalflux.jl") include("numericalflux.jl")
......
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
...@@ -19,6 +19,9 @@ const TensorBasis1d = TensorBasis{1} ...@@ -19,6 +19,9 @@ const TensorBasis1d = TensorBasis{1}
const TensorBasis2d = TensorBasis{2} const TensorBasis2d = TensorBasis{2}
const TensorBasis3d = TensorBasis{3} const TensorBasis3d = TensorBasis{3}
TensorBasis(se::SpectralElement...) = TensorBasis{length(se)}(se...)
Base.getindex(b::TensorBasis, idx::Int) = b.basis[idx] Base.getindex(b::TensorBasis, idx::Int) = b.basis[idx]
# avoid bounds check with enums # avoid bounds check with enums
# can we generalize Cart1d,Cart2d,Cart3d based on dimensions for other corodinates? # can we generalize Cart1d,Cart2d,Cart3d based on dimensions for other corodinates?
...@@ -53,10 +56,10 @@ end ...@@ -53,10 +56,10 @@ end
function range_volume(tb::TensorBasis, offset=1) 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 end
function range_boundary(tb::TensorBasis, offset=1) 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 end
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment