AlgebraicJulia / Decapodes.jl

A framework for composing and simulating multiphysics systems
https://algebraicjulia.github.io/Decapodes.jl/dev/
MIT License
46 stars 14 forks source link

GenSim Type Inference Failure due to Constants #221

Closed GeorgeR227 closed 1 month ago

GeorgeR227 commented 3 months ago

Running the physics in the canonical heat transfer model here: https://algebraicjulia.github.io/Decapodes.jl/dev/canon/#Decapodes.Canon.Physics.:heat_transfer, will fail to compile due to an unmatched hodge star. This occurs due to a type inference failure.

The reason for this happening is that gensim will replace constants and parameters with infer types, for various reasons, and then run an infer/resolve cycle. However since this functionality was added in gensim, several rules have come out dealing with constants. Thus if a user were to run an infer/resolve cycle themselves and then use gensim, this will compile.

Best solution here would be to add a infer/resolve cycle before the types are changed to use to constant typing rules.

lukem12345 commented 3 months ago

I agree with that solution (hopefully, a one-liner call to infer and resolve). No big refactoring should be done for now, unless the timetable for GAT refactoring is delayed.

GeorgeR227 commented 3 months ago

At least on this physics, I've tested that change and it seems to work fine. Fortunately, refactoring has to be done now anyways to allow for switching between CPU/CUDA code generation.

lukem12345 commented 3 months ago

Ok. Feel free to make a tiny PR that fixes this issue, and open a new issue for general refactoring. Or more particular issues as convenient.