Skip to content

Commit

Permalink
Refactor RegularDiscretization
Browse files Browse the repository at this point in the history
  • Loading branch information
juliohm committed Mar 15, 2024
1 parent 27b85b7 commit 8f7b2ba
Showing 1 changed file with 5 additions and 38 deletions.
43 changes: 5 additions & 38 deletions src/discretization/regular.jl
Original file line number Diff line number Diff line change
Expand Up @@ -121,44 +121,11 @@ function appendtopo(::Sphere{3}, tg)
SimpleTopology([middle; north; south])
end

function appendtopo(::CylinderSurface, tg)
sz = size(tg)
ip = isperiodic(tg)
np = @. sz + !ip
nx, ny = np

# connect quadrangles in the middle
middle = collect(elements(tg))

# connect south pole with triangles
south = map(1:(nx - 1)) do i
u = nx * ny + 1
v = i + 1
w = i
connect((u, v, w))
end
u = nx * ny + 1
v = 1
w = nx
push!(south, connect((u, v, w)))

# connect north pole with triangles
offset = nx * ny - nx
north = map(1:(nx - 1)) do i
u = nx * ny + 2
v = offset + i + 1
w = offset + i
connect((u, w, v))
end
u = nx * ny + 2
v = nx * ny - nx + 1
w = nx * ny
push!(north, connect((u, w, v)))
appendtopo(::CylinderSurface, tg) = _appendnorthsouth(tg)

SimpleTopology([middle; north; south])
end
appendtopo(::ConeSurface, tg) = _appendnorthsouth(tg)

function appendtopo(::ConeSurface, tg)
function _appendnorthsouth(tg)
sz = size(tg)
ip = isperiodic(tg)
np = @. sz + !ip
Expand All @@ -167,7 +134,7 @@ function appendtopo(::ConeSurface, tg)
# connect quadrangles in the middle
middle = collect(elements(tg))

# connect apex with triangles
# connect south pole with triangles
south = map(1:(nx - 1)) do i
u = nx * ny + 1
v = i + 1
Expand All @@ -179,7 +146,7 @@ function appendtopo(::ConeSurface, tg)
w = nx
push!(south, connect((u, v, w)))

# connect base center with triangles
# connect north pole with triangles
offset = nx * ny - nx
north = map(1:(nx - 1)) do i
u = nx * ny + 2
Expand Down

0 comments on commit 8f7b2ba

Please sign in to comment.