Skip to content

Commit 86665c9

Browse files
author
chmerdon
committed
CompressedRestriction needs dummy assemble! function (otherwise crashes when linear problem is solved again with same ProblemDescription but without providing old SolverConfiguration), improved show of Unknowns
1 parent c92a468 commit 86665c9

3 files changed

Lines changed: 20 additions & 2 deletions

File tree

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77

88
### Added
99
- Restrictions are listed in show of ProblemDescription
10+
- CompressedRestriction has (empty) assemble! function to prevent crash in some cases
11+
- improved show of Unknowns
1012

1113
## v.1.10.0
1214

src/common_restrictions/compressed_restriction.jl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,9 @@ function CompressedRestriction(unknown::Union{Unknown, Int}, matrix::AbstractMat
2323
)
2424
)
2525
end
26+
27+
28+
function assemble!(R::CompressedRestriction, sol, SC; kwargs...)
29+
# do nothing
30+
return nothing
31+
end

src/unknowns.jl

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ default_unknown_kwargs() = Dict{Symbol, Tuple{Any, String}}(
4242
:algebraic_constraint => (nothing, "is this unknown an algebraic constraint?"),
4343
)
4444

45-
test_function(u::Unknown) = u.parameters[:symbol_test] === nothing ? "X($(u.identifier))" : u.parameters[:symbol_test]
45+
test_function(u::Unknown) = u.parameters[:symbol_test] === nothing ? u.identifier : u.parameters[:symbol_test]
4646
ansatz_function(u::Unknown) = u.parameters[:symbol_ansatz] === nothing ? u.identifier : u.parameters[:symbol_ansatz]
4747

4848

@@ -72,7 +72,17 @@ function Unknown(u::String; identifier = Symbol(u), name = u, kwargs...)
7272
end
7373

7474
function Base.show(io::IO, u::Unknown)
75-
return print(io, "$(u.identifier) ($(u.name))")
75+
print(io, "$(u.identifier) [name=$(u.name)")
76+
if haskey(u.parameters, :dimension) && u.parameters[:dimension] !== nothing
77+
print(io, ", dim=$(u.parameters[:dimension])")
78+
end
79+
if haskey(u.parameters, :symbol_ansatz) && u.parameters[:symbol_ansatz] !== nothing
80+
print(io, ", ansatz=$(u.parameters[:symbol_ansatz])")
81+
end
82+
if haskey(u.parameters, :symbol_test) && u.parameters[:symbol_test] !== nothing
83+
print(io, ", test=$(u.parameters[:symbol_test])")
84+
end
85+
return print(io, "]")
7686
end
7787

7888
## remapping of all function operators

0 commit comments

Comments
 (0)