Is making assign
only work for weighted sums too restrictive?
#2743
connorjward
started this conversation in
Ideas
Replies: 1 comment 5 replies
-
The first one of these is a solve masquerading as an assign as a hack. Currently that would definitely break the adjoint. Arguably we should find a way to specify that the matrix in a solver is diagonal. The second one is something we didn't think of because we didn't think of the complex case. real, imag and conj should be allowed. Currently we don't know how to differentiate those anyway so that doesn't break anything. The last point about assemble is bang on. I think assemble actually means "do the numerical computation described by this symbolic expression" and assign falls exactly into that. |
Beta Was this translation helpful? Give feedback.
5 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I have recently encountered two occasions where our new policy of making
assign
only work for weighted sums seems a bit clunky:p += assemble(dt * inner(nabla_grad(v), nabla_grad(phi))*dx) / assemble(v*dx)
for the linear wave equation demo now fails withoutinterpolate
(@JDBetteridge found this).A.assign(ufl.conj(B))
which similarly fails withoutinterpolate
.With the way I have rewritten
assign
to use numpy operations, it would be quite easy to modify the tree visitor to add support for these operations (division and conj) since numpy has analogues for them. In generalassign
would then work for any expression where all the 'bits' are in the same function space (and be fast since we'd be using numpy). Is this worth doing? I confess I never quite understood the "assign
used to let you do things that weren't mathematically legal" argument so please tell me if this is a bad idea.I have another related question. AIUI
assign
is pretty much "assemble
some expression into aFunction
and then use it to modify an existingFunction
". In other words I think the following are equivalent:u = Function(V).assign(expr)
andu = assemble(expr)
u += expr
andu.dat.data += assemble(expr).dat.data
.With that in mind does it therefore make sense for the
assign
code I have written to actually belong inassemble.py
?Beta Was this translation helpful? Give feedback.
All reactions