Skip to content

Commit

Permalink
Merge pull request #126 from GalerkinToolkit/more_abstract_types
Browse files Browse the repository at this point in the history
Simplifying map inverses
  • Loading branch information
fverdugo authored Oct 24, 2024
2 parents c623bfa + 3efc160 commit 0bacbee
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
5 changes: 4 additions & 1 deletion src/domain.jl
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,10 @@ function call(g::AbstractQuantity,args::AbstractQuantity...)
GT.quantity(prototype,domain) do index
f_exprs = map(f->f(index),fs)
g_expr = g_term(index)
:($g_expr($(f_exprs...)))
# We use call since @rule is not able to
# identify function calls on variable slots
@term call($g_expr,$(f_exprs...))
#:($g_expr($(f_exprs...)))
end
end

Expand Down
17 changes: 15 additions & 2 deletions src/symbolics.jl
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,21 @@ function simplify(expr)
end

function simplify(expr::Expr)
r001 = @slots a b c d e f g @rule face_function(a,b,c,d,e)(reference_value(f,b,e)[g]) --> face_function_value(map(reference_tabulator,a,f),b,c,d,e,g)
expr2 = r001(expr)
# r_invmap needs to be processed before r_tabulator
# We use call since @rule is not able to identify function calls on variable slots (phi in this case)
r_invmap = @slots a b c phi @rule call( a inverse_map_impl(phi,b) , call(phi,c) ) --> call(a,c)
r_tabulator = @slots a b c d e f g @rule call(face_function(a,b,c,d,e),reference_value(f,b,e)[g]) --> face_function_value(map(reference_tabulator,a,f),b,c,d,e,g)
rules = [
r_invmap,
r_tabulator,
]
expr2 = nothing
for rule in rules
expr2 = rule(expr)
if expr2 !== nothing
break
end
end
if expr2 === nothing
args = map(simplify,expr.args)
Expr(expr.head,args...)
Expand Down

0 comments on commit 0bacbee

Please sign in to comment.