Skip to content

Commit

Permalink
Merge pull request #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 Nov 16, 2024
2 parents 021d230 + a0346df commit 7c9660e
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 6 deletions.
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

2 comments on commit 7c9660e

@j-fu
Copy link
Member Author

@j-fu j-fu commented on 7c9660e Nov 16, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/119576

Tip: Release Notes

Did you know you can add release notes too? Just add markdown formatted text underneath the comment after the text
"Release notes:" and it will be added to the registry PR, and if TagBot is installed it will also be added to the
release that TagBot creates. i.e.

@JuliaRegistrator register

Release notes:

## Breaking changes

- blah

To add them here just re-invoke and the PR will be updated.

Tagging

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v1.11.0 -m "<description of version>" 7c9660eb47f1aa5dffde5fd8dfa6bb92e6db1644
git push origin v1.11.0

Please sign in to comment.