Skip to content

Commit

Permalink
Internalize collate and compile Collage
Browse files Browse the repository at this point in the history
  • Loading branch information
lukem12345 committed Oct 20, 2023
1 parent fa8130d commit a25f9c6
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/Decapodes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export normalize_unicode, DerivOp, append_dot, unicode!, vec_to_dec!,
CartesianPoint, SpherePoint, r, theta, phi, TangentBasis, θhat, ϕhat,
average_rewrite, recursive_delete_parents, contract_operators,
default_dec_matrix_generate, default_dec_generate,
collate,
Collage,
@decapode

normalize_unicode(s::String) = Unicode.normalize(s, compose=true, stable=true, chartransform=Unicode.julia_chartransform)
Expand Down
11 changes: 10 additions & 1 deletion src/collages.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@

""" function collate(acset, column_names::Vector{Symbol})
struct Collage
src::SummationDecapode{Any,Any,Symbol}
tgt::SummationDecapode{Any,Any,Symbol}
uwd::Catlab.Programs.RelationalPrograms.UntypedUnnamedRelationDiagram{Symbol, Symbol}
symbols::Dict{Symbol, Symbol}
end

collate(c::Collage) = collate(c.src, c.tgt, c.uwd, c.symbols)

""" function collate(equations, boundaries, uwd, symbols)
Create a collage of two Decapodes that simulates with boundary conditions.
```
Expand Down
3 changes: 3 additions & 0 deletions src/simulation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -436,6 +436,9 @@ function gensim(user_d::AbstractNamedDecapode, input_vars; dimension::Int=2)
end
end

gensim(c::Collage; dimension::Int=2) =
gensim(collate(c); dimension=dimension)

""" function gensim(d::AbstractNamedDecapode; dimension::Int=2)
Generate a simulation function from the given Decapode. The returned function can then be combined with a mesh and a function describing function mappings to return a simulator to be passed to `solve`.
Expand Down
23 changes: 15 additions & 8 deletions test/collages.jl
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,18 @@ DiffusionMorphism = @relation () begin
rb3(Ċ, Zero)
end

DiffusionCollage = collate(
DiffusionSymbols = Dict(
:C => :K,
:Ċ => :K̇,
:Cb1 => :Kb1,
:Cb2 => :Kb2,
:Zero => :Null)

DiffusionCollage = Decapodes.collate(
DiffusionDynamics,
DiffusionBoundaries,
DiffusionMorphism,
Dict(
:C => :K,
:Ċ => :K̇,
:Cb1 => :Kb1,
:Cb2 => :Kb2,
:Zero => :Null))
#to_graphviz(DiffusionCollage)
DiffusionSymbols)

@test DiffusionCollage == @acset SummationDecapode{Any, Any, Symbol} begin
Var = 8
Expand Down Expand Up @@ -65,3 +66,9 @@ end
# ∂ₜ(C) == rb3(∘(d,⋆,d,⋆)(rb2(C)))
#end
# Such a technique would preserve the technical definition of "collage".

# Test gensim on a collage.
c = Collage(DiffusionDynamics, DiffusionBoundaries,
DiffusionMorphism, DiffusionSymbols)

@test gensim(c) == gensim(DiffusionCollage)

0 comments on commit a25f9c6

Please sign in to comment.