Add arity property to form#470
Conversation
|
A form doesn’t necessarily have a slingle arity, as each individual integrand can have different arities. This is for instance why things such as ‘ufl.system’ exists, as it would split the form by rank 2 and rank 1 systems. if we want to have arity as a property, it should probably be max arity. |
|
I changed over to return |
| if not self._integrals: | ||
| return 0 | ||
|
|
||
| from ufl.algorithms.analysis import extract_terminals_with_domain |
There was a problem hiding this comment.
Do we need this here to avoid circular imports?
There was a problem hiding this comment.
Yes exactly. Also used in other parts of form.py in the same manner.
| if len(set(arg.part() for arg in args)) > 1: | ||
| raise RuntimeError("Arity does not support mixed arguments in an integral.") |
There was a problem hiding this comment.
Works around the problems arising from having mixed arguments present in the form https://github.com/FEniCS/ufl/pull/470/changes#diff-40318d7ac6b526c958053e25f90768d68e58d7c26e6479fe580f7420f53de86fR146-R159. Probably this is too restrictive. But I am not quite sure what the right checks should be here instead.
There is currently no better way than
len(form.arguments())to check for the arity/rank of a form. Introduces property for simpler access. Sincerankis already associated with tensor ranks in ufl, use the namearity.If a form contains an ambiguous arity, i.e. terms with different argument counts
Noneis returned.Ref FEniCS/dolfinx#4118.