Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
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
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
# CHANGES

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

## v1.2.0 July 07, 2025
- major documentation and docstring overhaul
Expand Down
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "ExtendableFEMBase"
uuid = "12fb9182-3d4c-4424-8fd1-727a0899810c"
authors = ["Christian Merdon <[email protected]>", "Patrick Jaap <[email protected]>"]
version = "1.2.1"
version = "1.3.0"

[deps]
DiffResults = "163ba53b-c6d8-5494-b064-1a9d43ac40c5"
Expand Down
11 changes: 11 additions & 0 deletions src/feevaluator.jl
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,17 @@ struct SingleFEEvaluator{T <: Real, TvG <: Real, TiG <: Integer, operator, FETyp
compressiontargets::Array{Int, 1} # some operators allow for compressed storage (e.g. SymmetricGradient)
end

function Base.show(io::IO, FEB::SingleFEEvaluator)
println(io, "SingleFEEvaluator")
println(io, "-----------------")
println(io, "Operator: ", typeof(FEB).parameters[4])
println(io, "FESpace: ", typeof(FEB.FE))
println(io, "Element: ", typeof(FEB.FE).parameters[3])
println(io, "Geometry: ", typeof(FEB.L2G).parameters[3])
println(io, "Quadrature: ", length(FEB.xref), " points")
return
end


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

Expand Down
6 changes: 5 additions & 1 deletion src/fevector.jl
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,13 @@ $(TYPEDSIGNATURES)
Custom `show` function for `FEVectorBlock` that prints some information and the view of that block.
"""
function Base.show(io::IO, ::MIME"text/plain", FEB::FEVectorBlock)
@printf(io, "block %s [%d:%d] = ", FEB.name, FEB.offset + 1, FEB.last_index)
return show(io, view(FEB))
end
function Base.show(io::IO, FEB::FEVectorBlock)
@printf(io, "block %s [%d:%d] = ", FEB.name, FEB.offset + 1, FEB.last_index)
show(io, view(FEB))
return nothing
end

"""
$(TYPEDEF)
Expand Down
10 changes: 10 additions & 0 deletions src/point_evaluator.jl
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,16 @@ mutable struct PointEvaluator{Tv <: Real, UT, KFT <: Function}
parameters::Dict{Symbol, Any}
end

function Base.show(io::IO, PE::PointEvaluator)
println(io, "PointEvaluator")
println(io, "--------------")
println(io, "Unknowns: ", PE.u_args)
println(io, "Operators: ", PE.ops_args)
println(io, "Kernel function: ", typeof(PE.kernel))
println(io, "Parameters: ", PE.parameters)
return
end

default_peval_kwargs() = Dict{Symbol, Tuple{Any, String}}(
:name => ("PointEvaluator", "name for operator used in printouts"),
:resultdim => (0, "dimension of result field (default = length of operators)"),
Expand Down
10 changes: 10 additions & 0 deletions src/reconstructionoperators.jl
Original file line number Diff line number Diff line change
Expand Up @@ -91,3 +91,13 @@ function update_basis!(FEBE::FEReconstEvaluator)
end
return nothing
end

function Base.show(io::IO, FEB::FEReconstEvaluator)
println(io, "FEReconstEvaluator (reconstruction operator)")
println(io, "-------------------------------------------")
println(io, "Reconstruction FE space: ", typeof(FEB.FEB.FE))
println(io, "Reconstruction operator: ", typeof(FEB.FEB).parameters[4])
println(io, "Underlying SingleFEEvaluator:")
show(io, FEB.FEB)
return
end
11 changes: 11 additions & 0 deletions src/segment_integrator.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,17 @@ mutable struct SegmentIntegrator{Tv <: Real, UT, KFT <: Function, EG}
parameters::Dict{Symbol, Any}
end

function Base.show(io::IO, SI::SegmentIntegrator)
println(io, "SegmentIntegrator")
println(io, "-----------------")
println(io, "Domain geometry: ", segment_geometry(SI))
println(io, "Unknowns: ", SI.u_args)
println(io, "Operators: ", SI.ops_args)
println(io, "Kernel function: ", typeof(SI.kernel))
println(io, "Parameters: ", SI.parameters)
return
end

segment_geometry(::SegmentIntegrator{Tv, UT, KFT, EG}) where {Tv, UT, KFT, EG} = EG


Expand Down
1 change: 1 addition & 0 deletions test/test_febasis.jl
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ end

function test_vertex_values(EG, FEType, order)
qf = VertexRule(EG, order; T = Rational{Int})
@show qf
Copy link
Member

@pjaap pjaap Jul 9, 2025

Choose a reason for hiding this comment

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

I generally like the idea, but, nevertheless, the logs are pretty verbose now: https://github.com/WIAS-PDELib/ExtendableFEMBase.jl/actions/runs/16163910516/job/45621150705?pr=45#step:6:928

It may be better to test the show function directly with show(devnull, qf) which redirects the output into the void. Errors should be thrown as before, if something is not implemented correctly.

Copy link
Member

Choose a reason for hiding this comment

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

One could also add a global variable target_stream = devnull in the runtests.jl. The user can set this to stdout if inspecting the output is needed. Opinions?

Copy link
Member Author

Choose a reason for hiding this comment

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

and then use show(target_stream, obj) everywhere?

Copy link
Member

Choose a reason for hiding this comment

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

Yes, or just show(devnull, obj) ... I am not sure whether a switch is any good or just creates confusion.

Copy link
Member

Choose a reason for hiding this comment

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

After thinking for a few more seconds: no target_stream. If I want to inspect the output in the logs, I just remove the devnull

Copy link
Member Author

Choose a reason for hiding this comment

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

Ok, then I will use show(devnull, obj)

basis = get_basis(ON_CELLS, FEType, EG)
ndofs = get_ndofs(ON_CELLS, FEType, EG)
basis_vals = zeros(Rational{Int}, ndofs, 1)
Expand Down
11 changes: 7 additions & 4 deletions test/test_fematrix_and_vector.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,24 @@ function run_fematrix_tests()

@testset "FEMatrixVector" begin
println("\n")
println("=======================")
println("Testing FEMatrix&VEctor")
println("=======================")
println("===========================")
println("Testing FEMatrix & FEVector")
println("===========================")
xgrid = simplexgrid(0:0.1:1, 0:0.1:1)
FES1 = FESpace{H1Pk{1, 1, 1}}(xgrid)
@show FES1
FES2 = FESpace{H1Pk{1, 1, 2}}(xgrid)
@show FES2
A = FEMatrix(FES1, FES2)
@test size(A.entries) == (FES1.ndofs, FES2.ndofs)
@test size(A[1, 1]) == (FES1.ndofs, FES2.ndofs)
@show A

B = FEMatrix([FES1, FES2])
@test length(B) == 4
@test size(B.entries) == (FES1.ndofs + FES2.ndofs, FES1.ndofs + FES2.ndofs)
@test size(B[1, 2]) == (FES1.ndofs, FES2.ndofs)

@show B

C = FEMatrix([FES2, FES2], [FES1, FES1])
@test length(C) == 4
Expand Down
5 changes: 3 additions & 2 deletions test/test_interpolators.jl
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ function run_interpolator_tests()
QP = QPInfos(xgrid)
qf = VertexRule(EG, order)
FEB = FEEvaluator(FES, Identity, qf)
@show FEB
for cell::Int in cells
update_trafo!(L2G, cell)
update_basis!(FEB, cell)
Expand Down Expand Up @@ -101,15 +102,15 @@ function run_interpolator_tests()
# choose FE and generate FESpace
FES = FESpace{FEType}(xgrid; broken = broken)
AT = ON_CELLS
print("FEType = $FEType $(broken ? "broken" : "") $AT | ndofs = $(FES.ndofs) | order = $order")

# interpolate
Solution = FEVector(FES)
interpolate!(Solution[1], u; bonus_quadorder = order)
@show Solution

# compute error
error = compute_error(Solution[1], u, order)
println(" | error = $(norm(error, Inf))")
println("FEType = $FEType $(broken ? "broken" : "") $AT | ndofs = $(FES.ndofs) | order = $order | error = $(norm(error, Inf))")
return @test norm(error) < tolerance
end

Expand Down
2 changes: 2 additions & 0 deletions test/test_operators.jl
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ function test_derivatives2D()
## define P2-Courant finite element space
FEType = H1P2{2, 2}
FES = FESpace{FEType}(xgrid)
@show FES

## get midpoint quadrature rule for constants
qf = QuadratureRule{Float64, Triangle2D}(0)
Expand Down Expand Up @@ -113,6 +114,7 @@ function test_derivatives3D()
## define P2-Courant finite element space
FEType = H1P2{3, 3}
FES = FESpace{FEType}(xgrid)
@show FES

## get midpoint quadrature rule for constants
qf = QuadratureRule{Float64, Tetrahedron3D}(0)
Expand Down
2 changes: 2 additions & 0 deletions test/test_pointevaluator.jl
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ function test_pointevaluation2D()
Iu = FEVector(FES)
interpolate!(Iu[1], (result, qpinfo) -> (result[1] = qpinfo.x[1] + qpinfo.x[2]))
PE = PointEvaluator([(1, Identity)])
@show PE
initialize!(PE, Iu)
CF = CellFinder(xgrid)
eval = zeros(Float64, 1)
Expand All @@ -38,6 +39,7 @@ function test_pointevaluation3D()
Iu = FEVector(FES)
interpolate!(Iu[1], (result, qpinfo) -> (result[1] = qpinfo.x[1] + qpinfo.x[2] + qpinfo.x[3]))
PE = PointEvaluator([(1, Identity)])
@show PE
initialize!(PE, Iu)
CF = CellFinder(xgrid)
eval = zeros(Float64, 1)
Expand Down
3 changes: 3 additions & 0 deletions test/test_quadrature.jl
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ function run_quadrature_tests()
for order in 1:maxorder1D
integrand, exactvalue = exact_function(Val(1), order)
qf = QuadratureRule{Float64, Edge1D}(order)
@show qf
quadvalue = integrate(xgrid, ON_CELLS, integrand, length(exactvalue); force_quadrature_rule = qf)
println("EG = Edge1D | order = $order ($(qf.name), $(length(qf.w)) points) | error = $(quadvalue - exactvalue)")
@test isapprox(quadvalue, exactvalue)
Expand All @@ -30,6 +31,7 @@ function run_quadrature_tests()
for order in 1:maxorder2D[j]
integrand, exactvalue = exact_function(Val(2), order)
qf = QuadratureRule{Float64, EG}(order)
@show qf
quadvalue = integrate(xgrid, ON_CELLS, integrand, length(exactvalue); force_quadrature_rule = qf)
println("EG = $EG | order = $order ($(qf.name), $(length(qf.w)) points) | error = $(quadvalue - exactvalue)")
@test isapprox(quadvalue, exactvalue)
Expand All @@ -44,6 +46,7 @@ function run_quadrature_tests()
for order in 1:maxorder3D[j]
integrand, exactvalue = exact_function(Val(3), order)
qf = QuadratureRule{Float64, EG}(order)
@show qf
quadvalue = integrate(xgrid, ON_CELLS, integrand, length(exactvalue); force_quadrature_rule = qf)
println("EG = $EG | order = $order ($(qf.name), $(length(qf.w)) points) | error = $(quadvalue - exactvalue)")
@test isapprox(quadvalue, exactvalue)
Expand Down
2 changes: 2 additions & 0 deletions test/test_segmentintegrator.jl
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ function test_segmentintegrator_nokernel()
## init segment integrator
SI = SegmentIntegrator(Edge1D, [(1, Identity)])
initialize!(SI, uh)
@show SI

## integrate along line [1/4,1/4] to [3/4,1/4] in first triangle
## exact integral should be [3//32,0]
Expand Down Expand Up @@ -65,6 +66,7 @@ function test_segmentintegrator_withkernel()
## init segment integrator
SI = SegmentIntegrator(Edge1D, multiply_r!, [(1, Identity)]; bonus_quadorder = 1)
initialize!(SI, uh)
@show SI

@show xgrid[Coordinates], xgrid[CellNodes]

Expand Down
Loading