Skip to content

Commit 1cf0ae2

Browse files
ChrisRackauckas-ClaudeChrisRackauckasclaude
authored
Restore ProblemTypeCtx as the discretization metadata key (#99)
* Revert PDEBaseMetadataCtx back to ProblemTypeCtx Substituting a PDEBase-owned metadata key for `ProblemTypeCtx` silently broke the MethodOfLines solution interface. `ProblemTypeCtx` is not a private helper that can be reproduced locally: ModelingToolkitBase reads it to populate `prob.problem_type`, and SciMLBase's `wrap_sol` dispatches on that value to build a `PDETimeSeriesSolution`. With a different key the metadata never reaches `problem_type`, `wrap_sol` falls through to the identity method, and a raw `ODESolution` comes back with no error at discretize or solve time, so `sol[u(t,x)]` fails. Import it from ModelingToolkitBase, the owner, rather than through the ModelingToolkit re-export. That satisfies the owner check; the remaining publicness check needs the upstream `public` declaration in SciML/ModelingToolkit.jl#4842, so keep one narrow QA ignore until that ships. Co-Authored-By: Chris Rackauckas <accounts@chrisrackauckas.com> Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0117aJvytDT3y2jMi5Ng6Q5m * Require ModelingToolkitBase 1.58 and drop the last QA ignore `ProblemTypeCtx` is public as of ModelingToolkitBase 1.58.0 (SciML/ModelingToolkit.jl#4842), so PDEBase can import it from its owner with no exception. QA is now fully strict. Co-Authored-By: Chris Rackauckas <accounts@chrisrackauckas.com> Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0117aJvytDT3y2jMi5Ng6Q5m --------- Co-authored-by: ChrisRackauckas-Claude <accounts@chrisrackauckas.com> Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
1 parent 3ea8c85 commit 1cf0ae2

3 files changed

Lines changed: 7 additions & 9 deletions

File tree

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ AllocCheck = "0.2"
2020
BenchmarkTools = "1"
2121
DomainSets = "0.7, 0.8"
2222
IntervalSets = "0.7"
23-
ModelingToolkitBase = "1.57"
23+
ModelingToolkitBase = "1.58"
2424
ModelingToolkit = "11"
2525
PrecompileTools = "1.2.1"
2626
SciMLBase = "2.149.0, 3.1"

src/PDEBase.jl

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ import PrecompileTools
66
import SciMLBase
77
import Symbolics
88
import SymbolicUtils
9-
using ModelingToolkitBase: PDESystem, System, get_bcs, get_connector_type, get_domain,
10-
get_dvs, get_eqs, get_gui_metadata, get_iv, get_ivs, get_metadata, get_ps,
9+
using ModelingToolkitBase: PDESystem, ProblemTypeCtx, System, get_bcs, get_connector_type,
10+
get_domain, get_dvs, get_eqs, get_gui_metadata, get_iv, get_ivs, get_metadata, get_ps,
1111
get_systems, get_unknowns, mtkcompile
1212
using PrecompileTools: @compile_workload, @setup_workload
1313
using SciMLBase: AbstractDiscretization, AbstractDiscretizationMetadata, NonlinearProblem,
@@ -74,8 +74,6 @@ conditions are discretized.
7474
"""
7575
abstract type AbstractDiscretizationState end
7676

77-
struct PDEBaseMetadataCtx end
78-
7977
include("symbolic_utils.jl")
8078
include("utils.jl")
8179
include("variable_map.jl")

src/discretization_state.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ function generate_system(
126126
eqs = map(_normalize_nonlinear_eq, alleqs)
127127
sys = System(
128128
eqs, alldepvarsdisc, ps, initial_conditions = sys_defaults, name = name,
129-
metadata = [PDEBaseMetadataCtx => metadata], checks = checks
129+
metadata = [ProblemTypeCtx => metadata], checks = checks
130130
)
131131
return sys, nothing
132132
else
@@ -138,7 +138,7 @@ function generate_system(
138138
initialization_eqs = init_eqs,
139139
guesses = guesses,
140140
name = name,
141-
metadata = [PDEBaseMetadataCtx => metadata], checks = checks
141+
metadata = [ProblemTypeCtx => metadata], checks = checks
142142
)
143143
return sys, tspan
144144
end
@@ -164,7 +164,7 @@ function SciMLBase.discretize(
164164
return try
165165
simpsys = mtkcompile(sys)
166166
if tspan === nothing
167-
add_metadata!(getmetadata(sys, PDEBaseMetadataCtx, nothing), sys)
167+
add_metadata!(getmetadata(sys, ProblemTypeCtx, nothing), sys)
168168
# MTK v11 requires symbolic map for initial guess
169169
unknowns_list = get_unknowns(simpsys)
170170
u0_guess = Dict(u => 1.0 for u in unknowns_list)
@@ -173,7 +173,7 @@ function SciMLBase.discretize(
173173
discretization.kwargs..., kwargs...
174174
)
175175
else
176-
mol_metadata = getmetadata(simpsys, PDEBaseMetadataCtx, nothing)
176+
mol_metadata = getmetadata(simpsys, ProblemTypeCtx, nothing)
177177
add_metadata!(mol_metadata, sys)
178178
prob = ODEProblem(
179179
simpsys, nothing, tspan;

0 commit comments

Comments
 (0)