Closed vpuri3 closed 2 years ago
We could have just added a couple of vec
s to the definition of DiagonalOperator
but that would change Base.size
of the operator itself and then we'd have to store metadata somewhere. The only option is to make a new operator type.
AffineOperator
, the only other operator that stores some solution vector type, doesn't need to be changed as it can have a matrix type as L.b
because it doesn't affect its Base.size
.
In solving nonlinear PDEs, you often have to form the product,
u * u
whereu
is the solution vector. This operation can be cast as a aSciMLOperator
as follows:For a single trajectory, the size of
D
would be(N,N)
whereN
is the problem size. However, when you are evolvingK
trajectories at the same time the size of solution vector is(N,K)
. When you formD
by the above approach,Diagonal(zero(u))
returns aDiagonal
matrix of size(N,N)
or(K,K)
whichever's smaller, not respecting the intention of intention of our operation.For this reason, I have restricted
DiagonalOperator
to accept onlyAbstractVector
arguments. You could indeed pass avec(u)
toDiagonal
, but then the size ofD
would be(N*K, N*K)
which would be incompatible with your other operations of size(N,N)
.As diagonal scaling is a fundamental operation, I think we should address this problem. What we need is an elementwise-scaling operator that has size
(N,N)
but can act on objects of size(N,K)
(SciMLOperators.jl
has convention that the input to an(M,N)
operator must be anAbstractArray
of size(N,...)
). I propose creating an object calledBatchedDiagonalOperator
.This should solve the problem of performing nonlinear operations with intra-ODE parallelism