TSFC: support same-mesh ufl.Interpolate in Form kernels#5258
Conversation
| def is_modified_terminal(v): | ||
| "Check if v is a terminal or a terminal wrapped in terminal modifier types." | ||
| while not v._ufl_is_terminal_: | ||
| while not (v._ufl_is_terminal_ or isinstance(v, Interpolate)): |
There was a problem hiding this comment.
introduce a helper function is_fem_terminal()
There was a problem hiding this comment.
Here we need to make sure the dual_arg is indeed a terminal, because TSFC would have to generate a completely separate kernel to be globally assembled beforehand. For now, let the non-terminal dual_arg case be dispatched to BaseFormAssembler
| value_dict = {} | ||
| for alpha, table in per_derivative.items(): | ||
| table_qi = gem.Indexed(table, beta + zeta) | ||
| if not hasattr(vec_beta, "index_ordering"): |
There was a problem hiding this comment.
hasattr is an antipattern, check isinstance instead
| preserve_geometry_types = (CellVolume, FacetArea) | ||
|
|
||
|
|
||
| class InterpolateMapper(MultiFunction): |
|
This PR should reimplement |
| (k, subdomain_id) for k in kernels for subdomain_id in k.kinfo.subdomain_id | ||
| ) | ||
|
|
||
| def _compile_interpolate(self): |
There was a problem hiding this comment.
This could be fused into the rest of the form assembly
| if len(self._form.arguments()) == 2 and not self._diagonal: | ||
| if not self._bcs: | ||
| return None | ||
|
|
|
|
||
| summands = [] | ||
| argument_multiindices = ctx.argument_multiindices | ||
| if hasattr(argument_multiindices, "values"): |
There was a problem hiding this comment.
Is this to check if we have a dict or None?
There was a problem hiding this comment.
Ah, right we have mismatching conventions: Form uses a tuple and Inteprolate uses a dict
a844911 to
f7f5ee3
Compare
| integrand_exprs = builder.compile_integrand(integral.integrand(), params, ctx) | ||
| integral_exprs = builder.construct_integrals(integrand_exprs, params) | ||
| builder.stash_integrals(integral_exprs, params, ctx) | ||
| params["mode"] = "vanilla" |
There was a problem hiding this comment.
Is this hiding a bug?
| from firedrake.assemble import ( | ||
| OneFormAssembler, TwoFormAssembler, ZeroFormAssembler, | ||
| ) |
There was a problem hiding this comment.
TODO: let get_assembler do the dispatch
| for mesh, subelement in zip( | ||
| domain.iterable_like(element), element.sub_elements | ||
| ) | ||
| ] |
There was a problem hiding this comment.
Some of this could live in compute_form_data
Description
Depends on
FEniCS/ufl#497
firedrakeproject/fiat#261