Skip to content

Commit 7f1e489

Browse files
authored
fixes show method crash for FEVectorBlock + additional show functions (#45)
1 parent e8a21f8 commit 7f1e489

15 files changed

+71
-13
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
# CHANGES
22

3-
## v1.2.1 July 09, 2025
3+
## v1.3.0 July 09, 2025
44
- some bugfixes related to new template parameter from 1.2.0
55
- @show of FEVectorBlock does not crash anymore
6+
- added show functions for FEBasisEvaluator, PointEvaluator, SegmentEvaluator
67

78
## v1.2.0 July 07, 2025
89
- major documentation and docstring overhaul

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "ExtendableFEMBase"
22
uuid = "12fb9182-3d4c-4424-8fd1-727a0899810c"
33
authors = ["Christian Merdon <[email protected]>", "Patrick Jaap <[email protected]>"]
4-
version = "1.2.1"
4+
version = "1.3.0"
55

66
[deps]
77
DiffResults = "163ba53b-c6d8-5494-b064-1a9d43ac40c5"

src/feevaluator.jl

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,17 @@ struct SingleFEEvaluator{T <: Real, TvG <: Real, TiG <: Integer, operator, FETyp
2525
compressiontargets::Array{Int, 1} # some operators allow for compressed storage (e.g. SymmetricGradient)
2626
end
2727

28+
function Base.show(io::IO, FEB::SingleFEEvaluator)
29+
println(io, "SingleFEEvaluator")
30+
println(io, "-----------------")
31+
println(io, "Operator: ", typeof(FEB).parameters[4])
32+
println(io, "FESpace: ", typeof(FEB.FE))
33+
println(io, "Element: ", typeof(FEB.FE).parameters[3])
34+
println(io, "Geometry: ", typeof(FEB.L2G).parameters[3])
35+
println(io, "Quadrature: ", length(FEB.xref), " points")
36+
return
37+
end
38+
2839

2940
Base.getindex(FEB::FEEvaluator, c, dof, qp) = FEB.cvals[c, dof, qp]
3041

src/fevector.jl

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,13 @@ $(TYPEDSIGNATURES)
5555
Custom `show` function for `FEVectorBlock` that prints some information and the view of that block.
5656
"""
5757
function Base.show(io::IO, ::MIME"text/plain", FEB::FEVectorBlock)
58-
@printf(io, "block %s [%d:%d] = ", FEB.name, FEB.offset + 1, FEB.last_index)
5958
return show(io, view(FEB))
6059
end
60+
function Base.show(io::IO, FEB::FEVectorBlock)
61+
@printf(io, "block %s [%d:%d] = ", FEB.name, FEB.offset + 1, FEB.last_index)
62+
show(io, view(FEB))
63+
return nothing
64+
end
6165

6266
"""
6367
$(TYPEDEF)

src/point_evaluator.jl

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,16 @@ mutable struct PointEvaluator{Tv <: Real, UT, KFT <: Function}
1313
parameters::Dict{Symbol, Any}
1414
end
1515

16+
function Base.show(io::IO, PE::PointEvaluator)
17+
println(io, "PointEvaluator")
18+
println(io, "--------------")
19+
println(io, "Unknowns: ", PE.u_args)
20+
println(io, "Operators: ", PE.ops_args)
21+
println(io, "Kernel function: ", typeof(PE.kernel))
22+
println(io, "Parameters: ", PE.parameters)
23+
return
24+
end
25+
1626
default_peval_kwargs() = Dict{Symbol, Tuple{Any, String}}(
1727
:name => ("PointEvaluator", "name for operator used in printouts"),
1828
:resultdim => (0, "dimension of result field (default = length of operators)"),

src/reconstructionoperators.jl

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,3 +91,13 @@ function update_basis!(FEBE::FEReconstEvaluator)
9191
end
9292
return nothing
9393
end
94+
95+
function Base.show(io::IO, FEB::FEReconstEvaluator)
96+
println(io, "FEReconstEvaluator (reconstruction operator)")
97+
println(io, "-------------------------------------------")
98+
println(io, "Reconstruction FE space: ", typeof(FEB.FEB.FE))
99+
println(io, "Reconstruction operator: ", typeof(FEB.FEB).parameters[4])
100+
println(io, "Underlying SingleFEEvaluator:")
101+
show(io, FEB.FEB)
102+
return
103+
end

src/segment_integrator.jl

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,17 @@ mutable struct SegmentIntegrator{Tv <: Real, UT, KFT <: Function, EG}
1111
parameters::Dict{Symbol, Any}
1212
end
1313

14+
function Base.show(io::IO, SI::SegmentIntegrator)
15+
println(io, "SegmentIntegrator")
16+
println(io, "-----------------")
17+
println(io, "Domain geometry: ", segment_geometry(SI))
18+
println(io, "Unknowns: ", SI.u_args)
19+
println(io, "Operators: ", SI.ops_args)
20+
println(io, "Kernel function: ", typeof(SI.kernel))
21+
println(io, "Parameters: ", SI.parameters)
22+
return
23+
end
24+
1425
segment_geometry(::SegmentIntegrator{Tv, UT, KFT, EG}) where {Tv, UT, KFT, EG} = EG
1526

1627

test/runtests.jl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ using ExampleJuggler
66
using SparseArrays
77
using Aqua
88

9-
109
@testset "Aqua.jl" begin
1110
Aqua.test_all(
1211
ExtendableFEMBase;

test/test_febasis.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ end
2323

2424
function test_vertex_values(EG, FEType, order)
2525
qf = VertexRule(EG, order; T = Rational{Int})
26+
show(devnull, qf)
2627
basis = get_basis(ON_CELLS, FEType, EG)
2728
ndofs = get_ndofs(ON_CELLS, FEType, EG)
2829
basis_vals = zeros(Rational{Int}, ndofs, 1)

test/test_fematrix_and_vector.jl

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,28 +2,31 @@ function run_fematrix_tests()
22

33
@testset "FEMatrixVector" begin
44
println("\n")
5-
println("=======================")
6-
println("Testing FEMatrix&VEctor")
7-
println("=======================")
5+
println("===========================")
6+
println("Testing FEMatrix & FEVector")
7+
println("===========================")
88
xgrid = simplexgrid(0:0.1:1, 0:0.1:1)
99
FES1 = FESpace{H1Pk{1, 1, 1}}(xgrid)
10+
show(devnull, FES1)
1011
FES2 = FESpace{H1Pk{1, 1, 2}}(xgrid)
12+
show(devnull, FES2)
1113
A = FEMatrix(FES1, FES2)
1214
@test size(A.entries) == (FES1.ndofs, FES2.ndofs)
1315
@test size(A[1, 1]) == (FES1.ndofs, FES2.ndofs)
16+
show(devnull, A)
1417

1518
B = FEMatrix([FES1, FES2])
1619
@test length(B) == 4
1720
@test size(B.entries) == (FES1.ndofs + FES2.ndofs, FES1.ndofs + FES2.ndofs)
1821
@test size(B[1, 2]) == (FES1.ndofs, FES2.ndofs)
19-
22+
show(devnull, B)
2023

2124
C = FEMatrix([FES2, FES2], [FES1, FES1])
2225
@test length(C) == 4
2326
@test size(C.entries) == (2 * FES2.ndofs, 2 * FES1.ndofs)
2427
@test size(C[1, 2]) == (FES2.ndofs, FES1.ndofs)
2528
C.entries.cscmatrix = sprand(2 * FES2.ndofs, 2 * FES1.ndofs, 0.5)
26-
@show C
29+
show(devnull, C)
2730

2831
b = FEVector([FES1, FES2])
2932
b.entries .= rand(FES1.ndofs + FES2.ndofs)

0 commit comments

Comments
 (0)