Hi Chenjian,
Thanks for the tip about LinearOperator! That would be very nice if it works, but I was having trouble. I tried the following (apologies for the incomplete snippet, I hope it communicates the gist)
using VectorType = LinearAlgebra::distributed::Vector<double
MatrixFreeOperators::LaplaceOperator<dim, fe_degree, fe_degree+1, 1, VectorType, VectorizedArray<double>> A;
MatrixFreeOperators::MassOperator<dim, fe_degree, fe_degree+1, 1, VectorType, VectorizedArray<double>> B;
...
double shift = 1.0;
LinearOperator<VectorType> op_A = linear_operator(A);
LinearOperator<VectorType> op_B = linear_operator(B);
LinearOperator<VectorType> op_M = op_A - shift*op_B
The error happens inside the call to linear_operator, where there occurs
linear_operator.h:1221:69: error: non-const lvalue reference to type 'dealii::LinearAlgebra::distributed::Vector<double>' cannot bind to a value of unrelated type 'dealii::Vector<double>'
1221 | [&matrix](Range &b, const Domain &a) { matrix.vmult(b, a); }, |
My reading of this is that the lambda wrapping A.vmult() for some reason expects to work with an ordinary gets confused when I give it a distributed vector.
And at the end of the day, the LinearOperator stuff is much more flexible than what I tried with the wrapper class, but it is accomplishing the same thing, just with lambdas instead of stored references to A and B, right?
Cheers,
Nathaniel