Skip to content

Commit

Permalink
Add show methods for GridManager and Grid
Browse files Browse the repository at this point in the history
  • Loading branch information
lcw committed May 9, 2024
1 parent b534693 commit 9dececf
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 0 deletions.
38 changes: 38 additions & 0 deletions src/gridmanager.jl
Original file line number Diff line number Diff line change
Expand Up @@ -480,3 +480,41 @@ function materializequadranttointerpolation(abaqus::AbaqusMeshImport)

return quadranttointerpolation
end

function Base.show(io::IO, g::GridManager)
compact = get(io, :compact, false)
print(io, "GridManager(")
show(io, referencecell(g))
print(io, ", ")
show(io, coarsegrid(g))
print(io, "; comm=")
show(io, comm(g))
print(io, ")")
if !compact
nlocal = P4estTypes.lengthoflocalquadrants(forest(g))
nglobal = P4estTypes.lengthoflocalquadrants(forest(g))
print(io, " with $nlocal of the $nglobal global elements")
end

return
end

function Base.showarg(io::IO, g::GridManager, toplevel)
!toplevel && print(io, "::")

print(io, "GridManager{")
Base.showarg(io, referencecell(g), false)
print(io, ", ")
Base.showarg(io, coarsegrid(g), false)
print(io, "}")

if toplevel
nlocal = P4estTypes.lengthoflocalquadrants(forest(g))
nglobal = P4estTypes.lengthoflocalquadrants(forest(g))
print(io, " with $nlocal of the $nglobal global elements")
end

return
end

Base.summary(io::IO, g::GridManager) = Base.showarg(io, g, true)
32 changes: 32 additions & 0 deletions src/grids.jl
Original file line number Diff line number Diff line change
Expand Up @@ -150,3 +150,35 @@ function faceviews(A::AbstractMatrix, cell::AbstractCell)
reshape(view(A, (1+offsets[f]):offsets[f+1], :), facesizes[f]..., :)
end
end

function Base.show(io::IO, g::Grid)
compact = get(io, :compact, false)
print(io, "Raven.Grid{")
show(io, referencecell(g))
print(io, "}()")
if !compact
nlocal = numcells(g, Val(false))
nglobal = numcells(g, Val(true))
print(io, " with $nlocal of the $nglobal global elements")
end

return
end

function Base.showarg(io::IO, g::Grid, toplevel)
!toplevel && print(io, "::")

print(io, "Raven.Grid{")
Base.showarg(io, referencecell(g), true)
print(io, "}")

if toplevel
nlocal = numcells(g, Val(false))
nglobal = numcells(g, Val(true))
print(io, " with $nlocal of the $nglobal global elements")
end

return
end

Base.summary(io::IO, g::Grid) = Base.showarg(io, g, true)

0 comments on commit 9dececf

Please sign in to comment.