Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix show of Face and Cell values #771

Merged
merged 3 commits into from
Jul 25, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/FEValues/cell_values.jl
Original file line number Diff line number Diff line change
Expand Up @@ -285,3 +285,11 @@ function reinit!(cv::CellValues{<:Any, N_t, dNdx_t, dNdξ_t}, x::AbstractVector{
end
return nothing
end

function Base.show(io::IO, m::MIME"text/plain", cv::CellValues)
println(io, "CellValues with")
println(io, "- Quadrature rule with ", getnquadpoints(cv), " points")
print(io, "- Function interpolation: "); show(io, m, cv.ip)
println(io)
print(io, "- Geometric interpolation: "); show(io, m, cv.gip)
end
13 changes: 13 additions & 0 deletions src/FEValues/face_values.jl
Original file line number Diff line number Diff line change
Expand Up @@ -250,3 +250,16 @@ function checkface(fv::FaceValues, face::Int)
0 < face <= nfaces(fv) || error("Face index out of range.")
return nothing
end

function Base.show(io::IO, m::MIME"text/plain", fv::FaceValues)
println(io, "FaceValues with")
nqp = getnquadpoints.(fv.qr.face_rules)
if all(n==first(nqp) for n in nqp)
println(io, "- Quadrature rule with ", first(nqp), " points per face")
else
println(io, "- Quadrature rule with ", tuple(nqp...), " points on each face")
end
print(io, "- Function interpolation: "); show(io, m, fv.func_interp)
println(io)
print(io, "- Geometric interpolation: "); show(io, m, fv.geo_interp)
end
6 changes: 6 additions & 0 deletions test/test_cellvalues.jl
Original file line number Diff line number Diff line change
Expand Up @@ -308,4 +308,10 @@ end
end
end

@testset "show" begin
# Just smoke test
cv = CellValues(QuadratureRule{RefQuadrilateral}(2), Lagrange{RefQuadrilateral,2}())
show(stdout, MIME"text/plain"(), cv)
end

end # of testset
9 changes: 9 additions & 0 deletions test/test_facevalues.jl
Original file line number Diff line number Diff line change
Expand Up @@ -107,4 +107,13 @@ for (scalar_interpol, quad_rule) in (
end
end

@testset "show" begin
# Just smoke test to make sure show doesn't error.
fv = FaceValues(FaceQuadratureRule{RefQuadrilateral}(2), Lagrange{RefQuadrilateral,2}())
show(stdout, MIME"text/plain"(), fv)
fv.qr.face_rules[1] = deepcopy(fv.qr.face_rules[1])
push!(Ferrite.getweights(fv.qr.face_rules[1]), 1)
show(stdout, MIME"text/plain"(), fv)
end

end # of testset