Skip to content

Commit

Permalink
Fix show of FaceValues and CellValues (#771)
Browse files Browse the repository at this point in the history
  • Loading branch information
KnutAM authored Jul 25, 2023
1 parent a014185 commit debf386
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 0 deletions.
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
8 changes: 8 additions & 0 deletions test/test_cellvalues.jl
Original file line number Diff line number Diff line change
Expand Up @@ -308,4 +308,12 @@ end
end
end

@testset "show" begin
# Just smoke test
cv_quad = CellValues(QuadratureRule{RefQuadrilateral}(2), Lagrange{RefQuadrilateral,2}()^2)
cv_wedge = CellValues(QuadratureRule{RefPrism}(2), Lagrange{RefPrism,2}())
show(stdout, MIME"text/plain"(), cv_quad)
show(stdout, MIME"text/plain"(), cv_wedge)
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

0 comments on commit debf386

Please sign in to comment.