Skip to content

Commit

Permalink
Fixed always adding non_opt ops
Browse files Browse the repository at this point in the history
  • Loading branch information
GeorgeR227 committed Nov 1, 2024
1 parent 8cfff5e commit 808cd61
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
10 changes: 6 additions & 4 deletions src/simulation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -252,8 +252,10 @@ function compile_env(d::SummationDecapode, dec_matrices::Vector{Symbol}, con_dec
push!(defined_ops, op)
end

operators = vcat(d[:op1], d[:op2])

# These are nonoptimizable default DEC functions.
for op in non_optimizable(code_target)
for op in intersect(operators, non_optimizable(code_target))
op in defined_ops && continue

def = :($op = $(generator_function(code_target))(mesh, $(QuoteNode(op)), hodge))
Expand All @@ -263,7 +265,7 @@ function compile_env(d::SummationDecapode, dec_matrices::Vector{Symbol}, con_dec
end

# Add in user-defined operations
for op in vcat(d[:op1], d[:op2])
for op in operators
if op == DerivOp || op in defined_ops || op in ARITHMETIC_OPS
continue
end
Expand Down Expand Up @@ -688,8 +690,8 @@ end
Base.showerror(io::IO, e::UnsupportedStateeltypeException) = print(io, "Decapodes does not support state element types as $(e.type), only Float32 or Float64")

const MATRIX_OPTIMIZABLE_DEC_OPERATORS = Set([:₀, :₁, :₂, :₀⁻¹, :₂⁻¹,
:d₀, :d₁, :dual_d₀, :d̃₀, :dual_d₁, :d̃₁,
:avg₀₁])
:d₀, :d₁, :dual_d₀, :d̃₀, :dual_d₁, :d̃₁,
:avg₀₁])

const NONMATRIX_OPTIMIZABLE_DEC_OPERATORS = Set([:₁⁻¹, :₀₁, :₁₀, :₁₁, :₀₂, :₂₀])

Expand Down
5 changes: 4 additions & 1 deletion test/simulation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -641,6 +641,8 @@ end

end

filter_lnn(arr::AbstractVector) = filter(x -> !(x isa LineNumberNode), arr)

@testset "1-D Mat Generation" begin
Point2D = Point2{Float64}
function generate_dual_mesh(s::HasDeltaSet1D)
Expand All @@ -664,10 +666,11 @@ end
end
g = gensim(DiagonalInvHodge1)
@test g.args[2].args[2].args[3].args[2].args[2].args[3].value == :₁⁻¹
@test length(filter_lnn(g.args[2].args[2].args[3].args)) == 1
sim = eval(g)

# TODO: Error is being thrown here
# @test f = sim(line, default_dec_generate, DiagonalHodge()) isa Any
@test f = sim(line, default_dec_generate, DiagonalHodge()) isa Any
end

@testset "GenSim Compilation" begin
Expand Down

0 comments on commit 808cd61

Please sign in to comment.