JuliaLinearAlgebra / AlgebraicMultigrid.jl

Algebraic Multigrid in Julia
Other
116 stars 23 forks source link

User-defined near null space #80

Open fverdugo opened 3 years ago

fverdugo commented 3 years ago

Hi! First, let me congratulate you for this package, I have been using it and it performs very well! It's faster than PETSc GAMG in many cases according to my experience.

I am wondering if it is possible to pass a user-defined near null space to the SA-AMG routines. This is important e.g. in linear elasticity and other vector-valued problems.

By looking at this line

https://github.com/JuliaLinearAlgebra/AlgebraicMultigrid.jl/blob/1714fa4184199bf87a1d22038ac74e56021320e1/src/aggregation.jl#L18

it looks like the near null space is hardcoded to be a vector of ones. Thus, I guess that the answer to my question is NO at the moment.

I would like to know if somebody is working on this feature. If not, I can try to address it myself and file a PR.

ranjanan commented 3 years ago

Thank you for your kind words and for using the package!

Yes, I can have definitely have that be an optional argument with default as ones(T,n). Feel free to send a PR. It should be a quick change. I'll merge as soon as tests pass. Thank you!

fverdugo commented 3 years ago

Yes, I can have definitely have that be an optional argument with default as ones(T,n). Feel free to send a PR. It should be a quick change.

Perhaps this is not sufficient. In general, the near null space can have several vectors, so size(B,2) can be > 1. I don't know if the code will support the case when B is a matrix. I'll try once I have some time.

learning-chip commented 2 years ago

Came across the same issue. Note that pyamg.aggregation.smoothed_aggregation_solver allows near-nullspace candidates B of shape (N, K). As long as the SA setup logic follows PyAMG, passing a 2-D matrix B should be fine.