Skip to content

Commit

Permalink
fem: Reify known real expressions
Browse files Browse the repository at this point in the history
Will be used for type inference of return variable.
  • Loading branch information
wence- committed May 15, 2020
1 parent d961ab4 commit 533cc18
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions tsfc/fem.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,14 @@ def __init__(self, interface, **kwargs):
raise ValueError("unexpected keyword argument '{0}'".format(invalid_keywords.pop()))
self.__dict__.update(kwargs)

def reify(self, expr):
if self.complex_mode:
indices = gem.indices(len(expr.shape))
return gem.ComponentTensor(gem.MathFunction("real", gem.Indexed(expr, indices)),
indices)
else:
return expr

@cached_property
def fiat_cell(self):
return as_fiat_cell(self.ufl_cell)
Expand Down Expand Up @@ -136,7 +144,7 @@ def config(self):
return config

def cell_size(self):
return self.interface.cell_size(self.mt.restriction)
return self.interface.reify(self.interface.cell_size(self.mt.restriction))

def jacobian_at(self, point):
expr = Jacobian(self.mt.terminal.ufl_domain())
Expand Down Expand Up @@ -427,7 +435,7 @@ def translate_spatialcoordinate(terminal, mt, ctx):
# Rebuild modified terminal
expr = construct_modified_terminal(mt, terminal)
# Translate replaced UFL snippet
return ctx.translator(expr)
return ctx.reify(ctx.translator(expr))


class CellVolumeKernelInterface(ProxyKernelInterface):
Expand Down

0 comments on commit 533cc18

Please sign in to comment.