Solve distributed BlockVector with direct solver

46 views
Skip to first unread message

yy.wayne

unread,
Nov 5, 2022, 2:21:40 AM11/5/22
to deal.II User Group
Hello,

I assembled a matrix for a multi-component problem. I want to solve it with a direct solver, but neither Trilinos solver(SolverDirect amesos_klu) nor SparseDirectUMFPACK solver receive a LinearAlgebra::distributed::BlockVector as input. The Trilinos direct solver receives Vector and BlockVector, while SparseDirectUMFPACK solver receives LinearAlgebra::distributed::Vector. What direct solver should I use?

Peter Munch

unread,
Nov 5, 2022, 3:21:42 AM11/5/22
to deal.II User Group
If it is not too expensive, I would copy the block vector to the normal distributed vector. For this purpose, I use functions like these:

```
    template <typename VectorType, typename BlockVectorType>
    void
    split_up_components_fast(const VectorType &src, BlockVectorType &dst)
    {
      for (unsigned int i = 0, j = 0;
           i < src.get_partitioner()->locally_owned_size();
           ++j)
        for (unsigned int b = 0; b < dst.n_blocks(); ++b)
          dst.block(b).local_element(j) = src.local_element(i++);
    }

    template <typename VectorType, typename BlockVectorType>
    void
    merge_components_fast(const BlockVectorType &src, VectorType &dst)
    {
      for (unsigned int i = 0, j = 0;
           i < dst.get_partitioner()->locally_owned_size();
           ++j)
        for (unsigned int b = 0; b < src.n_blocks(); ++b)
          dst.local_element(i++) = src.block(b).local_element(j);
    }
```

However, you have make sure that the DoFs are enumerated consistently for LinearAlgebra::distributed::Vector.

Peter

yy.wayne

unread,
Nov 5, 2022, 3:23:18 AM11/5/22
to deal.II User Group
Thank you Peter
Reply all
Reply to author
Forward
0 new messages