Skip to content

Commit

Permalink
Merge pull request WIAS-PDELib#73 from WIAS-PDELib/jf/update_show
Browse files Browse the repository at this point in the history
Update show method
  • Loading branch information
j-fu authored and jpthiele committed Nov 20, 2024
2 parents 021d230 + a0346df commit 576caf3
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 6 deletions.
2 changes: 2 additions & 0 deletions .codespellrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[codespell]
ignore-words-list = missings,rcall,linke,fo
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "ExtendableGrids"
uuid = "cfc395e8-590f-11e8-1f13-43a2532b2fa8"
authors = ["Juergen Fuhrmann <[email protected]>", "Christian Merdon <[email protected]>", "Johannes Taraz <[email protected]>", "Patrick Jaap <[email protected]>"]
version = "1.10.5"
version = "1.11"

[deps]
AbstractTrees = "1520ce14-60c1-5f80-bbc7-55ef81b5835c"
Expand Down
32 changes: 27 additions & 5 deletions src/extendablegrid.jl
Original file line number Diff line number Diff line change
Expand Up @@ -541,16 +541,38 @@ function Base.map(f::Function, grid::ExtendableGrid{Tc, Ti}) where {Tc,Ti}
end
end

#
# Define two show methods, one extended for printing the repl, one
# compact for e.g. interpolating into a string
# See https://discourse.julialang.org/t/show-and-showcompact-on-custom-types/8493/6
#
function Base.show(io::IO, ::MIME"text/plain", grid::ExtendableGrid)
str = @sprintf("%s\n dim = %7d\n nnodes = %7d\n ncells = %7d\n nbfaces = %7d",
typeof(grid),
dim_space(grid), num_nodes(grid), num_cells(grid), num_bfaces(grid))
if num_edges(grid) > 0
str*=@sprintf("\n nedges = %7d", num_edges(grid))
end
if num_partitions(grid)>1
str*="\n npartitions/color = $(num_partitions_per_color(grid))"
end
print(io, str)
nothing
end

function Base.show(io::IO, grid::ExtendableGrid)
str = @sprintf("%s;\ndim: %d nodes: %d cells: %d bfaces: %d",
typeof(grid), dim_space(grid), num_nodes(grid), num_cells(grid), num_bfaces(grid))
str = @sprintf("%s(dim=%d, nnodes=%d, ncells=%d, nbfaces=%d",
typeof(grid),
dim_space(grid), num_nodes(grid), num_cells(grid), num_bfaces(grid))
if num_edges(grid) > 0
str*=@sprintf(", edges: %d", num_edges(grid))
str*=@sprintf(", nedges=%d", num_edges(grid))
end
if num_partitions(grid)>1
str*="\npartitions/color: $(num_partitions_per_color(grid))"
str*=", npart/color=$(num_partitions_per_color(grid))"
end
println(io, str)
str*=")"
print(io, str)
nothing
end

### Tests for the gmsh extension:
Expand Down

0 comments on commit 576caf3

Please sign in to comment.