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 8f7b2ba commit c28fb10
Showing 1 changed file with 24 additions and 24 deletions.
48 changes: 24 additions & 24 deletions src/discretization/regular.jl
Original file line number Diff line number Diff line change
Expand Up @@ -61,30 +61,6 @@ appendtopo(::Ball{2}, tg) = _appendcenter(tg)

appendtopo(::Disk, tg) = _appendcenter(tg)

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

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

# connect center with triangles
tris = map(1:(ny - 1)) do j
u = nx * ny + 1
v = 1 + (j - 1) * nx
w = 1 + (j) * nx
connect((u, v, w))
end
u = nx * ny + 1
v = 1 + (ny - 1) * nx
w = 1
push!(tris, connect((u, v, w)))

SimpleTopology([quads; tris])
end

function appendtopo(::Sphere{3}, tg)
sz = size(tg)
ip = isperiodic(tg)
Expand Down Expand Up @@ -125,6 +101,30 @@ appendtopo(::CylinderSurface, tg) = _appendnorthsouth(tg)

appendtopo(::ConeSurface, tg) = _appendnorthsouth(tg)

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

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

# connect center with triangles
tris = map(1:(ny - 1)) do j
u = nx * ny + 1
v = 1 + (j - 1) * nx
w = 1 + (j) * nx
connect((u, v, w))
end
u = nx * ny + 1
v = 1 + (ny - 1) * nx
w = 1
push!(tris, connect((u, v, w)))

SimpleTopology([quads; tris])
end

function _appendnorthsouth(tg)
sz = size(tg)
ip = isperiodic(tg)
Expand Down

0 comments on commit c28fb10

Please sign in to comment.