form splitter: use DAGTraverser and handle Action, Adjoint - #5484
leo-collins wants to merge 16 commits into
Conversation
|
This is great. Should we consider migrating this to ufl? |
Splitting a Function might be the only real blocker because we do things with MixedDat. |
| indices = self.select_block(blocks, a.number()) | ||
| if indices is None or len(a.function_space()) == 1: | ||
| return a | ||
| return Argument.reconstruct(a, function_space=subspace(a.function_space(), indices)) |
There was a problem hiding this comment.
| return Argument.reconstruct(a, function_space=subspace(a.function_space(), indices)) | |
| return a.reconstruct(function_space=subspace(a.function_space(), indices)) |
There was a problem hiding this comment.
This called the Firedrake Argument reconstruct which complains about the value shape not matching
There was a problem hiding this comment.
I would be tempted to remove that check
| return ZeroBaseForm(tuple(map(self, o.arguments()))) | ||
| @process.register(ZeroBaseForm) | ||
| def _(self, o, blocks): | ||
| return ZeroBaseForm(tuple(self._subspace_argument(a, blocks) for a in o.arguments())) |
There was a problem hiding this comment.
Why can we not map(self) anymore?
There was a problem hiding this comment.
DAGTraverser.__call__ is doing something else?
There was a problem hiding this comment.
blocks is no longer an attribute on self, so we have to pass it down. Before, _subspace_argument() was called in the split() method when handling a ZeroBaseForm.
There was a problem hiding this comment.
Maybe this works
from itertools import repeat
map(self, o.arguments(), repeat(blocks))
There was a problem hiding this comment.
Calling self on the arguments would return a split argument. ZeroBaseForm needs unsplit arguments on the subspaces.
|
I resolved a merge conflict after #4093 got merged |
Makes the
split_formMultiFunction be a DAGTraverser.Also handles splitting Adjoints and Actions. Previously, something like
would fail because
Fhas a single argument numbered 0, but the innerInterpolatehas an argument numbered 1, soExtractSubBlockwould try to select a non-existant block.For
Adjoint, we swap the row and columns, forActionwe need to maintain the argument that gets contracted out.