Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# CHANGES


## v1.2.0 May 28, 2025

### Changed
- TimerOutputs for measuring/storing/showing runtime and allocations in solve, now also for separate operators

### Fixed
- HomogeneousData/InterpolateBoundaryData operator fix when system matrix is of type GenericMTExtendableSparseMatrixCSC

## v1.1.1 April 29, 2025

### Fixed
Expand Down
4 changes: 3 additions & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "ExtendableFEM"
uuid = "a722555e-65e0-4074-a036-ca7ce79a4aed"
authors = ["Christian Merdon <merdon@wias-berlin.de>", "Patrick Jaap <patrick.jaap@wias-berlin.de>"]
version = "1.1.1"
version = "1.2"

[deps]
CommonSolve = "38540f10-b2f7-11e9-35d8-d573e4eb0ff2"
Expand All @@ -19,6 +19,7 @@ SciMLBase = "0bca4576-84f4-4d90-8ffe-ffa030f20462"
SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
SparseDiffTools = "47a9eef4-7e08-11e9-0b38-333d64bd3804"
Symbolics = "0c5d862f-8b57-4792-8d23-62f2024744c7"
TimerOutputs = "a759f4b9-e2f1-59dc-863e-4aeb61b1ea8f"
UnicodePlots = "b8865327-cd53-5732-bb35-84acbb429228"

