Using solver on blocksparsematrix

36 views
Skip to first unread message

GiovanniA

unread,
May 21, 2019, 5:50:32 AM5/21/19
to deal.II User Group
Hi everyone!
  I am trying to solve a system where I have a block matrix in the following form:

A 0 Bt
0 K Mt
B M 0

I can invert the matrices and reduce everything to a single equation, but I wanted to try to solve the block matrix directly.
I am using TrilinosWrappers, as the matrices are TW::SparseMatrix

This is what I tried:

```
      TW::BlockSparseMatrix system_matrix_block;
      TW::MPI::BlockVector rhs_block(3);
      TW::MPI::BlockVector solution_block(3);

      (Copy the matrices/values inside system_matrix_bloc and rhs_block)

      SolverControl      control(
          max_iterations, tolerance, verbosity_level > 1, verbosity_level > 0);

      TW::SolverCG                             solver_block(control);
      LA::MPI::PreconditionAMG                 amg_block;
      LA::MPI::PreconditionAMG::AdditionalData data_block;

      amg_block.initialize(system_matrix_block, data_block);
      solver_block.solve(system_matrix_block, solution_block, rhs_block, amg_block);
```

There are no problems building the matrix, but the solver and the preconditioner are not accepting a block matrix as imput.
Is there some way of doing this? Or is it possible to "transform" the block matrix to a simple sparse matrix?

Thank you very much for reading (and, hopefully, for the suggestions),
Giovanni

Wolfgang Bangerth

unread,
May 21, 2019, 10:35:29 PM5/21/19
to dea...@googlegroups.com
On 5/21/19 3:50 AM, GiovanniA wrote:
>
> There are no problems building the matrix, but the solver and the
> preconditioner are not accepting a block matrix as imput.

Can you post the error messages you get? The solver should have no problem
with it, though the AMG preconditioner can only work on a single block.

I will note that even if you could make this work, you'll have the problem
that (i) your block matrix is not positive definite, and so your attempt to
use a CG solver will not work, (ii) for the same reason, you will likely not
be able to use the AMG as a preconditioner for the whole system.

Best
WB

--
------------------------------------------------------------------------
Wolfgang Bangerth email: bang...@colostate.edu
www: http://www.math.colostate.edu/~bangerth/

Reply all
Reply to author
Forward
0 new messages