I am trying to apply AMG solver in my numerical simulator to solve big sparse linear systems (Ax=b). in order to apply it multilevel object should be created each time values of matrix A (sparsity structure is always same). Creating multilevel objects results in allocations that eventually affects the performance. Is there any in-place version or workaround?. Thank you
Generally, allocations in a complex algorithm are normal. A problem would occur if you see allocations in a “hot loop”, with allocations in each iteration of a loop running over the length of your solution vector. You could test this by running the code with matrices of different sizes coming e.g. from different refinement levels of a PDE discretization. If the number of allocations , not the amount of memory allocated scales with the number of unknowns of your system, I would suspect a problem. Otherwise, they probably are acceptable.
That said, with the AMG method, upon matrix entry update wile keeping the structure, there is the general possibility to keep the coarse grid hierarchy structure and to just update the numerical values of the coarse grid operators. This would resemble the symbolic/numeric factorization approach available with sparse direct solvers. This probaly could save much of the coarsening work.
AFAIU, this is in the moment not implemented in AlgebraicMultigrid.jl, it might be worth an issue, but of course for implementation somebody would have to find time for this, and I don’t know how much time an implementation might take.