[compat]
Expand Down Expand Up @@ -48,6 +49,7 @@ StaticArrays = "1.9.13"
Symbolics = "4.2,5,6"
Test = "1"
TetGen = "2.0.0"
TimerOutputs = "0.5.29"
Triangulate = "2.4.0"
UnicodePlots = "3.6.5"
julia = "1.9"
Expand Down
3 changes: 2 additions & 1 deletion examples/Example103_BurgersEquation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,9 @@ function main(;
t = 0
for it in 1:Int(floor(T / τ))
t += τ
ExtendableFEM.solve(PD, FES, SC; time = t)
ExtendableFEM.solve(PD, FES, SC; time = t, verbosity = -1, timeroutputs = :hide)
end
show(timeroutputs(SC))
end

## plot final state
Expand Down
3 changes: 2 additions & 1 deletion examples/Example205_HeatEquation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,9 @@ function main(;
t = 0
for it in 1:Int(floor(T / τ))
t += τ
ExtendableFEM.solve(PD, FES, SC; time = t)
ExtendableFEM.solve(PD, FES, SC; time = t, verbosity = -1, timeroutputs = :hide)
end
@show timeroutputs(SC)
end

## plot final state
Expand Down
2 changes: 2 additions & 0 deletions src/ExtendableFEM.jl
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ using SparseDiffTools: SparseDiffTools, ForwardColorJacCache,
forwarddiff_color_jacobian!, matrix_colors
using Symbolics: Symbolics
using SciMLBase: SciMLBase
using TimerOutputs: TimerOutput, print_timer, @timeit
using UnicodePlots: UnicodePlots


Expand Down Expand Up @@ -145,6 +146,7 @@ export tensor_view
include("solver_config.jl")
export SolverConfiguration
export residual
export timeroutputs

include("solvers.jl")
export solve
Expand Down
1 change: 1 addition & 0 deletions src/common_operators/combinedofs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ mutable struct CombineDofs{UT, CT} <: AbstractOperator
end

default_combop_kwargs() = Dict{Symbol, Tuple{Any, String}}(
:name => ("CombineDofs", "name for operator used in printouts"),
:penalty => (1.0e30, "penalty for fixed degrees of freedom"),
:verbosity => (0, "verbosity level"),
)
Expand Down
63 changes: 48 additions & 15 deletions src/solver_config.jl
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
default_statistics() = Dict{Symbol, Vector{Real}}(
:assembly_times => [],
:solver_times => [],
:assembly_allocations => [],
:solver_allocations => [],
:linear_residuals => [],
:nonlinear_residuals => [],
:matrix_nnz => [],
:total_times => [],
:total_allocations => [],
default_statistics(Tv = Float64, Ti = Int64) = Dict{Symbol, Any}(
:timeroutputs => TimerOutput(),
:linear_residuals => Tv[],
:nonlinear_residuals => Tv[],
:matrix_nnz => Ti[],
)

mutable struct SolverConfiguration{AT <: AbstractMatrix, bT, xT}
Expand All @@ -19,7 +14,7 @@ mutable struct SolverConfiguration{AT <: AbstractMatrix, bT, xT}
res::xT
freedofs::Vector{Int} ## stores indices of free dofs
LP::LinearProblem
statistics::Dict{Symbol, Vector{Real}}
statistics::Dict{Symbol, Any}
linsolver::Any
unknown_ids_in_sol::Array{Int, 1}
unknowns::Array{Unknown, 1}
Expand All @@ -28,17 +23,54 @@ mutable struct SolverConfiguration{AT <: AbstractMatrix, bT, xT}
parameters::Dict{Symbol, Any} # dictionary with user parameters
end

"""
````
residuals(S::SolverConfiguration)
````

returns the vector with the residuals of all iterations
"""
residuals(S::SolverConfiguration) = S.statistics[:nonlinear_residuals]

"""
````
residual(S::SolverConfiguration)
````

returns the residual of the last solve

"""
residual(S::SolverConfiguration) = S.statistics[:nonlinear_residuals][end]


"""
````
timeroutputs(S::SolverConfiguration)
````

returns TimerOutputs object that contains detailed information on solving and assembly times
"""
timeroutputs(S::SolverConfiguration) = S.statistics[:timeroutputs]


"""
````
lastmatrix(S::SolverConfiguration)
````

returns the currently stored system matrix
"""
lastmatrix(S::SolverConfiguration) = S.A

"""
````
lastrhs(S::SolverConfiguration)
````

returns the currently stored right-hand side
"""
lastrhs(S::SolverConfiguration) = S.b


#
# Default context information with help info.
#
Expand All @@ -65,6 +97,7 @@ default_solver_kwargs() = Dict{Symbol, Tuple{Any, String}}(
:constant_rhs => (false, "right-hand side is constant (skips reassembly)"),
:method_linear => (UMFPACKFactorization(), "any solver or custom LinearSolveFunction compatible with LinearSolve.jl (default = UMFPACKFactorization())"),
:precon_linear => (nothing, "function that computes preconditioner for method_linear in case an iterative solver is chosen"),
:timeroutputs => (:full, "configures show of timeroutputs (choose between :hide, :full, :compact)"),
:initialized => (false, "linear system in solver configuration is already assembled (turns true after first solve)"),
:plot => (false, "plot all solved unknowns with a (very rough but fast) unicode plot"),
)
Expand All @@ -83,8 +116,8 @@ end

"""
````
function iterate_until_stationarity(
SolverConfiguration(Problem::ProblemDescription
function SolverConfiguration(
Problem::ProblemDescription
[FES::Union{<:FESpace, Vector{<:FESpace}}];
init = nothing,
unknowns = Problem.unknowns,
Expand Down Expand Up @@ -170,5 +203,5 @@ function SolverConfiguration(Problem::ProblemDescription, unknowns::Array{Unknow
else
LP = LinearProblem(A.entries.cscmatrix, b.entries)
end
return SolverConfiguration{typeof(A), typeof(b), typeof(x)}(Problem, A, b, x, x_temp, res, freedofs, LP, default_statistics(), nothing, unknown_ids_in_sol, unknowns, copy(unknowns), offsets, parameters)
return SolverConfiguration{typeof(A), typeof(b), typeof(x)}(Problem, A, b, x, x_temp, res, freedofs, LP, default_statistics(TvM, TiM), nothing, unknown_ids_in_sol, unknowns, copy(unknowns), offsets, parameters)
end
Loading
Loading